Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(772)

Side by Side Diff: third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h

Issue 2508743002: Changed EWhiteSpace to an enum class and renamed its members to keywords (Closed)
Patch Set: Small mac fix Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(NORMAL), 76 m_currWS(EWhiteSpace::Normal),
77 m_lastWS(NORMAL), 77 m_lastWS(EWhiteSpace::Normal),
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
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 == NOWRAP) 149 if (m_width.fitsOnLine() || m_lastWS == EWhiteSpace::Nowrap)
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 WhitespacePosition whitespacePosition) { 235 WhitespacePosition whitespacePosition) {
236 // CSS2 16.6.1 236 // CSS2 16.6.1
237 // If a space (U+0020) at the beginning of a line has 'white-space' set to 237 // If a space (U+0020) at the beginning of a line has 'white-space' set to
238 // 'normal', 'nowrap', or 'pre-line', it is removed. 238 // 'normal', 'nowrap', or 'pre-line', it is removed.
239 // If a space (U+0020) at the end of a line has 'white-space' set to 'normal', 239 // If a space (U+0020) at the end of a line has 'white-space' set to 'normal',
240 // 'nowrap', or 'pre-line', it is also removed. 240 // 'nowrap', or 'pre-line', it is also removed.
241 // If spaces (U+0020) or tabs (U+0009) at the end of a line have 'white-space' 241 // If spaces (U+0020) or tabs (U+0009) at the end of a line have 'white-space'
242 // set to 'pre-wrap', UAs may visually collapse them. 242 // set to 'pre-wrap', UAs may visually collapse them.
243 return style.collapseWhiteSpace() || 243 return style.collapseWhiteSpace() ||
244 (whitespacePosition == TrailingWhitespace && 244 (whitespacePosition == TrailingWhitespace &&
245 style.whiteSpace() == PRE_WRAP && 245 style.whiteSpace() == EWhiteSpace::PreWrap &&
246 (!lineInfo.isEmpty() || !lineInfo.previousLineBrokeCleanly())); 246 (!lineInfo.isEmpty() || !lineInfo.previousLineBrokeCleanly()));
247 } 247 }
248 248
249 inline bool requiresLineBoxForContent(LineLayoutInline flow, 249 inline bool requiresLineBoxForContent(LineLayoutInline flow,
250 const LineInfo& lineInfo) { 250 const LineInfo& lineInfo) {
251 LineLayoutItem parent = flow.parent(); 251 LineLayoutItem parent = flow.parent();
252 if (flow.document().inNoQuirksMode() && 252 if (flow.document().inNoQuirksMode() &&
253 (flow.style(lineInfo.isFirstLine())->lineHeight() != 253 (flow.style(lineInfo.isFirstLine())->lineHeight() !=
254 parent.style(lineInfo.isFirstLine())->lineHeight() || 254 parent.style(lineInfo.isFirstLine())->lineHeight() ||
255 flow.style()->verticalAlign() != parent.style()->verticalAlign() || 255 flow.style()->verticalAlign() != parent.style()->verticalAlign() ||
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 unsigned lastSpace = m_current.offset(); 886 unsigned lastSpace = m_current.offset();
887 float wordSpacing = m_currentStyle->wordSpacing(); 887 float wordSpacing = m_currentStyle->wordSpacing();
888 float lastSpaceWordSpacing = 0; 888 float lastSpaceWordSpacing = 0;
889 float wordSpacingForWordMeasurement = 0; 889 float wordSpacingForWordMeasurement = 0;
890 890
891 float widthFromLastBreakingOpportunity = m_width.uncommittedWidth(); 891 float widthFromLastBreakingOpportunity = m_width.uncommittedWidth();
892 float charWidth = 0; 892 float charWidth = 0;
893 // Auto-wrapping text should wrap in the middle of a word only if it could not 893 // Auto-wrapping text should wrap in the middle of a word only if it could not
894 // wrap before the word, which is only possible if the word is the first thing 894 // wrap before the word, which is only possible if the word is the first thing
895 // on the line, that is, if |w| is zero. 895 // on the line, that is, if |w| is zero.
896 bool breakWords = 896 bool breakWords = m_currentStyle->breakWords() &&
897 m_currentStyle->breakWords() && 897 ((m_autoWrap && !m_width.committedWidth()) ||
898 ((m_autoWrap && !m_width.committedWidth()) || m_currWS == PRE); 898 m_currWS == EWhiteSpace::Pre);
899 bool midWordBreak = false; 899 bool midWordBreak = false;
900 bool breakAll = 900 bool breakAll =
901 m_currentStyle->wordBreak() == BreakAllWordBreak && m_autoWrap; 901 m_currentStyle->wordBreak() == BreakAllWordBreak && m_autoWrap;
902 bool keepAll = m_currentStyle->wordBreak() == KeepAllWordBreak && m_autoWrap; 902 bool keepAll = m_currentStyle->wordBreak() == KeepAllWordBreak && m_autoWrap;
903 bool prohibitBreakInside = m_currentStyle->hasTextCombine() && 903 bool prohibitBreakInside = m_currentStyle->hasTextCombine() &&
904 layoutText.isCombineText() && 904 layoutText.isCombineText() &&
905 LineLayoutTextCombine(layoutText).isCombined(); 905 LineLayoutTextCombine(layoutText).isCombined();
906 906
907 // This is currently only used for word-break: break-all, specifically for the 907 // This is currently only used for word-break: break-all, specifically for the
908 // case where we have a break opportunity within a word, then a string of non- 908 // case where we have a break opportunity within a word, then a string of non-
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 // Determine if we should try breaking in the middle of a word. 977 // Determine if we should try breaking in the middle of a word.
978 if (canBreakMidWord && !midWordBreak && !U16_IS_TRAIL(c)) 978 if (canBreakMidWord && !midWordBreak && !U16_IS_TRAIL(c))
979 midWordBreak = shouldMidWordBreak( 979 midWordBreak = shouldMidWordBreak(
980 c, layoutText, font, charWidth, widthFromLastBreakingOpportunity, 980 c, layoutText, font, charWidth, widthFromLastBreakingOpportunity,
981 breakAll, nextBreakablePositionForBreakAll); 981 breakAll, nextBreakablePositionForBreakAll);
982 982
983 // Determine if we are in the whitespace between words. 983 // Determine if we are in the whitespace between words.
984 int nextBreakablePosition = m_current.nextBreakablePosition(); 984 int nextBreakablePosition = m_current.nextBreakablePosition();
985 bool betweenWords = 985 bool betweenWords =
986 c == newlineCharacter || 986 c == newlineCharacter ||
987 (m_currWS != PRE && !m_atStart && 987 (m_currWS != EWhiteSpace::Pre && !m_atStart &&
988 m_layoutTextInfo.m_lineBreakIterator.isBreakable( 988 m_layoutTextInfo.m_lineBreakIterator.isBreakable(
989 m_current.offset(), nextBreakablePosition, lineBreakType) && 989 m_current.offset(), nextBreakablePosition, lineBreakType) &&
990 (!disableSoftHyphen || 990 (!disableSoftHyphen ||
991 m_current.previousInSameNode() != softHyphenCharacter)); 991 m_current.previousInSameNode() != softHyphenCharacter));
992 m_current.setNextBreakablePosition(nextBreakablePosition); 992 m_current.setNextBreakablePosition(nextBreakablePosition);
993 993
994 // If we're in the middle of a word or at the start of a new one and can't 994 // If we're in the middle of a word or at the start of a new one and can't
995 // break there, then continue to the next character. 995 // break there, then continue to the next character.
996 if (!betweenWords && !midWordBreak) { 996 if (!betweenWords && !midWordBreak) {
997 if (m_ignoringSpaces) { 997 if (m_ignoringSpaces) {
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 m_width.addUncommittedWidth(-hyphenWidth); 1395 m_width.addUncommittedWidth(-hyphenWidth);
1396 hyphenWidth = 0; 1396 hyphenWidth = 0;
1397 } 1397 }
1398 } 1398 }
1399 return false; 1399 return false;
1400 } 1400 }
1401 1401
1402 inline void BreakingContext::commitAndUpdateLineBreakIfNeeded() { 1402 inline void BreakingContext::commitAndUpdateLineBreakIfNeeded() {
1403 bool checkForBreak = m_autoWrap; 1403 bool checkForBreak = m_autoWrap;
1404 if (m_width.committedWidth() && !m_width.fitsOnLine() && 1404 if (m_width.committedWidth() && !m_width.fitsOnLine() &&
1405 m_lineBreak.getLineLayoutItem() && m_currWS == NOWRAP) { 1405 m_lineBreak.getLineLayoutItem() && m_currWS == EWhiteSpace::Nowrap) {
1406 if (m_width.fitsOnLine(0, ExcludeWhitespace)) { 1406 if (m_width.fitsOnLine(0, ExcludeWhitespace)) {
1407 m_width.commit(); 1407 m_width.commit();
1408 m_lineBreak.moveToStartOf(m_nextObject); 1408 m_lineBreak.moveToStartOf(m_nextObject);
1409 } 1409 }
1410 checkForBreak = true; 1410 checkForBreak = true;
1411 } else if (m_nextObject && m_current.getLineLayoutItem().isText() && 1411 } else if (m_nextObject && m_current.getLineLayoutItem().isText() &&
1412 m_nextObject.isText() && !m_nextObject.isBR() && 1412 m_nextObject.isText() && !m_nextObject.isBR() &&
1413 (m_autoWrap || m_nextObject.style()->autoWrap())) { 1413 (m_autoWrap || m_nextObject.style()->autoWrap())) {
1414 if (m_autoWrap && m_currentCharacterIsSpace) { 1414 if (m_autoWrap && m_currentCharacterIsSpace) {
1415 checkForBreak = true; 1415 checkForBreak = true;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 1491
1492 if (style.getTextIndentType() == TextIndentHanging) 1492 if (style.getTextIndentType() == TextIndentHanging)
1493 indentText = indentText == IndentText ? DoNotIndentText : IndentText; 1493 indentText = indentText == IndentText ? DoNotIndentText : IndentText;
1494 1494
1495 return indentText; 1495 return indentText;
1496 } 1496 }
1497 1497
1498 } // namespace blink 1498 } // namespace blink
1499 1499
1500 #endif // BreakingContextInlineHeaders_h 1500 #endif // BreakingContextInlineHeaders_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698