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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 static inline void setLogicalWidthForTextRun(RootInlineBox* lineBox, BidiRun* ru
n, LayoutText* layoutText, LayoutUnit xPos, const LineInfo& lineInfo, | 428 static inline void setLogicalWidthForTextRun(RootInlineBox* lineBox, BidiRun* ru
n, LayoutText* layoutText, LayoutUnit xPos, const LineInfo& lineInfo, |
429 GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& ver
ticalPositionCache, WordMeasurements& wordMeasurements) | 429 GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& ver
ticalPositionCache, WordMeasurements& wordMeasurements) |
430 { | 430 { |
431 HashSet<const SimpleFontData*> fallbackFonts; | 431 HashSet<const SimpleFontData*> fallbackFonts; |
432 GlyphOverflow glyphOverflow; | 432 GlyphOverflow glyphOverflow; |
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 = 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().typesettingFeatures() & Kerni
ng; | 443 bool kerningIsEnabled = font.fontDescription().typesettingFeatures() & Kerni
ng; |
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.fontD
escription().featureSettings(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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.fontMetrics().floatAscent(), f
ont.fontMetrics().floatDescent(), measuredWidth); |
502 | 502 |
503 run->m_box->setLogicalWidth(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()) { |
512 ASSERT(run->m_box->isText()); | 512 ASSERT(run->m_box->isText()); |
513 GlyphOverflowAndFallbackFontsMap::ValueType* it = textBoxDataMap.add(toI
nlineTextBox(run->m_box), std::make_pair(Vector<const SimpleFontData*>(), GlyphO
verflow())).storedValue; | 513 GlyphOverflowAndFallbackFontsMap::ValueType* it = textBoxDataMap.add(toI
nlineTextBox(run->m_box), std::make_pair(Vector<const SimpleFontData*>(), GlyphO
verflow())).storedValue; |
(...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 LayoutUnit currLogicalLeft = curr->logicalLeft(); | 1981 LayoutUnit currLogicalLeft = curr->logicalLeft(); |
1982 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), i
ndentText); | 1982 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), i
ndentText); |
1983 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), ind
entText); | 1983 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), ind
entText); |
1984 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() :
currLogicalLeft; | 1984 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() :
currLogicalLeft; |
1985 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc
kLeftEdge)) { | 1985 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc
kLeftEdge)) { |
1986 // This line spills out of our box in the appropriate direction. No
w we need to see if the line | 1986 // This line spills out of our box in the appropriate direction. No
w we need to see if the line |
1987 // can be truncated. In order for truncation to be possible, the li
ne must have sufficient space to | 1987 // can be truncated. In order for truncation to be possible, the li
ne must have sufficient space to |
1988 // accommodate our truncation string, and no replaced elements (imag
es, tables) can overlap the ellipsis | 1988 // accommodate our truncation string, and no replaced elements (imag
es, tables) can overlap the ellipsis |
1989 // space. | 1989 // space. |
1990 | 1990 |
1991 LayoutUnit width = indentText == IndentText ? firstLineEllipsisWidth
: ellipsisWidth; | 1991 LayoutUnit width(indentText == IndentText ? firstLineEllipsisWidth :
ellipsisWidth); |
1992 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; | 1992 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; |
1993 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi
dth)) { | 1993 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi
dth)) { |
1994 LayoutUnit totalLogicalWidth = curr->placeEllipsis(selectedEllip
sisStr, ltr, blockLeftEdge, blockRightEdge, width); | 1994 LayoutUnit totalLogicalWidth = curr->placeEllipsis(selectedEllip
sisStr, ltr, blockLeftEdge, blockRightEdge, width); |
1995 LayoutUnit logicalLeft; // We are only interested in the delta f
rom the base position. | 1995 LayoutUnit logicalLeft; // We are only interested in the delta f
rom the base position. |
1996 LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdg
e; | 1996 LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdg
e; |
1997 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft,
totalLogicalWidth, availableLogicalWidth, 0); | 1997 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft,
totalLogicalWidth, availableLogicalWidth, 0); |
1998 if (ltr) | 1998 if (ltr) |
1999 curr->moveInInlineDirection(logicalLeft); | 1999 curr->moveInInlineDirection(logicalLeft); |
2000 else | 2000 else |
2001 curr->moveInInlineDirection(logicalLeft - (availableLogicalW
idth - totalLogicalWidth)); | 2001 curr->moveInInlineDirection(logicalLeft - (availableLogicalW
idth - totalLogicalWidth)); |
(...skipping 105 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 |