Title: [165261] trunk
Revision
165261
Author
[email protected]
Date
2014-03-07 08:25:12 -0800 (Fri, 07 Mar 2014)

Log Message

[CSS Shapes] inset does not properly clamp large corner radii
https://bugs.webkit.org/show_bug.cgi?id=129726

Reviewed by Dirk Schulze.

Source/WebCore:

Make sure that radii that are larger than 50% of the associated shape
dimension (height or width) are properly reduced the same way as
border-radius radii are.

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

* rendering/shapes/Shape.cpp:
(WebCore::ensureRadiiDoNotOverlap): Drive by style fix.
(WebCore::Shape::createShape): Scale radii the same way as border
    radii are scaled.
* platform/graphics/FloatRoundedRect.h:
(WebCore::calcBorderRadiiConstraintScaleFor): Move border radii
    constraint calculation function out so that it can be shared by
    the shape code.
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::getRoundedBorderFor): Call renamed scale function.

LayoutTests:

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

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (165260 => 165261)


--- trunk/LayoutTests/ChangeLog	2014-03-07 13:39:00 UTC (rev 165260)
+++ trunk/LayoutTests/ChangeLog	2014-03-07 16:25:12 UTC (rev 165261)
@@ -1,3 +1,13 @@
+2014-03-07  Bem Jones-Bey  <[email protected]>
+
+        [CSS Shapes] inset does not properly clamp large corner radii
+        https://bugs.webkit.org/show_bug.cgi?id=129726
+
+        Reviewed by Dirk Schulze.
+
+        * fast/shapes/shape-outside-floats/shape-outside-floats-inset-rounded-large-radius-expected.html: Added.
+        * fast/shapes/shape-outside-floats/shape-outside-floats-inset-rounded-large-radius.html: Added.
+
 2014-03-07  Michał Pakuła vel Rutka  <[email protected]>
 
         Unreviewed EFL gardening

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


--- trunk/LayoutTests/fast/shapes/shape-outside-floats/shape-outside-floats-inset-rounded-large-radius-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/shapes/shape-outside-floats/shape-outside-floats-inset-rounded-large-radius-expected.html	2014-03-07 16:25:12 UTC (rev 165261)
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.container {
+    position: relative;
+    font: 20px/1 Ahem, sans-serif;
+    width: 500px;
+    height: 200px;
+    border: 1px solid black;
+}
+
+.rounded-rect {
+    width: 320px;
+    height: 160px;
+    border-radius: 80px;
+    background-color: blue;
+}
+
+#right-rounded-rect-outline {
+    position: absolute;
+    top: 20px;
+    right: 0px;
+}
+
+
+.right-rounded-rect-float-line {
+    float: right;
+    clear: right;
+    height: 20px;
+}
+</style>
+<body>
+<div class="container" style="text-align: right">
+X<br/>
+    <div id="right-rounded-rect-outline" class="rounded-rect"></div>
+    <!-- generated right-rounded-rect-float-line divs will be inserted here -->
+X<br/>
+X<br/>
+X<br/>
+X<br/>
+X<br/>
+X<br/>
+X<br/>
+X<br/>
+X
+</div>
+<script src=""
+<script src=""
+<script>
+genRightRoundedRectFloatShapeOutsideRefTest({
+    roundedRect: {x: 0, y: 20, width: 320, height: 160, rx: 80, ry: 80},
+    containerWidth: 500,
+    containerHeight: 200,
+    lineHeight: 20,
+    floatElementClassSuffix: "rounded-rect-float-line",
+    insertElementIdSuffix: "rounded-rect-outline",
+});
+</script>
+
+<p>Requires Ahem font. There is a 0px size inset applied on the right float with 200px radius.<br>
+The black squares should trace the left side of the rounded rectangle's blue outline.</p>
+<p>Bug <a href="" [CSS Shapes] inset does not properly clamp large corner radii</p>
+
+</body>
+</html>

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


