| 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. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
| 4 * All right reserved. | 4 * All right reserved. |
| 5 * Copyright (C) 2010 Google Inc. All rights reserved. | 5 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 6 * Copyright (C) 2013 Adobe Systems Incorporated. | 6 * Copyright (C) 2013 Adobe Systems Incorporated. |
| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 m_current(resolver.position()), | 66 m_current(resolver.position()), |
| 67 m_lineBreak(resolver.position()), | 67 m_lineBreak(resolver.position()), |
| 68 m_block(block), | 68 m_block(block), |
| 69 m_lastObject(m_current.getLineLayoutItem()), | 69 m_lastObject(m_current.getLineLayoutItem()), |
| 70 m_nextObject(nullptr), | 70 m_nextObject(nullptr), |
| 71 m_currentStyle(nullptr), | 71 m_currentStyle(nullptr), |
| 72 m_blockStyle(block.style()), | 72 m_blockStyle(block.style()), |
| 73 m_lineInfo(inLineInfo), | 73 m_lineInfo(inLineInfo), |
| 74 m_layoutTextInfo(inLayoutTextInfo), | 74 m_layoutTextInfo(inLayoutTextInfo), |
| 75 m_width(lineWidth), | 75 m_width(lineWidth), |
| 76 m_currWS(EWhiteSpace::Normal), | 76 m_currWS(EWhiteSpace::kNormal), |
| 77 m_lastWS(EWhiteSpace::Normal), | 77 m_lastWS(EWhiteSpace::kNormal), |
| 78 m_preservesNewline(false), | 78 m_preservesNewline(false), |
| 79 m_atStart(true), | 79 m_atStart(true), |
| 80 m_ignoringSpaces(false), | 80 m_ignoringSpaces(false), |
| 81 m_currentCharacterIsSpace(false), | 81 m_currentCharacterIsSpace(false), |
| 82 m_appliedStartWidth(appliedStartWidth), | 82 m_appliedStartWidth(appliedStartWidth), |
| 83 m_includeEndWidth(true), | 83 m_includeEndWidth(true), |
| 84 m_autoWrap(false), | 84 m_autoWrap(false), |
| 85 m_autoWrapWasEverTrueOnLine(false), | 85 m_autoWrapWasEverTrueOnLine(false), |
| 86 m_floatsFitOnLine(true), | 86 m_floatsFitOnLine(true), |
| 87 m_collapseWhiteSpace(false), | 87 m_collapseWhiteSpace(false), |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 float& lastWidthMeasurement, | 139 float& lastWidthMeasurement, |
| 140 float wordSpacingForWordMeasurement, | 140 float wordSpacingForWordMeasurement, |
| 141 const Font&, | 141 const Font&, |
| 142 float wordTrailingSpaceWidth, | 142 float wordTrailingSpaceWidth, |
| 143 UChar); | 143 UChar); |
| 144 void stopIgnoringSpaces(unsigned& lastSpace); | 144 void stopIgnoringSpaces(unsigned& lastSpace); |
| 145 void commitAndUpdateLineBreakIfNeeded(); | 145 void commitAndUpdateLineBreakIfNeeded(); |
| 146 InlineIterator handleEndOfLine(); | 146 InlineIterator handleEndOfLine(); |
| 147 | 147 |
| 148 void clearLineBreakIfFitsOnLine() { | 148 void clearLineBreakIfFitsOnLine() { |
| 149 if (m_width.fitsOnLine() || m_lastWS == EWhiteSpace::Nowrap) | 149 if (m_width.fitsOnLine() || m_lastWS == EWhiteSpace::kNowrap) |
| 150 m_lineBreak.clear(); | 150 m_lineBreak.clear(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 void setCurrentCharacterIsSpace(UChar); | 154 void setCurrentCharacterIsSpace(UChar); |
| 155 void skipTrailingWhitespace(InlineIterator&, const LineInfo&); | 155 void skipTrailingWhitespace(InlineIterator&, const LineInfo&); |
| 156 bool shouldMidWordBreak(UChar, | 156 bool shouldMidWordBreak(UChar, |
| 157 LineLayoutText, | 157 LineLayoutText, |
| 158 const Font&, | 158 const Font&, |
| 159 float& charWidth, | 159 float& charWidth, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 WhitespacePosition whitespacePosition) { | 236 WhitespacePosition whitespacePosition) { |
| 237 // CSS2 16.6.1 | 237 // CSS2 16.6.1 |
| 238 // If a space (U+0020) at the beginning of a line has 'white-space' set to | 238 // If a space (U+0020) at the beginning of a line has 'white-space' set to |
| 239 // 'normal', 'nowrap', or 'pre-line', it is removed. | 239 // 'normal', 'nowrap', or 'pre-line', it is removed. |
| 240 // If a space (U+0020) at the end of a line has 'white-space' set to 'normal', | 240 // If a space (U+0020) at the end of a line has 'white-space' set to 'normal', |
| 241 // 'nowrap', or 'pre-line', it is also removed. | 241 // 'nowrap', or 'pre-line', it is also removed. |
| 242 // If spaces (U+0020) or tabs (U+0009) at the end of a line have 'white-space' | 242 // If spaces (U+0020) or tabs (U+0009) at the end of a line have 'white-space' |
| 243 // set to 'pre-wrap', UAs may visually collapse them. | 243 // set to 'pre-wrap', UAs may visually collapse them. |
| 244 return style.collapseWhiteSpace() || | 244 return style.collapseWhiteSpace() || |
| 245 (whitespacePosition == TrailingWhitespace && | 245 (whitespacePosition == TrailingWhitespace && |
| 246 style.whiteSpace() == EWhiteSpace::PreWrap && | 246 style.whiteSpace() == EWhiteSpace::kPreWrap && |
| 247 (!lineInfo.isEmpty() || !lineInfo.previousLineBrokeCleanly())); | 247 (!lineInfo.isEmpty() || !lineInfo.previousLineBrokeCleanly())); |
| 248 } | 248 } |
| 249 | 249 |
| 250 inline bool requiresLineBoxForContent(LineLayoutInline flow, | 250 inline bool requiresLineBoxForContent(LineLayoutInline flow, |
| 251 const LineInfo& lineInfo) { | 251 const LineInfo& lineInfo) { |
| 252 LineLayoutItem parent = flow.parent(); | 252 LineLayoutItem parent = flow.parent(); |
| 253 if (flow.document().inNoQuirksMode() && | 253 if (flow.document().inNoQuirksMode() && |
| 254 (flow.style(lineInfo.isFirstLine())->lineHeight() != | 254 (flow.style(lineInfo.isFirstLine())->lineHeight() != |
| 255 parent.style(lineInfo.isFirstLine())->lineHeight() || | 255 parent.style(lineInfo.isFirstLine())->lineHeight() || |
| 256 flow.style()->verticalAlign() != parent.style()->verticalAlign() || | 256 flow.style()->verticalAlign() != parent.style()->verticalAlign() || |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 if (wordMeasurements[i].width > 0) | 664 if (wordMeasurements[i].width > 0) |
| 665 return wordMeasurements[i].width; | 665 return wordMeasurements[i].width; |
| 666 } | 666 } |
| 667 return 0; | 667 return 0; |
| 668 } | 668 } |
| 669 | 669 |
| 670 ALWAYS_INLINE TextDirection | 670 ALWAYS_INLINE TextDirection |
| 671 textDirectionFromUnicode(WTF::Unicode::CharDirection direction) { | 671 textDirectionFromUnicode(WTF::Unicode::CharDirection direction) { |
| 672 return direction == WTF::Unicode::RightToLeft || | 672 return direction == WTF::Unicode::RightToLeft || |
| 673 direction == WTF::Unicode::RightToLeftArabic | 673 direction == WTF::Unicode::RightToLeftArabic |
| 674 ? TextDirection::Rtl | 674 ? TextDirection::kRtl |
| 675 : TextDirection::Ltr; | 675 : TextDirection::kLtr; |
| 676 } | 676 } |
| 677 | 677 |
| 678 ALWAYS_INLINE float textWidth( | 678 ALWAYS_INLINE float textWidth( |
| 679 LineLayoutText text, | 679 LineLayoutText text, |
| 680 unsigned from, | 680 unsigned from, |
| 681 unsigned len, | 681 unsigned len, |
| 682 const Font& font, | 682 const Font& font, |
| 683 float xPos, | 683 float xPos, |
| 684 bool collapseWhiteSpace, | 684 bool collapseWhiteSpace, |
| 685 HashSet<const SimpleFontData*>* fallbackFonts = nullptr, | 685 HashSet<const SimpleFontData*>* fallbackFonts = nullptr, |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 float lastSpaceWordSpacing = 0; | 936 float lastSpaceWordSpacing = 0; |
| 937 float wordSpacingForWordMeasurement = 0; | 937 float wordSpacingForWordMeasurement = 0; |
| 938 | 938 |
| 939 float widthFromLastBreakingOpportunity = m_width.uncommittedWidth(); | 939 float widthFromLastBreakingOpportunity = m_width.uncommittedWidth(); |
| 940 float charWidth = 0; | 940 float charWidth = 0; |
| 941 // Auto-wrapping text should wrap in the middle of a word only if it could not | 941 // Auto-wrapping text should wrap in the middle of a word only if it could not |
| 942 // wrap before the word, which is only possible if the word is the first thing | 942 // wrap before the word, which is only possible if the word is the first thing |
| 943 // on the line, that is, if |w| is zero. | 943 // on the line, that is, if |w| is zero. |
| 944 bool breakWords = m_currentStyle->breakWords() && | 944 bool breakWords = m_currentStyle->breakWords() && |
| 945 ((m_autoWrap && !m_width.committedWidth()) || | 945 ((m_autoWrap && !m_width.committedWidth()) || |
| 946 m_currWS == EWhiteSpace::Pre); | 946 m_currWS == EWhiteSpace::kPre); |
| 947 bool midWordBreak = false; | 947 bool midWordBreak = false; |
| 948 bool breakAll = | 948 bool breakAll = |
| 949 m_currentStyle->wordBreak() == BreakAllWordBreak && m_autoWrap; | 949 m_currentStyle->wordBreak() == BreakAllWordBreak && m_autoWrap; |
| 950 bool keepAll = m_currentStyle->wordBreak() == KeepAllWordBreak && m_autoWrap; | 950 bool keepAll = m_currentStyle->wordBreak() == KeepAllWordBreak && m_autoWrap; |
| 951 bool prohibitBreakInside = m_currentStyle->hasTextCombine() && | 951 bool prohibitBreakInside = m_currentStyle->hasTextCombine() && |
| 952 layoutText.isCombineText() && | 952 layoutText.isCombineText() && |
| 953 LineLayoutTextCombine(layoutText).isCombined(); | 953 LineLayoutTextCombine(layoutText).isCombined(); |
| 954 | 954 |
| 955 // This is currently only used for word-break: break-all, specifically for the | 955 // This is currently only used for word-break: break-all, specifically for the |
| 956 // case where we have a break opportunity within a word, then a string of non- | 956 // case where we have a break opportunity within a word, then a string of non- |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 // Determine if we should try breaking in the middle of a word. | 1026 // Determine if we should try breaking in the middle of a word. |
| 1027 if (canBreakMidWord && !midWordBreak && !U16_IS_TRAIL(c)) | 1027 if (canBreakMidWord && !midWordBreak && !U16_IS_TRAIL(c)) |
| 1028 midWordBreak = shouldMidWordBreak( | 1028 midWordBreak = shouldMidWordBreak( |
| 1029 c, layoutText, font, charWidth, widthFromLastBreakingOpportunity, | 1029 c, layoutText, font, charWidth, widthFromLastBreakingOpportunity, |
| 1030 breakAll, nextBreakablePositionForBreakAll); | 1030 breakAll, nextBreakablePositionForBreakAll); |
| 1031 | 1031 |
| 1032 // Determine if we are in the whitespace between words. | 1032 // Determine if we are in the whitespace between words. |
| 1033 int nextBreakablePosition = m_current.nextBreakablePosition(); | 1033 int nextBreakablePosition = m_current.nextBreakablePosition(); |
| 1034 bool betweenWords = | 1034 bool betweenWords = |
| 1035 c == newlineCharacter || | 1035 c == newlineCharacter || |
| 1036 (m_currWS != EWhiteSpace::Pre && !m_atStart && | 1036 (m_currWS != EWhiteSpace::kPre && !m_atStart && |
| 1037 m_layoutTextInfo.m_lineBreakIterator.isBreakable( | 1037 m_layoutTextInfo.m_lineBreakIterator.isBreakable( |
| 1038 m_current.offset(), nextBreakablePosition, lineBreakType) && | 1038 m_current.offset(), nextBreakablePosition, lineBreakType) && |
| 1039 (!disableSoftHyphen || | 1039 (!disableSoftHyphen || |
| 1040 m_current.previousInSameNode() != softHyphenCharacter)); | 1040 m_current.previousInSameNode() != softHyphenCharacter)); |
| 1041 m_current.setNextBreakablePosition(nextBreakablePosition); | 1041 m_current.setNextBreakablePosition(nextBreakablePosition); |
| 1042 | 1042 |
| 1043 // If we're in the middle of a word or at the start of a new one and can't | 1043 // If we're in the middle of a word or at the start of a new one and can't |
| 1044 // break there, then continue to the next character. | 1044 // break there, then continue to the next character. |
| 1045 if (!betweenWords && !midWordBreak) { | 1045 if (!betweenWords && !midWordBreak) { |
| 1046 if (m_ignoringSpaces) { | 1046 if (m_ignoringSpaces) { |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 m_width.addUncommittedWidth(-hyphenWidth); | 1446 m_width.addUncommittedWidth(-hyphenWidth); |
| 1447 hyphenWidth = 0; | 1447 hyphenWidth = 0; |
| 1448 } | 1448 } |
| 1449 } | 1449 } |
| 1450 return false; | 1450 return false; |
| 1451 } | 1451 } |
| 1452 | 1452 |
| 1453 inline void BreakingContext::commitAndUpdateLineBreakIfNeeded() { | 1453 inline void BreakingContext::commitAndUpdateLineBreakIfNeeded() { |
| 1454 bool checkForBreak = m_autoWrap; | 1454 bool checkForBreak = m_autoWrap; |
| 1455 if (m_width.committedWidth() && !m_width.fitsOnLine() && | 1455 if (m_width.committedWidth() && !m_width.fitsOnLine() && |
| 1456 m_lineBreak.getLineLayoutItem() && m_currWS == EWhiteSpace::Nowrap) { | 1456 m_lineBreak.getLineLayoutItem() && m_currWS == EWhiteSpace::kNowrap) { |
| 1457 if (m_width.fitsOnLine(0, ExcludeWhitespace)) { | 1457 if (m_width.fitsOnLine(0, ExcludeWhitespace)) { |
| 1458 m_width.commit(); | 1458 m_width.commit(); |
| 1459 m_lineBreak.moveToStartOf(m_nextObject); | 1459 m_lineBreak.moveToStartOf(m_nextObject); |
| 1460 } | 1460 } |
| 1461 checkForBreak = true; | 1461 checkForBreak = true; |
| 1462 } else if (m_nextObject && m_current.getLineLayoutItem().isText() && | 1462 } else if (m_nextObject && m_current.getLineLayoutItem().isText() && |
| 1463 m_nextObject.isText() && !m_nextObject.isBR() && | 1463 m_nextObject.isText() && !m_nextObject.isBR() && |
| 1464 (m_autoWrap || m_nextObject.style()->autoWrap())) { | 1464 (m_autoWrap || m_nextObject.style()->autoWrap())) { |
| 1465 if (m_autoWrap && m_currentCharacterIsSpace) { | 1465 if (m_autoWrap && m_currentCharacterIsSpace) { |
| 1466 checkForBreak = true; | 1466 checkForBreak = true; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1542 | 1542 |
| 1543 if (style.getTextIndentType() == TextIndentHanging) | 1543 if (style.getTextIndentType() == TextIndentHanging) |
| 1544 indentText = indentText == IndentText ? DoNotIndentText : IndentText; | 1544 indentText = indentText == IndentText ? DoNotIndentText : IndentText; |
| 1545 | 1545 |
| 1546 return indentText; | 1546 return indentText; |
| 1547 } | 1547 } |
| 1548 | 1548 |
| 1549 } // namespace blink | 1549 } // namespace blink |
| 1550 | 1550 |
| 1551 #endif // BreakingContextInlineHeaders_h | 1551 #endif // BreakingContextInlineHeaders_h |
| OLD | NEW |