aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/imagebitmap.rs
diff options
context:
space:
mode:
authorsantoshpavan <santoshpavan.psp@gmail.com>2020-03-15 14:54:23 -0400
committerJosh Matthews <josh@joshmatthews.net>2020-03-30 15:52:15 -0400
commit8c405546a2023c3e098d9450c2d755392d3d5c9c (patch)
tree84257162590a9403fa495169a463e5f804946b69 /components/script/dom/imagebitmap.rs
parent236762880c48263f8fa2c5a4deb9cf8f7746013c (diff)
downloadservo-8c405546a2023c3e098d9450c2d755392d3d5c9c.tar.gz
servo-8c405546a2023c3e098d9450c2d755392d3d5c9c.zip
Implement ImageBitmap interface
Implementation of ImageBitmap ImageBitMap webidl file added Implementation of ImageBitmap mentioned the correct origin link basic new and new_inherited updated the mod.rs file to include imagebitmap imagebitmap implemented changed according to Serialization implemented serializable get methods for width and height basic imagebitmap added missing crates added Vec and missing crates Syntax fixes Reformatting and minor error fixes Implementation of ImageBitmap tidy-test runs Took out extra parameters in reflect_dom_object call added comments with specification links for webidl functions changing the code based on review comments adding resolved changes form the pull request Changes based on pr review Changes based on pr review ran test-tidy and fmt removed the duplicate crate removed unnecessary crates Kept only the relevant crate import Updated test expectations, exposed interface list, and manifest
Diffstat (limited to 'components/script/dom/imagebitmap.rs')
-rw-r--r--components/script/dom/imagebitmap.rs58
1 files changed, 58 insertions, 0 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
+ }
+}