aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYerkebulan Tulibergenov <yerkebulan@gmail.com>2025-02-21 22:17:24 -0800
committerGitHub <noreply@github.com>2025-02-22 06:17:24 +0000
commit89d7f874b2a4aeb5ead955726336cedfaabe2cc8 (patch)
tree581084127b7a13617fe625d9876cf914b69afe30
parentd72c9f35015651433a4ef08961ffacd1129dc21c (diff)
downloadservo-89d7f874b2a4aeb5ead955726336cedfaabe2cc8.tar.gz
servo-89d7f874b2a4aeb5ead955726336cedfaabe2cc8.zip
refactor: add CanGc as argument to create_buffer_source_with_length (#35596)
Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com> Co-authored-by: Josh Matthews <josh@joshmatthews.net>
-rw-r--r--components/script/dom/bindings/buffer_source.rs4
-rw-r--r--components/script/dom/imagedata.rs16
2 files changed, 11 insertions, 9 deletions
diff --git a/components/script/dom/bindings/buffer_source.rs b/components/script/dom/bindings/buffer_source.rs
index 071b95cf0a7..4532c0c95f0 100644
--- a/components/script/dom/bindings/buffer_source.rs
+++ b/components/script/dom/bindings/buffer_source.rs
@@ -52,6 +52,7 @@ pub(crate) enum BufferSource {
pub(crate) fn new_initialized_heap_buffer_source<T>(
init: HeapTypedArrayInit,
+ can_gc: CanGc,
) -> Result<HeapBufferSource<T>, ()>
where
T: TypedArrayElement + TypedArrayElementCreator,
@@ -65,7 +66,7 @@ where
HeapTypedArrayInit::Info { len, cx } => {
rooted!(in (*cx) let mut array = ptr::null_mut::<JSObject>());
let typed_array_result =
- create_buffer_source_with_length::<T>(cx, len as usize, array.handle_mut());
+ create_buffer_source_with_length::<T>(cx, len as usize, array.handle_mut(), can_gc);
if typed_array_result.is_err() {
return Err(());
}
@@ -371,6 +372,7 @@ fn create_buffer_source_with_length<T>(
cx: JSContext,
len: usize,
dest: MutableHandleObject,
+ _can_gc: CanGc,
) -> Result<TypedArray<T, *mut JSObject>, ()>
where
T: TypedArrayElement + TypedArrayElementCreator,
diff --git a/components/script/dom/imagedata.rs b/components/script/dom/imagedata.rs
index f8da034179e..03224afd303 100644
--- a/components/script/dom/imagedata.rs
+++ b/components/script/dom/imagedata.rs
@@ -67,6 +67,7 @@ impl ImageData {
) -> Fallible<DomRoot<ImageData>> {
let heap_typed_array = match new_initialized_heap_buffer_source::<ClampedU8>(
HeapTypedArrayInit::Buffer(BufferSource::ArrayBufferView(Heap::boxed(jsobject))),
+ can_gc,
) {
Ok(heap_typed_array) => heap_typed_array,
Err(_) => return Err(Error::JSFailed),
@@ -121,14 +122,13 @@ impl ImageData {
let cx = GlobalScope::get_cx();
let len = width * height * 4;
- let heap_typed_array =
- match new_initialized_heap_buffer_source::<ClampedU8>(HeapTypedArrayInit::Info {
- len,
- cx,
- }) {
- Ok(heap_typed_array) => heap_typed_array,
- Err(_) => return Err(Error::JSFailed),
- };
+ let heap_typed_array = match new_initialized_heap_buffer_source::<ClampedU8>(
+ HeapTypedArrayInit::Info { len, cx },
+ can_gc,
+ ) {
+ Ok(heap_typed_array) => heap_typed_array,
+ Err(_) => return Err(Error::JSFailed),
+ };
let imagedata = Box::new(ImageData {
reflector_: Reflector::new(),
width,