diff options
author | Ennui Langeweile <85590273+EnnuiL@users.noreply.github.com> | 2023-10-26 09:45:53 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-26 12:45:53 +0000 |
commit | 26a3dffd956b332361c75e5a3cef6dbf4d7584cc (patch) | |
tree | 9df26880ec7a6361747bbb1f1b80cee027660d5c | |
parent | a3d2f0c586e97e26906bd2327395186bf140f49b (diff) | |
download | servo-26a3dffd956b332361c75e5a3cef6dbf4d7584cc.tar.gz servo-26a3dffd956b332361c75e5a3cef6dbf4d7584cc.zip |
Clean up and merge some canvas-related WebIDLs (#30606)
* Clean up and merge some canvas-related WebIDLs
* Apply `./mach fmt`
* WebIDL has `test-tidy` support???
-rw-r--r-- | components/script/canvas_state.rs | 3 | ||||
-rw-r--r-- | components/script/dom/canvasgradient.rs | 2 | ||||
-rw-r--r-- | components/script/dom/dommatrixreadonly.rs | 36 | ||||
-rw-r--r-- | components/script/dom/imagedata.rs | 2 | ||||
-rw-r--r-- | components/script/dom/webidls/CanvasGradient.webidl | 13 | ||||
-rw-r--r-- | components/script/dom/webidls/CanvasPattern.webidl | 10 | ||||
-rw-r--r-- | components/script/dom/webidls/CanvasRenderingContext2D.webidl | 43 | ||||
-rw-r--r-- | components/script/dom/webidls/DOMMatrix.webidl | 24 | ||||
-rw-r--r-- | components/script/dom/webidls/ImageData.webidl | 22 |
9 files changed, 64 insertions, 91 deletions
diff --git a/components/script/canvas_state.rs b/components/script/canvas_state.rs index 9d1bc10d5e6..12ab63c89f3 100644 --- a/components/script/canvas_state.rs +++ b/components/script/canvas_state.rs @@ -30,9 +30,8 @@ use style_traits::values::ToCss; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::{ CanvasDirection, CanvasFillRule, CanvasImageSource, CanvasLineCap, CanvasLineJoin, - CanvasTextAlign, CanvasTextBaseline, + CanvasTextAlign, CanvasTextBaseline, ImageDataMethods, }; -use crate::dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods; use crate::dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; diff --git a/components/script/dom/canvasgradient.rs b/components/script/dom/canvasgradient.rs index f6a4a1a7bfd..e65f3047a40 100644 --- a/components/script/dom/canvasgradient.rs +++ b/components/script/dom/canvasgradient.rs @@ -9,7 +9,7 @@ use cssparser::{Color as CSSColor, Parser, ParserInput, RGBA}; use dom_struct::dom_struct; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::CanvasGradientBinding::CanvasGradientMethods; +use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasGradientMethods; use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; diff --git a/components/script/dom/dommatrixreadonly.rs b/components/script/dom/dommatrixreadonly.rs index a20c935ee89..dbd2ca48570 100644 --- a/components/script/dom/dommatrixreadonly.rs +++ b/components/script/dom/dommatrixreadonly.rs @@ -749,12 +749,24 @@ pub fn entries_to_matrix(entries: &[f64]) -> Fallible<(bool, Transform3D<f64>)> // https://drafts.fxtf.org/geometry-1/#validate-and-fixup pub fn dommatrixinit_to_matrix(dict: &DOMMatrixInit) -> Fallible<(bool, Transform3D<f64>)> { // Step 1. - if dict.a.is_some() && dict.m11.is_some() && dict.a.unwrap() != dict.m11.unwrap() || - dict.b.is_some() && dict.m12.is_some() && dict.b.unwrap() != dict.m12.unwrap() || - dict.c.is_some() && dict.m21.is_some() && dict.c.unwrap() != dict.m21.unwrap() || - dict.d.is_some() && dict.m22.is_some() && dict.d.unwrap() != dict.m22.unwrap() || - dict.e.is_some() && dict.m41.is_some() && dict.e.unwrap() != dict.m41.unwrap() || - dict.f.is_some() && dict.m42.is_some() && dict.f.unwrap() != dict.m42.unwrap() || + if dict.parent.a.is_some() && + dict.parent.m11.is_some() && + dict.parent.a.unwrap() != dict.parent.m11.unwrap() || + dict.parent.b.is_some() && + dict.parent.m12.is_some() && + dict.parent.b.unwrap() != dict.parent.m12.unwrap() || + dict.parent.c.is_some() && + dict.parent.m21.is_some() && + dict.parent.c.unwrap() != dict.parent.m21.unwrap() || + dict.parent.d.is_some() && + dict.parent.m22.is_some() && + dict.parent.d.unwrap() != dict.parent.m22.unwrap() || + dict.parent.e.is_some() && + dict.parent.m41.is_some() && + dict.parent.e.unwrap() != dict.parent.m41.unwrap() || + dict.parent.f.is_some() && + dict.parent.m42.is_some() && + dict.parent.f.unwrap() != dict.parent.m42.unwrap() || dict.is2D.is_some() && dict.is2D.unwrap() && (dict.m31 != 0.0 || @@ -772,17 +784,17 @@ pub fn dommatrixinit_to_matrix(dict: &DOMMatrixInit) -> Fallible<(bool, Transfor } else { let mut is_2d = dict.is2D; // Step 2. - let m11 = dict.m11.unwrap_or(dict.a.unwrap_or(1.0)); + let m11 = dict.parent.m11.unwrap_or(dict.parent.a.unwrap_or(1.0)); // Step 3. - let m12 = dict.m12.unwrap_or(dict.b.unwrap_or(0.0)); + let m12 = dict.parent.m12.unwrap_or(dict.parent.b.unwrap_or(0.0)); // Step 4. - let m21 = dict.m21.unwrap_or(dict.c.unwrap_or(0.0)); + let m21 = dict.parent.m21.unwrap_or(dict.parent.c.unwrap_or(0.0)); // Step 5. - let m22 = dict.m22.unwrap_or(dict.d.unwrap_or(1.0)); + let m22 = dict.parent.m22.unwrap_or(dict.parent.d.unwrap_or(1.0)); // Step 6. - let m41 = dict.m41.unwrap_or(dict.e.unwrap_or(0.0)); + let m41 = dict.parent.m41.unwrap_or(dict.parent.e.unwrap_or(0.0)); // Step 7. - let m42 = dict.m42.unwrap_or(dict.f.unwrap_or(0.0)); + let m42 = dict.parent.m42.unwrap_or(dict.parent.f.unwrap_or(0.0)); // Step 8. if is_2d.is_none() && (dict.m31 != 0.0 || diff --git a/components/script/dom/imagedata.rs b/components/script/dom/imagedata.rs index 78d0b56546c..26183b11228 100644 --- a/components/script/dom/imagedata.rs +++ b/components/script/dom/imagedata.rs @@ -15,7 +15,7 @@ use js::jsapi::{Heap, JSObject}; use js::rust::{HandleObject, Runtime}; use js::typedarray::{CreateWith, Uint8ClampedArray}; -use crate::dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods; +use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::ImageDataMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::DomRoot; diff --git a/components/script/dom/webidls/CanvasGradient.webidl b/components/script/dom/webidls/CanvasGradient.webidl deleted file mode 100644 index 46578087beb..00000000000 --- a/components/script/dom/webidls/CanvasGradient.webidl +++ /dev/null @@ -1,13 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -// https://html.spec.whatwg.org/multipage/#canvasgradient -[Exposed=(Window, PaintWorklet, Worker)] -interface CanvasGradient { - // opaque object - [Throws] - undefined addColorStop(double offset, DOMString color); -}; - - diff --git a/components/script/dom/webidls/CanvasPattern.webidl b/components/script/dom/webidls/CanvasPattern.webidl deleted file mode 100644 index bfd33b082f8..00000000000 --- a/components/script/dom/webidls/CanvasPattern.webidl +++ /dev/null @@ -1,10 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -// https://html.spec.whatwg.org/multipage/#canvaspattern -[Exposed=(Window, PaintWorklet, Worker)] -interface CanvasPattern { - //void setTransform(SVGMatrix matrix); -}; - diff --git a/components/script/dom/webidls/CanvasRenderingContext2D.webidl b/components/script/dom/webidls/CanvasRenderingContext2D.webidl index 436a39a57ee..dcb310d6849 100644 --- a/components/script/dom/webidls/CanvasRenderingContext2D.webidl +++ b/components/script/dom/webidls/CanvasRenderingContext2D.webidl @@ -13,6 +13,7 @@ typedef (HTMLOrSVGImageElement or HTMLCanvasElement or /*ImageBitmap or*/ OffscreenCanvas or + /*VideoFrame or*/ /*CSSImageValue*/ CSSStyleValue) CanvasImageSource; enum CanvasFillRule { "nonzero", "evenodd" }; @@ -39,14 +40,12 @@ CanvasRenderingContext2D includes CanvasPathDrawingStyles; CanvasRenderingContext2D includes CanvasTextDrawingStyles; CanvasRenderingContext2D includes CanvasPath; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasState { // state undefined save(); // push state on state stack undefined restore(); // pop state stack and restore state }; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasTransform { // transformations (default transform is the identity matrix) undefined scale(unrestricted double x, unrestricted double y); @@ -70,21 +69,18 @@ interface mixin CanvasTransform { undefined resetTransform(); }; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasCompositing { // compositing attribute unrestricted double globalAlpha; // (default 1.0) attribute DOMString globalCompositeOperation; // (default source-over) }; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasImageSmoothing { // image smoothing attribute boolean imageSmoothingEnabled; // (default true) // attribute ImageSmoothingQuality imageSmoothingQuality; // (default low) }; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasFillStrokeStyles { // colours and styles (see also the CanvasDrawingStyles interface) attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black) @@ -96,7 +92,6 @@ interface mixin CanvasFillStrokeStyles { CanvasPattern? createPattern(CanvasImageSource image, [LegacyNullToEmptyString] DOMString repetition); }; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasShadowStyles { // shadows attribute unrestricted double shadowOffsetX; // (default 0) @@ -105,13 +100,11 @@ interface mixin CanvasShadowStyles { attribute DOMString shadowColor; // (default transparent black) }; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasFilters { // filters //attribute DOMString filter; // (default "none") }; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasRect { // rects undefined clearRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h); @@ -119,7 +112,6 @@ interface mixin CanvasRect { undefined strokeRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h); }; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasDrawPath { // path API (see also CanvasPath) undefined beginPath(); @@ -137,7 +129,6 @@ interface mixin CanvasDrawPath { //boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y); }; -[Exposed=(PaintWorklet, Window)] interface mixin CanvasUserInterface { //void drawFocusIfNeeded(Element element); //void drawFocusIfNeeded(Path2D path, Element element); @@ -145,7 +136,6 @@ interface mixin CanvasUserInterface { //void scrollPathIntoView(Path2D path); }; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasText { // text (see also the CanvasPathDrawingStyles and CanvasTextDrawingStyles interfaces) [Pref="dom.canvas_text.enabled"] @@ -157,7 +147,6 @@ interface mixin CanvasText { TextMetrics measureText(DOMString text); }; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasDrawImage { // drawing images [Throws] @@ -172,7 +161,6 @@ interface mixin CanvasDrawImage { unrestricted double dw, unrestricted double dh); }; -[Exposed=(Window, Worker)] interface mixin CanvasImageData { // pixel manipulation [Throws] @@ -194,7 +182,6 @@ enum CanvasTextAlign { "start", "end", "left", "right", "center" }; enum CanvasTextBaseline { "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" }; enum CanvasDirection { "ltr", "rtl", "inherit" }; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasPathDrawingStyles { // line caps/joins attribute unrestricted double lineWidth; // (default 1) @@ -208,7 +195,6 @@ interface mixin CanvasPathDrawingStyles { //attribute unrestricted double lineDashOffset; }; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasTextDrawingStyles { // text attribute DOMString font; // (default 10px sans-serif) @@ -218,7 +204,6 @@ interface mixin CanvasTextDrawingStyles { attribute CanvasDirection direction; // "ltr", "rtl", "inherit" (default: "inherit") }; -[Exposed=(PaintWorklet, Window, Worker)] interface mixin CanvasPath { // shared path API methods undefined closePath(); @@ -250,3 +235,29 @@ interface mixin CanvasPath { unrestricted double radius_y, unrestricted double rotation, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false); }; + +[Exposed=(Window, PaintWorklet, Worker)] +interface CanvasGradient { + // opaque object + [Throws] + undefined addColorStop(double offset, DOMString color); +}; + +[Exposed=(Window, PaintWorklet, Worker)] +interface CanvasPattern { + // opaque object + //undefined setTransform(optional DOMMatrix2DInit transform = {}); +}; + +[Exposed=(Window,Worker), + Serializable] +interface ImageData { + [Throws] constructor(unsigned long sw, unsigned long sh/*, optional ImageDataSettings settings = {}*/); + [Throws] constructor(/* Uint8ClampedArray */ object data, unsigned long sw, optional unsigned long sh + /*, optional ImageDataSettings settings = {}*/); + + readonly attribute unsigned long width; + readonly attribute unsigned long height; + readonly attribute Uint8ClampedArray data; + //readonly attribute PredefinedColorSpace colorSpace; +}; diff --git a/components/script/dom/webidls/DOMMatrix.webidl b/components/script/dom/webidls/DOMMatrix.webidl index eaef16c3906..e0518bce659 100644 --- a/components/script/dom/webidls/DOMMatrix.webidl +++ b/components/script/dom/webidls/DOMMatrix.webidl @@ -1,14 +1,8 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * 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/. */ -/* - * The origin of this IDL file is - * https://drafts.fxtf.org/geometry-1/#DOMMatrix - * - * Copyright: - * To the extent possible under law, the editors have waived all copyright and - * related or neighboring rights to this work. - */ + +// https://drafts.fxtf.org/geometry/#dommatrix [Exposed=(Window,Worker,PaintWorklet), LegacyWindowAlias=WebKitCSSMatrix] @@ -76,8 +70,7 @@ interface DOMMatrix : DOMMatrixReadOnly { // DOMMatrix setMatrixValue(DOMString transformList); }; - -dictionary DOMMatrixInit { +dictionary DOMMatrix2DInit { unrestricted double a; unrestricted double b; unrestricted double c; @@ -86,18 +79,21 @@ dictionary DOMMatrixInit { unrestricted double f; unrestricted double m11; unrestricted double m12; - unrestricted double m13 = 0; - unrestricted double m14 = 0; unrestricted double m21; unrestricted double m22; + unrestricted double m41; + unrestricted double m42; +}; + +dictionary DOMMatrixInit : DOMMatrix2DInit { + unrestricted double m13 = 0; + unrestricted double m14 = 0; unrestricted double m23 = 0; unrestricted double m24 = 0; unrestricted double m31 = 0; unrestricted double m32 = 0; unrestricted double m33 = 1; unrestricted double m34 = 0; - unrestricted double m41; - unrestricted double m42; unrestricted double m43 = 0; unrestricted double m44 = 1; boolean is2D; diff --git a/components/script/dom/webidls/ImageData.webidl b/components/script/dom/webidls/ImageData.webidl deleted file mode 100644 index b05e201f42a..00000000000 --- a/components/script/dom/webidls/ImageData.webidl +++ /dev/null @@ -1,22 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ -/* - * The origin of this IDL file is - * https://html.spec.whatwg.org/multipage/#imagedata - * - * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and Opera Software ASA. - * You are granted a license to use, reproduce and create derivative works of this document. - */ - -[Exposed=(Window,Worker)] -interface ImageData { - [Throws] constructor(unsigned long sw, unsigned long sh); - [Throws] constructor(/* Uint8ClampedArray */ object data, unsigned long sw, optional unsigned long sh); - //[Constant] - readonly attribute unsigned long width; - //[Constant] - readonly attribute unsigned long height; - //[Constant, StoreInSlot] - readonly attribute Uint8ClampedArray data; -}; |