--- trunk/LayoutTests/fast/shapes/shape-outside-floats/shape-outside-floats-inset-rounded-large-radius.html	                        (rev 0)
+++ trunk/LayoutTests/fast/shapes/shape-outside-floats/shape-outside-floats-inset-rounded-large-radius.html	2014-03-07 16:25:12 UTC (rev 165261)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<style>
+.container {
+    font: 20px/1 Ahem, sans-serif;
+    width: 500px;
+    height: 200px;
+    border: 1px solid black;
+}
+
+.rounded-rect {
+    width: 320px;
+    height: 160px;
+    background-color: blue;
+    border-radius: 200px;
+    -webkit-shape-outside: inset(0px round 200px);
+}
+</style>
+
+<body>
+<div class="container" style="text-align: right">
+X<br/>
+    <div style="float: right" class="rounded-rect"></div>
+X<br/>
+X<br/>
+X<br/>
+X<br/>
+X<br/>
+X<br/>
+X<br/>
+X<br/>
+X
+</div>
+
+<p>Requires Ahem font. There is a 0px size inset applied on the right float with 200px radius.<br>
+The black squares should trace the left side of the rounded rectangle's blue outline.</p>
+<p>Bug <a href="" [CSS Shapes] inset does not properly clamp large corner radii</p>
+
+</body>

Modified: trunk/Source/WebCore/ChangeLog (165260 => 165261)


--- trunk/Source/WebCore/ChangeLog	2014-03-07 13:39:00 UTC (rev 165260)
+++ trunk/Source/WebCore/ChangeLog	2014-03-07 16:25:12 UTC (rev 165261)
@@ -1,3 +1,27 @@
+2014-03-07  Bem Jones-Bey  <[email protected]>
+
+        [CSS Shapes] inset does not properly clamp large corner radii
+        https://bugs.webkit.org/show_bug.cgi?id=129726
+
+        Reviewed by Dirk Schulze.
+
+        Make sure that radii that are larger than 50% of the associated shape
+        dimension (height or width) are properly reduced the same way as
+        border-radius radii are.
+
+        Test: fast/shapes/shape-outside-floats/shape-outside-floats-inset-rounded-large-radius.html
+
+        * rendering/shapes/Shape.cpp:
+        (WebCore::ensureRadiiDoNotOverlap): Drive by style fix.
+        (WebCore::Shape::createShape): Scale radii the same way as border
+            radii are scaled.
+        * platform/graphics/FloatRoundedRect.h:
+        (WebCore::calcBorderRadiiConstraintScaleFor): Move border radii
+            constraint calculation function out so that it can be shared by
+            the shape code.
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::getRoundedBorderFor): Call renamed scale function.
+
 2014-03-07  Carlos Garcia Campos  <[email protected]>
 
         [GST] Set name to several timeout sources

Modified: trunk/Source/WebCore/platform/graphics/FloatRoundedRect.h (165260 => 165261)


--- trunk/Source/WebCore/platform/graphics/FloatRoundedRect.h	2014-03-07 13:39:00 UTC (rev 165260)
+++ trunk/Source/WebCore/platform/graphics/FloatRoundedRect.h	2014-03-07 16:25:12 UTC (rev 165261)
@@ -134,6 +134,38 @@
     return a.rect() == b.rect() && a.radii() == b.radii();
 }
 
+inline float calcBorderRadiiConstraintScaleFor(const FloatRect& rect, const FloatRoundedRect::Radii& radii)
+{
+    // Constrain corner radii using CSS3 rules:
+    // http://www.w3.org/TR/css3-background/#the-border-radius
+
+    float factor = 1;
+    float radiiSum;
+
+    // top
+    radiiSum = radii.topLeft().width() + radii.topRight().width(); // Casts to avoid integer overflow.
+    if (radiiSum > rect.width())
+        factor = std::min(rect.width() / radiiSum, factor);
+
+    // bottom
+    radiiSum = radii.bottomLeft().width() + radii.bottomRight().width();
+    if (radiiSum > rect.width())
+        factor = std::min(rect.width() / radiiSum, factor);
+
+    // left
+    radiiSum = radii.topLeft().height() + radii.bottomLeft().height();
+    if (radiiSum > rect.height())
+        factor = std::min(rect.height() / radiiSum, factor);
+
+    // right
+    radiiSum = radii.topRight().height() + radii.bottomRight().height();
+    if (radiiSum > rect.height())
+        factor = std::min(rect.height() / radiiSum, factor);
+
+    ASSERT(factor <= 1);
+    return factor;
+}
+
 } // namespace WebCore
 
 #endif // FloatRoundedRect_h

