Title: [276877] trunk
Revision
276877
Author
wei...@apple.com
Date
2021-05-01 13:40:57 -0700 (Sat, 01 May 2021)

Log Message

Update operations in CanvasImageData.idl to use long rather than float as per spec
https://bugs.webkit.org/show_bug.cgi?id=225263

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

* canvas/2d.imageData.create2.tiny-expected.txt:
* canvas/2d.imageData.get.tiny-expected.txt:
Update results, which now don't pass, to match the spec behavior.

* web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.create2.double-expected.txt:
* web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.create2.zero-expected.txt:
* web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.double-expected.txt:
* web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.large.crash-expected.txt:
* web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.rounding-expected.txt:
* web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.zero-expected.txt:
Update results, which now pass!

Source/WebCore:

Use `[EnforceRange] long` to match the current HTML spec.

* html/canvas/CanvasImageData.idl:
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::createImageData const):
(WebCore::CanvasRenderingContext2DBase::getImageData const):
(WebCore::CanvasRenderingContext2DBase::putImageData):
* html/canvas/CanvasRenderingContext2DBase.h:

LayoutTests:

* canvas/philip/tests/2d.imageData.create2.tiny-expected.txt:
* canvas/philip/tests/2d.imageData.get.tiny-expected.txt:
Update results, which now don't pass, to match the spec behavior.

* fast/canvas/canvas-2d-imageData-create-nonfinite-expected.txt:
* fast/canvas/canvas-crash.html:
* fast/canvas/canvas-getImageData-invalid-expected.txt:
* fast/canvas/canvas-getImageData-invalid-result-buffer-crash.html:
* fast/canvas/canvas-getImageData-invalid.html:
* fast/canvas/canvas-getImageData-large-crash-expected.txt:
* fast/canvas/canvas-getImageData-rounding-expected.txt:
* fast/canvas/canvas-getImageData-rounding.html:
* fast/canvas/canvas-putImageData-expected.txt:
* fast/canvas/canvas-putImageData.js:
* fast/canvas/resources/canvas-2d-imageData-create-nonfinite.js:
Update tests and results to match spec behavior.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (276876 => 276877)


--- trunk/LayoutTests/ChangeLog	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/ChangeLog	2021-05-01 20:40:57 UTC (rev 276877)
@@ -1,3 +1,27 @@
+2021-05-01  Sam Weinig  <wei...@apple.com>
+
+        Update operations in CanvasImageData.idl to use long rather than float as per spec
+        https://bugs.webkit.org/show_bug.cgi?id=225263
+
+        Reviewed by Simon Fraser.
+
+        * canvas/philip/tests/2d.imageData.create2.tiny-expected.txt:
+        * canvas/philip/tests/2d.imageData.get.tiny-expected.txt:
+        Update results, which now don't pass, to match the spec behavior.
+
+        * fast/canvas/canvas-2d-imageData-create-nonfinite-expected.txt:
+        * fast/canvas/canvas-crash.html:
+        * fast/canvas/canvas-getImageData-invalid-expected.txt:
+        * fast/canvas/canvas-getImageData-invalid-result-buffer-crash.html:
+        * fast/canvas/canvas-getImageData-invalid.html:
+        * fast/canvas/canvas-getImageData-large-crash-expected.txt:
+        * fast/canvas/canvas-getImageData-rounding-expected.txt:
+        * fast/canvas/canvas-getImageData-rounding.html:
+        * fast/canvas/canvas-putImageData-expected.txt:
+        * fast/canvas/canvas-putImageData.js:
+        * fast/canvas/resources/canvas-2d-imageData-create-nonfinite.js:
+        Update tests and results to match spec behavior.
+
 2021-05-01  Zalan Bujtas  <za...@apple.com>
 
         [RenderTreeBuilder] Reset the "children inline" state when merging anonymous table boxes

Modified: trunk/LayoutTests/canvas/philip/tests/2d.imageData.create2.tiny-expected.txt (276876 => 276877)


--- trunk/LayoutTests/canvas/philip/tests/2d.imageData.create2.tiny-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/canvas/philip/tests/2d.imageData.create2.tiny-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -1 +1 @@
-Passed
+Aborted with exception: The index is not in the allowed range.

Modified: trunk/LayoutTests/canvas/philip/tests/2d.imageData.get.tiny-expected.txt (276876 => 276877)


--- trunk/LayoutTests/canvas/philip/tests/2d.imageData.get.tiny-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/canvas/philip/tests/2d.imageData.get.tiny-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -1 +1 @@
-Passed
+Aborted with exception: The index is not in the allowed range.

Modified: trunk/LayoutTests/fast/canvas/canvas-2d-imageData-create-nonfinite-expected.txt (276876 => 276877)


