Title: [231440] trunk
Revision
231440
Author
[email protected]
Date
2018-05-07 10:20:41 -0700 (Mon, 07 May 2018)

Log Message

Support negative sw/sh values in createImageBitmap().
https://bugs.webkit.org/show_bug.cgi?id=184449

Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

Update expectations.

* web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage-expected.txt:

Source/WebCore:

Tests: LayoutTests/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage.html
       LayoutTests/http/wpt/2dcontext/imagebitmap/createImageBitmap.html

* html/ImageBitmap.cpp:
(WebCore::ImageBitmap::createPromise): handle negative values per spec.

LayoutTests:

* http/wpt/2dcontext/imagebitmap/createImageBitmap-expected.txt: update test name
* http/wpt/2dcontext/imagebitmap/createImageBitmap.html: update expected result

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (231439 => 231440)


--- trunk/LayoutTests/ChangeLog	2018-05-07 17:10:34 UTC (rev 231439)
+++ trunk/LayoutTests/ChangeLog	2018-05-07 17:20:41 UTC (rev 231440)
@@ -1,3 +1,13 @@
+2018-05-07  Ms2ger  <[email protected]>
+
+        Support negative sw/sh values in createImageBitmap().
+        https://bugs.webkit.org/show_bug.cgi?id=184449
+
+        Reviewed by Dean Jackson.
+
+        * http/wpt/2dcontext/imagebitmap/createImageBitmap-expected.txt: update test name
+        * http/wpt/2dcontext/imagebitmap/createImageBitmap.html: update expected result
+
 2018-05-04  Youenn Fablet  <[email protected]>
 
         webrtc/addICECandidate-closed.html is timing out

Modified: trunk/LayoutTests/http/wpt/2dcontext/imagebitmap/createImageBitmap-expected.txt (231439 => 231440)


--- trunk/LayoutTests/http/wpt/2dcontext/imagebitmap/createImageBitmap-expected.txt	2018-05-07 17:10:34 UTC (rev 231439)
+++ trunk/LayoutTests/http/wpt/2dcontext/imagebitmap/createImageBitmap-expected.txt	2018-05-07 17:20:41 UTC (rev 231440)
@@ -1,8 +1,8 @@
 
 PASS createImageBitmap rejects with RangeError if width is zero 
 PASS createImageBitmap rejects with RangeError if height is zero 
-PASS createImageBitmap rejects with RangeError if width is negative 
-PASS createImageBitmap rejects with RangeError if height is negative 
+PASS createImageBitmap if width is negative 
+PASS createImageBitmap if height is negative 
 PASS createImageBitmap rejects with InvalidStateError on an HTMLImageElement with no image data 
 PASS createImageBitmap from an HTMLImageElement with image data 
 PASS createImageBitmap rejects with InvalidStateError from an canvas with zero dimensions 

Modified: trunk/LayoutTests/http/wpt/2dcontext/imagebitmap/createImageBitmap.html (231439 => 231440)


