Title: [162791] trunk
Revision
162791
Author
za...@apple.com
Date
2014-01-25 17:27:28 -0800 (Sat, 25 Jan 2014)

Log Message

Subpixel layout: RenderInline is not centered when child RenderTextControl's innerTextRenderer needs bias centering.
https://bugs.webkit.org/show_bug.cgi?id=125659

Source/WebCore:

Reviewed by Andreas Kling

layoutMod(logicalHeightDiff, 2) fails to bias round when subpixel layout is enabled. It sets
the denominator value to 2, which returns incorrect modulo result.
(subpixel off: 3px % 2 = 1 vs subpixel on: (3px * 64) -> 192 % 2 = 0)

Covered by existing tests.

* platform/LayoutUnit.h:
* rendering/RenderSearchField.cpp:
(WebCore::RenderSearchField::centerContainerIfNeeded):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::centerRenderer):
(WebCore::RenderTextControlSingleLine::layout):
* rendering/RenderTextControlSingleLine.h:

LayoutTests:

Reviewed by Andreas Kling.

layoutMod(logicalHeightDiff, 2) fails to bias round when subpixel layout is enabled. It sets
the denominator value to 2, which returns incorrect modulo result.
(subpixel off: 3px % 2 = 1 vs subpixel on: (3px * 64) -> 192 % 2 = 0)

Covered by existing tests.

* platform/mac/fast/block/float/032-expected.txt:
* platform/mac/fast/forms/search-vertical-alignment-expected.png:
* platform/mac/fast/forms/search-vertical-alignment-expected.txt:
* platform/mac-mountainlion/fast/forms/search-vertical-alignment-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (162790 => 162791)


--- trunk/LayoutTests/ChangeLog	2014-01-26 01:08:21 UTC (rev 162790)
+++ trunk/LayoutTests/ChangeLog	2014-01-26 01:27:28 UTC (rev 162791)
@@ -1,3 +1,21 @@
+2014-01-25  Zalan Bujtas  <za...@apple.com>
+
+        Subpixel layout: RenderInline is not centered when child RenderTextControl's innerTextRenderer needs bias centering.
+        https://bugs.webkit.org/show_bug.cgi?id=125659
+
+        Reviewed by Andreas Kling.
+
+        layoutMod(logicalHeightDiff, 2) fails to bias round when subpixel layout is enabled. It sets
+        the denominator value to 2, which returns incorrect modulo result.
+        (subpixel off: 3px % 2 = 1 vs subpixel on: (3px * 64) -> 192 % 2 = 0)
+
+        Covered by existing tests.
+
+        * platform/mac/fast/block/float/032-expected.txt:
+        * platform/mac/fast/forms/search-vertical-alignment-expected.png:
+        * platform/mac/fast/forms/search-vertical-alignment-expected.txt:
+        * platform/mac-mountainlion/fast/forms/search-vertical-alignment-expected.txt:
+
 2014-01-25  Antti Koivisto  <an...@apple.com>
 
         REGRESSION(r162744): wsj.com paints white

Modified: trunk/LayoutTests/platform/mac/fast/block/float/032-expected.txt (162790 => 162791)


