Chromium Code Reviews| Index: Source/core/layout/LayoutBlockFlowLine.cpp |
| diff --git a/Source/core/layout/LayoutBlockFlowLine.cpp b/Source/core/layout/LayoutBlockFlowLine.cpp |
| index f37a019d3e6ede2b2a216174bcfdda5fcd56d09b..151ba4f3646122e6355cb63d983494062fa06379 100644 |
| --- a/Source/core/layout/LayoutBlockFlowLine.cpp |
| +++ b/Source/core/layout/LayoutBlockFlowLine.cpp |
| @@ -33,6 +33,7 @@ |
| #include "core/layout/TextRunConstructor.h" |
| #include "core/layout/VerticalPositionCache.h" |
| #include "core/layout/line/BreakingContextInlineHeaders.h" |
| +#include "core/layout/line/GlyphOverflow.h" |
| #include "core/layout/line/LayoutTextInfo.h" |
| #include "core/layout/line/LineLayoutState.h" |
| #include "core/layout/line/LineWidth.h" |
| @@ -371,17 +372,66 @@ static inline void setLogicalWidthForTextRun(RootInlineBox* lineBox, BidiRun* ru |
| HashSet<const SimpleFontData*> fallbackFonts; |
| GlyphOverflow glyphOverflow; |
| + const Font& font = layoutText->style(lineInfo.isFirstLine())->font(); |
| // Always compute glyph overflow bounds if the block's line-box-contain value is "glyphs". |
| if (lineBox->fitsToGlyphs()) |
| glyphOverflow.computeBounds = true; |
| LayoutUnit hyphenWidth = 0; |
| - if (toInlineTextBox(run->m_box)->hasHyphen()) { |
| - const Font& font = layoutText->style(lineInfo.isFirstLine())->font(); |
| + if (toInlineTextBox(run->m_box)->hasHyphen()) |
| hyphenWidth = measureHyphenWidth(layoutText, font, run->direction()); |
| + |
|
Xianzhu
2015/06/11 18:22:48
Line 384 to line 432 below are original LayoutBloc
|
| + float measuredWidth = 0; |
| + FloatRect glyphBounds; |
| + |
| + bool kerningIsEnabled = font.fontDescription().typesettingFeatures() & Kerning; |
| + |
| +#if OS(MACOSX) |
| + // FIXME: Having any font feature settings enabled can lead to selection gaps on |
| + // Chromium-mac. https://bugs.webkit.org/show_bug.cgi?id=113418 |
| + bool canUseSimpleFontCodePath = layoutText->canUseSimpleFontCodePath() && !font.fontDescription().featureSettings(); |
| +#else |
| + bool canUseSimpleFontCodePath = layoutText->canUseSimpleFontCodePath(); |
| +#endif |
| + |
| + if (canUseSimpleFontCodePath) { |
|
Xianzhu
2015/06/11 18:22:47
We can use fast path when fitToGlyphs() because no
|
| + 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) |
| + continue; |
| + if (wordMeasurement.layoutText != layoutText || wordMeasurement.startOffset != lastEndOffset || wordMeasurement.endOffset > run->m_stop) |
| + continue; |
| + |
| + lastEndOffset = wordMeasurement.endOffset; |
| + if (kerningIsEnabled && lastEndOffset == run->m_stop) { |
| + int wordLength = lastEndOffset - wordMeasurement.startOffset; |
| + measuredWidth += layoutText->width(wordMeasurement.startOffset, wordLength, xPos, run->direction(), lineInfo.isFirstLine()); |
| + if (i > 0 && wordLength == 1 && layoutText->characterAt(wordMeasurement.startOffset) == ' ') |
| + measuredWidth += layoutText->style()->wordSpacing(); |
| + } else { |
| + FloatRect wordGlyphBounds = wordMeasurement.glyphBounds; |
| + wordGlyphBounds.move(measuredWidth, 0); |
| + glyphBounds.unite(wordGlyphBounds); |
|
Xianzhu
2015/06/11 18:22:48
Line 413-415 are added to accumulate work glyph bo
|
| + measuredWidth += wordMeasurement.width; |
| + } |
| + if (!wordMeasurement.fallbackFonts.isEmpty()) { |
| + HashSet<const SimpleFontData*>::const_iterator end = wordMeasurement.fallbackFonts.end(); |
| + for (HashSet<const SimpleFontData*>::const_iterator it = wordMeasurement.fallbackFonts.begin(); it != end; ++it) |
| + fallbackFonts.add(*it); |
| + } |
| + } |
| + if (measuredWidth && lastEndOffset != run->m_stop) { |
| + // If we don't have enough cached data, we'll measure the run again. |
| + measuredWidth = 0; |
| + fallbackFonts.clear(); |
| + } |
| } |
| - float measuredWidth = layoutText->width(run->m_start, run->m_stop - run->m_start, xPos, run->direction(), lineInfo.isFirstLine(), &fallbackFonts, &glyphOverflow); |
| + if (!measuredWidth) |
| + measuredWidth = layoutText->width(run->m_start, run->m_stop - run->m_start, xPos, run->direction(), lineInfo.isFirstLine(), &fallbackFonts, &glyphBounds); |
| + |
| + glyphOverflow.setFromBounds(glyphBounds, font.fontMetrics().floatAscent(), font.fontMetrics().floatDescent(), measuredWidth); |
| run->m_box->setLogicalWidth(measuredWidth + hyphenWidth); |
| if (!fallbackFonts.isEmpty()) { |