Title: [168599] trunk
Revision
168599
Author
mmaxfi...@apple.com
Date
2014-05-11 10:35:14 -0700 (Sun, 11 May 2014)

Log Message

[Mac] [iOS] Underlines are too low
https://bugs.webkit.org/show_bug.cgi?id=132770

Reviewed by Darin Adler.

Source/WebCore:
computeUnderlineOffset() inside InlineTextBox.cpp lowers underlines from text
baseline by a value that is proportional to the font size. However, this
lowering was done a second time in
GraphicsContext::computeLineBoundsAndAntialiasingModeForText(). This patch
removes this second, platform-dependent lowering.

This duplication was caused by merging iOS into open source, where iOS used
the GraphicsContext approach and open source used the InlineTextBox approach.

Covered by fast/css3-text/css3-text-decoration/text-decoration-thickness.html.

* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::computeLineBoundsAndAntialiasingModeForText): Remove
redundant lowering code
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paintDecoration): Clean up textDecorationThickness
variable

LayoutTests:
See per-file descriptions.

* fast/css3-text/css3-text-decoration/text-decoration-style-double-space-scales.html: Made
test more robust so it does not barely clip underlines, but rather gives them a couple
pixels of wiggle room.
* fast/css3-text/css3-text-decoration/text-decoration-thickness.html: Not only does this test
underline thickness, but it also tests underline position. Updated this test to not expect
incorrect results.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (168598 => 168599)


--- trunk/LayoutTests/ChangeLog	2014-05-11 09:42:47 UTC (rev 168598)
+++ trunk/LayoutTests/ChangeLog	2014-05-11 17:35:14 UTC (rev 168599)
@@ -1,3 +1,19 @@
+2014-05-09  Myles C. Maxfield  <lithe...@gmail.com>
+
+        [Mac] [iOS] Underlines are too low
+        https://bugs.webkit.org/show_bug.cgi?id=132770
+
+        Reviewed by Darin Adler.
+
+        See per-file descriptions.
+
+        * fast/css3-text/css3-text-decoration/text-decoration-style-double-space-scales.html: Made
+        test more robust so it does not barely clip underlines, but rather gives them a couple
+        pixels of wiggle room.
+        * fast/css3-text/css3-text-decoration/text-decoration-thickness.html: Not only does this test
+        underline thickness, but it also tests underline position. Updated this test to not expect
+        incorrect results.
+
 2014-05-11  Antti Koivisto  <an...@apple.com>
 
         Text with simple line layout not getting pushed below float when there is not enough space for it

Modified: trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-style-double-space-scales.html (168598 => 168599)


--- trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-style-double-space-scales.html	2014-05-11 09:42:47 UTC (rev 168598)
+++ trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-style-double-space-scales.html	2014-05-11 17:35:14 UTC (rev 168599)
@@ -7,7 +7,7 @@
 using overflow: hidden. It makes sure that this is exactly the same as a single underline. If the
 space between the two underlines does not scale with font size, it will appear as though there is a
 single thick underline (because they will be drawn on top of each other) and will thus fail this test.
-<div style="width: 100px; height: 99px; overflow: hidden;">
+<div style="width: 100px; height: 95px; overflow: hidden;">
 <div style="text-decoration: underline; font-size: 100px; -webkit-text-decoration-style: double; font-family: Ahem;">&nbsp;</div>
 </div>
 </body>

Modified: trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-thickness.html (168598 => 168599)


--- trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-thickness.html	2014-05-11 09:42:47 UTC (rev 168598)
+++ trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-thickness.html	2014-05-11 17:35:14 UTC (rev 168599)
@@ -7,7 +7,7 @@
 the text so that the underline should fill a box if the underline grows in proportion
 to text size. The comparison is to a box that has its background color set.
 <div style="position: relative; width: 600px; height: 600px; overflow: hidden;">
-<div style="font-family: Ahem; text-decoration: underline; font-size: 10000px; position: absolute; left: 0px; top: -8650px;">&nbsp;</div>
+<div style="font-family: Ahem; text-decoration: underline; font-size: 10000px; position: absolute; left: 0px; top: -8350px;">&nbsp;</div>
 </div>
 </body>
 </html>

