Use left/right instead of left/width for simple text runs
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Oct 2013 21:25:51 +0000 (21:25 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Oct 2013 21:25:51 +0000 (21:25 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158225 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/SimpleLineLayout.cpp
Source/WebCore/rendering/SimpleLineLayout.h
Source/WebCore/rendering/SimpleLineLayoutResolver.h

index 784b9ea..f9f71dc 100644 (file)
@@ -1,3 +1,20 @@
+2013-10-29  Antti Koivisto  <antti@apple.com>
+
+        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  <timothy_horton@apple.com>
 
         Try fixing the Mac build (though I have no idea why
index b37e75d..23b11e4 100644 (file)
@@ -227,10 +227,8 @@ static void adjustRunOffsets(Vector<Run, 4>& lineRuns, ETextAlign textAlign, flo
 {
     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 @@ std::unique_ptr<Layout> create(RenderBlockFlow& flow)
                 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;
index d9f9a0d..2475cf9 100644 (file)
@@ -48,14 +48,14 @@ struct Run {
         , 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 {
index d718497..5cd869a 100644 (file)
@@ -131,7 +131,7 @@ inline LayoutRect RunResolver::Run::rect() const
     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);
 }