Title: [274440] trunk
Revision
274440
Author
[email protected]
Date
2021-03-15 14:27:39 -0700 (Mon, 15 Mar 2021)

Log Message

RenderStyle::getRoundedInnerBorderFor should never produce a rect with negative width/height
https://bugs.webkit.org/show_bug.cgi?id=223147

Reviewed by Simon Fraser.

Source/WebCore:

Width/height may get resolved to negative values when the rect goemetry (left/top) is at maximum LayoutUnit.

Test: fast/shapes/assert-when-rounded-rect-overflows.html

* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::getRoundedInnerBorderFor const):

LayoutTests:

* fast/shapes/assert-when-rounded-rect-overflows-expected.txt: Added.
* fast/shapes/assert-when-rounded-rect-overflows.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (274439 => 274440)


--- trunk/LayoutTests/ChangeLog	2021-03-15 21:22:51 UTC (rev 274439)
+++ trunk/LayoutTests/ChangeLog	2021-03-15 21:27:39 UTC (rev 274440)
@@ -1,3 +1,13 @@
+2021-03-15  Zalan Bujtas  <[email protected]>
+
+        RenderStyle::getRoundedInnerBorderFor should never produce a rect with negative width/height
+        https://bugs.webkit.org/show_bug.cgi?id=223147
+
+        Reviewed by Simon Fraser.
+
+        * fast/shapes/assert-when-rounded-rect-overflows-expected.txt: Added.
+        * fast/shapes/assert-when-rounded-rect-overflows.html: Added.
+
 2021-03-15  Yusuke Suzuki  <[email protected]>
 
         WebGL should be aware of [AllowShared]

Added: trunk/LayoutTests/fast/shapes/assert-when-rounded-rect-overflows-expected.txt (0 => 274440)


--- trunk/LayoutTests/fast/shapes/assert-when-rounded-rect-overflows-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/shapes/assert-when-rounded-rect-overflows-expected.txt	2021-03-15 21:27:39 UTC (rev 274440)
@@ -0,0 +1 @@
+PASS if no crash or assert.

Added: trunk/LayoutTests/fast/shapes/assert-when-rounded-rect-overflows.html (0 => 274440)


--- trunk/LayoutTests/fast/shapes/assert-when-rounded-rect-overflows.html	                        (rev 0)
+++ trunk/LayoutTests/fast/shapes/assert-when-rounded-rect-overflows.html	2021-03-15 21:27:39 UTC (rev 274440)
@@ -0,0 +1,22 @@
+<style>
+div { 
+  word-wrap: break-word;
+  orphans: 3;
+  padding: 100px;
+  -webkit-appearance: button;
+  transition: all 1s cubic-bezier(0,56,0.10,0.68);
+  height: 0px;
+  font-size: 32%;
+}
+
+*:last-of-type { 
+  columns: 2;
+  widows: 3;
+  orphans: 2;
+}
+</style>
+<div>PASS if no crash or assert.<audio controls=""></div>
+<script>
+if (window.testRunner)
+  testRunner.dumpAsText();
+</script>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (274439 => 274440)


--- trunk/Source/WebCore/ChangeLog	2021-03-15 21:22:51 UTC (rev 274439)
+++ trunk/Source/WebCore/ChangeLog	2021-03-15 21:27:39 UTC (rev 274440)
@@ -1,3 +1,17 @@
+2021-03-15  Zalan Bujtas  <[email protected]>
+
+        RenderStyle::getRoundedInnerBorderFor should never produce a rect with negative width/height
+        https://bugs.webkit.org/show_bug.cgi?id=223147
+
+        Reviewed by Simon Fraser.
+
+        Width/height may get resolved to negative values when the rect goemetry (left/top) is at maximum LayoutUnit.
+
+        Test: fast/shapes/assert-when-rounded-rect-overflows.html
+
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::getRoundedInnerBorderFor const):
+
 2021-03-15  Yusuke Suzuki  <[email protected]>
 
         WebGL should be aware of [AllowShared]

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (274439 => 274440)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2021-03-15 21:22:51 UTC (rev 274439)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2021-03-15 21:27:39 UTC (rev 274440)
@@ -1550,8 +1550,14 @@
 RoundedRect RenderStyle::getRoundedInnerBorderFor(const LayoutRect& borderRect, LayoutUnit topWidth, LayoutUnit bottomWidth,
     LayoutUnit leftWidth, LayoutUnit rightWidth, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
 {
-    RoundedRect roundedRect { { borderRect.x() + leftWidth, borderRect.y() + topWidth,
-        borderRect.width() - leftWidth - rightWidth, borderRect.height() - topWidth - bottomWidth } };
+    auto width = std::max(0_lu, borderRect.width() - leftWidth - rightWidth);
+    auto height = std::max(0_lu, borderRect.height() - topWidth - bottomWidth);
+    auto roundedRect = RoundedRect {
+        borderRect.x() + leftWidth,
+        borderRect.y() + topWidth,
+        width,
+        height
+    };
     if (hasBorderRadius()) {
         auto radii = getRoundedBorderFor(borderRect).radii();
         radii.shrink(topWidth, bottomWidth, leftWidth, rightWidth);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to