Title: [163585] trunk
Revision
163585
Author
[email protected]
Date
2014-02-06 17:21:07 -0800 (Thu, 06 Feb 2014)

Log Message

[CSS Shapes] Rounded Insets Let Content Overlap Shape
https://bugs.webkit.org/show_bug.cgi?id=127852

Reviewed by Bem Jones-Bey.

Source/WebCore:

Using LengthSize to FloatSize conversion from LengthSize.h lead to miscalculated
inset border radius, when the border radius was defined by percentages. This patch
fixes the behavior and removes the incorrect conversion.

Test: fast/shapes/shape-outside-floats/shape-outside-rounded-inset.html

* css/LengthFunctions.cpp:
(WebCore::floatSizeForLengthSize): Add new helper function for LengthSize to FloatSize conversion.
* css/LengthFunctions.h:
* platform/LengthSize.h: Remove floatSize conversion.
* rendering/shapes/Shape.cpp:
(WebCore::Shape::createShape): Use new helper function to calculate the right with for the inset border radius.

LayoutTests:

* fast/shapes/shape-outside-floats/shape-outside-rounded-inset-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-rounded-inset.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (163584 => 163585)


--- trunk/LayoutTests/ChangeLog	2014-02-07 01:18:38 UTC (rev 163584)
+++ trunk/LayoutTests/ChangeLog	2014-02-07 01:21:07 UTC (rev 163585)
@@ -1,3 +1,13 @@
+2014-02-06  Zoltan Horvath  <[email protected]>
+
+        [CSS Shapes] Rounded Insets Let Content Overlap Shape
+        https://bugs.webkit.org/show_bug.cgi?id=127852
+
+        Reviewed by Bem Jones-Bey.
+
+        * fast/shapes/shape-outside-floats/shape-outside-rounded-inset-expected.html: Added.
+        * fast/shapes/shape-outside-floats/shape-outside-rounded-inset.html: Added.
+
 2014-02-04  Jeffrey Pfau  <[email protected]>
 
         Make adoption agency use the task queue

Added: trunk/LayoutTests/fast/shapes/shape-outside-floats/shape-outside-rounded-inset-expected.html (0 => 163585)


--- trunk/LayoutTests/fast/shapes/shape-outside-floats/shape-outside-rounded-inset-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/shapes/shape-outside-floats/shape-outside-rounded-inset-expected.html	2014-02-07 01:21:07 UTC (rev 163585)
@@ -0,0 +1,35 @@
+<html>
+<head>
+<style>
+.shape-outside {
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    font: 10px / 1 Ahem, sans-serif;
+    width: 80px;
+    height: 80px;
+    border-radius: 50%;
+    background-color: green;
+    float: left;
+}
+</style>
+</script>
+</head>
+<body>
+
+<div class='shape-outside'>
+    <span style="margin-left: 66px;"></span>x<br/>
+    <span style="margin-left: 75px;"></span>x<br/>
+    <span style="margin-left: 79px;"></span>x<br/>
+    <span style="margin-left: 80px;"></span>x<br/>
+    <span style="margin-left: 80px;"></span>x<br/>
+    <span style="margin-left: 79px;"></span>x<br/>
+    <span style="margin-left: 75px;"></span>x<br/>
+    <span style="margin-left: 66px;"></span>x<br/>
+</div>
+
+<p style="margin-top: 100px;">The black rectangles should respect the boundaries of the shape-outside (green circle),
+thus they shouldn't overlap with the green circle.</p>
+<p><a href=''>Bug 127852</a>: [CSS Shapes] Rounded Insets Let Content Overlap Shape</p>
+</body>
+</html>

Added: trunk/LayoutTests/fast/shapes/shape-outside-floats/shape-outside-rounded-inset.html (0 => 163585)


--- trunk/LayoutTests/fast/shapes/shape-outside-floats/shape-outside-rounded-inset.html	                        (rev 0)
+++ trunk/LayoutTests/fast/shapes/shape-outside-floats/shape-outside-rounded-inset.html	2014-02-07 01:21:07 UTC (rev 163585)
@@ -0,0 +1,40 @@
+<html>
+<head>
+<style>
+.container {
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    width: 120px;
+    font: 10px / 1 Ahem, sans-serif;
+}
+.shape-outside {
+    -webkit-shape-outside: inset(0px round 50%);
+    width: 80px;
+    height: 80px;
+    border-radius: 50%;
+    background-color: green;
+    float: left;
+}
+</style>
+</script>
+</head>
+<body>
+<div class='container'>
+    <div class='shape-outside'></div>
+    x<br/>
+    x<br/>
+    x<br/>
+    x<br/>
+    x<br/>
+    x<br/>
+    x<br/>
+    x<br/>
+</div>
+
+<p style="margin-top: 100px;">The black rectangles should respect the boundaries of the shape-outside (green circle),
+thus they shouldn't overlap with the green circle.</p>
+<p><a href=''>Bug 127852</a>: [CSS Shapes] Rounded Insets Let Content Overlap Shape</p>
+</p>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (163584 => 163585)