--- trunk/LayoutTests/fast/canvas/canvas-2d-imageData-create-nonfinite-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/fast/canvas/canvas-2d-imageData-create-nonfinite-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -3,13 +3,13 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS ctx.createImageData(Infinity, Infinity) threw exception TypeError: The provided value is non-finite.
-PASS ctx.createImageData(Infinity, 10) threw exception TypeError: The provided value is non-finite.
-PASS ctx.createImageData(-Infinity, 10) threw exception TypeError: The provided value is non-finite.
-PASS ctx.createImageData(10, Infinity) threw exception TypeError: The provided value is non-finite.
-PASS ctx.createImageData(10, -Infinity) threw exception TypeError: The provided value is non-finite.
-PASS ctx.createImageData(NaN, 10) threw exception TypeError: The provided value is non-finite.
-PASS ctx.createImageData(10, NaN) threw exception TypeError: The provided value is non-finite.
+PASS ctx.createImageData(Infinity, Infinity) threw exception TypeError: Value Infinity is outside the range [-2147483648, 2147483647].
+PASS ctx.createImageData(Infinity, 10) threw exception TypeError: Value Infinity is outside the range [-2147483648, 2147483647].
+PASS ctx.createImageData(-Infinity, 10) threw exception TypeError: Value -Infinity is outside the range [-2147483648, 2147483647].
+PASS ctx.createImageData(10, Infinity) threw exception TypeError: Value Infinity is outside the range [-2147483648, 2147483647].
+PASS ctx.createImageData(10, -Infinity) threw exception TypeError: Value -Infinity is outside the range [-2147483648, 2147483647].
+PASS ctx.createImageData(NaN, 10) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS ctx.createImageData(10, NaN) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/canvas/canvas-crash.html (276876 => 276877)


--- trunk/LayoutTests/fast/canvas/canvas-crash.html	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/fast/canvas/canvas-crash.html	2021-05-01 20:40:57 UTC (rev 276877)
@@ -13,7 +13,7 @@
 function canvastest()
 {
     var ctx = document.getCSSCanvasContext("2d", "canvastest", 13951, 11138);
-    ctx.putImageData(ctx.getImageData(1431655766, document.getElementById("a").appendChild(document.createElement("media")).clientWidth, 4096, -1024), 128, -65535, 127, -2147483648, 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111, -1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111);
+    ctx.putImageData(ctx.getImageData(1431655766, document.getElementById("a").appendChild(document.createElement("media")).clientWidth, 4096, -1024), 128, -65535, 127, -2147483648, 2147483647, -2147483648);
 }
 
 canvastest();

Modified: trunk/LayoutTests/fast/canvas/canvas-getImageData-invalid-expected.txt (276876 => 276877)


--- trunk/LayoutTests/fast/canvas/canvas-getImageData-invalid-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/fast/canvas/canvas-getImageData-invalid-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -3,18 +3,18 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS ctx.getImageData(NaN, 10, 10, 10) threw exception TypeError: The provided value is non-finite.
-PASS ctx.getImageData(10, NaN, 10, 10) threw exception TypeError: The provided value is non-finite.
-PASS ctx.getImageData(10, 10, NaN, 10) threw exception TypeError: The provided value is non-finite.
-PASS ctx.getImageData(10, 10, 10, NaN) threw exception TypeError: The provided value is non-finite.
-PASS ctx.getImageData(Infinity, 10, 10, 10) threw exception TypeError: The provided value is non-finite.
-PASS ctx.getImageData(10, Infinity, 10, 10) threw exception TypeError: The provided value is non-finite.
-PASS ctx.getImageData(10, 10, Infinity, 10) threw exception TypeError: The provided value is non-finite.
-PASS ctx.getImageData(10, 10, 10, Infinity) threw exception TypeError: The provided value is non-finite.
-PASS ctx.getImageData(undefined, 10, 10, 10) threw exception TypeError: The provided value is non-finite.
-PASS ctx.getImageData(10, undefined, 10, 10) threw exception TypeError: The provided value is non-finite.
-PASS ctx.getImageData(10, 10, undefined, 10) threw exception TypeError: The provided value is non-finite.
-PASS ctx.getImageData(10, 10, 10, undefined) threw exception TypeError: The provided value is non-finite.
+PASS ctx.getImageData(NaN, 10, 10, 10) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS ctx.getImageData(10, NaN, 10, 10) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS ctx.getImageData(10, 10, NaN, 10) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS ctx.getImageData(10, 10, 10, NaN) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS ctx.getImageData(Infinity, 10, 10, 10) threw exception TypeError: Value Infinity is outside the range [-2147483648, 2147483647].
+PASS ctx.getImageData(10, Infinity, 10, 10) threw exception TypeError: Value Infinity is outside the range [-2147483648, 2147483647].
+PASS ctx.getImageData(10, 10, Infinity, 10) threw exception TypeError: Value Infinity is outside the range [-2147483648, 2147483647].
+PASS ctx.getImageData(10, 10, 10, Infinity) threw exception TypeError: Value Infinity is outside the range [-2147483648, 2147483647].
+PASS ctx.getImageData(undefined, 10, 10, 10) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS ctx.getImageData(10, undefined, 10, 10) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS ctx.getImageData(10, 10, undefined, 10) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS ctx.getImageData(10, 10, 10, undefined) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
 PASS ctx.getImageData(10, 10, 0, 10) threw exception IndexSizeError: The index is not in the allowed range..
 PASS ctx.getImageData(10, 10, 10, 0) threw exception IndexSizeError: The index is not in the allowed range..
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/fast/canvas/canvas-getImageData-invalid-result-buffer-crash.html (276876 => 276877)


