Implement CanvasRenderingContext2D.getTransform()

This commit is contained in:
pylbrecht 2020-02-11 22:36:50 +01:00
parent 6b2079e5b3
commit 588c09b580
16 changed files with 42 additions and 22 deletions

View file

@ -18,6 +18,7 @@ use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom};
use crate::dom::bindings::str::DOMString;
use crate::dom::canvasgradient::CanvasGradient;
use crate::dom::canvaspattern::CanvasPattern;
use crate::dom::dommatrix::DOMMatrix;
use crate::dom::globalscope::GlobalScope;
use crate::dom::htmlcanvaselement::HTMLCanvasElement;
use crate::dom::imagedata::ImageData;
@ -224,6 +225,11 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
self.canvas_state.borrow().transform(a, b, c, d, e, f)
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-gettransform
fn GetTransform(&self) -> DomRoot<DOMMatrix> {
self.canvas_state.borrow().get_transform(&self.global())
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
fn SetTransform(&self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64) {
self.canvas_state.borrow().set_transform(a, b, c, d, e, f)

View file

@ -19,6 +19,7 @@ use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::bindings::str::DOMString;
use crate::dom::canvasgradient::CanvasGradient;
use crate::dom::canvaspattern::CanvasPattern;
use crate::dom::dommatrix::DOMMatrix;
use crate::dom::globalscope::GlobalScope;
use crate::dom::htmlcanvaselement::HTMLCanvasElement;
use crate::dom::imagedata::ImageData;
@ -470,6 +471,11 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
self.canvas_state.borrow().transform(a, b, c, d, e, f)
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-gettransform
fn GetTransform(&self) -> DomRoot<DOMMatrix> {
self.canvas_state.borrow().get_transform(&self.global())
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
fn SetTransform(&self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64) {
self.canvas_state.borrow().set_transform(a, b, c, d, e, f)

View file

@ -20,6 +20,7 @@ use crate::dom::bindings::str::DOMString;
use crate::dom::canvasgradient::CanvasGradient;
use crate::dom::canvaspattern::CanvasPattern;
use crate::dom::canvasrenderingcontext2d::CanvasRenderingContext2D;
use crate::dom::dommatrix::DOMMatrix;
use crate::dom::paintworkletglobalscope::PaintWorkletGlobalScope;
use crate::euclidext::Size2DExt;
use canvas_traits::canvas::CanvasImageData;
@ -119,6 +120,11 @@ impl PaintRenderingContext2DMethods for PaintRenderingContext2D {
self.context.Transform(a, b, c, d, e, f)
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-gettransform
fn GetTransform(&self) -> DomRoot<DOMMatrix> {
self.context.GetTransform()
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
fn SetTransform(&self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64) {
self.context.SetTransform(a, b, c, d, e, f);

View file

@ -59,7 +59,7 @@ interface mixin CanvasTransform {
unrestricted double e,
unrestricted double f);
// [NewObject] DOMMatrix getTransform();
[NewObject] DOMMatrix getTransform();
void setTransform(unrestricted double a,
unrestricted double b,
unrestricted double c,

View file

@ -10,7 +10,7 @@
* related or neighboring rights to this work.
*/
[Exposed=(Window,Worker),
[Exposed=(Window,Worker,PaintWorklet),
LegacyWindowAlias=WebKitCSSMatrix]
interface DOMMatrix : DOMMatrixReadOnly {
[Throws] constructor(optional (DOMString or sequence<unrestricted double>) init);

View file

@ -10,7 +10,7 @@
* related or neighboring rights to this work.
*/
[Exposed=(Window,Worker)]
[Exposed=(Window,Worker,PaintWorklet)]
interface DOMMatrixReadOnly {
[Throws] constructor(optional (DOMString or sequence<unrestricted double>) init);

View file

@ -10,7 +10,7 @@
*/
// http://dev.w3.org/fxtf/geometry/Overview.html#dompoint
[Exposed=(Window,Worker)]
[Exposed=(Window,Worker,PaintWorklet)]
interface DOMPoint : DOMPointReadOnly {
[Throws] constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
optional unrestricted double z = 0, optional unrestricted double w = 1);

View file

@ -10,7 +10,7 @@
*/
// http://dev.w3.org/fxtf/geometry/Overview.html#dompointreadonly
[Exposed=(Window,Worker)]
[Exposed=(Window,Worker,PaintWorklet)]
interface DOMPointReadOnly {
[Throws] constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
optional unrestricted double z = 0, optional unrestricted double w = 1);