aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/imagedata.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2024-10-07 21:51:58 -0400
committerGitHub <noreply@github.com>2024-10-08 01:51:58 +0000
commit7d931e673af2780f3f62d52cb17324ec2cc68c71 (patch)
tree450d534196e9eb8d0e04db37203b414f5d92420d /components/script/dom/imagedata.rs
parent946fa9cdee68bb834a3b75821e8e7f94cf86d31c (diff)
downloadservo-7d931e673af2780f3f62d52cb17324ec2cc68c71.tar.gz
servo-7d931e673af2780f3f62d52cb17324ec2cc68c71.zip
script: Include constructors and static methods in generated DOM traits (#33665)
* Add all constructors, special operations, and static methods to generated DOM interface traits. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move all constructors and static methods defined in bare impl blocks inside FooMethods trait impls. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Add missing doc links. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components/script/dom/imagedata.rs')
-rw-r--r--components/script/dom/imagedata.rs66
1 files changed, 32 insertions, 34 deletions
diff --git a/components/script/dom/imagedata.rs b/components/script/dom/imagedata.rs
index b9bd82393d3..116ce8de99b 100644
--- a/components/script/dom/imagedata.rs
+++ b/components/script/dom/imagedata.rs
@@ -146,30 +146,18 @@ impl ImageData {
imagedata, global, proto, can_gc,
))
}
- /// <https://html.spec.whatwg.org/multipage/#pixel-manipulation:dom-imagedata-3>
- #[allow(non_snake_case)]
- pub fn Constructor(
- global: &GlobalScope,
- proto: Option<HandleObject>,
- can_gc: CanGc,
- width: u32,
- height: u32,
- ) -> Fallible<DomRoot<Self>> {
- Self::new_without_jsobject(global, proto, width, height, can_gc)
+ #[allow(unsafe_code)]
+ pub fn to_shared_memory(&self) -> IpcSharedMemory {
+ IpcSharedMemory::from_bytes(unsafe { self.as_slice() })
}
- /// <https://html.spec.whatwg.org/multipage/#pixel-manipulation:dom-imagedata-4>
- #[allow(unused_variables, non_snake_case)]
- pub fn Constructor_(
- cx: JSContext,
- global: &GlobalScope,
- proto: Option<HandleObject>,
- can_gc: CanGc,
- jsobject: *mut JSObject,
- width: u32,
- opt_height: Option<u32>,
- ) -> Fallible<DomRoot<Self>> {
- Self::new_with_jsobject(global, proto, width, opt_height, jsobject, can_gc)
+ #[allow(unsafe_code)]
+ pub unsafe fn get_rect(&self, rect: Rect<u64>) -> Cow<[u8]> {
+ pixels::rgba8_get_rect(self.as_slice(), self.get_size().to_u64(), rect)
+ }
+
+ pub fn get_size(&self) -> Size2D<u32> {
+ Size2D::new(self.Width(), self.Height())
}
/// Nothing must change the array on the JS side while the slice is live.
@@ -188,23 +176,33 @@ impl ImageData {
let ptr: *const [u8] = internal_data.as_slice() as *const _;
&*ptr
}
+}
- #[allow(unsafe_code)]
- pub fn to_shared_memory(&self) -> IpcSharedMemory {
- IpcSharedMemory::from_bytes(unsafe { self.as_slice() })
- }
-
- #[allow(unsafe_code)]
- pub unsafe fn get_rect(&self, rect: Rect<u64>) -> Cow<[u8]> {
- pixels::rgba8_get_rect(self.as_slice(), self.get_size().to_u64(), rect)
+impl ImageDataMethods for ImageData {
+ /// <https://html.spec.whatwg.org/multipage/#pixel-manipulation:dom-imagedata-3>
+ fn Constructor(
+ global: &GlobalScope,
+ proto: Option<HandleObject>,
+ can_gc: CanGc,
+ width: u32,
+ height: u32,
+ ) -> Fallible<DomRoot<Self>> {
+ Self::new_without_jsobject(global, proto, width, height, can_gc)
}
- pub fn get_size(&self) -> Size2D<u32> {
- Size2D::new(self.Width(), self.Height())
+ /// <https://html.spec.whatwg.org/multipage/#pixel-manipulation:dom-imagedata-4>
+ fn Constructor_(
+ _cx: JSContext,
+ global: &GlobalScope,
+ proto: Option<HandleObject>,
+ can_gc: CanGc,
+ jsobject: *mut JSObject,
+ width: u32,
+ opt_height: Option<u32>,
+ ) -> Fallible<DomRoot<Self>> {
+ Self::new_with_jsobject(global, proto, width, opt_height, jsobject, can_gc)
}
-}
-impl ImageDataMethods for ImageData {
/// <https://html.spec.whatwg.org/multipage/#dom-imagedata-width>
fn Width(&self) -> u32 {
self.width