Title: [176531] trunk/Source/WebCore
Revision
176531
Author
[email protected]
Date
2014-11-24 17:00:57 -0800 (Mon, 24 Nov 2014)

Log Message

Simple line layout: Rename TextFragment::mustBreak to TextFragment::isLineBreak
https://bugs.webkit.org/show_bug.cgi?id=139035

Reviewed by Antti Koivisto.

Move new line logic to FlowContents class.
This is in preparation to support <br>.

No change in functionality.

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::TextFragment::TextFragment):
(WebCore::SimpleLineLayout::removeTrailingWhitespace):
(WebCore::SimpleLineLayout::nextFragment):
(WebCore::SimpleLineLayout::createLineRuns):
* rendering/SimpleLineLayoutFlowContents.h:
(WebCore::SimpleLineLayout::FlowContents::isNewline):
(WebCore::SimpleLineLayout::FlowContents::isNewlineCharacter): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (176530 => 176531)


--- trunk/Source/WebCore/ChangeLog	2014-11-25 00:26:35 UTC (rev 176530)
+++ trunk/Source/WebCore/ChangeLog	2014-11-25 01:00:57 UTC (rev 176531)
@@ -1,3 +1,24 @@
+2014-11-24  Zalan Bujtas  <[email protected]>
+
+        Simple line layout: Rename TextFragment::mustBreak to TextFragment::isLineBreak
+        https://bugs.webkit.org/show_bug.cgi?id=139035
+
+        Reviewed by Antti Koivisto.
+
+        Move new line logic to FlowContents class.
+        This is in preparation to support <br>.
+
+        No change in functionality.
+
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::TextFragment::TextFragment):
+        (WebCore::SimpleLineLayout::removeTrailingWhitespace):
+        (WebCore::SimpleLineLayout::nextFragment):
+        (WebCore::SimpleLineLayout::createLineRuns):
+        * rendering/SimpleLineLayoutFlowContents.h:
+        (WebCore::SimpleLineLayout::FlowContents::isNewline):
+        (WebCore::SimpleLineLayout::FlowContents::isNewlineCharacter): Deleted.
+
 2014-11-24  Benjamin Poulain  <[email protected]>
 
         Move :placeholder-shown out of experimental

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (176530 => 176531)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2014-11-25 00:26:35 UTC (rev 176530)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2014-11-25 01:00:57 UTC (rev 176531)
@@ -226,7 +226,7 @@
         , end(0)
         , isWhitespaceOnly(false)
         , isBreakable(false)
-        , mustBreak(false)
+        , isLineBreak(false)
         , width(0)
     {
     }
@@ -237,7 +237,7 @@
         , end(textEnd)
         , isWhitespaceOnly(isWhitespaceOnly)
         , isBreakable(false)
-        , mustBreak(false)
+        , isLineBreak(false)
         , width(textWidth)
     {
     }
@@ -252,7 +252,7 @@
     unsigned end : 31;
     bool isWhitespaceOnly : 1;
     bool isBreakable;
-    bool mustBreak;
+    bool isLineBreak;
     float width;
 };
 
@@ -389,7 +389,7 @@
     }
 
     // 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.
-    if (lastPosition != lineState.position && style.preserveNewline && !flowContents.isEnd(lineState.position) && flowContents.isNewlineCharacter(lineState.position))
+    if (lastPosition != lineState.position && style.preserveNewline && !flowContents.isEnd(lineState.position) && flowContents.isLineBreak(lineState.position))
         ++lineState.position;
 }
 
@@ -459,16 +459,16 @@
     // 3. non-whitespace characters.
     const auto& style = flowContents.style();
     TextFragment fragment;
-    fragment.mustBreak = style.preserveNewline && flowContents.isNewlineCharacter(previousFragmentEnd);
+    fragment.isLineBreak = flowContents.isLineBreak(previousFragmentEnd);
     unsigned spaceCount = 0;
     unsigned whitespaceEnd = previousFragmentEnd;
-    if (!fragment.mustBreak)
+    if (!fragment.isLineBreak)
         whitespaceEnd = flowContents.findNextNonWhitespacePosition(previousFragmentEnd, spaceCount);
     fragment.isWhitespaceOnly = previousFragmentEnd < whitespaceEnd;
     fragment.start = previousFragmentEnd;
     if (fragment.isWhitespaceOnly)
         fragment.end = whitespaceEnd;
-    else if (fragment.mustBreak)
+    else if (fragment.isLineBreak)
         fragment.end = fragment.start + 1;
     else
         fragment.end = flowContents.findNextBreakablePosition(previousFragmentEnd + 1);
@@ -481,7 +481,7 @@
     unsigned fragmentLength = fragment.end - fragment.start;
     if (fragment.isCollapsedWhitespace)
         fragment.width = style.spaceWidth;
-    else if (fragment.mustBreak)
+    else if (fragment.isLineBreak)
         fragment.width = 0; // Newline character's width is 0.
     else if (fragmentLength == spaceCount) // Space only.
         fragment.width = style.spaceWidth * spaceCount;
@@ -497,7 +497,7 @@
     while (!flowContents.isEnd(lineState.position)) {
         // Find the next text fragment. Start from the end of the previous fragment -current line end.
         TextFragment fragment = nextFragment(lineState.position, flowContents, lineState.width());
-        if ((lineCanBeWrapped && !lineState.fits(fragment.width)) || fragment.mustBreak) {
+        if ((lineCanBeWrapped && !lineState.fits(fragment.width)) || fragment.isLineBreak) {
             // Overflow wrapping behaviour:
             // 1. Newline character: wraps the line unless it's treated as whitespace.
             // 2. Whitesapce collapse on: whitespace is skipped.
@@ -505,7 +505,7 @@
             // 4. First, non-whitespace fragment is either wrapped or kept on the line. (depends on overflow-wrap)
             // 5. Non-whitespace fragment when there's already another fragment on the line gets pushed to the next line.
             bool isFirstFragment = !lineState.width();
-            if (fragment.mustBreak) {
+            if (fragment.isLineBreak) {
                 if (isFirstFragment)
                     lineState.addUncommitted(fragment);
                 else {

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h (176530 => 176531)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h	2014-11-25 00:26:35 UTC (rev 176530)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h	2014-11-25 01:00:57 UTC (rev 176531)
@@ -45,7 +45,7 @@
 
     float textWidth(unsigned from, unsigned to, float xPosition) const;
 
-    bool isNewlineCharacter(unsigned position) const;
+    bool isLineBreak(unsigned position) const;
     bool isEnd(unsigned position) const;
 
     struct Segment {
@@ -95,9 +95,9 @@
     return segment.text[position - segment.start];
 }
 
-inline bool FlowContents::isNewlineCharacter(unsigned position) const
+inline bool FlowContents::isLineBreak(unsigned position) const
 {
-    return characterAt(position) == '\n';
+    return m_style.preserveNewline && characterAt(position) == '\n';
 }
 
 inline bool FlowContents::isEnd(unsigned position) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to