--- trunk/LayoutTests/fast/canvas/canvas-getImageData-invalid-result-buffer-crash.html	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/fast/canvas/canvas-getImageData-invalid-result-buffer-crash.html	2021-05-01 20:40:57 UTC (rev 276877)
@@ -5,7 +5,7 @@
 function runTest() {
     var canvas = document.getElementById("test");
     var ctx = canvas.getContext("2d");
-    ctx.getImageData(10000, 125, -381000000, -0.9);
+    ctx.getImageData(10000, 125, -381000000, -2);
 }
 </script>
 </head>

Modified: trunk/LayoutTests/fast/canvas/canvas-getImageData-invalid.html (276876 => 276877)


--- trunk/LayoutTests/fast/canvas/canvas-getImageData-invalid.html	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/fast/canvas/canvas-getImageData-invalid.html	2021-05-01 20:40:57 UTC (rev 276877)
@@ -9,18 +9,18 @@
 
 ctx = document.createElement('canvas').getContext('2d');
 
-shouldThrow("ctx.getImageData(NaN, 10, 10, 10)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.getImageData(10, NaN, 10, 10)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.getImageData(10, 10, NaN, 10)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.getImageData(10, 10, 10, NaN)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.getImageData(Infinity, 10, 10, 10)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.getImageData(10, Infinity, 10, 10)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.getImageData(10, 10, Infinity, 10)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.getImageData(10, 10, 10, Infinity)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.getImageData(undefined, 10, 10, 10)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.getImageData(10, undefined, 10, 10)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.getImageData(10, 10, undefined, 10)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.getImageData(10, 10, 10, undefined)", '"TypeError: The provided value is non-finite"');
+shouldThrow("ctx.getImageData(NaN, 10, 10, 10)", '"TypeError: Value NaN is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.getImageData(10, NaN, 10, 10)", '"TypeError: Value NaN is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.getImageData(10, 10, NaN, 10)", '"TypeError: Value NaN is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.getImageData(10, 10, 10, NaN)", '"TypeError: Value NaN is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.getImageData(Infinity, 10, 10, 10)", '"TypeError: Value Infinity is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.getImageData(10, Infinity, 10, 10)", '"TypeError: Value Infinity is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.getImageData(10, 10, Infinity, 10)", '"TypeError: Value Infinity is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.getImageData(10, 10, 10, Infinity)", '"TypeError: Value Infinity is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.getImageData(undefined, 10, 10, 10)", '"TypeError: Value NaN is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.getImageData(10, undefined, 10, 10)", '"TypeError: Value NaN is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.getImageData(10, 10, undefined, 10)", '"TypeError: Value NaN is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.getImageData(10, 10, 10, undefined)", '"TypeError: Value NaN is outside the range [-2147483648, 2147483647]"');
 shouldThrow("ctx.getImageData(10, 10, 0, 10)", '"IndexSizeError: The index is not in the allowed range."');
 shouldThrow("ctx.getImageData(10, 10, 10, 0)", '"IndexSizeError: The index is not in the allowed range."');
 </script>

Modified: trunk/LayoutTests/fast/canvas/canvas-getImageData-large-crash-expected.txt (276876 => 276877)


--- trunk/LayoutTests/fast/canvas/canvas-getImageData-large-crash-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/fast/canvas/canvas-getImageData-large-crash-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -1 +1,2 @@
+CONSOLE MESSAGE: TypeError: Value 4294967295 is outside the range [-2147483648, 2147483647]
 PASSED (If this page did not crash.)

Modified: trunk/LayoutTests/fast/canvas/canvas-getImageData-rounding-expected.txt (276876 => 276877)


--- trunk/LayoutTests/fast/canvas/canvas-getImageData-rounding-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/fast/canvas/canvas-getImageData-rounding-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -7,28 +7,28 @@
 PASS imageData.width is 20
 PASS imageData.height is 10
 getImageData(0.1, 0.2, 20, 10)
-PASS imageData.width is 21
-PASS imageData.height is 11
+PASS imageData.width is 20
+PASS imageData.height is 10
 getImageData(0.9, 0.8, 20, 10)
-PASS imageData.width is 21
-PASS imageData.height is 11
-getImageData(0, 0, 19.9, 9.9)
 PASS imageData.width is 20
 PASS imageData.height is 10
+getImageData(0, 0, 19.9, 9.9)
+PASS imageData.width is 19
+PASS imageData.height is 9
 getImageData(0, 0, 19.1, 9.1)
-PASS imageData.width is 20
+PASS imageData.width is 19
+PASS imageData.height is 9
+getImageData(0.9, 0, 1.2, 10)
+PASS imageData.width is 1
 PASS imageData.height is 10
-getImageData(0.9, 0, 0.2, 10)
-PASS imageData.width is 2
-PASS imageData.height is 10
 getImageData(-1, -1, 20, 10)
 PASS imageData.width is 20
 PASS imageData.height is 10
 getImageData(-1.1, 0, 20, 10)
-PASS imageData.width is 21
+PASS imageData.width is 20
 PASS imageData.height is 10
 getImageData(-1.9, 0, 20, 10)
-PASS imageData.width is 21
+PASS imageData.width is 20
 PASS imageData.height is 10
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/fast/canvas/canvas-getImageData-rounding.html (276876 => 276877)


--- trunk/LayoutTests/fast/canvas/canvas-getImageData-rounding.html	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/fast/canvas/canvas-getImageData-rounding.html	2021-05-01 20:40:57 UTC (rev 276877)
@@ -11,8 +11,8 @@
 
 function dimensionsShouldBe(sx, sy, sw, sh, width, height)
 {
+    debug('getImageData(' + sx + ', ' + sy + ', ' + sw + ', ' + sh + ')');
     imageData = ctx.getImageData(sx, sy, sw, sh);
-    debug('getImageData(' + sx + ', ' + sy + ', ' + sw + ', ' + sh + ')');
     shouldBe('imageData.width', width + '');
     shouldBe('imageData.height', height + '');
 }
@@ -21,22 +21,22 @@
 dimensionsShouldBe(   0,  0,   20,  10,     20, 10);
 
 // Source point is not an integer
-dimensionsShouldBe(  .1, .2,   20,  10,     21, 11);
-dimensionsShouldBe(  .9, .8,   20,  10,     21, 11);
+dimensionsShouldBe(  .1, .2,   20,  10,     20, 10);
+dimensionsShouldBe(  .9, .8,   20,  10,     20, 10);
 
 // Size is not an integer
-dimensionsShouldBe(   0,  0, 19.9, 9.9,     20, 10);
-dimensionsShouldBe(   0,  0, 19.1, 9.1,     20, 10);
+dimensionsShouldBe(   0,  0, 19.9, 9.9,     19, 9);
+dimensionsShouldBe(   0,  0, 19.1, 9.1,     19, 9);
 
 // Width straddles a pixel boundary
-dimensionsShouldBe(  .9,  0,   .2,  10,      2, 10);
+dimensionsShouldBe(  .9,  0,   1.2,  10,      1, 10);
 
 // Basic integer negative values
 dimensionsShouldBe(  -1, -1,   20,  10,     20, 10);
 
 // Non-integer negative values
-dimensionsShouldBe(-1.1,  0,   20,  10,     21, 10);
-dimensionsShouldBe(-1.9,  0,   20,  10,     21, 10);
+dimensionsShouldBe(-1.1,  0,   20,  10,     20, 10);
+dimensionsShouldBe(-1.9,  0,   20,  10,     20, 10);
 </script>
 <script src=""
 </body>

Modified: trunk/LayoutTests/fast/canvas/canvas-putImageData-expected.txt (276876 => 276877)


--- trunk/LayoutTests/fast/canvas/canvas-putImageData-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/fast/canvas/canvas-putImageData-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -145,24 +145,24 @@
 PASS getPixel(1,1) is [0,128,0,255]
 PASS getPixel(9,9) is [0,128,0,255]
 PASS context.putImageData({}, 0, 0) threw exception TypeError: Argument 1 ('imagedata') to CanvasRenderingContext2D.putImageData must be an instance of ImageData.
-PASS context.putImageData(buffer, NaN, 0, 0, 0, 0, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, NaN, 0, 0, 0, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, 0, NaN, 0, 0, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, 0, 0, NaN, 0, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, 0, 0, 0, NaN, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, 0, 0, 0, 0, NaN) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, Infinity, 0, 0, 0, 0, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, Infinity, 0, 0, 0, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, 0, Infinity, 0, 0, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, 0, 0, Infinity, 0, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, 0, 0, 0, Infinity, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, 0, 0, 0, 0, Infinity) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, undefined, 0, 0, 0, 0, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, undefined, 0, 0, 0, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, 0, undefined, 0, 0, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, 0, 0, undefined, 0, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, 0, 0, 0, undefined, 0) threw exception TypeError: The provided value is non-finite.
-PASS context.putImageData(buffer, 0, 0, 0, 0, 0, undefined) threw exception TypeError: The provided value is non-finite.
+PASS context.putImageData(buffer, NaN, 0, 0, 0, 0, 0) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, NaN, 0, 0, 0, 0) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, 0, NaN, 0, 0, 0) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, 0, 0, NaN, 0, 0) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, 0, 0, 0, NaN, 0) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, 0, 0, 0, 0, NaN) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, Infinity, 0, 0, 0, 0, 0) threw exception TypeError: Value Infinity is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, Infinity, 0, 0, 0, 0) threw exception TypeError: Value Infinity is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, 0, Infinity, 0, 0, 0) threw exception TypeError: Value Infinity is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, 0, 0, Infinity, 0, 0) threw exception TypeError: Value Infinity is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, 0, 0, 0, Infinity, 0) threw exception TypeError: Value Infinity is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, 0, 0, 0, 0, Infinity) threw exception TypeError: Value Infinity is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, undefined, 0, 0, 0, 0, 0) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, undefined, 0, 0, 0, 0) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, 0, undefined, 0, 0, 0) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, 0, 0, undefined, 0, 0) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, 0, 0, 0, undefined, 0) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
+PASS context.putImageData(buffer, 0, 0, 0, 0, 0, undefined) threw exception TypeError: Value NaN is outside the range [-2147483648, 2147483647].
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/canvas/canvas-putImageData.js (276876 => 276877)


