diff --git a/components/script/dom/bindings/buffer_source.rs b/components/script/dom/bindings/buffer_source.rs index 2e7073356b5..031ecf9c185 100644 --- a/components/script/dom/bindings/buffer_source.rs +++ b/components/script/dom/bindings/buffer_source.rs @@ -67,14 +67,14 @@ unsafe impl crate::dom::bindings::trace::JSTraceable for HeapBufferSource } } -pub fn new_initialized_heap_buffer_source_types( +pub fn new_initialized_heap_buffer_source( init: HeapTypedArrayInit, ) -> Result, ()> where T: TypedArrayElement + TypedArrayElementCreator, T::Element: Clone + Copy, { - let heap_buffer_source_types = match init { + let heap_buffer_source = match init { HeapTypedArrayInit::Buffer(buffer_source) => HeapBufferSource { buffer_source: buffer_source, phantom: PhantomData::default(), @@ -82,13 +82,13 @@ where HeapTypedArrayInit::Info { len, cx } => { rooted!(in (*cx) let mut array = ptr::null_mut::()); let typed_array_result = - create_buffer_source_types_with_length::(cx, len as usize, array.handle_mut()); + create_buffer_source_with_length::(cx, len as usize, array.handle_mut()); if typed_array_result.is_err() { return Err(()); } - let heap_buffer_source_types = HeapBufferSource::::default(); + let heap_buffer_source = HeapBufferSource::::default(); - match &heap_buffer_source_types.buffer_source { + match &heap_buffer_source.buffer_source { BufferSource::Int8Array(buffer) | BufferSource::Int16Array(buffer) | BufferSource::Int32Array(buffer) | @@ -106,10 +106,10 @@ where buffer.set(*array); }, } - heap_buffer_source_types + heap_buffer_source }, }; - Ok(heap_buffer_source_types) + Ok(heap_buffer_source) } pub enum HeapTypedArrayInit { @@ -131,8 +131,7 @@ where pub fn set_data(&self, cx: JSContext, data: &[T::Element]) -> Result<(), ()> { rooted!(in (*cx) let mut array = ptr::null_mut::()); - let _: TypedArray = - create_buffer_source_types(cx, data, array.handle_mut())?; + let _: TypedArray = create_buffer_source(cx, data, array.handle_mut())?; match &self.buffer_source { BufferSource::Int8Array(buffer) | @@ -367,7 +366,7 @@ where } /// -pub fn create_buffer_source_types( +pub fn create_buffer_source( cx: JSContext, data: &[T::Element], dest: MutableHandleObject, @@ -384,7 +383,7 @@ where } } -fn create_buffer_source_types_with_length( +fn create_buffer_source_with_length( cx: JSContext, len: usize, dest: MutableHandleObject, diff --git a/components/script/dom/dommatrixreadonly.rs b/components/script/dom/dommatrixreadonly.rs index 496e4e972c7..d4f73b1ed68 100644 --- a/components/script/dom/dommatrixreadonly.rs +++ b/components/script/dom/dommatrixreadonly.rs @@ -15,7 +15,7 @@ use js::typedarray::{Float32Array, Float64Array}; use style::parser::ParserContext; use url::Url; -use crate::dom::bindings::buffer_source::create_buffer_source_types; +use crate::dom::bindings::buffer_source::create_buffer_source; use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods}; use crate::dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::DOMMatrixReadOnlyMethods; @@ -686,14 +686,14 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly { .map(|&x| x as f32) .collect(); rooted!(in (*cx) let mut array = ptr::null_mut::()); - create_buffer_source_types(cx, &vec, array.handle_mut()) + create_buffer_source(cx, &vec, array.handle_mut()) .expect("Converting matrix to float32 array should never fail") } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-tofloat64array fn ToFloat64Array(&self, cx: JSContext) -> Float64Array { rooted!(in (*cx) let mut array = ptr::null_mut::()); - create_buffer_source_types(cx, &self.matrix.borrow().to_array(), array.handle_mut()) + create_buffer_source(cx, &self.matrix.borrow().to_array(), array.handle_mut()) .expect("Converting matrix to float64 array should never fail") } } diff --git a/components/script/dom/filereadersync.rs b/components/script/dom/filereadersync.rs index ef47648d460..5a20f26f476 100644 --- a/components/script/dom/filereadersync.rs +++ b/components/script/dom/filereadersync.rs @@ -9,7 +9,7 @@ use js::jsapi::JSObject; use js::rust::HandleObject; use js::typedarray::{ArrayBuffer, ArrayBufferU8}; -use crate::dom::bindings::buffer_source::create_buffer_source_types; +use crate::dom::bindings::buffer_source::create_buffer_source; use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use crate::dom::bindings::codegen::Bindings::FileReaderSyncBinding::FileReaderSyncMethods; use crate::dom::bindings::error::{Error, Fallible}; @@ -95,7 +95,7 @@ impl FileReaderSyncMethods for FileReaderSync { // step 2 rooted!(in(*cx) let mut array_buffer = ptr::null_mut::()); - create_buffer_source_types::(cx, &blob_contents, array_buffer.handle_mut()) + create_buffer_source::(cx, &blob_contents, array_buffer.handle_mut()) .map_err(|_| Error::JSFailed) } } diff --git a/components/script/dom/imagedata.rs b/components/script/dom/imagedata.rs index ba11fcd05c5..95fb34b5979 100644 --- a/components/script/dom/imagedata.rs +++ b/components/script/dom/imagedata.rs @@ -14,7 +14,7 @@ use js::rust::HandleObject; use js::typedarray::{ClampedU8, CreateWith, Uint8ClampedArray}; use super::bindings::buffer_source::{ - new_initialized_heap_buffer_source_types, BufferSource, HeapBufferSource, HeapTypedArrayInit, + new_initialized_heap_buffer_source, BufferSource, HeapBufferSource, HeapTypedArrayInit, }; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::ImageDataMethods; use crate::dom::bindings::error::{Error, Fallible}; @@ -63,7 +63,7 @@ impl ImageData { opt_height: Option, jsobject: *mut JSObject, ) -> Fallible> { - let heap_typed_array = match new_initialized_heap_buffer_source_types::( + let heap_typed_array = match new_initialized_heap_buffer_source::( HeapTypedArrayInit::Buffer(BufferSource::Uint8ClampedArray(Heap::boxed(jsobject))), ) { Ok(heap_typed_array) => heap_typed_array, @@ -117,7 +117,7 @@ impl ImageData { let len = width * height * 4; let heap_typed_array = - match new_initialized_heap_buffer_source_types::(HeapTypedArrayInit::Info { + match new_initialized_heap_buffer_source::(HeapTypedArrayInit::Info { len, cx, }) { diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 464ca0220dd..9b88ec5e3ba 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -17,7 +17,7 @@ use script_traits::serializable::BlobImpl; use script_traits::MsDuration; use servo_config::prefs; -use crate::dom::bindings::buffer_source::create_buffer_source_types; +use crate::dom::bindings::buffer_source::create_buffer_source; use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::codegen::Bindings::EventListenerBinding::EventListener; use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function; @@ -214,7 +214,7 @@ impl TestBindingMethods for TestBinding { let data: [u8; 16] = [0; 16]; rooted!(in (*cx) let mut array = ptr::null_mut::()); - create_buffer_source_types(cx, &data, array.handle_mut()) + create_buffer_source(cx, &data, array.handle_mut()) .expect("Creating ClampedU8 array should never fail") } fn AnyAttribute(&self, _: SafeJSContext) -> JSVal { diff --git a/components/script/dom/textencoder.rs b/components/script/dom/textencoder.rs index f237dca3903..66f9fdae775 100644 --- a/components/script/dom/textencoder.rs +++ b/components/script/dom/textencoder.rs @@ -9,7 +9,7 @@ use js::jsapi::JSObject; use js::rust::HandleObject; use js::typedarray::Uint8Array; -use crate::dom::bindings::buffer_source::create_buffer_source_types; +use crate::dom::bindings::buffer_source::create_buffer_source; use crate::dom::bindings::codegen::Bindings::TextEncoderBinding::TextEncoderMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; @@ -55,7 +55,7 @@ impl TextEncoderMethods for TextEncoder { let encoded = input.0.as_bytes(); rooted!(in(*cx) let mut js_object = ptr::null_mut::()); - create_buffer_source_types(cx, &encoded, js_object.handle_mut()) + create_buffer_source(cx, &encoded, js_object.handle_mut()) .expect("Converting input to uint8 array should never fail") } }