| 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 * Copyright (C) 2013 Adobe Systems Incorporated. | 5 * Copyright (C) 2013 Adobe Systems Incorporated. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 void commitAndUpdateLineBreakIfNeeded(); | 108 void commitAndUpdateLineBreakIfNeeded(); |
| 109 InlineIterator handleEndOfLine(); | 109 InlineIterator handleEndOfLine(); |
| 110 | 110 |
| 111 void clearLineBreakIfFitsOnLine() | 111 void clearLineBreakIfFitsOnLine() |
| 112 { | 112 { |
| 113 if (m_width.fitsOnLine() || m_lastWS == NOWRAP) | 113 if (m_width.fitsOnLine() || m_lastWS == NOWRAP) |
| 114 m_lineBreak.clear(); | 114 m_lineBreak.clear(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 private: | 117 private: |
| 118 void setCurrentCharacterIsSpace(UChar); |
| 118 void skipTrailingWhitespace(InlineIterator&, const LineInfo&); | 119 void skipTrailingWhitespace(InlineIterator&, const LineInfo&); |
| 119 bool shouldMidWordBreak(UChar, LineLayoutText, const Font&, | 120 bool shouldMidWordBreak(UChar, LineLayoutText, const Font&, |
| 120 float& charWidth, float& widthFromLastBreakingOpportunity, | 121 float& charWidth, float& widthFromLastBreakingOpportunity, |
| 121 bool breakAll, int& nextBreakablePositionForBreakAll); | 122 bool breakAll, int& nextBreakablePositionForBreakAll); |
| 122 bool rewindToMidWordBreak(WordMeasurement&, int end, float width); | 123 bool rewindToMidWordBreak(WordMeasurement&, int end, float width); |
| 123 bool rewindToFirstMidWordBreak(LineLayoutText, const ComputedStyle&, const F
ont&, bool breakAll, WordMeasurement&); | 124 bool rewindToFirstMidWordBreak(LineLayoutText, const ComputedStyle&, const F
ont&, bool breakAll, WordMeasurement&); |
| 124 bool rewindToMidWordBreak(LineLayoutText, const ComputedStyle&, const Font&,
bool breakAll, WordMeasurement&); | 125 bool rewindToMidWordBreak(LineLayoutText, const ComputedStyle&, const Font&,
bool breakAll, WordMeasurement&); |
| 125 bool hyphenate(LineLayoutText, const ComputedStyle&, const Font&, const Hyph
enation&, float lastSpaceWordSpacing, WordMeasurement&); | 126 bool hyphenate(LineLayoutText, const ComputedStyle&, const Font&, const Hyph
enation&, float lastSpaceWordSpacing, WordMeasurement&); |
| 126 bool isBreakAtSoftHyphen() const; | 127 bool isBreakAtSoftHyphen() const; |
| 127 | 128 |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 // Update prior line break context characters, using U+FFFD (OBJECT REPLACEM
ENT CHARACTER) for replaced element. | 521 // Update prior line break context characters, using U+FFFD (OBJECT REPLACEM
ENT CHARACTER) for replaced element. |
| 521 m_layoutTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter
); | 522 m_layoutTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter
); |
| 522 } | 523 } |
| 523 | 524 |
| 524 inline void nextCharacter(UChar& currentCharacter, UChar& lastCharacter, UChar&
secondToLastCharacter) | 525 inline void nextCharacter(UChar& currentCharacter, UChar& lastCharacter, UChar&
secondToLastCharacter) |
| 525 { | 526 { |
| 526 secondToLastCharacter = lastCharacter; | 527 secondToLastCharacter = lastCharacter; |
| 527 lastCharacter = currentCharacter; | 528 lastCharacter = currentCharacter; |
| 528 } | 529 } |
| 529 | 530 |
| 531 ALWAYS_INLINE void BreakingContext::setCurrentCharacterIsSpace(UChar c) |
| 532 { |
| 533 m_currentCharacterIsSpace = c == spaceCharacter || c == tabulationCharacter
|| (!m_preservesNewline && (c == newlineCharacter)); |
| 534 } |
| 535 |
| 530 inline float firstPositiveWidth(const WordMeasurements& wordMeasurements) | 536 inline float firstPositiveWidth(const WordMeasurements& wordMeasurements) |
| 531 { | 537 { |
| 532 for (size_t i = 0; i < wordMeasurements.size(); ++i) { | 538 for (size_t i = 0; i < wordMeasurements.size(); ++i) { |
| 533 if (wordMeasurements[i].width > 0) | 539 if (wordMeasurements[i].width > 0) |
| 534 return wordMeasurements[i].width; | 540 return wordMeasurements[i].width; |
| 535 } | 541 } |
| 536 return 0; | 542 return 0; |
| 537 } | 543 } |
| 538 | 544 |
| 539 ALWAYS_INLINE TextDirection textDirectionFromUnicode(WTF::Unicode::CharDirection
direction) | 545 ALWAYS_INLINE TextDirection textDirectionFromUnicode(WTF::Unicode::CharDirection
direction) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 } | 604 } |
| 599 } | 605 } |
| 600 | 606 |
| 601 ALWAYS_INLINE bool BreakingContext::rewindToMidWordBreak( | 607 ALWAYS_INLINE bool BreakingContext::rewindToMidWordBreak( |
| 602 WordMeasurement& wordMeasurement, int end, float width) | 608 WordMeasurement& wordMeasurement, int end, float width) |
| 603 { | 609 { |
| 604 wordMeasurement.endOffset = end; | 610 wordMeasurement.endOffset = end; |
| 605 wordMeasurement.width = width; | 611 wordMeasurement.width = width; |
| 606 | 612 |
| 607 m_current.moveTo(m_current.getLineLayoutItem(), end, m_current.nextBreakable
Position()); | 613 m_current.moveTo(m_current.getLineLayoutItem(), end, m_current.nextBreakable
Position()); |
| 614 setCurrentCharacterIsSpace(m_current.current()); |
| 608 m_lineBreak.moveTo(m_current.getLineLayoutItem(), end, m_current.nextBreakab
lePosition()); | 615 m_lineBreak.moveTo(m_current.getLineLayoutItem(), end, m_current.nextBreakab
lePosition()); |
| 609 return true; | 616 return true; |
| 610 } | 617 } |
| 611 | 618 |
| 612 ALWAYS_INLINE bool BreakingContext::rewindToFirstMidWordBreak(LineLayoutText tex
t, | 619 ALWAYS_INLINE bool BreakingContext::rewindToFirstMidWordBreak(LineLayoutText tex
t, |
| 613 const ComputedStyle& style, const Font& font, bool breakAll, | 620 const ComputedStyle& style, const Font& font, bool breakAll, |
| 614 WordMeasurement& wordMeasurement) | 621 WordMeasurement& wordMeasurement) |
| 615 { | 622 { |
| 616 int start = wordMeasurement.startOffset; | 623 int start = wordMeasurement.startOffset; |
| 617 int end; | 624 int end; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 // words with their trailing space, then subtract its width. | 789 // words with their trailing space, then subtract its width. |
| 783 float wordTrailingSpaceWidth = (font.getFontDescription().getTypesettingFeat
ures() & Kerning) ? | 790 float wordTrailingSpaceWidth = (font.getFontDescription().getTypesettingFeat
ures() & Kerning) ? |
| 784 font.width(constructTextRun(font, &spaceCharacter, 1, style, style.direc
tion())) + wordSpacing | 791 font.width(constructTextRun(font, &spaceCharacter, 1, style, style.direc
tion())) + wordSpacing |
| 785 : 0; | 792 : 0; |
| 786 | 793 |
| 787 UChar lastCharacter = m_layoutTextInfo.m_lineBreakIterator.lastCharacter(); | 794 UChar lastCharacter = m_layoutTextInfo.m_lineBreakIterator.lastCharacter(); |
| 788 UChar secondToLastCharacter = m_layoutTextInfo.m_lineBreakIterator.secondToL
astCharacter(); | 795 UChar secondToLastCharacter = m_layoutTextInfo.m_lineBreakIterator.secondToL
astCharacter(); |
| 789 for (; m_current.offset() < layoutText.textLength(); m_current.fastIncrement
InTextNode()) { | 796 for (; m_current.offset() < layoutText.textLength(); m_current.fastIncrement
InTextNode()) { |
| 790 bool previousCharacterIsSpace = m_currentCharacterIsSpace; | 797 bool previousCharacterIsSpace = m_currentCharacterIsSpace; |
| 791 UChar c = m_current.current(); | 798 UChar c = m_current.current(); |
| 792 m_currentCharacterIsSpace = c == spaceCharacter || c == tabulationCharac
ter || (!m_preservesNewline && (c == newlineCharacter)); | 799 setCurrentCharacterIsSpace(c); |
| 793 | 800 |
| 794 if (!m_collapseWhiteSpace || !m_currentCharacterIsSpace) { | 801 if (!m_collapseWhiteSpace || !m_currentCharacterIsSpace) { |
| 795 m_lineInfo.setEmpty(false); | 802 m_lineInfo.setEmpty(false); |
| 796 m_width.setTrailingWhitespaceWidth(0); | 803 m_width.setTrailingWhitespaceWidth(0); |
| 797 } | 804 } |
| 798 | 805 |
| 799 if (c == softHyphenCharacter && m_autoWrap && !hyphenWidth && !disableSo
ftHyphen) { | 806 if (c == softHyphenCharacter && m_autoWrap && !hyphenWidth && !disableSo
ftHyphen) { |
| 800 hyphenWidth = layoutText.hyphenWidth(font, textDirectionFromUnicode(
m_resolver.position().direction())); | 807 hyphenWidth = layoutText.hyphenWidth(font, textDirectionFromUnicode(
m_resolver.position().direction())); |
| 801 m_width.addUncommittedWidth(hyphenWidth); | 808 m_width.addUncommittedWidth(hyphenWidth); |
| 802 } | 809 } |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 | 1202 |
| 1196 if (style.getTextIndentType() == TextIndentHanging) | 1203 if (style.getTextIndentType() == TextIndentHanging) |
| 1197 indentText = indentText == IndentText ? DoNotIndentText : IndentText; | 1204 indentText = indentText == IndentText ? DoNotIndentText : IndentText; |
| 1198 | 1205 |
| 1199 return indentText; | 1206 return indentText; |
| 1200 } | 1207 } |
| 1201 | 1208 |
| 1202 } // namespace blink | 1209 } // namespace blink |
| 1203 | 1210 |
| 1204 #endif // BreakingContextInlineHeaders_h | 1211 #endif // BreakingContextInlineHeaders_h |
| OLD | NEW |