diff --git a/Cargo.lock b/Cargo.lock
index f9cebd773fd..da769c06780 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1209,6 +1209,7 @@ dependencies = [
"serde",
"servo_malloc_size_of",
"servo_url",
+ "snapshot",
"strum",
"strum_macros",
"uuid",
@@ -7117,8 +7118,10 @@ version = "0.0.1"
dependencies = [
"euclid",
"ipc-channel",
+ "malloc_size_of_derive",
"pixels",
"serde",
+ "servo_malloc_size_of",
]
[[package]]
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs
index b50f0b1e75f..a34b49f4a65 100644
--- a/components/script/dom/globalscope.rs
+++ b/components/script/dom/globalscope.rs
@@ -2983,9 +2983,7 @@ impl GlobalScope {
}
if let Some(snapshot) = canvas.get_image_data() {
- let size = snapshot.size().cast();
- let image_bitmap = ImageBitmap::new(self, size.width, size.height, can_gc);
- image_bitmap.set_bitmap_data(snapshot.to_vec());
+ let image_bitmap = ImageBitmap::new(self, snapshot, can_gc);
image_bitmap.set_origin_clean(canvas.origin_is_clean());
p.resolve_native(&(image_bitmap), can_gc);
}
@@ -2999,9 +2997,7 @@ impl GlobalScope {
}
if let Some(snapshot) = canvas.get_image_data() {
- let size = snapshot.size().cast();
- let image_bitmap = ImageBitmap::new(self, size.width, size.height, can_gc);
- image_bitmap.set_bitmap_data(snapshot.to_vec());
+ let image_bitmap = ImageBitmap::new(self, snapshot, can_gc);
image_bitmap.set_origin_clean(canvas.origin_is_clean());
p.resolve_native(&(image_bitmap), can_gc);
}
diff --git a/components/script/dom/imagebitmap.rs b/components/script/dom/imagebitmap.rs
index 97a1a54bba7..cddd8cf1188 100644
--- a/components/script/dom/imagebitmap.rs
+++ b/components/script/dom/imagebitmap.rs
@@ -2,13 +2,13 @@
* 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 std::cell::Cell;
+use std::cell::{Cell, Ref};
use std::collections::HashMap;
-use std::vec::Vec;
use base::id::{ImageBitmapId, ImageBitmapIndex};
use constellation_traits::SerializableImageBitmap;
use dom_struct::dom_struct;
+use snapshot::Snapshot;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::ImageBitmapBinding::ImageBitmapMethods;
@@ -23,41 +23,39 @@ use crate::script_runtime::CanGc;
#[dom_struct]
pub(crate) struct ImageBitmap {
reflector_: Reflector,
- width: u32,
- height: u32,
/// The actual pixel data of the bitmap
///
/// If this is `None`, then the bitmap data has been released by calling
/// [`close`](https://html.spec.whatwg.org/multipage/#dom-imagebitmap-close)
- bitmap_data: DomRefCell