aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/imagedata.rs
diff options
context:
space:
mode:
authorTaym Haddadi <haddadi.taym@gmail.com>2024-02-25 13:13:17 +0100
committerGitHub <noreply@github.com>2024-02-25 12:13:17 +0000
commitd0b663800f3faa7343791349c9b0e38e9aeacb82 (patch)
treeb6c65c6bcd3a5b9a1f1da7e7367c2c498e972417 /components/script/dom/imagedata.rs
parent32f1d07323db257db31fead024271d3a57d72b49 (diff)
downloadservo-d0b663800f3faa7343791349c9b0e38e9aeacb82.tar.gz
servo-d0b663800f3faa7343791349c9b0e38e9aeacb82.zip
WedIDL: bring dom/bindings/typedarray further in line with spec (#31375)
* WedIDL: bring dom/bindings/typedarray further in line with spec Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> * Rename HeapBufferSourceTypes to HeapBufferSource Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> * fmt code Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> --------- Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
Diffstat (limited to 'components/script/dom/imagedata.rs')
-rw-r--r--components/script/dom/imagedata.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/components/script/dom/imagedata.rs b/components/script/dom/imagedata.rs
index a2907a98b3f..ba11fcd05c5 100644
--- a/components/script/dom/imagedata.rs
+++ b/components/script/dom/imagedata.rs
@@ -9,12 +9,12 @@ use std::vec::Vec;
use dom_struct::dom_struct;
use euclid::default::{Rect, Size2D};
use ipc_channel::ipc::IpcSharedMemory;
-use js::jsapi::JSObject;
+use js::jsapi::{Heap, JSObject};
use js::rust::HandleObject;
use js::typedarray::{ClampedU8, CreateWith, Uint8ClampedArray};
-use super::bindings::typedarrays::{
- new_initialized_heap_typed_array, HeapTypedArray, HeapTypedArrayInit,
+use super::bindings::buffer_source::{
+ new_initialized_heap_buffer_source_types, BufferSource, HeapBufferSource, HeapTypedArrayInit,
};
use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::ImageDataMethods;
use crate::dom::bindings::error::{Error, Fallible};
@@ -29,7 +29,7 @@ pub struct ImageData {
width: u32,
height: u32,
#[ignore_malloc_size_of = "mozjs"]
- data: HeapTypedArray<ClampedU8>,
+ data: HeapBufferSource<ClampedU8>,
}
impl ImageData {
@@ -63,14 +63,14 @@ impl ImageData {
opt_height: Option<u32>,
jsobject: *mut JSObject,
) -> Fallible<DomRoot<ImageData>> {
- let heap_typed_array = match new_initialized_heap_typed_array::<ClampedU8>(
- HeapTypedArrayInit::Object(jsobject),
+ let heap_typed_array = match new_initialized_heap_buffer_source_types::<ClampedU8>(
+ HeapTypedArrayInit::Buffer(BufferSource::Uint8ClampedArray(Heap::boxed(jsobject))),
) {
Ok(heap_typed_array) => heap_typed_array,
Err(_) => return Err(Error::JSFailed),
};
- let typed_array = match heap_typed_array.get_internal() {
+ let typed_array = match heap_typed_array.get_buffer() {
Ok(array) => array,
Err(_) => {
return Err(Error::Type(
@@ -117,7 +117,7 @@ impl ImageData {
let len = width * height * 4;
let heap_typed_array =
- match new_initialized_heap_typed_array::<ClampedU8>(HeapTypedArrayInit::Info {
+ match new_initialized_heap_buffer_source_types::<ClampedU8>(HeapTypedArrayInit::Info {
len,
cx,
}) {
@@ -163,7 +163,7 @@ impl ImageData {
assert!(self.data.is_initialized());
let internal_data = self
.data
- .get_internal()
+ .get_buffer()
.expect("Failed to get Data from ImageData.");
// NOTE(nox): This is just as unsafe as `as_slice` itself even though we
// are extending the lifetime of the slice, because the data in
@@ -202,6 +202,6 @@ impl ImageDataMethods for ImageData {
/// <https://html.spec.whatwg.org/multipage/#dom-imagedata-data>
fn GetData(&self, _: JSContext) -> Fallible<Uint8ClampedArray> {
- self.data.get_internal().map_err(|_| Error::JSFailed)
+ self.data.get_buffer().map_err(|_| Error::JSFailed)
}
}