| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // of a text run, since we already did this for the parent of the text run. | 197 // of a text run, since we already did this for the parent of the text run. |
| 198 // We do have to schedule layouts, though, since a style change can force us | 198 // We do have to schedule layouts, though, since a style change can force us |
| 199 // to need to relayout. | 199 // to need to relayout. |
| 200 if (diff.needsFullLayout()) { | 200 if (diff.needsFullLayout()) { |
| 201 setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::StyleChange); | 201 setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::StyleChange); |
| 202 m_knownToHaveNoOverflowAndNoFallbackFonts = false; | 202 m_knownToHaveNoOverflowAndNoFallbackFonts = false; |
| 203 } | 203 } |
| 204 | 204 |
| 205 const ComputedStyle& newStyle = styleRef(); | 205 const ComputedStyle& newStyle = styleRef(); |
| 206 ETextTransform oldTransform = | 206 ETextTransform oldTransform = |
| 207 oldStyle ? oldStyle->textTransform() : ETextTransform::None; | 207 oldStyle ? oldStyle->textTransform() : ETextTransform::kNone; |
| 208 ETextSecurity oldSecurity = oldStyle ? oldStyle->textSecurity() : TSNONE; | 208 ETextSecurity oldSecurity = oldStyle ? oldStyle->textSecurity() : TSNONE; |
| 209 if (oldTransform != newStyle.textTransform() || | 209 if (oldTransform != newStyle.textTransform() || |
| 210 oldSecurity != newStyle.textSecurity()) | 210 oldSecurity != newStyle.textSecurity()) |
| 211 transformText(); | 211 transformText(); |
| 212 | 212 |
| 213 // This is an optimization that kicks off font load before layout. | 213 // This is an optimization that kicks off font load before layout. |
| 214 if (!text().containsOnlyWhitespace()) | 214 if (!text().containsOnlyWhitespace()) |
| 215 newStyle.font().willUseFontData(text()); | 215 newStyle.font().willUseFontData(text()); |
| 216 | 216 |
| 217 TextAutosizer* textAutosizer = document().textAutosizer(); | 217 TextAutosizer* textAutosizer = document().textAutosizer(); |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 LayoutBlock* cb = containingBlock(); | 767 LayoutBlock* cb = containingBlock(); |
| 768 const ComputedStyle& cbStyle = cb->styleRef(); | 768 const ComputedStyle& cbStyle = cb->styleRef(); |
| 769 | 769 |
| 770 LayoutUnit leftEdge; | 770 LayoutUnit leftEdge; |
| 771 LayoutUnit rightEdge; | 771 LayoutUnit rightEdge; |
| 772 leftEdge = std::min(LayoutUnit(), rootLeft); | 772 leftEdge = std::min(LayoutUnit(), rootLeft); |
| 773 rightEdge = std::max(cb->logicalWidth(), rootRight); | 773 rightEdge = std::max(cb->logicalWidth(), rootRight); |
| 774 | 774 |
| 775 bool rightAligned = false; | 775 bool rightAligned = false; |
| 776 switch (cbStyle.textAlign()) { | 776 switch (cbStyle.textAlign()) { |
| 777 case ETextAlign::Right: | 777 case ETextAlign::kRight: |
| 778 case ETextAlign::WebkitRight: | 778 case ETextAlign::kWebkitRight: |
| 779 rightAligned = true; | 779 rightAligned = true; |
| 780 break; | 780 break; |
| 781 case ETextAlign::Left: | 781 case ETextAlign::kLeft: |
| 782 case ETextAlign::WebkitLeft: | 782 case ETextAlign::kWebkitLeft: |
| 783 case ETextAlign::Center: | 783 case ETextAlign::kCenter: |
| 784 case ETextAlign::WebkitCenter: | 784 case ETextAlign::kWebkitCenter: |
| 785 break; | 785 break; |
| 786 case ETextAlign::Justify: | 786 case ETextAlign::kJustify: |
| 787 case ETextAlign::Start: | 787 case ETextAlign::kStart: |
| 788 rightAligned = !cbStyle.isLeftToRightDirection(); | 788 rightAligned = !cbStyle.isLeftToRightDirection(); |
| 789 break; | 789 break; |
| 790 case ETextAlign::End: | 790 case ETextAlign::kEnd: |
| 791 rightAligned = cbStyle.isLeftToRightDirection(); | 791 rightAligned = cbStyle.isLeftToRightDirection(); |
| 792 break; | 792 break; |
| 793 } | 793 } |
| 794 | 794 |
| 795 // for unicode-bidi: plaintext, use inlineBoxBidiLevel() to test the correct | 795 // for unicode-bidi: plaintext, use inlineBoxBidiLevel() to test the correct |
| 796 // direction for the cursor. | 796 // direction for the cursor. |
| 797 if (rightAligned && style()->unicodeBidi() == Plaintext) { | 797 if (rightAligned && style()->unicodeBidi() == Plaintext) { |
| 798 if (inlineBox->bidiLevel() % 2 != 1) | 798 if (inlineBox->bidiLevel() % 2 != 1) |
| 799 rightAligned = false; | 799 rightAligned = false; |
| 800 } | 800 } |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 Hyphenation* hyphenation = | 1087 Hyphenation* hyphenation = |
| 1088 styleToUse.autoWrap() ? styleToUse.getHyphenation() : nullptr; | 1088 styleToUse.autoWrap() ? styleToUse.getHyphenation() : nullptr; |
| 1089 bool disableSoftHyphen = styleToUse.getHyphens() == HyphensNone; | 1089 bool disableSoftHyphen = styleToUse.getHyphens() == HyphensNone; |
| 1090 float maxWordWidth = 0; | 1090 float maxWordWidth = 0; |
| 1091 if (!hyphenation) | 1091 if (!hyphenation) |
| 1092 maxWordWidth = std::numeric_limits<float>::infinity(); | 1092 maxWordWidth = std::numeric_limits<float>::infinity(); |
| 1093 | 1093 |
| 1094 BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver; | 1094 BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver; |
| 1095 BidiCharacterRun* run; | 1095 BidiCharacterRun* run; |
| 1096 TextDirection textDirection = styleToUse.direction(); | 1096 TextDirection textDirection = styleToUse.direction(); |
| 1097 if ((is8Bit() && textDirection == TextDirection::Ltr) || | 1097 if ((is8Bit() && textDirection == TextDirection::kLtr) || |
| 1098 isOverride(styleToUse.unicodeBidi())) { | 1098 isOverride(styleToUse.unicodeBidi())) { |
| 1099 run = 0; | 1099 run = 0; |
| 1100 } else { | 1100 } else { |
| 1101 TextRun textRun(text()); | 1101 TextRun textRun(text()); |
| 1102 BidiStatus status(textDirection, false); | 1102 BidiStatus status(textDirection, false); |
| 1103 bidiResolver.setStatus(status); | 1103 bidiResolver.setStatus(status); |
| 1104 bidiResolver.setPositionIgnoringNestedIsolates( | 1104 bidiResolver.setPositionIgnoringNestedIsolates( |
| 1105 TextRunIterator(&textRun, 0)); | 1105 TextRunIterator(&textRun, 0)); |
| 1106 bool hardLineBreak = false; | 1106 bool hardLineBreak = false; |
| 1107 bool reorderRuns = false; | 1107 bool reorderRuns = false; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 | 1349 |
| 1350 if ((needsWordSpacing && len > 1) || (ignoringSpaces && !firstWord)) | 1350 if ((needsWordSpacing && len > 1) || (ignoringSpaces && !firstWord)) |
| 1351 currMaxWidth += wordSpacing; | 1351 currMaxWidth += wordSpacing; |
| 1352 | 1352 |
| 1353 m_minWidth = std::max(currMinWidth, m_minWidth); | 1353 m_minWidth = std::max(currMinWidth, m_minWidth); |
| 1354 m_maxWidth = std::max(currMaxWidth, m_maxWidth); | 1354 m_maxWidth = std::max(currMaxWidth, m_maxWidth); |
| 1355 | 1355 |
| 1356 if (!styleToUse.autoWrap()) | 1356 if (!styleToUse.autoWrap()) |
| 1357 m_minWidth = m_maxWidth; | 1357 m_minWidth = m_maxWidth; |
| 1358 | 1358 |
| 1359 if (styleToUse.whiteSpace() == EWhiteSpace::Pre) { | 1359 if (styleToUse.whiteSpace() == EWhiteSpace::kPre) { |
| 1360 if (firstLine) | 1360 if (firstLine) |
| 1361 m_firstLineMinWidth = m_maxWidth; | 1361 m_firstLineMinWidth = m_maxWidth; |
| 1362 m_lastLineLineMinWidth = currMaxWidth; | 1362 m_lastLineLineMinWidth = currMaxWidth; |
| 1363 } | 1363 } |
| 1364 | 1364 |
| 1365 const SimpleFontData* fontData = f.primaryFont(); | 1365 const SimpleFontData* fontData = f.primaryFont(); |
| 1366 DCHECK(fontData); | 1366 DCHECK(fontData); |
| 1367 | 1367 |
| 1368 GlyphOverflow glyphOverflow; | 1368 GlyphOverflow glyphOverflow; |
| 1369 if (fontData) { | 1369 if (fontData) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 // Text nodes aren't event targets, so don't descend any further. | 1591 // Text nodes aren't event targets, so don't descend any further. |
| 1592 } | 1592 } |
| 1593 | 1593 |
| 1594 void applyTextTransform(const ComputedStyle* style, | 1594 void applyTextTransform(const ComputedStyle* style, |
| 1595 String& text, | 1595 String& text, |
| 1596 UChar previousCharacter) { | 1596 UChar previousCharacter) { |
| 1597 if (!style) | 1597 if (!style) |
| 1598 return; | 1598 return; |
| 1599 | 1599 |
| 1600 switch (style->textTransform()) { | 1600 switch (style->textTransform()) { |
| 1601 case ETextTransform::None: | 1601 case ETextTransform::kNone: |
| 1602 break; | 1602 break; |
| 1603 case ETextTransform::Capitalize: | 1603 case ETextTransform::kCapitalize: |
| 1604 makeCapitalized(&text, previousCharacter); | 1604 makeCapitalized(&text, previousCharacter); |
| 1605 break; | 1605 break; |
| 1606 case ETextTransform::Uppercase: | 1606 case ETextTransform::kUppercase: |
| 1607 text = text.upper(style->locale()); | 1607 text = text.upper(style->locale()); |
| 1608 break; | 1608 break; |
| 1609 case ETextTransform::Lowercase: | 1609 case ETextTransform::kLowercase: |
| 1610 text = text.lower(style->locale()); | 1610 text = text.lower(style->locale()); |
| 1611 break; | 1611 break; |
| 1612 } | 1612 } |
| 1613 } | 1613 } |
| 1614 | 1614 |
| 1615 void LayoutText::setTextInternal(PassRefPtr<StringImpl> text) { | 1615 void LayoutText::setTextInternal(PassRefPtr<StringImpl> text) { |
| 1616 ASSERT(text); | 1616 ASSERT(text); |
| 1617 m_text = std::move(text); | 1617 m_text = std::move(text); |
| 1618 | 1618 |
| 1619 if (style()) { | 1619 if (style()) { |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1858 LayoutUnit logicalHeight = | 1858 LayoutUnit logicalHeight = |
| 1859 lastTextBox()->logicalBottomVisualOverflow() - logicalTop; | 1859 lastTextBox()->logicalBottomVisualOverflow() - logicalTop; |
| 1860 | 1860 |
| 1861 LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight); | 1861 LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight); |
| 1862 if (!style()->isHorizontalWritingMode()) | 1862 if (!style()->isHorizontalWritingMode()) |
| 1863 rect = rect.transposedRect(); | 1863 rect = rect.transposedRect(); |
| 1864 return rect; | 1864 return rect; |
| 1865 } | 1865 } |
| 1866 | 1866 |
| 1867 LayoutRect LayoutText::localVisualRect() const { | 1867 LayoutRect LayoutText::localVisualRect() const { |
| 1868 if (style()->visibility() != EVisibility::Visible) | 1868 if (style()->visibility() != EVisibility::kVisible) |
| 1869 return LayoutRect(); | 1869 return LayoutRect(); |
| 1870 | 1870 |
| 1871 return unionRect(visualOverflowRect(), localSelectionRect()); | 1871 return unionRect(visualOverflowRect(), localSelectionRect()); |
| 1872 } | 1872 } |
| 1873 | 1873 |
| 1874 LayoutRect LayoutText::localSelectionRect() const { | 1874 LayoutRect LayoutText::localSelectionRect() const { |
| 1875 ASSERT(!needsLayout()); | 1875 ASSERT(!needsLayout()); |
| 1876 | 1876 |
| 1877 if (getSelectionState() == SelectionNone) | 1877 if (getSelectionState() == SelectionNone) |
| 1878 return LayoutRect(); | 1878 return LayoutRect(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1993 LayoutRect rect = LayoutRect( | 1993 LayoutRect rect = LayoutRect( |
| 1994 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); | 1994 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); |
| 1995 LayoutBlock* block = containingBlock(); | 1995 LayoutBlock* block = containingBlock(); |
| 1996 if (block && hasTextBoxes()) | 1996 if (block && hasTextBoxes()) |
| 1997 block->adjustChildDebugRect(rect); | 1997 block->adjustChildDebugRect(rect); |
| 1998 | 1998 |
| 1999 return rect; | 1999 return rect; |
| 2000 } | 2000 } |
| 2001 | 2001 |
| 2002 } // namespace blink | 2002 } // namespace blink |
| OLD | NEW |