Take overflow-wrap into account when calculating...
parent
d147d954e9
commit
54c5407dc7
|
@ -1072,6 +1072,34 @@ gfxTextRun::GetAdvanceWidth(Range aRange, PropertyProvider *aProvider,
|
||||||
return result + GetAdvanceForGlyphs(ligatureRange);
|
return result + GetAdvanceForGlyphs(ligatureRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfxFloat
|
||||||
|
gfxTextRun::GetMinAdvanceWidth(Range aRange)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(aRange.end <= GetLength(), "Substring out of range");
|
||||||
|
|
||||||
|
Range ligatureRange = aRange;
|
||||||
|
ShrinkToLigatureBoundaries(&ligatureRange);
|
||||||
|
|
||||||
|
gfxFloat result = std::max(
|
||||||
|
ComputePartialLigatureWidth(Range(aRange.start, ligatureRange.start),
|
||||||
|
nullptr),
|
||||||
|
ComputePartialLigatureWidth(Range(ligatureRange.end, aRange.end),
|
||||||
|
nullptr));
|
||||||
|
|
||||||
|
// XXX Do we need to take spacing into account? When each grapheme cluster
|
||||||
|
// takes its own line, we shouldn't be adding spacings around them.
|
||||||
|
gfxFloat clusterAdvance = 0;
|
||||||
|
for (uint32_t i = ligatureRange.start; i < ligatureRange.end; ++i) {
|
||||||
|
clusterAdvance += GetAdvanceForGlyph(i);
|
||||||
|
if (i + 1 == ligatureRange.end || IsClusterStart(i + 1)) {
|
||||||
|
result = std::max(result, clusterAdvance);
|
||||||
|
clusterAdvance = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
gfxTextRun::SetLineBreaks(Range aRange,
|
gfxTextRun::SetLineBreaks(Range aRange,
|
||||||
bool aLineBreakBefore, bool aLineBreakAfter,
|
bool aLineBreakBefore, bool aLineBreakAfter,
|
||||||
|
|
|
@ -298,6 +298,12 @@ public:
|
||||||
return GetAdvanceWidth(Range(this), nullptr);
|
return GetAdvanceWidth(Range(this), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the minimum advance width for a substring assuming line
|
||||||
|
* breaking is allowed everywhere.
|
||||||
|
*/
|
||||||
|
gfxFloat GetMinAdvanceWidth(Range aRange);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all stored line breaks for the given range (both before and after),
|
* Clear all stored line breaks for the given range (both before and after),
|
||||||
* and then set the line-break state before aRange.start to aBreakBefore and
|
* and then set the line-break state before aRange.start to aBreakBefore and
|
||||||
|
|
|
@ -8244,6 +8244,16 @@ nsTextFrame::AddInlineMinISizeForFlow(nsRenderingContext *aRenderingContext,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If overflow-wrap is break-word, we can wrap everywhere.
|
||||||
|
if (textStyle->WordCanWrap(this)) {
|
||||||
|
aData->OptionallyBreak();
|
||||||
|
aData->mCurrentLine +=
|
||||||
|
textRun->GetMinAdvanceWidth(Range(start, flowEndInTextRun));
|
||||||
|
aData->mTrailingWhitespace = 0;
|
||||||
|
aData->OptionallyBreak();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AutoTArray<bool,BIG_TEXT_NODE_SIZE> hyphBuffer;
|
AutoTArray<bool,BIG_TEXT_NODE_SIZE> hyphBuffer;
|
||||||
bool *hyphBreakBefore = nullptr;
|
bool *hyphBreakBefore = nullptr;
|
||||||
if (hyphenating) {
|
if (hyphenating) {
|
||||||
|
|
Loading…
Reference in New Issue