--- trunk/LayoutTests/fast/canvas/canvas-putImageData.js	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/fast/canvas/canvas-putImageData.js	2021-05-01 20:40:57 UTC (rev 276877)
@@ -202,24 +202,24 @@
 
 
 shouldThrowErrorName("context.putImageData({}, 0, 0)", "TypeError");
-shouldThrow("context.putImageData(buffer, NaN, 0, 0, 0, 0, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, NaN, 0, 0, 0, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, 0, NaN, 0, 0, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, 0, 0, NaN, 0, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, NaN, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, NaN)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, Infinity, 0, 0, 0, 0, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, Infinity, 0, 0, 0, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, 0, Infinity, 0, 0, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, 0, 0, Infinity, 0, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, Infinity, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, Infinity)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, undefined, 0, 0, 0, 0, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, undefined, 0, 0, 0, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, 0, undefined, 0, 0, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, 0, 0, undefined, 0, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, undefined, 0)", "'TypeError: The provided value is non-finite'");
-shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, undefined)", "'TypeError: The provided value is non-finite'");
+shouldThrow("context.putImageData(buffer, NaN, 0, 0, 0, 0, 0)", "'TypeError: Value NaN is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, NaN, 0, 0, 0, 0)", "'TypeError: Value NaN is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, 0, NaN, 0, 0, 0)", "'TypeError: Value NaN is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, 0, 0, NaN, 0, 0)", "'TypeError: Value NaN is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, NaN, 0)", "'TypeError: Value NaN is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, NaN)", "'TypeError: Value NaN is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, Infinity, 0, 0, 0, 0, 0)", "'TypeError: Value Infinity is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, Infinity, 0, 0, 0, 0)", "'TypeError: Value Infinity is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, 0, Infinity, 0, 0, 0)", "'TypeError: Value Infinity is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, 0, 0, Infinity, 0, 0)", "'TypeError: Value Infinity is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, Infinity, 0)", "'TypeError: Value Infinity is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, Infinity)", "'TypeError: Value Infinity is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, undefined, 0, 0, 0, 0, 0)", "'TypeError: Value NaN is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, undefined, 0, 0, 0, 0)", "'TypeError: Value NaN is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, 0, undefined, 0, 0, 0)", "'TypeError: Value NaN is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, 0, 0, undefined, 0, 0)", "'TypeError: Value NaN is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, undefined, 0)", "'TypeError: Value NaN is outside the range [-2147483648, 2147483647]'");
+shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, undefined)", "'TypeError: Value NaN is outside the range [-2147483648, 2147483647]'");
 
 // Ensure we don't mess up bounds clipping checks
 var rectcanvas = document.createElement("canvas");

