Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (151326 => 151327)
--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2013-06-07 17:22:37 UTC (rev 151326)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2013-06-07 17:59:01 UTC (rev 151327)
@@ -806,10 +806,10 @@
setMarginEndForChild(renderer, -endOverhang);
}
-static inline float measureHyphenWidth(RenderText* renderer, const Font& font)
+static inline float measureHyphenWidth(RenderText* renderer, const Font& font, HashSet<const SimpleFontData*>* fallbackFonts = 0)
{
RenderStyle* style = renderer->style();
- return font.width(RenderBlock::constructTextRun(renderer, font, style->hyphenString().string(), style));
+ return font.width(RenderBlock::constructTextRun(renderer, font, style->hyphenString().string(), style), fallbackFonts);
}
class WordMeasurement {
@@ -830,7 +830,7 @@
};
static inline void setLogicalWidthForTextRun(RootInlineBox* lineBox, BidiRun* run, RenderText* renderer, float xPos, const LineInfo& lineInfo,
- GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache, WordMeasurements& wordMeasurements)
+ GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache, WordMeasurements& wordMeasurements)
{
HashSet<const SimpleFontData*> fallbackFonts;
GlyphOverflow glyphOverflow;
@@ -853,7 +853,7 @@
LayoutUnit hyphenWidth = 0;
if (toInlineTextBox(run->m_box)->hasHyphen()) {
const Font& font = renderer->style(lineInfo.isFirstLine())->font();
- hyphenWidth = measureHyphenWidth(renderer, font);
+ hyphenWidth = measureHyphenWidth(renderer, font, &fallbackFonts);
}
float measuredWidth = 0;
@@ -866,8 +866,8 @@
if (!lineBox->fitsToGlyphs() && canUseSimpleFontCodePath) {
int lastEndOffset = run->m_start;
for (size_t i = 0, size = wordMeasurements.size(); i < size && lastEndOffset < run->m_stop; ++i) {
- const WordMeasurement& wordMeasurement = wordMeasurements[i];
- if (wordMeasurement.width <=0 || wordMeasurement.startOffset == wordMeasurement.endOffset)
+ WordMeasurement& wordMeasurement = wordMeasurements[i];
+ if (wordMeasurement.width <= 0 || wordMeasurement.startOffset == wordMeasurement.endOffset)
continue;
if (wordMeasurement.renderer != renderer || wordMeasurement.startOffset != lastEndOffset || wordMeasurement.endOffset > run->m_stop)
continue;
@@ -875,7 +875,9 @@
lastEndOffset = wordMeasurement.endOffset;
if (kerningIsEnabled && lastEndOffset == run->m_stop) {
int wordLength = lastEndOffset - wordMeasurement.startOffset;
- measuredWidth += renderer->width(wordMeasurement.startOffset, wordLength, xPos + measuredWidth, lineInfo.isFirstLine());
+ GlyphOverflow overflow;
+ measuredWidth += renderer->width(wordMeasurement.startOffset, wordLength, xPos + measuredWidth, lineInfo.isFirstLine(),
+ &wordMeasurement.fallbackFonts, &overflow);
UChar c = renderer->characterAt(wordMeasurement.startOffset);
if (i > 0 && wordLength == 1 && (c == ' ' || c == '\t'))
measuredWidth += renderer->style()->wordSpacing();
@@ -2560,14 +2562,14 @@
return false;
}
-static ALWAYS_INLINE float textWidth(RenderText* text, unsigned from, unsigned len, const Font& font, float xPos, bool isFixedPitch, bool collapseWhiteSpace, HashSet<const SimpleFontData*>* fallbackFonts = 0, TextLayout* layout = 0)
+static ALWAYS_INLINE float textWidth(RenderText* text, unsigned from, unsigned len, const Font& font, float xPos, bool isFixedPitch, bool collapseWhiteSpace, HashSet<const SimpleFontData*>& fallbackFonts, TextLayout* layout = 0)
{
GlyphOverflow glyphOverflow;
if (isFixedPitch || (!from && len == text->textLength()) || text->style()->hasTextCombine())
- return text->width(from, len, font, xPos, fallbackFonts, &glyphOverflow);
+ return text->width(from, len, font, xPos, &fallbackFonts, &glyphOverflow);
if (layout)
- return Font::width(*layout, from, len, fallbackFonts);
+ return Font::width(*layout, from, len, &fallbackFonts);
TextRun run = RenderBlock::constructTextRun(text, font, text, from, len, text->style());
run.setCharactersLength(text->textLength() - from);
@@ -2576,7 +2578,7 @@
run.setCharacterScanForCodePath(!text->canUseSimpleFontCodePath());
run.setTabSize(!collapseWhiteSpace, text->style()->tabSize());
run.setXPos(xPos);
- return font.width(run, fallbackFonts, &glyphOverflow);
+ return font.width(run, &fallbackFonts, &glyphOverflow);
}
static void tryHyphenating(RenderText* text, const Font& font, const AtomicString& localeIdentifier, unsigned consecutiveHyphenatedLines, int consecutiveHyphenatedLinesLimit, int minimumPrefixLimit, int minimumSuffixLimit, unsigned lastSpace, unsigned pos, float xPos, int availableWidth, bool isFixedPitch, bool collapseWhiteSpace, int lastSpaceWordSpacing, InlineIterator& lineBreak, int nextBreakable, bool& hyphenated)
@@ -2635,7 +2637,8 @@
ASSERT(pos - lastSpace - prefixLength >= minimumSuffixLength);
#if !ASSERT_DISABLED
- float prefixWidth = hyphenWidth + textWidth(text, lastSpace, prefixLength, font, xPos, isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;
+ HashSet<const SimpleFontData*> fallbackFonts;
+ float prefixWidth = hyphenWidth + textWidth(text, lastSpace, prefixLength, font, xPos, isFixedPitch, collapseWhiteSpace, fallbackFonts) + lastSpaceWordSpacing;
ASSERT(xPos + prefixWidth <= availableWidth);
#else
UNUSED_PARAM(isFixedPitch);
@@ -3078,7 +3081,8 @@
// Non-zero only when kerning is enabled and TextLayout isn't used, in which case we measure
// words with their trailing space, then subtract its width.
- float wordTrailingSpaceWidth = (f.typesettingFeatures() & Kerning) && !textLayout ? f.width(constructTextRun(t, f, &space, 1, style)) + wordSpacing : 0;
+ HashSet<const SimpleFontData*> fallbackFonts;
+ float wordTrailingSpaceWidth = (f.typesettingFeatures() & Kerning) && !textLayout ? f.width(constructTextRun(t, f, &space, 1, style), &fallbackFonts) + wordSpacing : 0;
UChar lastCharacter = renderTextInfo.m_lineBreakIterator.lastCharacter();
UChar secondToLastCharacter = renderTextInfo.m_lineBreakIterator.secondToLastCharacter();
@@ -3092,7 +3096,7 @@
lineInfo.setEmpty(false, m_block, &width);
if (c == softHyphen && autoWrap && !hyphenWidth && style->hyphens() != HyphensNone) {
- hyphenWidth = measureHyphenWidth(t, f);
+ hyphenWidth = measureHyphenWidth(t, f, &fallbackFonts);
width.addUncommittedWidth(hyphenWidth);
}
@@ -3103,7 +3107,7 @@
if ((breakAll || breakWords) && !midWordBreak) {
wrapW += charWidth;
bool midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && current.m_pos + 1 < t->textLength() && U16_IS_TRAIL(t->characters()[current.m_pos + 1]);
- charWidth = textWidth(t, current.m_pos, midWordBreakIsBeforeSurrogatePair ? 2 : 1, f, width.committedWidth() + wrapW, isFixedPitch, collapseWhiteSpace, 0, textLayout);
+ charWidth = textWidth(t, current.m_pos, midWordBreakIsBeforeSurrogatePair ? 2 : 1, f, width.committedWidth() + wrapW, isFixedPitch, collapseWhiteSpace, fallbackFonts, textLayout);
midWordBreak = width.committedWidth() + wrapW + charWidth > width.availableWidth();
}
@@ -3137,10 +3141,14 @@
float additionalTempWidth;
if (wordTrailingSpaceWidth && c == ' ')
- additionalTempWidth = textWidth(t, lastSpace, current.m_pos + 1 - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout) - wordTrailingSpaceWidth;
+ additionalTempWidth = textWidth(t, lastSpace, current.m_pos + 1 - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, wordMeasurement.fallbackFonts, textLayout) - wordTrailingSpaceWidth;
else
- additionalTempWidth = textWidth(t, lastSpace, current.m_pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout);
+ additionalTempWidth = textWidth(t, lastSpace, current.m_pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, wordMeasurement.fallbackFonts, textLayout);
+ if (wordMeasurement.fallbackFonts.isEmpty() && !fallbackFonts.isEmpty())
+ wordMeasurement.fallbackFonts.swap(fallbackFonts);
+ fallbackFonts.clear();
+
wordMeasurement.width = additionalTempWidth + wordSpacingForWordMeasurement;
additionalTempWidth += lastSpaceWordSpacing;
width.addUncommittedWidth(additionalTempWidth);
@@ -3163,7 +3171,7 @@
// as candidate width for this line.
bool lineWasTooWide = false;
if (width.fitsOnLine() && currentCharacterIsWS && currentStyle->breakOnlyAfterWhiteSpace() && !midWordBreak) {
- float charWidth = textWidth(t, current.m_pos, 1, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout) + (applyWordSpacing ? wordSpacing : 0);
+ float charWidth = textWidth(t, current.m_pos, 1, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, wordMeasurement.fallbackFonts, textLayout) + (applyWordSpacing ? wordSpacing : 0);
// Check if line is too big even without the extra space
// at the end of the line. If it is not, do nothing.
// If the line needs the extra whitespace to be too long,
@@ -3301,7 +3309,7 @@
wordMeasurement.renderer = t;
// IMPORTANT: current.m_pos is > length here!
- float additionalTempWidth = ignoringSpaces ? 0 : textWidth(t, lastSpace, current.m_pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout);
+ float additionalTempWidth = ignoringSpaces ? 0 : textWidth(t, lastSpace, current.m_pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, wordMeasurement.fallbackFonts, textLayout);
wordMeasurement.startOffset = lastSpace;
wordMeasurement.endOffset = current.m_pos;
wordMeasurement.width = ignoringSpaces ? 0 : additionalTempWidth + wordSpacingForWordMeasurement;
@@ -3310,6 +3318,10 @@
float inlineLogicalTempWidth = inlineLogicalWidth(current.m_obj, !appliedStartWidth, includeEndWidth);
width.addUncommittedWidth(additionalTempWidth + inlineLogicalTempWidth);
+ if (wordMeasurement.fallbackFonts.isEmpty() && !fallbackFonts.isEmpty())
+ wordMeasurement.fallbackFonts.swap(fallbackFonts);
+ fallbackFonts.clear();
+
if (collapseWhiteSpace && currentCharacterIsSpace && additionalTempWidth)
width.setTrailingWhitespaceWidth(additionalTempWidth + inlineLogicalTempWidth);
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (151326 => 151327)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2013-06-07 17:22:37 UTC (rev 151326)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2013-06-07 17:59:01 UTC (rev 151327)
@@ -893,7 +893,7 @@
return font.width(RenderBlock::constructTextRun(renderer, font, style->hyphenString().string(), style));
}
-static float maxWordFragmentWidth(RenderText* renderer, RenderStyle* style, const Font& font, const UChar* word, int wordLength, int minimumPrefixLength, int minimumSuffixLength, int& suffixStart)
+static float maxWordFragmentWidth(RenderText* renderer, RenderStyle* style, const Font& font, const UChar* word, int wordLength, int minimumPrefixLength, int minimumSuffixLength, int& suffixStart, HashSet<const SimpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow)
{
suffixStart = 0;
if (wordLength <= minimumSuffixLength)
@@ -920,7 +920,7 @@
TextRun run = RenderBlock::constructTextRun(renderer, font, fragmentWithHyphen.characters(), fragmentWithHyphen.length(), style);
run.setCharactersLength(fragmentWithHyphen.length());
run.setCharacterScanForCodePath(!renderer->canUseSimpleFontCodePath());
- float fragmentWidth = font.width(run);
+ float fragmentWidth = font.width(run, &fallbackFonts, &glyphOverflow);
// Narrow prefixes are ignored. See tryHyphenating in RenderBlockLineLayout.cpp.
if (fragmentWidth <= minimumFragmentWidthToConsider)
@@ -968,7 +968,7 @@
// Non-zero only when kerning is enabled, in which case we measure words with their trailing
// space, then subtract its width.
- float wordTrailingSpaceWidth = f.typesettingFeatures() & Kerning ? f.width(RenderBlock::constructTextRun(this, f, &space, 1, styleToUse)) + wordSpacing : 0;
+ float wordTrailingSpaceWidth = f.typesettingFeatures() & Kerning ? f.width(RenderBlock::constructTextRun(this, f, &space, 1, styleToUse), &fallbackFonts) + wordSpacing : 0;
// If automatic hyphenation is allowed, we keep track of the width of the widest word (or word
// fragment) encountered so far, and only try hyphenating words that are wider.
@@ -1069,7 +1069,7 @@
if (w > maxWordWidth) {
int suffixStart;
- float maxFragmentWidth = maxWordFragmentWidth(this, styleToUse, f, characters() + i, wordLen, minimumPrefixLength, minimumSuffixLength, suffixStart);
+ float maxFragmentWidth = maxWordFragmentWidth(this, styleToUse, f, characters() + i, wordLen, minimumPrefixLength, minimumSuffixLength, suffixStart, fallbackFonts, glyphOverflow);
if (suffixStart) {
float suffixWidth;
@@ -1150,7 +1150,7 @@
run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize());
run.setXPos(leadWidth + currMaxWidth);
- currMaxWidth += f.width(run);
+ currMaxWidth += f.width(run, &fallbackFonts);
glyphOverflow.right = 0;
needsWordSpacing = isSpace && !previousCharacterIsSpace && i == len - 1;
}