Changeset 176531 in webkit
- Timestamp:
- Nov 24, 2014, 5:00:57 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
rendering/SimpleLineLayout.cpp (modified) (9 diffs)
-
rendering/SimpleLineLayoutFlowContents.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r176529 r176531 1 2014-11-24 Zalan Bujtas <zalan@apple.com> 2 3 Simple line layout: Rename TextFragment::mustBreak to TextFragment::isLineBreak 4 https://bugs.webkit.org/show_bug.cgi?id=139035 5 6 Reviewed by Antti Koivisto. 7 8 Move new line logic to FlowContents class. 9 This is in preparation to support <br>. 10 11 No change in functionality. 12 13 * rendering/SimpleLineLayout.cpp: 14 (WebCore::SimpleLineLayout::TextFragment::TextFragment): 15 (WebCore::SimpleLineLayout::removeTrailingWhitespace): 16 (WebCore::SimpleLineLayout::nextFragment): 17 (WebCore::SimpleLineLayout::createLineRuns): 18 * rendering/SimpleLineLayoutFlowContents.h: 19 (WebCore::SimpleLineLayout::FlowContents::isNewline): 20 (WebCore::SimpleLineLayout::FlowContents::isNewlineCharacter): Deleted. 21 1 22 2014-11-24 Benjamin Poulain <benjamin@webkit.org> 2 23 -
trunk/Source/WebCore/rendering/SimpleLineLayout.cpp
r176527 r176531 227 227 , isWhitespaceOnly(false) 228 228 , isBreakable(false) 229 , mustBreak(false)229 , isLineBreak(false) 230 230 , width(0) 231 231 { … … 238 238 , isWhitespaceOnly(isWhitespaceOnly) 239 239 , isBreakable(false) 240 , mustBreak(false)240 , isLineBreak(false) 241 241 , width(textWidth) 242 242 { … … 253 253 bool isWhitespaceOnly : 1; 254 254 bool isBreakable; 255 bool mustBreak;255 bool isLineBreak; 256 256 float width; 257 257 }; … … 390 390 391 391 // If we skipped any whitespace and now the line end is a "preserved" newline, skip the newline too as we are wrapping the line here already. 392 if (lastPosition != lineState.position && style.preserveNewline && !flowContents.isEnd(lineState.position) && flowContents.is NewlineCharacter(lineState.position))392 if (lastPosition != lineState.position && style.preserveNewline && !flowContents.isEnd(lineState.position) && flowContents.isLineBreak(lineState.position)) 393 393 ++lineState.position; 394 394 } … … 460 460 const auto& style = flowContents.style(); 461 461 TextFragment fragment; 462 fragment. mustBreak = style.preserveNewline && flowContents.isNewlineCharacter(previousFragmentEnd);462 fragment.isLineBreak = flowContents.isLineBreak(previousFragmentEnd); 463 463 unsigned spaceCount = 0; 464 464 unsigned whitespaceEnd = previousFragmentEnd; 465 if (!fragment. mustBreak)465 if (!fragment.isLineBreak) 466 466 whitespaceEnd = flowContents.findNextNonWhitespacePosition(previousFragmentEnd, spaceCount); 467 467 fragment.isWhitespaceOnly = previousFragmentEnd < whitespaceEnd; … … 469 469 if (fragment.isWhitespaceOnly) 470 470 fragment.end = whitespaceEnd; 471 else if (fragment. mustBreak)471 else if (fragment.isLineBreak) 472 472 fragment.end = fragment.start + 1; 473 473 else … … 482 482 if (fragment.isCollapsedWhitespace) 483 483 fragment.width = style.spaceWidth; 484 else if (fragment. mustBreak)484 else if (fragment.isLineBreak) 485 485 fragment.width = 0; // Newline character's width is 0. 486 486 else if (fragmentLength == spaceCount) // Space only. … … 498 498 // Find the next text fragment. Start from the end of the previous fragment -current line end. 499 499 TextFragment fragment = nextFragment(lineState.position, flowContents, lineState.width()); 500 if ((lineCanBeWrapped && !lineState.fits(fragment.width)) || fragment. mustBreak) {500 if ((lineCanBeWrapped && !lineState.fits(fragment.width)) || fragment.isLineBreak) { 501 501 // Overflow wrapping behaviour: 502 502 // 1. Newline character: wraps the line unless it's treated as whitespace. … … 506 506 // 5. Non-whitespace fragment when there's already another fragment on the line gets pushed to the next line. 507 507 bool isFirstFragment = !lineState.width(); 508 if (fragment. mustBreak) {508 if (fragment.isLineBreak) { 509 509 if (isFirstFragment) 510 510 lineState.addUncommitted(fragment); -
trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h
r176528 r176531 46 46 float textWidth(unsigned from, unsigned to, float xPosition) const; 47 47 48 bool is NewlineCharacter(unsigned position) const;48 bool isLineBreak(unsigned position) const; 49 49 bool isEnd(unsigned position) const; 50 50 … … 96 96 } 97 97 98 inline bool FlowContents::is NewlineCharacter(unsigned position) const98 inline bool FlowContents::isLineBreak(unsigned position) const 99 99 { 100 return characterAt(position) == '\n';100 return m_style.preserveNewline && characterAt(position) == '\n'; 101 101 } 102 102
Note:
See TracChangeset
for help on using the changeset viewer.