Modified: trunk/LayoutTests/fast/canvas/resources/canvas-2d-imageData-create-nonfinite.js (276876 => 276877)


--- trunk/LayoutTests/fast/canvas/resources/canvas-2d-imageData-create-nonfinite.js	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/fast/canvas/resources/canvas-2d-imageData-create-nonfinite.js	2021-05-01 20:40:57 UTC (rev 276877)
@@ -3,10 +3,10 @@
 var canvas = document.getElementById('canvas');
 var ctx = canvas.getContext('2d');
 
-shouldThrow("ctx.createImageData(Infinity, Infinity)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.createImageData(Infinity, 10)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.createImageData(-Infinity, 10)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.createImageData(10, Infinity)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.createImageData(10, -Infinity)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.createImageData(NaN, 10)", '"TypeError: The provided value is non-finite"');
-shouldThrow("ctx.createImageData(10, NaN)", '"TypeError: The provided value is non-finite"');
+shouldThrow("ctx.createImageData(Infinity, Infinity)", '"TypeError: Value Infinity is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.createImageData(Infinity, 10)", '"TypeError: Value Infinity is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.createImageData(-Infinity, 10)", '"TypeError: Value -Infinity is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.createImageData(10, Infinity)", '"TypeError: Value Infinity is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.createImageData(10, -Infinity)", '"TypeError: Value -Infinity is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.createImageData(NaN, 10)", '"TypeError: Value NaN is outside the range [-2147483648, 2147483647]"');
+shouldThrow("ctx.createImageData(10, NaN)", '"TypeError: Value NaN is outside the range [-2147483648, 2147483647]"');

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (276876 => 276877)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-05-01 20:40:57 UTC (rev 276877)
@@ -1,3 +1,22 @@
+2021-05-01  Sam Weinig  <wei...@apple.com>
+
+        Update operations in CanvasImageData.idl to use long rather than float as per spec
+        https://bugs.webkit.org/show_bug.cgi?id=225263
+
+        Reviewed by Simon Fraser.
+
+        * canvas/2d.imageData.create2.tiny-expected.txt:
+        * canvas/2d.imageData.get.tiny-expected.txt:
+        Update results, which now don't pass, to match the spec behavior.
+
+        * web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.create2.double-expected.txt:
+        * web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.create2.zero-expected.txt:
+        * web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.double-expected.txt:
+        * web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.large.crash-expected.txt:
+        * web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.rounding-expected.txt:
+        * web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.zero-expected.txt:
+        Update results, which now pass!
+
 2021-04-30  Oriol Brufau  <obru...@igalia.com>
 
         [css-logical] Fix logical shorthands with var()

Modified: trunk/LayoutTests/imported/w3c/canvas/2d.imageData.create2.tiny-expected.txt (276876 => 276877)


--- trunk/LayoutTests/imported/w3c/canvas/2d.imageData.create2.tiny-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/imported/w3c/canvas/2d.imageData.create2.tiny-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -2,4 +2,4 @@
 createImageData(sw, sh) works for sizes smaller than one pixel
 Spec references: 2d.imageData.create2.size 2d.imageData.one
 Actual output:
-Passed
+Aborted with exception: The index is not in the allowed range.

Modified: trunk/LayoutTests/imported/w3c/canvas/2d.imageData.get.tiny-expected.txt (276876 => 276877)


--- trunk/LayoutTests/imported/w3c/canvas/2d.imageData.get.tiny-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/imported/w3c/canvas/2d.imageData.get.tiny-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -2,4 +2,4 @@
 getImageData() works for sizes smaller than one pixel
 Spec references: 2d.imageData.one
 Actual output:
-Passed
+Aborted with exception: The index is not in the allowed range.

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.create2.double-expected.txt (276876 => 276877)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.create2.double-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.create2.double-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -2,5 +2,5 @@
 createImageData(w, h) double is converted to long
 Actual output:
 
-FAIL createImageData(w, h) double is converted to long assert_equals: imgdata1.width === 10 (got 11[number], expected 10[number]) expected 10 but got 11
+PASS createImageData(w, h) double is converted to long
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.create2.zero-expected.txt (276876 => 276877)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.create2.zero-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.create2.zero-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -2,5 +2,5 @@
 createImageData(sw, sh) throws INDEX_SIZE_ERR if size is zero
 Actual output:
 
-FAIL createImageData(sw, sh) throws INDEX_SIZE_ERR if size is zero assert_throws_dom: function "function () { ctx.createImageData(0.99, 10); }" did not throw
+PASS createImageData(sw, sh) throws INDEX_SIZE_ERR if size is zero
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.double-expected.txt (276876 => 276877)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.double-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.double-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -2,5 +2,5 @@
 createImageData(w, h) double is converted to long
 Actual output:
 
-FAIL createImageData(w, h) double is converted to long assert_equals: imgdata1.width === 10 (got 11[number], expected 10[number]) expected 10 but got 11
+PASS createImageData(w, h) double is converted to long
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.large.crash-expected.txt (276876 => 276877)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.large.crash-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.large.crash-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -2,5 +2,5 @@
 Test that canvas crash when image data cannot be allocated.
 Actual output:
 
-FAIL Test that canvas crash when image data cannot be allocated. assert_throws_js: function "function () { ctx.getImageData(10, 0xffffffff, 2147483647, 10); }" did not throw
+PASS Test that canvas crash when image data cannot be allocated.
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.rounding-expected.txt (276876 => 276877)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.rounding-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.rounding-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -2,5 +2,5 @@
 Test the handling of non-integer source coordinates in getImageData().
 Actual output:
 
-FAIL Test the handling of non-integer source coordinates in getImageData(). assert_true: imageData.width == width expected true got false
+PASS Test the handling of non-integer source coordinates in getImageData().
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.zero-expected.txt (276876 => 276877)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.zero-expected.txt	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/pixel-manipulation/2d.imageData.get.zero-expected.txt	2021-05-01 20:40:57 UTC (rev 276877)
@@ -2,5 +2,5 @@
 getImageData() throws INDEX_SIZE_ERR if size is zero
 Actual output:
 
-FAIL getImageData() throws INDEX_SIZE_ERR if size is zero assert_throws_dom: function "function () { ctx.getImageData(1, 1, 0.1, 10); }" did not throw
+PASS getImageData() throws INDEX_SIZE_ERR if size is zero
 

Modified: trunk/Source/WebCore/ChangeLog (276876 => 276877)


--- trunk/Source/WebCore/ChangeLog	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/Source/WebCore/ChangeLog	2021-05-01 20:40:57 UTC (rev 276877)
@@ -1,3 +1,19 @@
+2021-05-01  Sam Weinig  <wei...@apple.com>
+
+        Update operations in CanvasImageData.idl to use long rather than float as per spec
+        https://bugs.webkit.org/show_bug.cgi?id=225263
+
+        Reviewed by Simon Fraser.
+
+        Use `[EnforceRange] long` to match the current HTML spec.
+
+        * html/canvas/CanvasImageData.idl:
+        * html/canvas/CanvasRenderingContext2DBase.cpp:
+        (WebCore::CanvasRenderingContext2DBase::createImageData const):
+        (WebCore::CanvasRenderingContext2DBase::getImageData const):
+        (WebCore::CanvasRenderingContext2DBase::putImageData):
+        * html/canvas/CanvasRenderingContext2DBase.h:
+
 2021-05-01  Zalan Bujtas  <za...@apple.com>
 
         [LFC] Move formatting contexts to layout/formattingContexts directory

Modified: trunk/Source/WebCore/html/canvas/CanvasImageData.idl (276876 => 276877)


--- trunk/Source/WebCore/html/canvas/CanvasImageData.idl	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/Source/WebCore/html/canvas/CanvasImageData.idl	2021-05-01 20:40:57 UTC (rev 276877)
@@ -25,12 +25,10 @@
 
 // https://html.spec.whatwg.org/multipage/canvas.html#canvasimagedata
 interface mixin CanvasImageData {
-    // FIXME: All the float arguments below should be longs.
-
     // pixel manipulation
-    ImageData createImageData(float sw, float sh);
+    ImageData createImageData([EnforceRange] long sw, [EnforceRange] long sh);
     ImageData createImageData(ImageData imagedata);
-    ImageData getImageData(float sx, float sy, float sw, float sh);
-    undefined putImageData(ImageData imagedata, float dx, float dy);
-    undefined putImageData(ImageData imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
+    ImageData getImageData([EnforceRange] long sx, [EnforceRange] long sy, [EnforceRange] long sw, [EnforceRange] long sh);
+    undefined putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy);
+    undefined putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy, [EnforceRange] long dirtyX, [EnforceRange] long dirtyY, [EnforceRange] long dirtyWidth, [EnforceRange] long dirtyHeight);
 };

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (276876 => 276877)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2021-05-01 20:40:57 UTC (rev 276877)
@@ -2164,25 +2164,16 @@
     return createEmptyImageData(imageData.size());
 }
 
-ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2DBase::createImageData(float sw, float sh) const
+ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2DBase::createImageData(int sw, int sh) const
 {
     if (!sw || !sh)
         return Exception { IndexSizeError };
 
-    FloatSize logicalSize(std::abs(sw), std::abs(sh));
-    if (!logicalSize.isExpressibleAsIntSize())
-        return nullptr;
-
-    IntSize size = expandedIntSize(logicalSize);
-    if (size.width() < 1)
-        size.setWidth(1);
-    if (size.height() < 1)
-        size.setHeight(1);
-
+    IntSize size { std::abs(sw), std::abs(sh) };
     return createEmptyImageData(size);
 }
 
-ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2DBase::getImageData(float sx, float sy, float sw, float sh) const
+ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2DBase::getImageData(int sx, int sy, int sw, int sh) const
 {
     if (!canvasBase().originClean()) {
         static NeverDestroyed<String> consoleMessage(MAKE_STATIC_STRING_IMPL("Unable to get image data from canvas because the canvas has been tainted by cross-origin data."));
@@ -2202,16 +2193,8 @@
         sh = -sh;
     }
 
-    FloatRect logicalRect(sx, sy, sw, sh);
-    if (logicalRect.width() < 1)
-        logicalRect.setWidth(1);
-    if (logicalRect.height() < 1)
-        logicalRect.setHeight(1);
-    if (!logicalRect.isExpressibleAsIntRect())
-        return nullptr;
+    IntRect imageDataRect { sx, sy, sw, sh };
 
-    IntRect imageDataRect = enclosingIntRect(logicalRect);
-
     ImageBuffer* buffer = canvasBase().buffer();
     if (!buffer)
         return createEmptyImageData(imageDataRect.size());
@@ -2226,12 +2209,12 @@
     return imageData;
 }
 
