Skip to content

Commit

Permalink
Add support for "from-image" to ImageBitmapOptions.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=250476

Reviewed by Tim Nguyen.

"none" is deprecated, and has been renamed to "from-image".
This adds the new "from-image" value, with the same behaviour as "none".

* LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/imagebitmap/createImageBitmap-flipY-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/imagebitmap/createImageBitmap-sizeOverflow-expected.txt:
* Source/WebCore/html/ImageBitmapOptions.h:
* Source/WebCore/html/ImageBitmapOptions.idl:

Canonical link: https://commits.webkit.org/266893@main
  • Loading branch information
mattwoodrow committed Aug 15, 2023
1 parent c007fbf commit 556e20c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@

FAIL createImageBitmap from an HTMLCanvasElement imageOrientation: "from-image", and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
PASS createImageBitmap from an HTMLCanvasElement imageOrientation: "from-image", and drawImage on the created ImageBitmap
PASS createImageBitmap from an HTMLCanvasElement imageOrientation: "flipY", and drawImage on the created ImageBitmap
FAIL createImageBitmap from an HTMLVideoElement imageOrientation: "from-image", and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
PASS createImageBitmap from an HTMLVideoElement imageOrientation: "from-image", and drawImage on the created ImageBitmap
PASS createImageBitmap from an HTMLVideoElement imageOrientation: "flipY", and drawImage on the created ImageBitmap
FAIL createImageBitmap from an HTMLVideoElement from a data URL imageOrientation: "from-image", and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
PASS createImageBitmap from an HTMLVideoElement from a data URL imageOrientation: "from-image", and drawImage on the created ImageBitmap
PASS createImageBitmap from an HTMLVideoElement from a data URL imageOrientation: "flipY", and drawImage on the created ImageBitmap
FAIL createImageBitmap from a bitmap HTMLImageElement imageOrientation: "from-image", and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
PASS createImageBitmap from a bitmap HTMLImageElement imageOrientation: "from-image", and drawImage on the created ImageBitmap
PASS createImageBitmap from a bitmap HTMLImageElement imageOrientation: "flipY", and drawImage on the created ImageBitmap
FAIL createImageBitmap from a vector HTMLImageElement imageOrientation: "from-image", and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
PASS createImageBitmap from a vector HTMLImageElement imageOrientation: "from-image", and drawImage on the created ImageBitmap
FAIL createImageBitmap from a vector HTMLImageElement imageOrientation: "flipY", and drawImage on the created ImageBitmap assert_approx_equals: Red channel of the pixel at (5, 5) expected 0 +/- 3 but got 255
FAIL createImageBitmap from a bitmap SVGImageElement imageOrientation: "from-image", and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
FAIL createImageBitmap from a bitmap SVGImageElement imageOrientation: "flipY", and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
FAIL createImageBitmap from a vector SVGImageElement imageOrientation: "from-image", and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
FAIL createImageBitmap from a vector SVGImageElement imageOrientation: "flipY", and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
FAIL createImageBitmap from an OffscreenCanvas imageOrientation: "from-image", and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
PASS createImageBitmap from an OffscreenCanvas imageOrientation: "flipY", and drawImage on the created ImageBitmap
FAIL createImageBitmap from an ImageData imageOrientation: "from-image", and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
PASS createImageBitmap from an ImageData imageOrientation: "from-image", and drawImage on the created ImageBitmap
PASS createImageBitmap from an ImageData imageOrientation: "flipY", and drawImage on the created ImageBitmap
FAIL createImageBitmap from an ImageBitmap imageOrientation: "from-image", and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
PASS createImageBitmap from an ImageBitmap imageOrientation: "from-image", and drawImage on the created ImageBitmap
PASS createImageBitmap from an ImageBitmap imageOrientation: "flipY", and drawImage on the created ImageBitmap
FAIL createImageBitmap from a Blob imageOrientation: "from-image", and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
PASS createImageBitmap from a Blob imageOrientation: "from-image", and drawImage on the created ImageBitmap
PASS createImageBitmap from a Blob imageOrientation: "flipY", and drawImage on the created ImageBitmap

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ PASS createImageBitmap does not crash or reject the promise when passing very la
PASS createImageBitmap does not crash or reject the promise when passing very large sw
PASS createImageBitmap does not crash or reject the promise when passing very large sh
PASS createImageBitmap does not crash or reject the promise when passing very large sx, sy, sw and sh
FAIL createImageBitmap throws an InvalidStateError error with big imageBitmap scaled up in big height promise_rejects_dom: function "function() { throw e }" threw object "TypeError: Type error" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
FAIL createImageBitmap throws an InvalidStateError error with big imageBitmap scaled up in big width promise_rejects_dom: function "function() { throw e }" threw object "TypeError: Type error" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
FAIL createImageBitmap throws an InvalidStateError error with big imageBitmap scaled up in big height assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL createImageBitmap throws an InvalidStateError error with big imageBitmap scaled up in big width assert_unreached: Should have rejected: undefined Reached unreachable code

2 changes: 1 addition & 1 deletion Source/WebCore/html/ImageBitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ void ImageBitmap::createCompletionHandler(ScriptExecutionContext& scriptExecutio
// If no cropping, resizing, flipping, etc. are needed, then simply use the
// resulting ImageBuffer directly.
auto alphaPremultiplication = alphaPremultiplicationForPremultiplyAlpha(options.premultiplyAlpha);
if (sourceRectangle.returnValue().location().isZero() && sourceRectangle.returnValue().size() == imageData->size() && sourceRectangle.returnValue().size() == outputSize && options.orientation == ImageBitmapOptions::Orientation::None) {
if (sourceRectangle.returnValue().location().isZero() && sourceRectangle.returnValue().size() == imageData->size() && sourceRectangle.returnValue().size() == outputSize && options.orientation != ImageBitmapOptions::Orientation::FlipY) {
bitmapData->putPixelBuffer(imageData->pixelBuffer(), sourceRectangle.releaseReturnValue(), { }, alphaPremultiplication);

OptionSet<SerializationState> serializationState = SerializationState::OriginClean;
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/html/ImageBitmapOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
namespace WebCore {

struct ImageBitmapOptions {
enum class Orientation { None, FlipY };
enum class Orientation { FromImage, FlipY, None };
enum class PremultiplyAlpha { None, Premultiply, Default };
enum class ColorSpaceConversion { None, Default };
enum class ResizeQuality { Pixelated, Low, Medium, High };

Orientation orientation { Orientation::None };
Orientation orientation { Orientation::FromImage };
PremultiplyAlpha premultiplyAlpha { PremultiplyAlpha::Default };
ColorSpaceConversion colorSpaceConversion { ColorSpaceConversion::Default };
std::optional<unsigned> resizeWidth;
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/html/ImageBitmapOptions.idl
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/

enum ImageOrientation { "none", "flipY" };
enum ImageOrientation { "from-image", "flipY", "none" };
enum PremultiplyAlpha { "none", "premultiply", "default" };
enum ColorSpaceConversion { "none", "default" };
enum ResizeQuality { "pixelated", "low", "medium", "high" };

dictionary ImageBitmapOptions {
[ImplementedAs=orientation] ImageOrientation imageOrientation = "none";
[ImplementedAs=orientation] ImageOrientation imageOrientation = "from-image";
PremultiplyAlpha premultiplyAlpha = "default";
ColorSpaceConversion colorSpaceConversion = "default";
[EnforceRange] unsigned long resizeWidth;
Expand Down

0 comments on commit 556e20c

Please sign in to comment.