Title: [133475] trunk
Revision
133475
Author
[email protected]
Date
2012-11-05 07:25:12 -0800 (Mon, 05 Nov 2012)

Log Message

[CSS Exclusions] Layout of the first shape-inside line can be incorrect
https://bugs.webkit.org/show_bug.cgi?id=100996

Patch by Hans Muller <[email protected]> on 2012-11-05
Reviewed by Dirk Schulze.

Source/WebCore:

Made the conversion from floating point top/bottom logical shape bounds coordinates
LayoutUnits explicit and corrected the case where the top value was truncated.  A
float logicalTop value is converted to LayoutUnit with fromFloatCeil() to ensure
that the LayoutUnit value is within the shape.

Test: fast/exclusions/shape-inside/shape-inside-shape-logical-top.html

* rendering/ExclusionShapeInsideInfo.h:
(WebCore::ExclusionShapeInsideInfo::shapeLogicalTop): Redefined this method in terms of shapeLogicalBoundsY,Max().
(WebCore::ExclusionShapeInsideInfo::shapeLogicalBottom):  Ditto.
(WebCore::ExclusionShapeInsideInfo::lineOverlapsShapeBounds):  Ditto.
(ExclusionShapeInsideInfo):
(WebCore::ExclusionShapeInsideInfo::shapeLogicalBoundsY): Explicit conversion from floating point shape coordinates to LayoutUnits.
(WebCore::ExclusionShapeInsideInfo::shapeLogicalBoundsMaxY): Ditto.

LayoutTests:

Verify that the first line of shape-inside content is laid out correctly
when the top of the shape's bounds has a non-integral value.

* fast/exclusions/shape-inside/shape-inside-shape-logical-top-expected.html: Added.
* fast/exclusions/shape-inside/shape-inside-shape-logical-top.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (133474 => 133475)


--- trunk/LayoutTests/ChangeLog	2012-11-05 15:20:49 UTC (rev 133474)
+++ trunk/LayoutTests/ChangeLog	2012-11-05 15:25:12 UTC (rev 133475)
@@ -1,3 +1,16 @@
+2012-11-05  Hans Muller  <[email protected]>
+
+        [CSS Exclusions] Layout of the first shape-inside line can be incorrect
+        https://bugs.webkit.org/show_bug.cgi?id=100996
+
+        Reviewed by Dirk Schulze.
+
+        Verify that the first line of shape-inside content is laid out correctly
+        when the top of the shape's bounds has a non-integral value.
+
+        * fast/exclusions/shape-inside/shape-inside-shape-logical-top-expected.html: Added.
+        * fast/exclusions/shape-inside/shape-inside-shape-logical-top.html: Added.
+
 2012-11-05  Stephen White  <[email protected]>
 
         [chromium] Mark a flaky test.  Unreviewed.

Added: trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-shape-logical-top-expected.html (0 => 133475)


--- trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-shape-logical-top-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-shape-logical-top-expected.html	2012-11-05 15:25:12 UTC (rev 133475)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style id="stylesheet">
+    #shape-inside {
+        position: relative;
+        padding: 20.5px 35px 25px 15px;
+        width: 150px;
+        height: 175px;
+    }
+    #border {
+        position: absolute;
+        top: 13px;
+        left: 8px;
+        width: 161px;
+        height: 186px;
+        border: 2px solid blue;
+    }
+</style>
+<script>
+function init() {
+    // If subpixel layout is not enabled, fix shape-inside's padding-top value.
+    var shapeInsideElt = document.getElementById("shape-inside");
+    if (window.getComputedStyle(shapeInsideElt).paddingTop == "20px")
+        shapeInsideElt.style.paddingTop = "21px"
+}
+</script>
+</head>
+<body _onload_="init()">
+    <div id="shape-inside">
+        <div id="border"></div>
+        This text should be contained by the blue square.
+    </div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-shape-logical-top.html (0 => 133475)


--- trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-shape-logical-top.html	                        (rev 0)
+++ trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-shape-logical-top.html	2012-11-05 15:25:12 UTC (rev 133475)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+    if (window.internals)
+        window.internals.settings.setCSSExclusionsEnabled(true);
+</script>
+<style>
+    #shape-inside {
+        position: relative;
+        width: 200px;
+        height: 220px;
+        -webkit-shape-inside: polygon(15px 20.5px, 165px 20.5px, 165px 195px, 15px 195px);
+    }
+    #border {
+        position: absolute;
+        top: 13px;
+        left: 8px;
+        width: 161px;
+        height: 186px;
+        border: 2px solid blue;
+    }
+</style>
+</head>
+<body>
+    <div id="shape-inside">
+        <div id="border"></div>
+        This text should be contained by the blue square.
+    </div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (133474 => 133475)


