aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/imagebitmap.rs58
-rw-r--r--components/script/dom/mod.rs1
-rw-r--r--components/script/dom/webidls/ImageBitmap.webidl36
-rw-r--r--tests/wpt/metadata/html/dom/idlharness.https.html.ini24
-rw-r--r--tests/wpt/metadata/workers/semantics/interface-objects/001.worker.js.ini4
-rw-r--r--tests/wpt/mozilla/meta/MANIFEST.json4
-rw-r--r--tests/wpt/mozilla/tests/mozilla/interfaces.html1
-rw-r--r--tests/wpt/mozilla/tests/mozilla/interfaces.worker.js1
8 files changed, 99 insertions, 30 deletions
diff --git a/components/script/dom/imagebitmap.rs b/components/script/dom/imagebitmap.rs
new file mode 100644
index 00000000000..e5d3ec6098e
--- /dev/null
+++ b/components/script/dom/imagebitmap.rs
@@ -0,0 +1,58 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use crate::dom::bindings::cell::DomRefCell;
+
+use crate::dom::bindings::codegen::Bindings::ImageBitmapBinding::ImageBitmapMethods;
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::globalscope::GlobalScope;
+
+use crate::dom::bindings::error::Fallible;
+use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
+use dom_struct::dom_struct;
+
+use std::vec::Vec;
+
+#[dom_struct]
+pub struct ImageBitmap {
+ reflector_: Reflector,
+ width: u32,
+ height: u32,
+ bitmap_data: DomRefCell<Vec<u8>>,
+}
+
+impl ImageBitmap {
+ fn new_inherited(width_arg: u32, height_arg: u32) -> ImageBitmap {
+ ImageBitmap {
+ reflector_: Reflector::new(),
+ width: width_arg,
+ height: height_arg,
+ bitmap_data: DomRefCell::new(vec![]),
+ }
+ }
+
+ #[allow(dead_code)]
+ pub fn new(global: &GlobalScope, width: u32, height: u32) -> Fallible<DomRoot<ImageBitmap>> {
+ //assigning to a variable the return object of new_inherited
+ let imagebitmap = Box::new(ImageBitmap::new_inherited(width, height));
+
+ Ok(reflect_dom_object(imagebitmap, global))
+ }
+}
+
+impl ImageBitmapMethods for ImageBitmap {
+ // https://html.spec.whatwg.org/multipage/#dom-imagebitmap-height
+ fn Height(&self) -> u32 {
+ //to do: add a condition for checking detached internal slot
+ //and return 0 if set to true
+ self.height
+ }
+
+ // https://html.spec.whatwg.org/multipage/#dom-imagebitmap-width
+ fn Width(&self) -> u32 {
+ //to do: add a condition to check detached internal slot
+ ////and return 0 if set to true
+ self.width
+ }
+}
diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs
index 3691ba5a299..6cd85a3db60 100644
--- a/components/script/dom/mod.rs
+++ b/components/script/dom/mod.rs
@@ -408,6 +408,7 @@ pub mod htmlulistelement;
pub mod htmlunknownelement;
pub mod htmlvideoelement;
pub mod identityhub;
+pub mod imagebitmap;
pub mod imagedata;
pub mod inputevent;
pub mod keyboardevent;
diff --git a/components/script/dom/webidls/ImageBitmap.webidl b/components/script/dom/webidls/ImageBitmap.webidl
new file mode 100644
index 00000000000..ea49061a756
--- /dev/null
+++ b/components/script/dom/webidls/ImageBitmap.webidl
@@ -0,0 +1,36 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+/*
+ * The origin of this IDL file is
+ * https://html.spec.whatwg.org/multipage/#imagebitmap
+ *
+ * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and Opera Software ASA.
+ * You are granted a license to use, reproduce and create derivative works of this document.
+ */
+
+//[Exposed=(Window,Worker), Serializable, Transferable]
+[Exposed=(Window,Worker)]
+interface ImageBitmap {
+ readonly attribute unsigned long width;
+ readonly attribute unsigned long height;
+ //void close();
+};
+
+typedef (CanvasImageSource or
+ Blob or
+ ImageData) ImageBitmapSource;
+
+enum ImageOrientation { "none", "flipY" };
+enum PremultiplyAlpha { "none", "premultiply", "default" };
+enum ColorSpaceConversion { "none", "default" };
+enum ResizeQuality { "pixelated", "low", "medium", "high" };
+
+dictionary ImageBitmapOptions {
+ ImageOrientation imageOrientation = "none";
+ PremultiplyAlpha premultiplyAlpha = "default";
+ ColorSpaceConversion colorSpaceConversion = "default";
+ [EnforceRange] unsigned long resizeWidth;
+ [EnforceRange] unsigned long resizeHeight;
+ ResizeQuality resizeQuality = "low";
+};
diff --git a/tests/wpt/metadata/html/dom/idlharness.https.html.ini b/tests/wpt/metadata/html/dom/idlharness.https.html.ini
index 85cd8fec619..fcbfbda1366 100644
--- a/tests/wpt/metadata/html/dom/idlharness.https.html.ini
+++ b/tests/wpt/metadata/html/dom/idlharness.https.html.ini
@@ -29,9 +29,6 @@
[SVGElement interface: attribute onmouseout]
expected: FAIL
- [ImageBitmap interface: existence and properties of interface prototype object's "constructor" property]
- expected: FAIL
-
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "getLineDash()" with the proper type]
expected: FAIL
@@ -386,9 +383,6 @@
[DataTransferItemList interface object length]
expected: FAIL
- [ImageBitmap interface: existence and properties of interface prototype object's @@unscopables property]
- expected: FAIL
-
[DataTransfer interface: attribute items]
expected: FAIL
@@ -662,9 +656,6 @@
[SVGAElement interface: attribute hostname]
expected: FAIL
- [ImageBitmap interface object name]
- expected: FAIL
-
[SVGElement interface: attribute oncut]
expected: FAIL
@@ -824,9 +815,6 @@
[OffscreenCanvasRenderingContext2D interface: operation createImageData(long, long)]
expected: FAIL
- [ImageBitmap interface: existence and properties of interface prototype object]
- expected: FAIL
-
[SVGElement interface: attribute onauxclick]
expected: FAIL
@@ -974,15 +962,9 @@
[OffscreenCanvasRenderingContext2D interface: operation createPattern(CanvasImageSource, DOMString)]
expected: FAIL
- [ImageBitmap interface: existence and properties of interface object]
- expected: FAIL
-
[History interface: attribute scrollRestoration]
expected: FAIL
- [ImageBitmap interface: attribute height]
- expected: FAIL
-
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "filter" with the proper type]
expected: FAIL
@@ -1145,9 +1127,6 @@
[SVGSVGElement interface: attribute ononline]
expected: FAIL
- [ImageBitmap interface: attribute width]
- expected: FAIL
-
[DataTransfer interface: attribute types]
expected: FAIL
@@ -1262,9 +1241,6 @@
[SVGElement interface: attribute onkeypress]
expected: FAIL
- [ImageBitmap interface object length]
- expected: FAIL
-
[OffscreenCanvasRenderingContext2D interface: operation fillRect(unrestricted double, unrestricted double, unrestricted double, unrestricted double)]
expected: FAIL
diff --git a/tests/wpt/metadata/workers/semantics/interface-objects/001.worker.js.ini b/tests/wpt/metadata/workers/semantics/interface-objects/001.worker.js.ini
index b9c13b0592d..91c7a3c6cb7 100644
--- a/tests/wpt/metadata/workers/semantics/interface-objects/001.worker.js.ini
+++ b/tests/wpt/metadata/workers/semantics/interface-objects/001.worker.js.ini
@@ -3,9 +3,6 @@
[The SharedWorker interface object should be exposed.]
expected: FAIL
- [The ImageBitmap interface object should be exposed.]
- expected: FAIL
-
[The CanvasPath interface object should be exposed.]
expected: FAIL
@@ -56,4 +53,3 @@
[The IDBTransaction interface object should be exposed.]
expected: FAIL
-
diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json
index 475c987053e..ff18a615fa1 100644
--- a/tests/wpt/mozilla/meta/MANIFEST.json
+++ b/tests/wpt/mozilla/meta/MANIFEST.json
@@ -13863,14 +13863,14 @@
]
],
"interfaces.html": [
- "12f1d0b7f17be6575d4527423aed0ec845c4c2d5",
+ "dc9a1f5f378bc50487bfb7dc3db6d121d2f325ca",
[
null,
{}
]
],
"interfaces.worker.js": [
- "c1223084790b2980c8184e3cd9ab5ae17bc8b303",
+ "a74a91489541ab99ae58001e3f63afc9ecc5c553",
[
"mozilla/interfaces.worker.html",
{}
diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.html b/tests/wpt/mozilla/tests/mozilla/interfaces.html
index 12f1d0b7f17..dc9a1f5f378 100644
--- a/tests/wpt/mozilla/tests/mozilla/interfaces.html
+++ b/tests/wpt/mozilla/tests/mozilla/interfaces.html
@@ -161,6 +161,7 @@ test_interfaces([
"HTMLUnknownElement",
"HTMLVideoElement",
"ImageData",
+ "ImageBitmap",
"Image",
"InputEvent",
"KeyboardEvent",
diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js b/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js
index c1223084790..a74a9148954 100644
--- a/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js
+++ b/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js
@@ -35,6 +35,7 @@ test_interfaces([
"Headers",
"History",
"ImageData",
+ "ImageBitmap",
"MessageChannel",
"MessageEvent",
"MessagePort",