Inline blocks with margin wrap incorrectly with subpixel layout turned on
authoreae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 May 2012 21:42:13 +0000 (21:42 +0000)
committereae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 May 2012 21:42:13 +0000 (21:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=87897

Reviewed by Levi Weintraub.

Source/WebCore:

Change WebCore::getBorderPaddingMargin and the helper function
getBPMWidth to return a LayoutUnit rather than an int as the padding and
margin values have subpixel precision. This fixes an issue where we would
incorrectly wrap inline blocks with a subpixel padding or margin.

Test: fast/sub-pixel/inline-block-with-margin.html

* rendering/RenderBlock.cpp:
(WebCore::getBPMWidth):
(WebCore::getBorderPaddingMargin):
(WebCore::RenderBlock::computeInlinePreferredLogicalWidths):

LayoutTests:

Add test for inline blocks with a subpixel margin. Marked as skipped on
all platforms but chromium as subpixel layout has not yet been enabled
for any other platform.

* fast/sub-pixel/inline-block-with-margin-expected.html: Added.
* fast/sub-pixel/inline-block-with-margin.html: Added.
* platform/efl/Skipped:
* platform/gtk-wk2/Skipped:
* platform/mac-lion/Skipped:
* platform/mac-snowleopard/Skipped:
* platform/mac-wk2/Skipped:
* platform/mac/Skipped:
* platform/qt-4.8/Skipped:
* platform/qt/Skipped:
* platform/win-wk2/Skipped:
* platform/win-xp/Skipped:
* platform/win/Skipped:
* platform/wincairo/Skipped:
* platform/wk2/Skipped:

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

18 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/sub-pixel/inline-block-with-margin-expected.html [new file with mode: 0644]
LayoutTests/fast/sub-pixel/inline-block-with-margin.html [new file with mode: 0644]
LayoutTests/platform/efl/Skipped
LayoutTests/platform/gtk-wk2/Skipped
LayoutTests/platform/mac-lion/Skipped
LayoutTests/platform/mac-snowleopard/Skipped
LayoutTests/platform/mac-wk2/Skipped
LayoutTests/platform/mac/Skipped
LayoutTests/platform/qt-4.8/Skipped
LayoutTests/platform/qt/Skipped
LayoutTests/platform/win-wk2/Skipped
LayoutTests/platform/win-xp/Skipped
LayoutTests/platform/win/Skipped
LayoutTests/platform/wincairo/Skipped
LayoutTests/platform/wk2/Skipped
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp

index 997f266..67e7c38 100644 (file)
@@ -1,3 +1,30 @@
+2012-05-30  Emil A Eklund  <eae@chromium.org>
+
+        Inline blocks with margin wrap incorrectly with subpixel layout turned on
+        https://bugs.webkit.org/show_bug.cgi?id=87897
+
+        Reviewed by Levi Weintraub.
+
+        Add test for inline blocks with a subpixel margin. Marked as skipped on
+        all platforms but chromium as subpixel layout has not yet been enabled
+        for any other platform.
+
+        * fast/sub-pixel/inline-block-with-margin-expected.html: Added.
+        * fast/sub-pixel/inline-block-with-margin.html: Added.
+        * platform/efl/Skipped:
+        * platform/gtk-wk2/Skipped:
+        * platform/mac-lion/Skipped:
+        * platform/mac-snowleopard/Skipped:
+        * platform/mac-wk2/Skipped:
+        * platform/mac/Skipped:
+        * platform/qt-4.8/Skipped:
+        * platform/qt/Skipped:
+        * platform/win-wk2/Skipped:
+        * platform/win-xp/Skipped:
+        * platform/win/Skipped:
+        * platform/wincairo/Skipped:
+        * platform/wk2/Skipped:
+
 2012-05-30  Jessie Berlin  <jberlin@apple.com>
 
         [Qt][GTK][Mac][Win] New plugins/npruntime/delete-plugin-within-* tests introduced in r117012
diff --git a/LayoutTests/fast/sub-pixel/inline-block-with-margin-expected.html b/LayoutTests/fast/sub-pixel/inline-block-with-margin-expected.html
new file mode 100644 (file)
index 0000000..2070ba0
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE>
+<html>
+    <head>
+        <style>
+            div > span { margin-left: 0.4em; }
+        </style>
+    </head>
+    <body>
+        <div>Should not <span>wrap</span></div>
+        <section>
+            Line above should not wrap.
+        </section>
+    </body>
+</html>
diff --git a/LayoutTests/fast/sub-pixel/inline-block-with-margin.html b/LayoutTests/fast/sub-pixel/inline-block-with-margin.html
new file mode 100644 (file)
index 0000000..1669572
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE>
+<html>
+    <head>
+        <style>
+            div { display: inline-block; }
+            div > span { margin-left: 0.4em; }
+        </style>
+    </head>
+    <body>
+        <div>Should not <span>wrap</span></div>
+        <section>
+            Line above should not wrap.
+        </section>
+    </body>
+</html>
index abaed32..a6a8a9d 100644 (file)
@@ -1228,6 +1228,7 @@ fast/frames/transparent-scrollbar.html
 # https://bugs.webkit.org/show_bug.cgi?id=85532
 fast/sub-pixel/client-rect-has-subpixel-precision.html
 fast/sub-pixel/client-width-height-snapping.html
+fast/sub-pixel/inline-block-with-margin.html
 fast/sub-pixel/layout-boxes-with-zoom.html
 fast/sub-pixel/size-of-box-with-zoom.html
 
index b9f9717..bef2557 100644 (file)
@@ -342,6 +342,7 @@ editing/text-iterator/findString-selection-disabled.html
 # https://bugs.webkit.org/show_bug.cgi?id=85532
 fast/sub-pixel/client-rect-has-subpixel-precision.html
 fast/sub-pixel/client-width-height-snapping.html
+fast/sub-pixel/inline-block-with-margin.html
 fast/sub-pixel/layout-boxes-with-zoom.html
 fast/sub-pixel/size-of-box-with-zoom.html
 
index 9caff75..7bf1b77 100644 (file)
@@ -100,6 +100,7 @@ java/
 # https://bugs.webkit.org/show_bug.cgi?id=85532
 fast/sub-pixel/client-rect-has-subpixel-precision.html
 fast/sub-pixel/client-width-height-snapping.html
+fast/sub-pixel/inline-block-with-margin.html
 fast/sub-pixel/layout-boxes-with-zoom.html
 fast/sub-pixel/size-of-box-with-zoom.html
 
index 1e662a8..30eccfc 100644 (file)
@@ -198,6 +198,7 @@ fast/hidpi
 # https://bugs.webkit.org/show_bug.cgi?id=85532
 fast/sub-pixel/client-rect-has-subpixel-precision.html
 fast/sub-pixel/client-width-height-snapping.html
+fast/sub-pixel/inline-block-with-margin.html
 fast/sub-pixel/layout-boxes-with-zoom.html
 fast/sub-pixel/size-of-box-with-zoom.html
 
index ef62adc..e031b90 100644 (file)
@@ -203,6 +203,7 @@ fast/events/remove-target-with-shadow-in-drag.html
 # https://bugs.webkit.org/show_bug.cgi?id=85532
 fast/sub-pixel/client-rect-has-subpixel-precision.html
 fast/sub-pixel/client-width-height-snapping.html
+fast/sub-pixel/inline-block-with-margin.html
 fast/sub-pixel/layout-boxes-with-zoom.html
 fast/sub-pixel/size-of-box-with-zoom.html
 
index 474c466..f3bc5c6 100644 (file)
@@ -803,6 +803,7 @@ scrollbars/scrollbar-miss-mousemove-disabled.html
 # https://bugs.webkit.org/show_bug.cgi?id=85532
 fast/sub-pixel/client-rect-has-subpixel-precision.html
 fast/sub-pixel/client-width-height-snapping.html
+fast/sub-pixel/inline-block-with-margin.html
 fast/sub-pixel/layout-boxes-with-zoom.html
 fast/sub-pixel/size-of-box-with-zoom.html
 
index e554041..6a26e72 100644 (file)
@@ -86,6 +86,7 @@ plugins/fullscreen-plugins-dont-reload.html
 # https://bugs.webkit.org/show_bug.cgi?id=85532
 fast/sub-pixel/client-rect-has-subpixel-precision.html
 fast/sub-pixel/client-width-height-snapping.html
+fast/sub-pixel/inline-block-with-margin.html
 fast/sub-pixel/layout-boxes-with-zoom.html
 fast/sub-pixel/size-of-box-with-zoom.html
 
index fedce3b..7fdf46c 100644 (file)
@@ -216,6 +216,7 @@ fast/dom/shadow/tab-order-iframe-and-shadow.html
 # https://bugs.webkit.org/show_bug.cgi?id=85532
 fast/sub-pixel/client-rect-has-subpixel-precision.html
 fast/sub-pixel/client-width-height-snapping.html
+fast/sub-pixel/inline-block-with-margin.html
 fast/sub-pixel/layout-boxes-with-zoom.html
 fast/sub-pixel/size-of-box-with-zoom.html
 
index 75696c2..ed3b6ff 100644 (file)
@@ -937,6 +937,7 @@ inspector/extensions/extensions-resources.html
 # https://bugs.webkit.org/show_bug.cgi?id=85532
 fast/sub-pixel/client-rect-has-subpixel-precision.html
 fast/sub-pixel/client-width-height-snapping.html
+fast/sub-pixel/inline-block-with-margin.html
 fast/sub-pixel/layout-boxes-with-zoom.html
 fast/sub-pixel/size-of-box-with-zoom.html
 
index e5909fd..f156634 100644 (file)
@@ -37,6 +37,7 @@ fast/images/embed-image.html
 # https://bugs.webkit.org/show_bug.cgi?id=85532
 fast/sub-pixel/client-rect-has-subpixel-precision.html
 fast/sub-pixel/client-width-height-snapping.html
+fast/sub-pixel/inline-block-with-margin.html
 fast/sub-pixel/layout-boxes-with-zoom.html
 fast/sub-pixel/size-of-box-with-zoom.html
 
index 4428d04..89b576e 100644 (file)
@@ -1728,6 +1728,7 @@ fast/block/lineboxcontain/font.html
 # https://bugs.webkit.org/show_bug.cgi?id=85532
 fast/sub-pixel/client-rect-has-subpixel-precision.html
 fast/sub-pixel/client-width-height-snapping.html
+fast/sub-pixel/inline-block-with-margin.html
 fast/sub-pixel/layout-boxes-with-zoom.html
 fast/sub-pixel/size-of-box-with-zoom.html
 
index fb33ae4..d5ddc2a 100644 (file)
@@ -2086,6 +2086,7 @@ fast/dom/navigator-vibration.html
 # https://bugs.webkit.org/show_bug.cgi?id=85532
 fast/sub-pixel/client-rect-has-subpixel-precision.html
 fast/sub-pixel/client-width-height-snapping.html
+fast/sub-pixel/inline-block-with-margin.html
 fast/sub-pixel/layout-boxes-with-zoom.html
 fast/sub-pixel/size-of-box-with-zoom.html
 
index fe68e39..a02ba2c 100644 (file)
@@ -87,6 +87,7 @@ inspector/styles/styles-computed-trace.html
 # https://bugs.webkit.org/show_bug.cgi?id=85532
 fast/sub-pixel/client-rect-has-subpixel-precision.html
 fast/sub-pixel/client-width-height-snapping.html
+fast/sub-pixel/inline-block-with-margin.html
 fast/sub-pixel/layout-boxes-with-zoom.html
 fast/sub-pixel/size-of-box-with-zoom.html
 
index 8bdc4ed..085e457 100644 (file)
@@ -1,3 +1,22 @@
+2012-05-30  Emil A Eklund  <eae@chromium.org>
+
+        Inline blocks with margin wrap incorrectly with subpixel layout turned on
+        https://bugs.webkit.org/show_bug.cgi?id=87897
+
+        Reviewed by Levi Weintraub.
+
+        Change WebCore::getBorderPaddingMargin and the helper function
+        getBPMWidth to return a LayoutUnit rather than an int as the padding and
+        margin values have subpixel precision. This fixes an issue where we would
+        incorrectly wrap inline blocks with a subpixel padding or margin. 
+
+        Test: fast/sub-pixel/inline-block-with-margin.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::getBPMWidth):
+        (WebCore::getBorderPaddingMargin):
+        (WebCore::RenderBlock::computeInlinePreferredLogicalWidths):
+
 2012-05-30  Tony Chang  <tony@chromium.org>
 
         rename flexbox css values from justify and distribute to space-between and space-around
index 07fea7a..9e9a8e5 100755 (executable)
@@ -5393,14 +5393,14 @@ RenderObject* InlineMinMaxIterator::next()
     return current;
 }
 
-static int getBPMWidth(int childValue, Length cssUnit)
+static LayoutUnit getBPMWidth(LayoutUnit childValue, Length cssUnit)
 {
     if (cssUnit.type() != Auto)
-        return (cssUnit.isFixed() ? cssUnit.value() : childValue);
+        return (cssUnit.isFixed() ? static_cast<LayoutUnit>(cssUnit.value()) : childValue);
     return 0;
 }
 
-static int getBorderPaddingMargin(const RenderBoxModelObject* child, bool endOfInline)
+static LayoutUnit getBorderPaddingMargin(const RenderBoxModelObject* child, bool endOfInline)
 {
     RenderStyle* childStyle = child->style();
     if (endOfInline)