| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ight reserved. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ight reserved. |
| 4 * Copyright (C) 2010 Google Inc. All rights reserved. | 4 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 433 |
| 434 const Font& font = layoutText.style(lineInfo.isFirstLine())->font(); | 434 const Font& font = layoutText.style(lineInfo.isFirstLine())->font(); |
| 435 | 435 |
| 436 LayoutUnit hyphenWidth; | 436 LayoutUnit hyphenWidth; |
| 437 if (toInlineTextBox(run->m_box)->hasHyphen()) | 437 if (toInlineTextBox(run->m_box)->hasHyphen()) |
| 438 hyphenWidth = LayoutUnit(layoutText.hyphenWidth(font, run->direction()))
; | 438 hyphenWidth = LayoutUnit(layoutText.hyphenWidth(font, run->direction()))
; |
| 439 | 439 |
| 440 float measuredWidth = 0; | 440 float measuredWidth = 0; |
| 441 FloatRect glyphBounds; | 441 FloatRect glyphBounds; |
| 442 | 442 |
| 443 bool kerningIsEnabled = font.fontDescription().getTypesettingFeatures() & Ke
rning; | 443 bool kerningIsEnabled = font.getFontDescription().getTypesettingFeatures() &
Kerning; |
| 444 | 444 |
| 445 #if OS(MACOSX) | 445 #if OS(MACOSX) |
| 446 // FIXME: Having any font feature settings enabled can lead to selection gap
s on | 446 // FIXME: Having any font feature settings enabled can lead to selection gap
s on |
| 447 // Chromium-mac. https://bugs.webkit.org/show_bug.cgi?id=113418 | 447 // Chromium-mac. https://bugs.webkit.org/show_bug.cgi?id=113418 |
| 448 bool canUseCachedWordMeasurements = font.canShapeWordByWord() && !font.fontD
escription().featureSettings(); | 448 bool canUseCachedWordMeasurements = font.canShapeWordByWord() && !font.getFo
ntDescription().featureSettings(); |
| 449 #else | 449 #else |
| 450 bool canUseCachedWordMeasurements = font.canShapeWordByWord(); | 450 bool canUseCachedWordMeasurements = font.canShapeWordByWord(); |
| 451 #endif | 451 #endif |
| 452 | 452 |
| 453 if (canUseCachedWordMeasurements) { | 453 if (canUseCachedWordMeasurements) { |
| 454 int lastEndOffset = run->m_start; | 454 int lastEndOffset = run->m_start; |
| 455 for (size_t i = 0, size = wordMeasurements.size(); i < size && lastEndOf
fset < run->m_stop; ++i) { | 455 for (size_t i = 0, size = wordMeasurements.size(); i < size && lastEndOf
fset < run->m_stop; ++i) { |
| 456 const WordMeasurement& wordMeasurement = wordMeasurements[i]; | 456 const WordMeasurement& wordMeasurement = wordMeasurements[i]; |
| 457 if (wordMeasurement.startOffset == wordMeasurement.endOffset) | 457 if (wordMeasurement.startOffset == wordMeasurement.endOffset) |
| 458 continue; | 458 continue; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 // Negative word-spacing and/or letter-spacing may cause some glyphs to over
flow the left boundary and result | 491 // Negative word-spacing and/or letter-spacing may cause some glyphs to over
flow the left boundary and result |
| 492 // negative measured width. Reset measured width to 0 and adjust glyph bound
s accordingly to cover the overflow. | 492 // negative measured width. Reset measured width to 0 and adjust glyph bound
s accordingly to cover the overflow. |
| 493 if (measuredWidth < 0) { | 493 if (measuredWidth < 0) { |
| 494 if (measuredWidth < glyphBounds.x()) { | 494 if (measuredWidth < glyphBounds.x()) { |
| 495 glyphBounds.expand(glyphBounds.x() - measuredWidth, 0); | 495 glyphBounds.expand(glyphBounds.x() - measuredWidth, 0); |
| 496 glyphBounds.setX(measuredWidth); | 496 glyphBounds.setX(measuredWidth); |
| 497 } | 497 } |
| 498 measuredWidth = 0; | 498 measuredWidth = 0; |
| 499 } | 499 } |
| 500 | 500 |
| 501 glyphOverflow.setFromBounds(glyphBounds, font.fontMetrics().floatAscent(), f
ont.fontMetrics().floatDescent(), measuredWidth); | 501 glyphOverflow.setFromBounds(glyphBounds, font.getFontMetrics().floatAscent()
, font.getFontMetrics().floatDescent(), measuredWidth); |
| 502 | 502 |
| 503 run->m_box->setLogicalWidth(LayoutUnit(measuredWidth) + hyphenWidth); | 503 run->m_box->setLogicalWidth(LayoutUnit(measuredWidth) + hyphenWidth); |
| 504 if (!fallbackFonts.isEmpty()) { | 504 if (!fallbackFonts.isEmpty()) { |
| 505 ASSERT(run->m_box->isText()); | 505 ASSERT(run->m_box->isText()); |
| 506 GlyphOverflowAndFallbackFontsMap::ValueType* it = textBoxDataMap.add(toI
nlineTextBox(run->m_box), std::make_pair(Vector<const SimpleFontData*>(), GlyphO
verflow())).storedValue; | 506 GlyphOverflowAndFallbackFontsMap::ValueType* it = textBoxDataMap.add(toI
nlineTextBox(run->m_box), std::make_pair(Vector<const SimpleFontData*>(), GlyphO
verflow())).storedValue; |
| 507 ASSERT(it->value.first.isEmpty()); | 507 ASSERT(it->value.first.isEmpty()); |
| 508 copyToVector(fallbackFonts, it->value.first); | 508 copyToVector(fallbackFonts, it->value.first); |
| 509 run->m_box->parent()->clearDescendantsHaveSameLineHeightAndBaseline(); | 509 run->m_box->parent()->clearDescendantsHaveSameLineHeightAndBaseline(); |
| 510 } | 510 } |
| 511 if (!glyphOverflow.isApproximatelyZero()) { | 511 if (!glyphOverflow.isApproximatelyZero()) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 if (r->m_lineLayoutItem.isText()) { | 627 if (r->m_lineLayoutItem.isText()) { |
| 628 LineLayoutText rt(r->m_lineLayoutItem); | 628 LineLayoutText rt(r->m_lineLayoutItem); |
| 629 if (textAlign == JUSTIFY && r != trailingSpaceRun && textJustify !=
TextJustifyNone) { | 629 if (textAlign == JUSTIFY && r != trailingSpaceRun && textJustify !=
TextJustifyNone) { |
| 630 if (!isAfterExpansion) | 630 if (!isAfterExpansion) |
| 631 toInlineTextBox(r->m_box)->setCanHaveLeadingExpansion(true); | 631 toInlineTextBox(r->m_box)->setCanHaveLeadingExpansion(true); |
| 632 expansions.addRunWithExpansions(*r, isAfterExpansion, textJustif
y); | 632 expansions.addRunWithExpansions(*r, isAfterExpansion, textJustif
y); |
| 633 } | 633 } |
| 634 | 634 |
| 635 if (rt.textLength()) { | 635 if (rt.textLength()) { |
| 636 if (!r->m_start && needsWordSpacing && isSpaceOrNewline(rt.chara
cterAt(r->m_start))) | 636 if (!r->m_start && needsWordSpacing && isSpaceOrNewline(rt.chara
cterAt(r->m_start))) |
| 637 totalLogicalWidth += rt.style(lineInfo.isFirstLine())->font(
).fontDescription().wordSpacing(); | 637 totalLogicalWidth += rt.style(lineInfo.isFirstLine())->font(
).getFontDescription().wordSpacing(); |
| 638 needsWordSpacing = !isSpaceOrNewline(rt.characterAt(r->m_stop -
1)); | 638 needsWordSpacing = !isSpaceOrNewline(rt.characterAt(r->m_stop -
1)); |
| 639 } | 639 } |
| 640 | 640 |
| 641 setLogicalWidthForTextRun(lineBox, r, rt, totalLogicalWidth, lineInf
o, textBoxDataMap, verticalPositionCache, wordMeasurements); | 641 setLogicalWidthForTextRun(lineBox, r, rt, totalLogicalWidth, lineInf
o, textBoxDataMap, verticalPositionCache, wordMeasurements); |
| 642 } else { | 642 } else { |
| 643 isAfterExpansion = false; | 643 isAfterExpansion = false; |
| 644 if (!r->m_lineLayoutItem.isLayoutInline()) { | 644 if (!r->m_lineLayoutItem.isLayoutInline()) { |
| 645 LayoutBox* layoutBox = toLayoutBox(r->m_lineLayoutItem.layoutObj
ect()); | 645 LayoutBox* layoutBox = toLayoutBox(r->m_lineLayoutItem.layoutObj
ect()); |
| 646 if (layoutBox->isRubyRun()) | 646 if (layoutBox->isRubyRun()) |
| 647 setMarginsForRubyRun(r, toLayoutRubyRun(layoutBox), previous
Object, lineInfo); | 647 setMarginsForRubyRun(r, toLayoutRubyRun(layoutBox), previous
Object, lineInfo); |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 if (!Character::treatAsSpace(c)) | 1179 if (!Character::treatAsSpace(c)) |
| 1180 break; | 1180 break; |
| 1181 trailingWhitespaceChar = c; | 1181 trailingWhitespaceChar = c; |
| 1182 } | 1182 } |
| 1183 | 1183 |
| 1184 // FIXME: This ignores first-line. | 1184 // FIXME: This ignores first-line. |
| 1185 const Font& font = text->style()->font(); | 1185 const Font& font = text->style()->font(); |
| 1186 TextRun run = constructTextRun(font, &trailingWhitespaceChar, 1, | 1186 TextRun run = constructTextRun(font, &trailingWhitespaceChar, 1, |
| 1187 text->styleRef(), text->style()->direction()); | 1187 text->styleRef(), text->style()->direction()); |
| 1188 float spaceWidth = font.width(run); | 1188 float spaceWidth = font.width(run); |
| 1189 inlineMax -= LayoutUnit::fromFloatCeil(spaceWidth + font.fontDescription
().wordSpacing()); | 1189 inlineMax -= LayoutUnit::fromFloatCeil(spaceWidth + font.getFontDescript
ion().wordSpacing()); |
| 1190 if (inlineMin > inlineMax) | 1190 if (inlineMin > inlineMax) |
| 1191 inlineMin = inlineMax; | 1191 inlineMin = inlineMax; |
| 1192 } | 1192 } |
| 1193 } | 1193 } |
| 1194 | 1194 |
| 1195 // When converting between floating point and LayoutUnits we risk losing precisi
on | 1195 // When converting between floating point and LayoutUnits we risk losing precisi
on |
| 1196 // with each conversion. When this occurs while accumulating our preferred width
s, | 1196 // with each conversion. When this occurs while accumulating our preferred width
s, |
| 1197 // we can wind up with a line width that's larger than our maxPreferredWidth due
to | 1197 // we can wind up with a line width that's larger than our maxPreferredWidth due
to |
| 1198 // pure float accumulation. | 1198 // pure float accumulation. |
| 1199 static inline LayoutUnit adjustFloatForSubPixelLayout(float value) | 1199 static inline LayoutUnit adjustFloatForSubPixelLayout(float value) |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2107 if (!line || !line->isFirstLineStyle()) | 2107 if (!line || !line->isFirstLineStyle()) |
| 2108 return reason; | 2108 return reason; |
| 2109 // It's the RootInlineBox that paints the ::first-line background. Note that
since it may be | 2109 // It's the RootInlineBox that paints the ::first-line background. Note that
since it may be |
| 2110 // expensive to figure out if the first line is affected by any ::first-line
selectors at all, | 2110 // expensive to figure out if the first line is affected by any ::first-line
selectors at all, |
| 2111 // we just invalidate it unconditionally, since that's typically cheaper. | 2111 // we just invalidate it unconditionally, since that's typically cheaper. |
| 2112 invalidateDisplayItemClient(*line); | 2112 invalidateDisplayItemClient(*line); |
| 2113 return reason; | 2113 return reason; |
| 2114 } | 2114 } |
| 2115 | 2115 |
| 2116 } // namespace blink | 2116 } // namespace blink |
| OLD | NEW |