Title: [158225] trunk/Source/WebCore
Revision
158225
Author
[email protected]
Date
2013-10-29 14:25:51 -0700 (Tue, 29 Oct 2013)

Log Message

Use left/right instead of left/width for simple text runs
https://bugs.webkit.org/show_bug.cgi?id=123465

Reviewed by Andreas Kling.

This simplifies the code a bit.

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::adjustRunOffsets):
(WebCore::SimpleLineLayout::create):
* rendering/SimpleLineLayout.h:
(WebCore::SimpleLineLayout::Run::Run):
* rendering/SimpleLineLayoutResolver.h:
(WebCore::SimpleLineLayout::RunResolver::Run::rect):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (158224 => 158225)


--- trunk/Source/WebCore/ChangeLog	2013-10-29 21:25:18 UTC (rev 158224)
+++ trunk/Source/WebCore/ChangeLog	2013-10-29 21:25:51 UTC (rev 158225)
@@ -1,3 +1,20 @@
+2013-10-29  Antti Koivisto  <[email protected]>
+
+        Use left/right instead of left/width for simple text runs
+        https://bugs.webkit.org/show_bug.cgi?id=123465
+
+        Reviewed by Andreas Kling.
+
+        This simplifies the code a bit.
+
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::adjustRunOffsets):
+        (WebCore::SimpleLineLayout::create):
+        * rendering/SimpleLineLayout.h:
+        (WebCore::SimpleLineLayout::Run::Run):
+        * rendering/SimpleLineLayoutResolver.h:
+        (WebCore::SimpleLineLayout::RunResolver::Run::rect):
+
 2013-10-29  Tim Horton  <[email protected]>
 
         Try fixing the Mac build (though I have no idea why

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (158224 => 158225)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2013-10-29 21:25:18 UTC (rev 158224)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2013-10-29 21:25:51 UTC (rev 158225)
@@ -227,10 +227,8 @@
 {
     float lineLeft = computeLineLeft(textAlign, availableWidth - lineWidth);
     for (unsigned i = 0; i < lineRuns.size(); ++i) {
-        float adjustedLeft = floor(lineLeft + lineRuns[i].left);
-        float adjustedRight = ceil(lineLeft + lineRuns[i].left + lineRuns[i].width);
-        lineRuns[i].left = adjustedLeft;
-        lineRuns[i].width = adjustedRight - adjustedLeft;
+        lineRuns[i].left = floor(lineLeft + lineRuns[i].left);
+        lineRuns[i].right = ceil(lineLeft + lineRuns[i].right);
     }
 }
 
@@ -293,15 +291,14 @@
                 ASSERT(previousWasSpaceBetweenWords);
                 // Include space to the end of the previous run.
                 lineRuns.last().textLength++;
-                lineRuns.last().width += wordTrailingSpaceWidth;
+                lineRuns.last().right += wordTrailingSpaceWidth;
                 // Start a new run on the same line.
-                float previousRight = lineRuns.last().left + lineRuns.last().width;
-                lineRuns.append(Run(wordStartOffset + 1, previousRight));
+                lineRuns.append(Run(wordStartOffset + 1, lineRuns.last().right));
             }
 
             lineWidth.commit();
 
-            lineRuns.last().width = lineWidth.committedWidth() - lineRuns.last().left;
+            lineRuns.last().right = lineWidth.committedWidth();
             lineRuns.last().textLength = wordEndOffset - lineRuns.last().textOffset;
 
             lineEndOffset = wordEndOffset;

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.h (158224 => 158225)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.h	2013-10-29 21:25:18 UTC (rev 158224)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.h	2013-10-29 21:25:51 UTC (rev 158225)
@@ -48,14 +48,14 @@
         , textLength(0)
         , isEndOfLine(false)
         , left(left)
-        , width(0)
+        , right(left)
     { }
 
     unsigned textOffset;
     unsigned textLength : 31;
     unsigned isEndOfLine : 1;
     float left;
-    float width;
+    float right;
 };
 
 struct Layout {

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h (158224 => 158225)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h	2013-10-29 21:25:18 UTC (rev 158224)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h	2013-10-29 21:25:51 UTC (rev 158225)
@@ -131,7 +131,7 @@
     auto& run = m_iterator.simpleRun();
 
     LayoutPoint linePosition(run.left, resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline - resolver.m_ascent);
-    LayoutSize lineSize(run.width, resolver.m_ascent + resolver.m_descent);
+    LayoutSize lineSize(run.right - run.left, resolver.m_ascent + resolver.m_descent);
     return LayoutRect(linePosition + resolver.m_contentOffset, lineSize);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to