diff --git a/Libraries/LibWeb/HTML/HTMLOrSVGElement.idl b/Libraries/LibWeb/HTML/HTMLOrSVGElement.idl
index 88c4b22c5ad..3f7641e4c65 100644
--- a/Libraries/LibWeb/HTML/HTMLOrSVGElement.idl
+++ b/Libraries/LibWeb/HTML/HTMLOrSVGElement.idl
@@ -1,3 +1,5 @@
+#import
+
// https://html.spec.whatwg.org/#htmlorsvgelement
interface mixin HTMLOrSVGElement {
[SameObject] readonly attribute DOMStringMap dataset;
diff --git a/Libraries/LibWeb/HTML/ImageBitmap.h b/Libraries/LibWeb/HTML/ImageBitmap.h
index c1ede98b76e..4e1ad6641bd 100644
--- a/Libraries/LibWeb/HTML/ImageBitmap.h
+++ b/Libraries/LibWeb/HTML/ImageBitmap.h
@@ -16,7 +16,7 @@
namespace Web::HTML {
-using ImageBitmapSource = Variant, GC::Root>;
+using ImageBitmapSource = FlattenVariant, GC::Root>>;
// https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#imagebitmapoptions
struct ImageBitmapOptions {
diff --git a/Libraries/LibWeb/HTML/ImageBitmap.idl b/Libraries/LibWeb/HTML/ImageBitmap.idl
index d2ec371ab18..644655485fd 100644
--- a/Libraries/LibWeb/HTML/ImageBitmap.idl
+++ b/Libraries/LibWeb/HTML/ImageBitmap.idl
@@ -1,5 +1,7 @@
#import
#import
+#import
+#import
// https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#images-2
[Exposed=(Window,Worker), Serializable, Transferable]
@@ -9,8 +11,10 @@ interface ImageBitmap {
undefined close();
};
-// FIXME: This should also includes CanvasImageSource
-typedef (Blob or
+
+// https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#imagebitmapsource
+typedef (CanvasImageSource or
+ Blob or
ImageData) ImageBitmapSource;
enum ImageOrientation { "from-image", "flipY" };
diff --git a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
index 4d93c84cc5d..04f19d618fa 100644
--- a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
+++ b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
@@ -133,12 +133,25 @@ GC::Ref WindowOrWorkerGlobalScopeMixin::create_image_bitmap_imp
(void)options;
// 3. Check the usability of the image argument. If this throws an exception or returns bad, then return a promise rejected with an "InvalidStateError" DOMException.
- // FIXME: "Check the usability of the image argument" is only defined for CanvasImageSource, let's skip it for other types
- if (image.has()) {
- if (auto usability = check_usability_of_image(image.get()); usability.is_error() or usability.value() == CanvasImageSourceUsability::Bad) {
- auto error = WebIDL::InvalidStateError::create(this_impl().realm(), "image argument is not usable"_string);
- return WebIDL::create_rejected_promise_from_exception(realm, error);
- }
+ auto error_promise = image.visit(
+ [](GC::Root&) -> Optional> {
+ return {};
+ },
+ [](GC::Root&) -> Optional> {
+ return {};
+ },
+ [&](auto& canvas_image_source) -> Optional> {
+ // Note: "Check the usability of the image argument" is only defined for CanvasImageSource
+ if (auto usability = check_usability_of_image(canvas_image_source); usability.is_error() or usability.value() == CanvasImageSourceUsability::Bad) {
+ auto error = WebIDL::InvalidStateError::create(this_impl().realm(), "image argument is not usable"_string);
+ return WebIDL::create_rejected_promise_from_exception(realm, error);
+ }
+
+ return {};
+ });
+
+ if (error_promise.has_value()) {
+ return error_promise.release_value();
}
// 4. Let p be a new promise.
diff --git a/Libraries/LibWeb/HTML/WorkerGlobalScope.idl b/Libraries/LibWeb/HTML/WorkerGlobalScope.idl
index 07c1901deb4..c801754609f 100644
--- a/Libraries/LibWeb/HTML/WorkerGlobalScope.idl
+++ b/Libraries/LibWeb/HTML/WorkerGlobalScope.idl
@@ -3,6 +3,7 @@
#import
#import
#import
+#import
#import
#import
#import
diff --git a/Libraries/LibWeb/SVG/SVGElement.idl b/Libraries/LibWeb/SVG/SVGElement.idl
index d132fa57892..383667be6ed 100644
--- a/Libraries/LibWeb/SVG/SVGElement.idl
+++ b/Libraries/LibWeb/SVG/SVGElement.idl
@@ -1,6 +1,7 @@
#import
#import
-#import
+#import
+#import
#import
#import