--- trunk/Source/WebCore/ChangeLog	2012-11-05 15:20:49 UTC (rev 133474)
+++ trunk/Source/WebCore/ChangeLog	2012-11-05 15:25:12 UTC (rev 133475)
@@ -1,3 +1,25 @@
+2012-11-05  Hans Muller  <[email protected]>
+
+        [CSS Exclusions] Layout of the first shape-inside line can be incorrect
+        https://bugs.webkit.org/show_bug.cgi?id=100996
+
+        Reviewed by Dirk Schulze.
+
+        Made the conversion from floating point top/bottom logical shape bounds coordinates
+        LayoutUnits explicit and corrected the case where the top value was truncated.  A
+        float logicalTop value is converted to LayoutUnit with fromFloatCeil() to ensure
+        that the LayoutUnit value is within the shape.
+        
+        Test: fast/exclusions/shape-inside/shape-inside-shape-logical-top.html
+
+        * rendering/ExclusionShapeInsideInfo.h:
+        (WebCore::ExclusionShapeInsideInfo::shapeLogicalTop): Redefined this method in terms of shapeLogicalBoundsY,Max().
+        (WebCore::ExclusionShapeInsideInfo::shapeLogicalBottom):  Ditto.
+        (WebCore::ExclusionShapeInsideInfo::lineOverlapsShapeBounds):  Ditto.
+        (ExclusionShapeInsideInfo):
+        (WebCore::ExclusionShapeInsideInfo::shapeLogicalBoundsY): Explicit conversion from floating point shape coordinates to LayoutUnits.
+        (WebCore::ExclusionShapeInsideInfo::shapeLogicalBoundsMaxY): Ditto.
+
 2012-11-05  Antti Koivisto  <[email protected]>
 
         Protect against resource deletion during iteration in MemoryCache::pruneDeadResourcesToSize

Modified: trunk/Source/WebCore/rendering/ExclusionShapeInsideInfo.h (133474 => 133475)


--- trunk/Source/WebCore/rendering/ExclusionShapeInsideInfo.h	2012-11-05 15:20:49 UTC (rev 133474)
+++ trunk/Source/WebCore/rendering/ExclusionShapeInsideInfo.h	2012-11-05 15:25:12 UTC (rev 133475)
@@ -54,16 +54,10 @@
     static void removeExclusionShapeInsideInfoForRenderBlock(const RenderBlock*);
     static bool isExclusionShapeInsideInfoEnabledForRenderBlock(const RenderBlock*);
 
-    LayoutUnit shapeLogicalTop() const 
-    { 
-        ASSERT(m_shape);
-        return m_shape->shapeLogicalBoundingBox().y();
-    }
-    LayoutUnit shapeLogicalBottom() const
-    {
-        ASSERT(m_shape);
-        return m_shape->shapeLogicalBoundingBox().maxY();
-    }
+    LayoutUnit shapeLogicalTop() const { return shapeLogicalBoundsY(); }
+    LayoutUnit shapeLogicalBottom() const { return shapeLogicalBoundsMaxY(); }
+    bool lineOverlapsShapeBounds() const { return m_lineTop < shapeLogicalBottom() && m_lineTop + m_lineHeight >= shapeLogicalTop(); }
+
     bool hasSegments() const
     {
         return lineOverlapsShapeBounds() && m_segments.size();
@@ -74,13 +68,26 @@
         return m_segments;
     }
     bool computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight);
-    bool lineOverlapsShapeBounds() const;
     void computeShapeSize(LayoutUnit logicalWidth, LayoutUnit logicalHeight);
     void dirtyShapeSize() { m_shapeSizeDirty = true; }
 
 private:
     ExclusionShapeInsideInfo(RenderBlock*);
 
+    inline LayoutUnit shapeLogicalBoundsY() const
+    {
+        ASSERT(m_shape);
+        // Use fromFloatCeil() to ensure that the returned LayoutUnit value is within the shape's bounds.
+        return FractionalLayoutUnit::fromFloatCeil(m_shape->shapeLogicalBoundingBox().y());
+    }
+
+    inline LayoutUnit shapeLogicalBoundsMaxY() const
+    {
+        ASSERT(m_shape);
+        // Use fromFloatFloor() to ensure that the returned LayoutUnit value is within the shape's bounds.
+        return FractionalLayoutUnit::fromFloatFloor(m_shape->shapeLogicalBoundingBox().maxY());
+    }
+
     RenderBlock* m_block;
     OwnPtr<ExclusionShape> m_shape;
 
@@ -93,13 +100,6 @@
     bool m_shapeSizeDirty;
 };
 
-inline bool ExclusionShapeInsideInfo::lineOverlapsShapeBounds() const
-{
-    ASSERT(m_shape);
-    FloatRect shapeBounds = m_shape->shapeLogicalBoundingBox();
-    return m_lineTop < shapeBounds.maxY() && m_lineTop + m_lineHeight >= shapeBounds.y();
 }
-
-}
 #endif
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to