Title: [125632] trunk/Source/WebCore
Revision
125632
Author
le...@chromium.org
Date
2012-08-14 18:39:20 -0700 (Tue, 14 Aug 2012)

Log Message

r125591 broke tests with SUBPIXEL_LAYOUT disabled
https://bugs.webkit.org/show_bug.cgi?id=94027

Reviewed by Eric Seidel.

The previous patch to fix block preferred widths for subpixel layout broke ports
without the flag enabled. This patch adds a static inline function --
adjustFloatForSubPixelLayout -- that truncates with sub-pixel layout disabled, and
ceil's to the nearest FractionalLayoutUnit when sub-pixel layout is enabled.

A block's max preferred width should be enough to layout the entire line without
wrapping. r125591 addressed a bug whereby converting floats to LayoutUnits with sub-
pixel layout enabled lost precision in certain cases, and could result in a line
being layed out to slightly over the max preferred width of the block.

This patch reverts the behavior when sub-pixel layout is disabled to truncating
sub-pixel values (such as those that originate in Length) when assigning them to
LayoutUnits, and ceiling the length of the entire line to the next largest integer.

Covered by existing tests.

* rendering/RenderBlock.cpp:
(WebCore):
(WebCore::adjustFloatForSubPixelLayout):
(WebCore::RenderBlock::computeInlinePreferredLogicalWidths):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125631 => 125632)


--- trunk/Source/WebCore/ChangeLog	2012-08-15 01:28:54 UTC (rev 125631)
+++ trunk/Source/WebCore/ChangeLog	2012-08-15 01:39:20 UTC (rev 125632)
@@ -1,3 +1,31 @@
+2012-08-14  Levi Weintraub  <le...@chromium.org>
+
+        r125591 broke tests with SUBPIXEL_LAYOUT disabled
+        https://bugs.webkit.org/show_bug.cgi?id=94027
+
+        Reviewed by Eric Seidel.
+
+        The previous patch to fix block preferred widths for subpixel layout broke ports
+        without the flag enabled. This patch adds a static inline function --
+        adjustFloatForSubPixelLayout -- that truncates with sub-pixel layout disabled, and
+        ceil's to the nearest FractionalLayoutUnit when sub-pixel layout is enabled.
+
+        A block's max preferred width should be enough to layout the entire line without
+        wrapping. r125591 addressed a bug whereby converting floats to LayoutUnits with sub-
+        pixel layout enabled lost precision in certain cases, and could result in a line
+        being layed out to slightly over the max preferred width of the block.
+
+        This patch reverts the behavior when sub-pixel layout is disabled to truncating
+        sub-pixel values (such as those that originate in Length) when assigning them to
+        LayoutUnits, and ceiling the length of the entire line to the next largest integer.
+
+        Covered by existing tests.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore):
+        (WebCore::adjustFloatForSubPixelLayout):
+        (WebCore::RenderBlock::computeInlinePreferredLogicalWidths):
+
 2012-08-14  Chris Evans  <cev...@google.com>
 
         Handle the XPath / (root) operator correctly for nodes that aren't attached to the document.

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (125631 => 125632)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-08-15 01:28:54 UTC (rev 125631)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-08-15 01:39:20 UTC (rev 125632)
@@ -5664,6 +5664,25 @@
     preferredWidth = max(snappedResult, preferredWidth);
 }
 
+// With sub-pixel enabled: When converting between floating point and LayoutUnits
+// we risk losing precision with each conversion. When this occurs while
+// accumulating our preferred widths, we can wind up with a line width that's
+// larger than our maxPreferredWidth due to pure float accumulation.
+//
+// With sub-pixel disabled: values from Lengths or the render tree aren't subject
+// to the same loss of precision, as they're always truncated and stored as
+// integers. We mirror that behavior here to prevent over-allocating our preferred
+// width.
+static inline LayoutUnit adjustFloatForSubPixelLayout(float value)
+{
+#if ENABLE(SUBPIXEL_LAYOUT)
+    return ceiledLayoutUnit(value);
+#else
+    return static_cast<int>(value);
+#endif
+}
+
+
 void RenderBlock::computeInlinePreferredLogicalWidths()
 {
     float inlineMax = 0;
@@ -5753,9 +5772,9 @@
                     Length startMargin = childStyle->marginStart();
                     Length endMargin = childStyle->marginEnd();
                     if (startMargin.isFixed())
-                        margins += ceiledLayoutUnit(startMargin.value());
+                        margins += adjustFloatForSubPixelLayout(startMargin.value());
                     if (endMargin.isFixed())
-                        margins += ceiledLayoutUnit(endMargin.value());
+                        margins += adjustFloatForSubPixelLayout(endMargin.value());
                     childMin += margins.ceilToFloat();
                     childMax += margins.ceilToFloat();
                 }
@@ -5797,7 +5816,7 @@
                     childMax += ti.ceilToFloat();
 
                     if (childMin < 0)
-                        textIndent = ceiledLayoutUnit(childMin);
+                        textIndent = adjustFloatForSubPixelLayout(childMin);
                     else
                         addedTextIndent = true;
                 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to