Title: [159105] trunk
Revision
159105
Author
[email protected]
Date
2013-11-12 06:44:37 -0800 (Tue, 12 Nov 2013)

Log Message

Text on simple lines sometimes paints one pixel off
https://bugs.webkit.org/show_bug.cgi?id=124200

Reviewed by Andreas Kling.

Source/WebCore: 

Test: fast/text/line-runs-simple-lines.html

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::adjustRunOffsets):
        
    Don't round on run construction time.

(WebCore::SimpleLineLayout::createTextRuns):
* rendering/SimpleLineLayoutResolver.h:
(WebCore::SimpleLineLayout::RunResolver::Run::rect):
        
    Instead round when generating rects.

(WebCore::SimpleLineLayout::RunResolver::Run::baseline):
        
    Provide the baseline (used by painting) as unrounded FloatPoint.

LayoutTests: 

* fast/text/line-runs-rounding-simple-lines-expected.html: Added.
* fast/text/line-runs-rounding-simple-lines.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (159104 => 159105)


--- trunk/LayoutTests/ChangeLog	2013-11-12 14:40:29 UTC (rev 159104)
+++ trunk/LayoutTests/ChangeLog	2013-11-12 14:44:37 UTC (rev 159105)
@@ -1,3 +1,13 @@
+2013-11-12  Antti Koivisto  <[email protected]>
+
+        Text on simple lines sometimes paints one pixel off
+        https://bugs.webkit.org/show_bug.cgi?id=124200
+
+        Reviewed by Andreas Kling.
+
+        * fast/text/line-runs-rounding-simple-lines-expected.html: Added.
+        * fast/text/line-runs-rounding-simple-lines.html: Added.
+
 2013-11-12  Zan Dobersek  <[email protected]>
 
         JSC bindings generator should generate deletable JSC functions

Added: trunk/LayoutTests/fast/text/line-runs-rounding-simple-lines-expected.html (0 => 159105)


--- trunk/LayoutTests/fast/text/line-runs-rounding-simple-lines-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/line-runs-rounding-simple-lines-expected.html	2013-11-12 14:44:37 UTC (rev 159105)
@@ -0,0 +1,9 @@
+<script>
+if (window.internals)
+    internals.settings.setSimpleLineLayoutEnabled(false);
+</script>
+<style>
+div { font-size: 11px; font-family: '.LucidaGrandeUI'; }
+</style>
+<div>Lorem ipsum dolor</div>
+<div>Lorem ipsum  dolor</div>

Added: trunk/LayoutTests/fast/text/line-runs-rounding-simple-lines.html (0 => 159105)


--- trunk/LayoutTests/fast/text/line-runs-rounding-simple-lines.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/line-runs-rounding-simple-lines.html	2013-11-12 14:44:37 UTC (rev 159105)
@@ -0,0 +1,5 @@
+<style>
+div { font-size: 11px; font-family: '.LucidaGrandeUI'; }
+</style>
+<div>Lorem ipsum dolor</div>
+<div>Lorem ipsum  dolor</div>

Modified: trunk/Source/WebCore/ChangeLog (159104 => 159105)


--- trunk/Source/WebCore/ChangeLog	2013-11-12 14:40:29 UTC (rev 159104)
+++ trunk/Source/WebCore/ChangeLog	2013-11-12 14:44:37 UTC (rev 159105)
@@ -1,3 +1,27 @@
+2013-11-12  Antti Koivisto  <[email protected]>
+
+        Text on simple lines sometimes paints one pixel off
+        https://bugs.webkit.org/show_bug.cgi?id=124200
+
+        Reviewed by Andreas Kling.
+
+        Test: fast/text/line-runs-simple-lines.html
+
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::adjustRunOffsets):
+        
+            Don't round on run construction time.
+
+        (WebCore::SimpleLineLayout::createTextRuns):
+        * rendering/SimpleLineLayoutResolver.h:
+        (WebCore::SimpleLineLayout::RunResolver::Run::rect):
+        
+            Instead round when generating rects.
+
+        (WebCore::SimpleLineLayout::RunResolver::Run::baseline):
+        
+            Provide the baseline (used by painting) as unrounded FloatPoint.
+
 2013-11-11  Andreas Kling  <[email protected]>
 
         Elements with class names automatically get unique ElementData.

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (159104 => 159105)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2013-11-12 14:40:29 UTC (rev 159104)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2013-11-12 14:44:37 UTC (rev 159105)
@@ -260,12 +260,13 @@
     return 0;
 }
 
-static void adjustRunOffsets(Vector<Run, 4>& lineRuns, ETextAlign textAlign, float lineWidth, float availableWidth)
+static void adjustRunOffsets(Vector<Run, 4>& lineRuns, float adjustment)
 {
-    float lineLeft = computeLineLeft(textAlign, availableWidth - lineWidth);
+    if (!adjustment)
+        return;
     for (unsigned i = 0; i < lineRuns.size(); ++i) {
-        lineRuns[i].left = floor(lineLeft + lineRuns[i].left);
-        lineRuns[i].right = ceil(lineLeft + lineRuns[i].right);
+        lineRuns[i].left += adjustment;
+        lineRuns[i].right += adjustment;
     }
 }
 
@@ -381,7 +382,8 @@
 
         lineRuns.last().isEndOfLine = true;
 
-        adjustRunOffsets(lineRuns, textAlign, lineWidth.committedWidth(), lineWidth.availableWidth());
+        float lineLeft = computeLineLeft(textAlign, lineWidth.availableWidth() - lineWidth.committedWidth());
+        adjustRunOffsets(lineRuns, lineLeft);
 
         for (unsigned i = 0; i < lineRuns.size(); ++i)
             runs.append(lineRuns[i]);

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h (159104 => 159105)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h	2013-11-12 14:40:29 UTC (rev 159104)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h	2013-11-12 14:44:37 UTC (rev 159105)
@@ -45,7 +45,7 @@
         explicit Run(const Iterator&);
 
         LayoutRect rect() const;
-        LayoutPoint baseline() const;
+        FloatPoint baseline() const;
         String text() const;
 
         unsigned lineIndex() const;
@@ -130,18 +130,18 @@
     auto& resolver = m_iterator.resolver();
     auto& run = m_iterator.simpleRun();
 
-    LayoutPoint linePosition(run.left, resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline - resolver.m_ascent);
-    LayoutSize lineSize(run.right - run.left, resolver.m_ascent + resolver.m_descent);
+    LayoutPoint linePosition(floor(run.left), resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline - resolver.m_ascent);
+    LayoutSize lineSize(ceil(run.right) - floor(run.left), resolver.m_ascent + resolver.m_descent);
     return LayoutRect(linePosition + resolver.m_contentOffset, lineSize);
 }
 
-inline LayoutPoint RunResolver::Run::baseline() const
+inline FloatPoint RunResolver::Run::baseline() const
 {
     auto& resolver = m_iterator.resolver();
     auto& run = m_iterator.simpleRun();
 
     float baselineY = resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline;
-    return LayoutPoint(run.left, baselineY) + resolver.m_contentOffset;
+    return FloatPoint(run.left, baselineY) + resolver.m_contentOffset;
 }
 
 inline String RunResolver::Run::text() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to