Modified: trunk/Source/WebCore/rendering/shapes/Shape.cpp (165260 => 165261)


--- trunk/Source/WebCore/rendering/shapes/Shape.cpp	2014-03-07 13:39:00 UTC (rev 165260)
+++ trunk/Source/WebCore/rendering/shapes/Shape.cpp	2014-03-07 16:25:12 UTC (rev 165261)
@@ -100,7 +100,7 @@
     return size.transposedSize();
 }
 
-static inline void ensureRadiiDoNotOverlap(FloatRect &bounds, FloatSize &radii)
+static inline void ensureRadiiDoNotOverlap(FloatRect& bounds, FloatSize& radii)
 {
     float widthRatio = bounds.width() / (2 * radii.width());
     float heightRatio = bounds.height() / (2 * radii.height());
@@ -239,6 +239,8 @@
             floatSizeForLengthSize(inset.bottomLeftRadius(), boxSize),
             floatSizeForLengthSize(inset.bottomRightRadius(), boxSize));
 
+        cornerRadii.scale(calcBorderRadiiConstraintScaleFor(logicalRect, cornerRadii));
+
         shape = createInsetShape(FloatRoundedRect(logicalRect, cornerRadii));
         break;
     }

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (165260 => 165261)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2014-03-07 13:39:00 UTC (rev 165260)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2014-03-07 16:25:12 UTC (rev 165261)
@@ -26,6 +26,7 @@
 #include "ContentData.h"
 #include "CursorList.h"
 #include "CSSPropertyNames.h"
+#include "FloatRoundedRect.h"
 #include "Font.h"
 #include "FontSelector.h"
 #include "Pagination.h"
@@ -1066,38 +1067,6 @@
             valueForLength(border.bottomRight().height(), size.height(), renderView)));
 }
 
-static float calcConstraintScaleFor(const LayoutRect& rect, const RoundedRect::Radii& radii)
-{
-    // Constrain corner radii using CSS3 rules:
-    // http://www.w3.org/TR/css3-background/#the-border-radius
-    
-    float factor = 1;
-    float radiiSum;
-
-    // top
-    radiiSum = radii.topLeft().width() + radii.topRight().width(); // Casts to avoid integer overflow.
-    if (radiiSum > rect.width())
-        factor = std::min(rect.width() / radiiSum, factor);
-
-    // bottom
-    radiiSum = radii.bottomLeft().width() + radii.bottomRight().width();
-    if (radiiSum > rect.width())
-        factor = std::min(rect.width() / radiiSum, factor);
-    
-    // left
-    radiiSum = radii.topLeft().height() + radii.bottomLeft().height();
-    if (radiiSum > rect.height())
-        factor = std::min(rect.height() / radiiSum, factor);
-    
-    // right
-    radiiSum = radii.topRight().height() + radii.bottomRight().height();
-    if (radiiSum > rect.height())
-        factor = std::min(rect.height() / radiiSum, factor);
-    
-    ASSERT(factor <= 1);
-    return factor;
-}
-
 StyleImage* RenderStyle::listStyleImage() const { return rareInheritedData->listStyleImage.get(); }
 void RenderStyle::setListStyleImage(PassRefPtr<StyleImage> v)
 {
@@ -1120,7 +1089,7 @@
     RoundedRect roundedRect(borderRect);
     if (hasBorderRadius()) {
         RoundedRect::Radii radii = calcRadiiFor(surround->border, borderRect.size(), renderView);
-        radii.scale(calcConstraintScaleFor(borderRect, radii));
+        radii.scale(calcBorderRadiiConstraintScaleFor(borderRect, radii));
         roundedRect.includeLogicalEdges(radii, isHorizontalWritingMode(), includeLogicalLeftEdge, includeLogicalRightEdge);
     }
     return roundedRect;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to