diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index afe4b5392b8..42107fcf340 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -46,6 +46,7 @@ static bool is_platform_object(Type const& type) "FileList"sv, "FormData"sv, "HTMLCollection"sv, + "ImageBitmap"sv, "ImageData"sv, "Instance"sv, "IntersectionObserverEntry"sv, diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.cpp b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.cpp index d824ff34e37..5cfe17501ee 100644 --- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.cpp +++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.cpp @@ -5,6 +5,7 @@ */ #include +#include namespace Web::HTML { diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.h b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.h index 2bcdd4ffd63..b274c490762 100644 --- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.h +++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include #include @@ -14,7 +15,7 @@ namespace Web::HTML { // https://html.spec.whatwg.org/multipage/canvas.html#canvasimagesource // NOTE: This is the Variant created by the IDL wrapper generator, and needs to be updated accordingly. -using CanvasImageSource = Variant, JS::Handle>; +using CanvasImageSource = Variant, JS::Handle, JS::Handle>; // https://html.spec.whatwg.org/multipage/canvas.html#canvasdrawimage class CanvasDrawImage { diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.idl b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.idl index f944f045fe2..aef9653c3ec 100644 --- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.idl +++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.idl @@ -1,11 +1,12 @@ #import #import +#import typedef (HTMLImageElement or // FIXME: We should use HTMLOrSVGImageElement instead of HTMLImageElement // FIXME: HTMLVideoElement or - HTMLCanvasElement -// FIXME: ImageBitmap + HTMLCanvasElement or + ImageBitmap // FIXME: OffscreenCanvas // FIXME: VideoFrame ) CanvasImageSource; diff --git a/Userland/Libraries/LibWeb/HTML/CanvasPattern.cpp b/Userland/Libraries/LibWeb/HTML/CanvasPattern.cpp index c36fd92fc39..47689d3517c 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasPattern.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasPattern.cpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace Web::HTML { diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 8d584dd77b8..340b661fb76 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -636,6 +637,14 @@ WebIDL::ExceptionOr check_usability_of_image(CanvasI if (canvas_element->width() == 0 || canvas_element->height() == 0) return WebIDL::InvalidStateError::create(canvas_element->realm(), "Canvas width or height is zero"_fly_string); return Optional {}; + }, + + // ImageBitmap + // FIXME: VideoFrame + [](JS::Handle const& image_bitmap) -> WebIDL::ExceptionOr> { + if (image_bitmap->is_detached()) + return WebIDL::InvalidStateError::create(image_bitmap->realm(), "Image bitmap is detached"_fly_string); + return Optional {}; })); if (usability.has_value()) return usability.release_value(); @@ -659,8 +668,7 @@ bool image_is_not_origin_clean(CanvasImageSource const& image) // image's media data is CORS-cross-origin. // HTMLCanvasElement - // FIXME: ImageBitmap - [](JS::Handle const&) { + [](OneOf, JS::Handle> auto const&) { // FIXME: image's bitmap's origin-clean flag is false. return false; }); diff --git a/Userland/Libraries/LibWeb/HTML/ImageBitmap.cpp b/Userland/Libraries/LibWeb/HTML/ImageBitmap.cpp index 59a7922bdf2..075471ebf83 100644 --- a/Userland/Libraries/LibWeb/HTML/ImageBitmap.cpp +++ b/Userland/Libraries/LibWeb/HTML/ImageBitmap.cpp @@ -104,4 +104,9 @@ void ImageBitmap::set_bitmap(RefPtr bitmap) m_height = m_bitmap->height(); } +Gfx::Bitmap* ImageBitmap::bitmap() const +{ + return m_bitmap.ptr(); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/ImageBitmap.h b/Userland/Libraries/LibWeb/HTML/ImageBitmap.h index a6d9a3124c6..294ccc7edcb 100644 --- a/Userland/Libraries/LibWeb/HTML/ImageBitmap.h +++ b/Userland/Libraries/LibWeb/HTML/ImageBitmap.h @@ -50,6 +50,7 @@ public: // Implementation specific: void set_bitmap(RefPtr); + Gfx::Bitmap* bitmap() const; private: explicit ImageBitmap(JS::Realm&);