--- trunk/LayoutTests/http/wpt/2dcontext/imagebitmap/createImageBitmap.html	2018-05-07 17:10:34 UTC (rev 231439)
+++ trunk/LayoutTests/http/wpt/2dcontext/imagebitmap/createImageBitmap.html	2018-05-07 17:20:41 UTC (rev 231440)
@@ -8,6 +8,13 @@
 <body>
 <script>
 (function() {
+    let loadImage = new Promise(function(resolve, reject) {
+        let img = new Image();
+        img._onload_ = function() { resolve(img); };
+        img._onerror_ = function() { reject(); };
+        img.src = ""
+    });
+
     promise_test(function(t) {
         return promise_rejects(t, new RangeError, createImageBitmap(new Image(), 0, 0, 0, 10));
     }, "createImageBitmap rejects with RangeError if width is zero");
@@ -17,12 +24,26 @@
     }, "createImageBitmap rejects with RangeError if height is zero");
 
     promise_test(function(t) {
-        return promise_rejects(t, new RangeError, createImageBitmap(new Image(), 0, 0, -10, 10));
-    }, "createImageBitmap rejects with RangeError if width is negative");
+        return loadImage.then(function(img) {
+            assert_equals(img.width, 20);
+            assert_equals(img.height, 20);
+            return createImageBitmap(img, 10, 10, -10, -10);
+        }).then(function(imageBitmap) {
+            assert_equals(imageBitmap.width, 10);
+            assert_equals(imageBitmap.height, 10);
+        });
+    }, "createImageBitmap if width is negative");
 
     promise_test(function(t) {
-        return promise_rejects(t, new RangeError, createImageBitmap(new Image(), 0, 0, 10, -10));
-    }, "createImageBitmap rejects with RangeError if height is negative");
+        return loadImage.then(function(img) {
+            assert_equals(img.width, 20);
+            assert_equals(img.height, 20);
+            return createImageBitmap(img, 10, 10, 10, -10);
+        }).then(function(imageBitmap) {
+            assert_equals(imageBitmap.width, 10);
+            assert_equals(imageBitmap.height, 10);
+        });
+    }, "createImageBitmap if height is negative");
 
     promise_test(function(t) {
         return promise_rejects(t, "InvalidStateError", createImageBitmap(new Image()));
@@ -29,11 +50,7 @@
     }, "createImageBitmap rejects with InvalidStateError on an HTMLImageElement with no image data");
 
     promise_test(function() {
-        return new Promise(function(resolve, reject) {
-            let img = new Image();
-            img._onload_ = function() { resolve(img); };
-            img.src = ""
-        }).then(function(img) {
+        return loadImage.then(function(img) {
             return createImageBitmap(img);
         }).then(function(imageBitmap) {
             assert_equals(imageBitmap.width, 20, "ImageBitmap width should be 20");

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (231439 => 231440)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2018-05-07 17:10:34 UTC (rev 231439)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2018-05-07 17:20:41 UTC (rev 231440)
@@ -1,3 +1,14 @@
+2018-05-07  Ms2ger  <[email protected]>
+
+        Support negative sw/sh values in createImageBitmap().
+        https://bugs.webkit.org/show_bug.cgi?id=184449
+
+        Reviewed by Dean Jackson.
+
+        Update expectations.
+
+        * web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage-expected.txt:
+
 2018-05-04  Chris Nardi  <[email protected]>
 
         Serialize all URLs with double-quotes per CSSOM spec

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage-expected.txt (231439 => 231440)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage-expected.txt	2018-05-07 17:10:34 UTC (rev 231439)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage-expected.txt	2018-05-07 17:20:41 UTC (rev 231440)
@@ -3,27 +3,27 @@
 PASS createImageBitmap from an HTMLCanvasElement scaled down, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from an HTMLCanvasElement scaled up, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from an HTMLCanvasElement resized, and drawImage on the created ImageBitmap 
-FAIL createImageBitmap from an HTMLCanvasElement with negative sw/sh, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "RangeError: Cannot create ImageBitmap with a negative width or height"
+PASS createImageBitmap from an HTMLCanvasElement with negative sw/sh, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from an HTMLVideoElement, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from an HTMLVideoElement scaled down, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from an HTMLVideoElement scaled up, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from an HTMLVideoElement resized, and drawImage on the created ImageBitmap 
-FAIL createImageBitmap from an HTMLVideoElement with negative sw/sh, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "RangeError: Cannot create ImageBitmap with a negative width or height"
+PASS createImageBitmap from an HTMLVideoElement with negative sw/sh, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from an HTMLVideoElement from a data URL, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from an HTMLVideoElement from a data URL scaled down, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from an HTMLVideoElement from a data URL scaled up, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from an HTMLVideoElement from a data URL resized, and drawImage on the created ImageBitmap 
-FAIL createImageBitmap from an HTMLVideoElement from a data URL with negative sw/sh, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "RangeError: Cannot create ImageBitmap with a negative width or height"
+PASS createImageBitmap from an HTMLVideoElement from a data URL with negative sw/sh, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from a bitmap HTMLImageElement, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from a bitmap HTMLImageElement scaled down, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from a bitmap HTMLImageElement scaled up, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from a bitmap HTMLImageElement resized, and drawImage on the created ImageBitmap 
-FAIL createImageBitmap from a bitmap HTMLImageElement with negative sw/sh, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "RangeError: Cannot create ImageBitmap with a negative width or height"
+PASS createImageBitmap from a bitmap HTMLImageElement with negative sw/sh, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from a vector HTMLImageElement, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from a vector HTMLImageElement scaled down, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from a vector HTMLImageElement scaled up, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from a vector HTMLImageElement resized, and drawImage on the created ImageBitmap 
-FAIL createImageBitmap from a vector HTMLImageElement with negative sw/sh, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "RangeError: Cannot create ImageBitmap with a negative width or height"
+PASS createImageBitmap from a vector HTMLImageElement with negative sw/sh, and drawImage on the created ImageBitmap 
 FAIL createImageBitmap from a bitmap SVGImageElement, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
 FAIL createImageBitmap from a bitmap SVGImageElement scaled down, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
 FAIL createImageBitmap from a bitmap SVGImageElement scaled up, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
@@ -43,15 +43,15 @@
 FAIL createImageBitmap from an ImageData scaled down, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with ImageData is not implemented"
 FAIL createImageBitmap from an ImageData scaled up, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with ImageData is not implemented"
 FAIL createImageBitmap from an ImageData resized, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with ImageData is not implemented"
-FAIL createImageBitmap from an ImageData with negative sw/sh, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "RangeError: Cannot create ImageBitmap with a negative width or height"
+FAIL createImageBitmap from an ImageData with negative sw/sh, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with ImageData is not implemented"
 PASS createImageBitmap from an ImageBitmap, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from an ImageBitmap scaled down, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from an ImageBitmap scaled up, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from an ImageBitmap resized, and drawImage on the created ImageBitmap 
-FAIL createImageBitmap from an ImageBitmap with negative sw/sh, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "RangeError: Cannot create ImageBitmap with a negative width or height"
+PASS createImageBitmap from an ImageBitmap with negative sw/sh, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from a Blob, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from a Blob scaled down, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from a Blob scaled up, and drawImage on the created ImageBitmap 
 PASS createImageBitmap from a Blob resized, and drawImage on the created ImageBitmap 
-FAIL createImageBitmap from a Blob with negative sw/sh, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "RangeError: Cannot create ImageBitmap with a negative width or height"
+PASS createImageBitmap from a Blob with negative sw/sh, and drawImage on the created ImageBitmap 
 

Modified: trunk/Source/WebCore/ChangeLog (231439 => 231440)


--- trunk/Source/WebCore/ChangeLog	2018-05-07 17:10:34 UTC (rev 231439)
+++ trunk/Source/WebCore/ChangeLog	2018-05-07 17:20:41 UTC (rev 231440)
@@ -1,3 +1,16 @@
+2018-05-07  Ms2ger  <[email protected]>
+
+        Support negative sw/sh values in createImageBitmap().
+        https://bugs.webkit.org/show_bug.cgi?id=184449
+
+        Reviewed by Dean Jackson.
+
+        Tests: LayoutTests/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage.html
+               LayoutTests/http/wpt/2dcontext/imagebitmap/createImageBitmap.html
+
+        * html/ImageBitmap.cpp:
+        (WebCore::ImageBitmap::createPromise): handle negative values per spec.
+
 2018-05-07  Brian Burg  <[email protected]>
 
         Web Inspector: opt out of process swap on navigation if a Web Inspector frontend is connected

Modified: trunk/Source/WebCore/html/ImageBitmap.cpp (231439 => 231440)


--- trunk/Source/WebCore/html/ImageBitmap.cpp	2018-05-07 17:10:34 UTC (rev 231439)
+++ trunk/Source/WebCore/html/ImageBitmap.cpp	2018-05-07 17:20:41 UTC (rev 231440)
@@ -98,14 +98,14 @@
         return;
     }
 
-    if (sw < 0 || sh < 0) {
-        promise.reject(RangeError, "Cannot create ImageBitmap with a negative width or height");
-        return;
-    }
+    auto left = sw >= 0 ? sx : sx + sw;
+    auto top = sh >= 0 ? sy : sy + sh;
+    auto width = std::abs(sw);
+    auto height = std::abs(sh);
 
     WTF::switchOn(source,
         [&] (auto& specificSource) {
-            createPromise(scriptExecutionContext, specificSource, WTFMove(options), IntRect { sx, sy, sw, sh }, WTFMove(promise));
+            createPromise(scriptExecutionContext, specificSource, WTFMove(options), IntRect { left, top, width, height }, WTFMove(promise));
         }
     );
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to