| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
| 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 ASSERT(m_text); | 787 ASSERT(m_text); |
| 788 StringImpl& text = *m_text.impl(); | 788 StringImpl& text = *m_text.impl(); |
| 789 if (text[0] == spaceCharacter || (text[0] == newlineCharacter && !style()->p
reserveNewline()) || text[0] == tabulationCharacter) { | 789 if (text[0] == spaceCharacter || (text[0] == newlineCharacter && !style()->p
reserveNewline()) || text[0] == tabulationCharacter) { |
| 790 const Font& font = style()->font(); // FIXME: This ignores first-line. | 790 const Font& font = style()->font(); // FIXME: This ignores first-line. |
| 791 if (stripFrontSpaces) { | 791 if (stripFrontSpaces) { |
| 792 const UChar spaceChar = spaceCharacter; | 792 const UChar spaceChar = spaceCharacter; |
| 793 TextRun run = constructTextRun(font, &spaceChar, 1, styleRef(), dire
ction); | 793 TextRun run = constructTextRun(font, &spaceChar, 1, styleRef(), dire
ction); |
| 794 float spaceWidth = font.width(run); | 794 float spaceWidth = font.width(run); |
| 795 floatMaxWidth -= spaceWidth; | 795 floatMaxWidth -= spaceWidth; |
| 796 } else { | 796 } else { |
| 797 floatMaxWidth += font.fontDescription().wordSpacing(); | 797 floatMaxWidth += font.getFontDescription().wordSpacing(); |
| 798 } | 798 } |
| 799 } | 799 } |
| 800 | 800 |
| 801 stripFrontSpaces = collapseWhiteSpace && m_hasEndWhiteSpace; | 801 stripFrontSpaces = collapseWhiteSpace && m_hasEndWhiteSpace; |
| 802 | 802 |
| 803 if (!style()->autoWrap() || floatMinWidth > floatMaxWidth) | 803 if (!style()->autoWrap() || floatMinWidth > floatMaxWidth) |
| 804 floatMinWidth = floatMaxWidth; | 804 floatMinWidth = floatMaxWidth; |
| 805 | 805 |
| 806 // Compute our max widths by scanning the string for newlines. | 806 // Compute our max widths by scanning the string for newlines. |
| 807 if (hasBreak) { | 807 if (hasBreak) { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 // Terminate word boundary at bidi run boundary. | 999 // Terminate word boundary at bidi run boundary. |
| 1000 if (run) | 1000 if (run) |
| 1001 j = std::min(j, run->stop() + 1); | 1001 j = std::min(j, run->stop() + 1); |
| 1002 int wordLen = j - i; | 1002 int wordLen = j - i; |
| 1003 if (wordLen) { | 1003 if (wordLen) { |
| 1004 bool isSpace = (j < len) && c == spaceCharacter; | 1004 bool isSpace = (j < len) && c == spaceCharacter; |
| 1005 | 1005 |
| 1006 // Non-zero only when kerning is enabled, in which case we measure w
ords with their trailing | 1006 // Non-zero only when kerning is enabled, in which case we measure w
ords with their trailing |
| 1007 // space, then subtract its width. | 1007 // space, then subtract its width. |
| 1008 float wordTrailingSpaceWidth = 0; | 1008 float wordTrailingSpaceWidth = 0; |
| 1009 if (isSpace && (f.fontDescription().getTypesettingFeatures() & Kerni
ng)) { | 1009 if (isSpace && (f.getFontDescription().getTypesettingFeatures() & Ke
rning)) { |
| 1010 ASSERT(textDirection >=0 && textDirection <= 1); | 1010 ASSERT(textDirection >=0 && textDirection <= 1); |
| 1011 if (!cachedWordTrailingSpaceWidth[textDirection]) | 1011 if (!cachedWordTrailingSpaceWidth[textDirection]) |
| 1012 cachedWordTrailingSpaceWidth[textDirection] = f.width(constr
uctTextRun(f, &spaceCharacter, 1, styleToUse, textDirection)) + wordSpacing; | 1012 cachedWordTrailingSpaceWidth[textDirection] = f.width(constr
uctTextRun(f, &spaceCharacter, 1, styleToUse, textDirection)) + wordSpacing; |
| 1013 wordTrailingSpaceWidth = cachedWordTrailingSpaceWidth[textDirect
ion]; | 1013 wordTrailingSpaceWidth = cachedWordTrailingSpaceWidth[textDirect
ion]; |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 float w; | 1016 float w; |
| 1017 if (wordTrailingSpaceWidth && isSpace) { | 1017 if (wordTrailingSpaceWidth && isSpace) { |
| 1018 w = widthFromFont(f, i, wordLen + 1, leadWidth, currMaxWidth, te
xtDirection, &fallbackFonts, &glyphBounds) - wordTrailingSpaceWidth; | 1018 w = widthFromFont(f, i, wordLen + 1, leadWidth, currMaxWidth, te
xtDirection, &fallbackFonts, &glyphBounds) - wordTrailingSpaceWidth; |
| 1019 } else { | 1019 } else { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 if (!styleToUse.autoWrap()) | 1103 if (!styleToUse.autoWrap()) |
| 1104 m_minWidth = m_maxWidth; | 1104 m_minWidth = m_maxWidth; |
| 1105 | 1105 |
| 1106 if (styleToUse.whiteSpace() == PRE) { | 1106 if (styleToUse.whiteSpace() == PRE) { |
| 1107 if (firstLine) | 1107 if (firstLine) |
| 1108 m_firstLineMinWidth = m_maxWidth; | 1108 m_firstLineMinWidth = m_maxWidth; |
| 1109 m_lastLineLineMinWidth = currMaxWidth; | 1109 m_lastLineLineMinWidth = currMaxWidth; |
| 1110 } | 1110 } |
| 1111 | 1111 |
| 1112 GlyphOverflow glyphOverflow; | 1112 GlyphOverflow glyphOverflow; |
| 1113 glyphOverflow.setFromBounds(glyphBounds, f.fontMetrics().floatAscent(), f.fo
ntMetrics().floatDescent(), m_maxWidth); | 1113 glyphOverflow.setFromBounds(glyphBounds, f.getFontMetrics().floatAscent(), f
.getFontMetrics().floatDescent(), m_maxWidth); |
| 1114 // We shouldn't change our mind once we "know". | 1114 // We shouldn't change our mind once we "know". |
| 1115 ASSERT(!m_knownToHaveNoOverflowAndNoFallbackFonts || (fallbackFonts.isEmpty(
) && glyphOverflow.isApproximatelyZero())); | 1115 ASSERT(!m_knownToHaveNoOverflowAndNoFallbackFonts || (fallbackFonts.isEmpty(
) && glyphOverflow.isApproximatelyZero())); |
| 1116 m_knownToHaveNoOverflowAndNoFallbackFonts = fallbackFonts.isEmpty() && glyph
Overflow.isApproximatelyZero(); | 1116 m_knownToHaveNoOverflowAndNoFallbackFonts = fallbackFonts.isEmpty() && glyph
Overflow.isApproximatelyZero(); |
| 1117 | 1117 |
| 1118 clearPreferredLogicalWidthsDirty(); | 1118 clearPreferredLogicalWidthsDirty(); |
| 1119 } | 1119 } |
| 1120 | 1120 |
| 1121 bool LayoutText::isAllCollapsibleWhitespace() const | 1121 bool LayoutText::isAllCollapsibleWhitespace() const |
| 1122 { | 1122 { |
| 1123 unsigned length = textLength(); | 1123 unsigned length = textLength(); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1493 return 0; | 1493 return 0; |
| 1494 | 1494 |
| 1495 float w; | 1495 float w; |
| 1496 if (&f == &style()->font()) { | 1496 if (&f == &style()->font()) { |
| 1497 if (!style()->preserveNewline() && !from && len == textLength()) { | 1497 if (!style()->preserveNewline() && !from && len == textLength()) { |
| 1498 if (fallbackFonts) { | 1498 if (fallbackFonts) { |
| 1499 ASSERT(glyphBounds); | 1499 ASSERT(glyphBounds); |
| 1500 if (preferredLogicalWidthsDirty() || !m_knownToHaveNoOverflowAnd
NoFallbackFonts) | 1500 if (preferredLogicalWidthsDirty() || !m_knownToHaveNoOverflowAnd
NoFallbackFonts) |
| 1501 const_cast<LayoutText*>(this)->computePreferredLogicalWidths
(0, *fallbackFonts, *glyphBounds); | 1501 const_cast<LayoutText*>(this)->computePreferredLogicalWidths
(0, *fallbackFonts, *glyphBounds); |
| 1502 else | 1502 else |
| 1503 *glyphBounds = FloatRect(0, -f.fontMetrics().floatAscent(),
m_maxWidth, f.fontMetrics().floatHeight()); | 1503 *glyphBounds = FloatRect(0, -f.getFontMetrics().floatAscent(
), m_maxWidth, f.getFontMetrics().floatHeight()); |
| 1504 w = m_maxWidth; | 1504 w = m_maxWidth; |
| 1505 } else { | 1505 } else { |
| 1506 w = maxLogicalWidth(); | 1506 w = maxLogicalWidth(); |
| 1507 } | 1507 } |
| 1508 } else { | 1508 } else { |
| 1509 w = widthFromFont(f, from, len, xPos.toFloat(), 0, textDirection, fa
llbackFonts, glyphBounds); | 1509 w = widthFromFont(f, from, len, xPos.toFloat(), 0, textDirection, fa
llbackFonts, glyphBounds); |
| 1510 } | 1510 } |
| 1511 } else { | 1511 } else { |
| 1512 TextRun run = constructTextRun(f, this, from, len, styleRef(), textDirec
tion); | 1512 TextRun run = constructTextRun(f, this, from, len, styleRef(), textDirec
tion); |
| 1513 run.setCharactersLength(textLength() - from); | 1513 run.setCharactersLength(textLength() - from); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1751 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { | 1751 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { |
| 1752 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box, in
validationReason); | 1752 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box, in
validationReason); |
| 1753 if (box->truncation() != cNoTruncation) { | 1753 if (box->truncation() != cNoTruncation) { |
| 1754 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox()) | 1754 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox()) |
| 1755 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(
*ellipsisBox, invalidationReason); | 1755 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(
*ellipsisBox, invalidationReason); |
| 1756 } | 1756 } |
| 1757 } | 1757 } |
| 1758 } | 1758 } |
| 1759 | 1759 |
| 1760 } // namespace blink | 1760 } // namespace blink |
| OLD | NEW |