-void CanvasRenderingContext2DBase::putImageData(ImageData& data, float dx, float dy)
+void CanvasRenderingContext2DBase::putImageData(ImageData& data, int dx, int dy)
 {
     putImageData(data, dx, dy, 0, 0, data.width(), data.height());
 }
 
-void CanvasRenderingContext2DBase::putImageData(ImageData& data, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight)
+void CanvasRenderingContext2DBase::putImageData(ImageData& data, int dx, int dy, int dirtyX, int dirtyY, int dirtyWidth, int dirtyHeight)
 {
     ImageBuffer* buffer = canvasBase().buffer();
     if (!buffer)
@@ -2250,20 +2233,20 @@
         dirtyHeight = -dirtyHeight;
     }
 
-    FloatRect clipRect(dirtyX, dirtyY, dirtyWidth, dirtyHeight);
-    clipRect.intersect(IntRect(0, 0, data.width(), data.height()));
-    IntSize destOffset(static_cast<int>(dx), static_cast<int>(dy));
-    IntRect destRect = enclosingIntRect(clipRect);
+    IntRect clipRect { dirtyX, dirtyY, dirtyWidth, dirtyHeight };
+    clipRect.intersect(IntRect { 0, 0, data.width(), data.height() });
+    IntSize destOffset { dx, dy };
+    IntRect destRect = clipRect;
     destRect.move(destOffset);