Modified: trunk/Source/WebCore/ChangeLog (168598 => 168599)


--- trunk/Source/WebCore/ChangeLog	2014-05-11 09:42:47 UTC (rev 168598)
+++ trunk/Source/WebCore/ChangeLog	2014-05-11 17:35:14 UTC (rev 168599)
@@ -1,3 +1,28 @@
+2014-05-09  Myles C. Maxfield  <lithe...@gmail.com>
+
+        [Mac] [iOS] Underlines are too low
+        https://bugs.webkit.org/show_bug.cgi?id=132770
+
+        Reviewed by Darin Adler.
+
+        computeUnderlineOffset() inside InlineTextBox.cpp lowers underlines from text
+        baseline by a value that is proportional to the font size. However, this
+        lowering was done a second time in
+        GraphicsContext::computeLineBoundsAndAntialiasingModeForText(). This patch
+        removes this second, platform-dependent lowering.
+
+        This duplication was caused by merging iOS into open source, where iOS used
+        the GraphicsContext approach and open source used the InlineTextBox approach.
+
+        Covered by fast/css3-text/css3-text-decoration/text-decoration-thickness.html.
+
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::computeLineBoundsAndAntialiasingModeForText): Remove
+        redundant lowering code
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::paintDecoration): Clean up textDecorationThickness
+        variable
+
 2014-05-11  Antti Koivisto  <an...@apple.com>
 
         Text with simple line layout not getting pushed below float when there is not enough space for it

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (168598 => 168599)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2014-05-11 09:42:47 UTC (rev 168598)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2014-05-11 17:35:14 UTC (rev 168599)
@@ -977,16 +977,8 @@
             color = Color(color.red(), color.green(), color.blue(), alpha);
         }
 
-        // Don't offset line from bottom of text if scale is less than offsetUnderLineScale.
-        static const float offsetUnderlineScale = 0.4f;
-        float dy = scale < offsetUnderlineScale ? 0 : 1;
-
-        // If we've increased the thickness of the line, make sure to move the location too.
-        if (thickness > 1)
-            dy += roundf(thickness) - 1;
-
         FloatPoint devicePoint = transform.mapPoint(point);
-        FloatPoint deviceOrigin = FloatPoint(roundf(devicePoint.x()), ceilf(devicePoint.y()) + dy);
+        FloatPoint deviceOrigin = FloatPoint(roundf(devicePoint.x()), ceilf(devicePoint.y()));
         origin = transform.inverse().mapPoint(deviceOrigin);
     }
     return FloatRect(origin.x(), origin.y(), width, thickness);

Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (168598 => 168599)


--- trunk/Source/WebCore/rendering/InlineTextBox.cpp	2014-05-11 09:42:47 UTC (rev 168598)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp	2014-05-11 17:35:14 UTC (rev 168599)
@@ -979,9 +979,6 @@
     UNUSED_PARAM(textPainter);
 #endif
 
-    // FIXME: We should improve this rule and not always just assume 1.
-    const float textDecorationThickness = 1.f;
-
     if (m_truncation == cFullTruncation)
         return;
 
@@ -1004,9 +1001,8 @@
     bool isPrinting = renderer().document().printing();
 
     const float textDecorationBaseFontSize = 16;
-    float fontSizeScaling = renderer().style().fontSize() / textDecorationBaseFontSize;
-    float strokeThickness = roundf(textDecorationThickness * fontSizeScaling);
-    context.setStrokeThickness(strokeThickness);
+    float textDecorationThickness = renderer().style().fontSize() / textDecorationBaseFontSize;
+    context.setStrokeThickness(textDecorationThickness);
 
     bool linesAreOpaque = !isPrinting && (!(decoration & TextDecorationUnderline) || underline.alpha() == 255) && (!(decoration & TextDecorationOverline) || overline.alpha() == 255) && (!(decoration & TextDecorationLineThrough) || linethrough.alpha() == 255);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to