--- trunk/Source/WebCore/ChangeLog	2014-02-07 01:18:38 UTC (rev 163584)
+++ trunk/Source/WebCore/ChangeLog	2014-02-07 01:21:07 UTC (rev 163585)
@@ -1,3 +1,23 @@
+2014-02-06  Zoltan Horvath  <[email protected]>
+
+        [CSS Shapes] Rounded Insets Let Content Overlap Shape
+        https://bugs.webkit.org/show_bug.cgi?id=127852
+
+        Reviewed by Bem Jones-Bey.
+
+        Using LengthSize to FloatSize conversion from LengthSize.h lead to miscalculated
+        inset border radius, when the border radius was defined by percentages. This patch
+        fixes the behavior and removes the incorrect conversion.
+
+        Test: fast/shapes/shape-outside-floats/shape-outside-rounded-inset.html
+
+        * css/LengthFunctions.cpp:
+        (WebCore::floatSizeForLengthSize): Add new helper function for LengthSize to FloatSize conversion.
+        * css/LengthFunctions.h:
+        * platform/LengthSize.h: Remove floatSize conversion.
+        * rendering/shapes/Shape.cpp:
+        (WebCore::Shape::createShape): Use new helper function to calculate the right with for the inset border radius.
+
 2014-02-06  Joseph Pecoraro  <[email protected]>
 
         Regenerate JSTestObj now that ScriptArguments moved. Generator knows what to do.

Modified: trunk/Source/WebCore/css/LengthFunctions.cpp (163584 => 163585)


--- trunk/Source/WebCore/css/LengthFunctions.cpp	2014-02-07 01:18:38 UTC (rev 163584)
+++ trunk/Source/WebCore/css/LengthFunctions.cpp	2014-02-07 01:21:07 UTC (rev 163585)
@@ -25,7 +25,7 @@
 #include "LengthFunctions.h"
 
 #include "LayoutUnit.h"
-#include "Length.h"
+#include "LengthSize.h"
 #include "RenderView.h"
 
 namespace WebCore {
@@ -210,4 +210,9 @@
     return 0;
 }
 
+FloatSize floatSizeForLengthSize(const LengthSize& lengthSize, const FloatSize& boxSize)
+{
+    return FloatSize(floatValueForLength(lengthSize.width(), boxSize.width()), floatValueForLength(lengthSize.height(), boxSize.height()));
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/LengthFunctions.h (163584 => 163585)


--- trunk/Source/WebCore/css/LengthFunctions.h	2014-02-07 01:18:38 UTC (rev 163584)
+++ trunk/Source/WebCore/css/LengthFunctions.h	2014-02-07 01:21:07 UTC (rev 163585)
@@ -26,9 +26,11 @@
 
 namespace WebCore {
 
+class FloatSize;
 class LayoutUnit;
 class RenderView;
 struct Length;
+struct LengthSize;
 
 int minimumIntValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false);
 int intValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false);
@@ -36,6 +38,7 @@
 LayoutUnit valueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false);
 float floatValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0);
 float floatValueForLength(const Length&, float maximumValue, RenderView* = 0);
+FloatSize floatSizeForLengthSize(const LengthSize&, const FloatSize&);
 
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/platform/LengthSize.h (163584 => 163585)


--- trunk/Source/WebCore/platform/LengthSize.h	2014-02-07 01:18:38 UTC (rev 163584)
+++ trunk/Source/WebCore/platform/LengthSize.h	2014-02-07 01:21:07 UTC (rev 163585)
@@ -21,7 +21,6 @@
 #ifndef LengthSize_h
 #define LengthSize_h
 
-#include "FloatSize.h"
 #include "Length.h"
 
 namespace WebCore {
@@ -54,11 +53,6 @@
         return LengthSize(m_width.blend(from.width(), progress), m_height.blend(from.height(), progress));
     }
 
-    FloatSize floatSize() const
-    {
-        return FloatSize(m_width.value(), m_height.value());
-    }
-
 private:
     Length m_width;
     Length m_height;

Modified: trunk/Source/WebCore/rendering/shapes/Shape.cpp (163584 => 163585)


--- trunk/Source/WebCore/rendering/shapes/Shape.cpp	2014-02-07 01:18:38 UTC (rev 163584)
+++ trunk/Source/WebCore/rendering/shapes/Shape.cpp	2014-02-07 01:21:07 UTC (rev 163585)
@@ -232,11 +232,14 @@
             boxHeight - top - floatValueForLength(inset.bottom(), boxHeight));
         FloatRect logicalRect = physicalRectToLogical(rect, logicalBoxSize.height(), writingMode);
 
-        shape = createInsetShape(FloatRoundedRect(logicalRect,
-            inset.topLeftRadius().floatSize(),
-            inset.topRightRadius().floatSize(),
-            inset.bottomLeftRadius().floatSize(),
-            inset.bottomRightRadius().floatSize()));
+        FloatSize boxSize(boxWidth, boxHeight);
+        FloatRoundedRect::Radii cornerRadii(
+            floatSizeForLengthSize(inset.topLeftRadius(), boxSize),
+            floatSizeForLengthSize(inset.topRightRadius(), boxSize),
+            floatSizeForLengthSize(inset.bottomLeftRadius(), boxSize),
+            floatSizeForLengthSize(inset.bottomRightRadius(), boxSize));
+
+        shape = createInsetShape(FloatRoundedRect(logicalRect, cornerRadii));
         break;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to