-    destRect.intersect(IntRect(IntPoint(), buffer->logicalSize()));
+    destRect.intersect(IntRect { { }, buffer->logicalSize() });
     if (destRect.isEmpty())
         return;
-    IntRect sourceRect(destRect);
+    IntRect sourceRect { destRect };
     sourceRect.move(-destOffset);
-    sourceRect.intersect(IntRect(0, 0, data.width(), data.height()));
+    sourceRect.intersect(IntRect { 0, 0, data.width(), data.height() });
 
     if (!sourceRect.isEmpty())
-        buffer->putImageData(AlphaPremultiplication::Unpremultiplied, data, sourceRect, IntPoint(destOffset));
+        buffer->putImageData(AlphaPremultiplication::Unpremultiplied, data, sourceRect, IntPoint { destOffset });
 
     didDraw(FloatRect { destRect }, { }); // ignore transform, shadow and clip
 }

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h (276876 => 276877)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h	2021-05-01 19:55:35 UTC (rev 276876)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h	2021-05-01 20:40:57 UTC (rev 276877)
@@ -188,10 +188,10 @@
     ExceptionOr<RefPtr<CanvasPattern>> createPattern(CanvasImageSource&&, const String& repetition);
 
     RefPtr<ImageData> createImageData(ImageData&) const;
-    ExceptionOr<RefPtr<ImageData>> createImageData(float width, float height) const;
-    ExceptionOr<RefPtr<ImageData>> getImageData(float sx, float sy, float sw, float sh) const;
-    void putImageData(ImageData&, float dx, float dy);
-    void putImageData(ImageData&, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
+    ExceptionOr<RefPtr<ImageData>> createImageData(int width, int height) const;
+    ExceptionOr<RefPtr<ImageData>> getImageData(int sx, int sy, int sw, int sh) const;
+    void putImageData(ImageData&, int dx, int dy);
+    void putImageData(ImageData&, int dx, int dy, int dirtyX, int dirtyY, int dirtyWidth, int dirtyHeight);
 
     static constexpr float webkitBackingStorePixelRatio() { return 1; }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to