Title: [217521] trunk
Revision
217521
Author
[email protected]
Date
2017-05-27 09:23:24 -0700 (Sat, 27 May 2017)

Log Message

enclosingIntRect returns a rect with -1 width/height when the input FloatRect overflows integer.
https://bugs.webkit.org/show_bug.cgi?id=172676

Reviewed by Simon Fraser.

Source/WebCore:

Clamp integer values soon after the enclosing rectangle is resolved.

* platform/graphics/FloatRect.cpp:
(WebCore::enclosingIntRect):

Tools:

* TestWebKitAPI/Tests/WebCore/FloatRect.cpp:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (217520 => 217521)


--- trunk/Source/WebCore/ChangeLog	2017-05-27 05:25:06 UTC (rev 217520)
+++ trunk/Source/WebCore/ChangeLog	2017-05-27 16:23:24 UTC (rev 217521)
@@ -1,3 +1,15 @@
+2017-05-27  Zalan Bujtas  <[email protected]>
+
+        enclosingIntRect returns a rect with -1 width/height when the input FloatRect overflows integer.
+        https://bugs.webkit.org/show_bug.cgi?id=172676
+
+        Reviewed by Simon Fraser.
+
+        Clamp integer values soon after the enclosing rectangle is resolved.
+
+        * platform/graphics/FloatRect.cpp:
+        (WebCore::enclosingIntRect):
+
 2017-05-26  Joseph Pecoraro  <[email protected]>
 
         Simply some NSNumber usage

Modified: trunk/Source/WebCore/platform/graphics/FloatRect.cpp (217520 => 217521)


--- trunk/Source/WebCore/platform/graphics/FloatRect.cpp	2017-05-27 05:25:06 UTC (rev 217520)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.cpp	2017-05-27 16:23:24 UTC (rev 217521)
@@ -215,10 +215,9 @@
 
 IntRect enclosingIntRect(const FloatRect& rect)
 {
-    IntPoint location = flooredIntPoint(rect.minXMinYCorner());
-    IntPoint maxPoint = ceiledIntPoint(rect.maxXMaxYCorner());
-
-    return IntRect(location, maxPoint - location);
+    FloatPoint location = flooredIntPoint(rect.minXMinYCorner());
+    FloatPoint maxPoint = ceiledIntPoint(rect.maxXMaxYCorner());
+    return IntRect(IntPoint(location), IntSize(maxPoint - location));
 }
 
 IntRect roundedIntRect(const FloatRect& rect)

Modified: trunk/Tools/ChangeLog (217520 => 217521)


--- trunk/Tools/ChangeLog	2017-05-27 05:25:06 UTC (rev 217520)
+++ trunk/Tools/ChangeLog	2017-05-27 16:23:24 UTC (rev 217521)
@@ -1,3 +1,13 @@
+2017-05-27  Zalan Bujtas  <[email protected]>
+
+        enclosingIntRect returns a rect with -1 width/height when the input FloatRect overflows integer.
+        https://bugs.webkit.org/show_bug.cgi?id=172676
+
+        Reviewed by Simon Fraser.
+
+        * TestWebKitAPI/Tests/WebCore/FloatRect.cpp:
+        (TestWebKitAPI::TEST):
+
 2017-05-26  Zalan Bujtas  <[email protected]>
 
         TestWebKitAPI: EnclosingIntRect and RoundedIntRect should use EXPECT_EQ.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/FloatRect.cpp (217520 => 217521)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/FloatRect.cpp	2017-05-27 05:25:06 UTC (rev 217520)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/FloatRect.cpp	2017-05-27 16:23:24 UTC (rev 217521)
@@ -766,6 +766,17 @@
     EXPECT_EQ(20, enclosed.y());
     EXPECT_EQ(1035, enclosed.maxX());
     EXPECT_EQ(789, enclosed.maxY());
+
+    WebCore::FloatRect maxIntRect(INT_MIN, INT_MIN, 0, 0);
+    maxIntRect.shiftMaxXEdgeTo(INT_MAX);
+    maxIntRect.shiftMaxYEdgeTo(INT_MAX);
+
+    auto enclosed2 = WebCore::enclosingIntRect(maxIntRect);
+
+    EXPECT_EQ(INT_MIN, enclosed2.x());
+    EXPECT_EQ(INT_MIN, enclosed2.y());
+    EXPECT_EQ(INT_MAX, enclosed2.width());
+    EXPECT_EQ(INT_MAX, enclosed2.height());
 }
 
 TEST(FloatRect, RoundedIntRect)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to