--- trunk/LayoutTests/platform/mac/fast/block/float/032-expected.txt	2014-01-26 01:08:21 UTC (rev 162790)
+++ trunk/LayoutTests/platform/mac/fast/block/float/032-expected.txt	2014-01-26 01:27:28 UTC (rev 162791)
@@ -46,10 +46,10 @@
         RenderTextControl {INPUT} at (55,5) size 106x106 [bgcolor=#800080] [border: (2px inset #000000)]
         RenderText {#text} at (0,0) size 0x0
 layer at (216,572) size 100x13
-  RenderBlock {DIV} at (3,46) size 100x14
+  RenderBlock {DIV} at (3,47) size 100x13
 layer at (316,700) size 100x13
-  RenderBlock {DIV} at (3,46) size 100x14
+  RenderBlock {DIV} at (3,47) size 100x13
 layer at (66,828) size 100x13
-  RenderBlock {DIV} at (3,46) size 100x14
+  RenderBlock {DIV} at (3,47) size 100x13
 layer at (66,956) size 100x13
-  RenderBlock {DIV} at (3,46) size 100x14
+  RenderBlock {DIV} at (3,47) size 100x13

Modified: trunk/LayoutTests/platform/mac/fast/forms/search-vertical-alignment-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/forms/search-vertical-alignment-expected.txt (162790 => 162791)


--- trunk/LayoutTests/platform/mac/fast/forms/search-vertical-alignment-expected.txt	2014-01-26 01:08:21 UTC (rev 162790)
+++ trunk/LayoutTests/platform/mac/fast/forms/search-vertical-alignment-expected.txt	2014-01-26 01:27:28 UTC (rev 162791)
@@ -22,7 +22,7 @@
         RenderText {#text} at (0,0) size 0x0
       RenderBlock {P} at (0,113) size 784x18
         RenderTextControl {INPUT} at (2,2) size 176x16 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
-          RenderFlexibleBox {DIV} at (3,1) size 170x14
+          RenderFlexibleBox {DIV} at (3,1) size 170x13
             RenderBlock {DIV} at (0,1) size 17x11
             RenderBlock {DIV} at (17,0) size 140x13
             RenderBlock {DIV} at (156,1) size 14x11
@@ -48,12 +48,12 @@
   RenderBlock {DIV} at (3,16) size 140x13
     RenderText {#text} at (0,0) size 24x13
       text run at (0,0) width 24: "Text"
-layer at (30,125) size 139x13
+layer at (30,124) size 139x13
   RenderBlock {DIV} at (0,0) size 140x13
     RenderText {#text} at (0,0) size 24x13
       text run at (0,0) width 24: "Text"
-layer at (196,125) size 139x13
-  RenderBlock {DIV} at (3,1) size 140x14
+layer at (196,124) size 139x13
+  RenderBlock {DIV} at (3,1) size 140x13
     RenderText {#text} at (0,0) size 24x13
       text run at (0,0) width 24: "Text"
 layer at (30,160) size 139x6 scrollHeight 13

Modified: trunk/LayoutTests/platform/mac-mountainlion/fast/forms/search-vertical-alignment-expected.txt (162790 => 162791)


--- trunk/LayoutTests/platform/mac-mountainlion/fast/forms/search-vertical-alignment-expected.txt	2014-01-26 01:08:21 UTC (rev 162790)
+++ trunk/LayoutTests/platform/mac-mountainlion/fast/forms/search-vertical-alignment-expected.txt	2014-01-26 01:27:28 UTC (rev 162791)
@@ -22,7 +22,7 @@
         RenderText {#text} at (0,0) size 0x0
       RenderBlock {P} at (0,113) size 784x18
         RenderTextControl {INPUT} at (2,2) size 153x16 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
-          RenderFlexibleBox {DIV} at (3,1) size 147x14
+          RenderFlexibleBox {DIV} at (3,1) size 147x13
             RenderBlock {DIV} at (0,1) size 17x11
             RenderBlock {DIV} at (17,0) size 117x13
             RenderBlock {DIV} at (134,1) size 13x11
@@ -48,12 +48,12 @@
   RenderBlock {DIV} at (3,16) size 117x13
     RenderText {#text} at (0,0) size 24x13
       text run at (0,0) width 24: "Text"
-layer at (30,125) size 117x13
+layer at (30,124) size 117x13
   RenderBlock {DIV} at (0,0) size 117x13
     RenderText {#text} at (0,0) size 24x13
       text run at (0,0) width 24: "Text"
-layer at (174,125) size 117x13
-  RenderBlock {DIV} at (3,1) size 117x14
+layer at (174,124) size 117x13
+  RenderBlock {DIV} at (3,1) size 117x13
     RenderText {#text} at (0,0) size 24x13
       text run at (0,0) width 24: "Text"
 layer at (30,160) size 117x6 scrollHeight 13

Modified: trunk/Source/WebCore/ChangeLog (162790 => 162791)


--- trunk/Source/WebCore/ChangeLog	2014-01-26 01:08:21 UTC (rev 162790)
+++ trunk/Source/WebCore/ChangeLog	2014-01-26 01:27:28 UTC (rev 162791)
@@ -1,3 +1,24 @@
+2014-01-25  Zalan Bujtas  <za...@apple.com>
+
+        Subpixel layout: RenderInline is not centered when child RenderTextControl's innerTextRenderer needs bias centering.
+        https://bugs.webkit.org/show_bug.cgi?id=125659
+
+        Reviewed by Andreas Kling
+
+        layoutMod(logicalHeightDiff, 2) fails to bias round when subpixel layout is enabled. It sets
+        the denominator value to 2, which returns incorrect modulo result.
+        (subpixel off: 3px % 2 = 1 vs subpixel on: (3px * 64) -> 192 % 2 = 0)
+
+        Covered by existing tests.
+
+        * platform/LayoutUnit.h:
+        * rendering/RenderSearchField.cpp:
+        (WebCore::RenderSearchField::centerContainerIfNeeded):
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::centerRenderer):
+        (WebCore::RenderTextControlSingleLine::layout):
+        * rendering/RenderTextControlSingleLine.h:
+
 2014-01-25  Sam Weinig  <s...@webkit.org>
 
         Remove more unnecessary #if PLATFORM(IOS)s in ApplicationCacheStorage.cpp

Modified: trunk/Source/WebCore/platform/LayoutUnit.h (162790 => 162791)


--- trunk/Source/WebCore/platform/LayoutUnit.h	2014-01-26 01:08:21 UTC (rev 162790)
+++ trunk/Source/WebCore/platform/LayoutUnit.h	2014-01-26 01:27:28 UTC (rev 162791)
@@ -958,11 +958,6 @@
     return value.abs();
 }
 
-inline LayoutUnit layoutMod(const LayoutUnit& numerator, const LayoutUnit& denominator)
-{
-    return numerator % denominator;
-}
-
 inline bool isIntegerValue(const LayoutUnit value)
 {
     return value.toInt() == value;

Modified: trunk/Source/WebCore/rendering/RenderSearchField.cpp (162790 => 162791)


--- trunk/Source/WebCore/rendering/RenderSearchField.cpp	2014-01-26 01:08:21 UTC (rev 162790)
+++ trunk/Source/WebCore/rendering/RenderSearchField.cpp	2014-01-26 01:27:28 UTC (rev 162791)
@@ -373,8 +373,7 @@
 
     // A quirk for find-in-page box on Safari Windows.
     // http://webkit.org/b/63157
-    LayoutUnit logicalHeightDiff = containerRenderer->logicalHeight() - contentLogicalHeight();
-    containerRenderer->setLogicalTop(containerRenderer->logicalTop() - (logicalHeightDiff / 2 + layoutMod(logicalHeightDiff, 2)));
+    centerRenderer(*containerRenderer);
 }
 
 }

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp (162790 => 162791)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2014-01-26 01:08:21 UTC (rev 162790)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2014-01-26 01:27:28 UTC (rev 162791)
@@ -93,6 +93,13 @@
     return containerElement() ? contentLogicalHeight() : logicalHeight();
 }
 
+void RenderTextControlSingleLine::centerRenderer(RenderBox& renderer) const
+{
+    LayoutUnit logicalHeightDiff = renderer.logicalHeight() - contentLogicalHeight();
+    float center = logicalHeightDiff / 2;
+    renderer.setLogicalTop(renderer.logicalTop() - LayoutUnit(round(center)));
+}
+
 static void setNeedsLayoutOnAncestors(RenderObject* start, RenderObject* ancestor)
 {
     ASSERT(start != ancestor);
@@ -170,10 +177,9 @@
         RenderBlockFlow::layoutBlock(true);
 
     // Center the child block in the block progression direction (vertical centering for horizontal text fields).
-    if (!container && innerTextRenderer && innerTextRenderer->height() != contentLogicalHeight()) {
-        LayoutUnit logicalHeightDiff = innerTextRenderer->logicalHeight() - contentLogicalHeight();
-        innerTextRenderer->setLogicalTop(innerTextRenderer->logicalTop() - (logicalHeightDiff / 2 + layoutMod(logicalHeightDiff, 2)));
-    } else
+    if (!container && innerTextRenderer && innerTextRenderer->height() != contentLogicalHeight())
+        centerRenderer(*innerTextRenderer);
+    else
         centerContainerIfNeeded(containerRenderer);
 
     // Ignores the paddings for the inner spin button.

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h (162790 => 162791)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h	2014-01-26 01:08:21 UTC (rev 162790)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h	2014-01-26 01:27:28 UTC (rev 162791)
@@ -43,6 +43,7 @@
 protected:
     virtual void centerContainerIfNeeded(RenderBox*) const { }
     virtual LayoutUnit computeLogicalHeightLimit() const;
+    void centerRenderer(RenderBox& renderer) const;
     HTMLElement* containerElement() const;
     HTMLElement* innerBlockElement() const;
     HTMLInputElement& inputElement() const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to