Auto merge of #12202 - peterjoel:issue_8509, r=nox

DOMMatrix and DOMMatrixReadOnly

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #8509.

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12202)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-09-16 13:02:36 -05:00 committed by GitHub
commit 1fee88e59c
14 changed files with 1241 additions and 114 deletions

View file

@ -41,9 +41,8 @@ use dom::bindings::reflector::{Reflectable, Reflector};
use dom::bindings::str::{DOMString, USVString};
use dom::bindings::utils::WindowProxyHandler;
use encoding::types::EncodingRef;
use euclid::{Matrix2D, Matrix4D, Point2D};
use euclid::length::Length as EuclidLength;
use euclid::matrix2d::Matrix2D;
use euclid::point::Point2D;
use euclid::rect::Rect;
use euclid::size::Size2D;
use html5ever::tree_builder::QuirksMode;
@ -320,6 +319,7 @@ no_jsmanaged_fields!(LengthOrPercentageOrAuto);
no_jsmanaged_fields!(RGBA);
no_jsmanaged_fields!(EuclidLength<Unit, T>);
no_jsmanaged_fields!(Matrix2D<T>);
no_jsmanaged_fields!(Matrix4D<T>);
no_jsmanaged_fields!(StorageType);
no_jsmanaged_fields!(CanvasGradientStop, LinearGradientStyle, RadialGradientStyle);
no_jsmanaged_fields!(LineCapStyle, LineJoinStyle, CompositionOrBlending);

View file

@ -0,0 +1,369 @@
/* 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 http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::DOMMatrixBinding::{Wrap, DOMMatrixMethods, DOMMatrixInit};
use dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::DOMMatrixReadOnlyMethods;
use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::reflector::reflect_dom_object;
use dom::dommatrixreadonly::{dommatrixinit_to_matrix, DOMMatrixReadOnly, entries_to_matrix};
use euclid::Matrix4D;
#[dom_struct]
pub struct DOMMatrix {
parent: DOMMatrixReadOnly
}
impl DOMMatrix {
#[allow(unrooted_must_root)]
pub fn new(global: GlobalRef, is2D: bool, matrix: Matrix4D<f64>) -> Root<Self> {
let dommatrix = Self::new_inherited(is2D, matrix);
reflect_dom_object(box dommatrix, global, Wrap)
}
pub fn new_inherited(is2D: bool, matrix: Matrix4D<f64>) -> Self {
DOMMatrix {
parent: DOMMatrixReadOnly::new_inherited(is2D, matrix)
}
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-dommatrix
pub fn Constructor(global: GlobalRef) -> Fallible<Root<Self>> {
Self::Constructor_(global, vec![1.0, 0.0, 0.0, 1.0, 0.0, 0.0])
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-dommatrix-numbersequence
pub fn Constructor_(global: GlobalRef, entries: Vec<f64>) -> Fallible<Root<Self>> {
entries_to_matrix(&entries[..])
.map(|(is2D, matrix)| {
Self::new(global, is2D, matrix)
})
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-frommatrix
pub fn FromMatrix(global: GlobalRef, other: &DOMMatrixInit) -> Fallible<Root<Self>> {
dommatrixinit_to_matrix(&other)
.map(|(is2D, matrix)| {
Self::new(global, is2D, matrix)
})
}
pub fn from_readonly(global: GlobalRef, ro: &DOMMatrixReadOnly) -> Root<Self> {
Self::new(global, ro.is_2d(), ro.matrix().clone())
}
}
impl DOMMatrixMethods for DOMMatrix {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m11
fn M11(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M11()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m11
fn SetM11(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m11(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m12
fn M12(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M12()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m12
fn SetM12(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m12(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m13
fn M13(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M13()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m13
fn SetM13(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m13(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m14
fn M14(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M14()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m14
fn SetM14(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m14(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m21
fn M21(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M21()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m21
fn SetM21(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m21(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m22
fn M22(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M22()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m22
fn SetM22(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m22(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m23
fn M23(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M23()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m23
fn SetM23(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m23(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m24
fn M24(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M24()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m24
fn SetM24(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m24(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m31
fn M31(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M31()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m31
fn SetM31(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m31(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m32
fn M32(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M32()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m32
fn SetM32(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m32(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m33
fn M33(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M33()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m33
fn SetM33(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m33(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m34
fn M34(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M34()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m34
fn SetM34(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m34(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m41
fn M41(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M41()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m41
fn SetM41(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m41(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m42
fn M42(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M42()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m42
fn SetM42(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m42(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m43
fn M43(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M43()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m43
fn SetM43(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m43(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m44
fn M44(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().M44()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m44
fn SetM44(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m44(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-a
fn A(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().A()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-a
fn SetA(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m11(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-b
fn B(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().B()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-b
fn SetB(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m12(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-c
fn C(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().C()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-c
fn SetC(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m21(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-d
fn D(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().D()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-d
fn SetD(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m22(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-e
fn E(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().E()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-e
fn SetE(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m41(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-f
fn F(&self) -> f64 {
self.upcast::<DOMMatrixReadOnly>().F()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-f
fn SetF(&self, value: f64) {
self.upcast::<DOMMatrixReadOnly>().set_m42(value);
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-multiplyself
fn MultiplySelf(&self, other:&DOMMatrixInit) -> Fallible<Root<DOMMatrix>> {
// Steps 1-3.
self.upcast::<DOMMatrixReadOnly>().multiply_self(other)
// Step 4.
.and(Ok(Root::from_ref(&self)))
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-premultiplyself
fn PreMultiplySelf(&self, other:&DOMMatrixInit) -> Fallible<Root<DOMMatrix>> {
// Steps 1-3.
self.upcast::<DOMMatrixReadOnly>().pre_multiply_self(other)
// Step 4.
.and(Ok(Root::from_ref(&self)))
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-translateself
fn TranslateSelf(&self, tx: f64, ty: f64, tz: f64) -> Root<DOMMatrix> {
// Steps 1-2.
self.upcast::<DOMMatrixReadOnly>().translate_self(tx, ty, tz);
// Step 3.
Root::from_ref(&self)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scaleself
fn ScaleSelf(&self, scaleX: f64, scaleY: Option<f64>, scaleZ: f64,
originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
// Steps 1-6.
self.upcast::<DOMMatrixReadOnly>().scale_self(scaleX, scaleY, scaleZ, originX, originY, originZ);
// Step 7.
Root::from_ref(&self)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scale3dself
fn Scale3dSelf(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
// Steps 1-4.
self.upcast::<DOMMatrixReadOnly>().scale_3d_self(scale, originX, originY, originZ);
// Step 5.
Root::from_ref(&self)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateself
fn RotateSelf(&self, rotX: f64, rotY: Option<f64>, rotZ: Option<f64>) -> Root<DOMMatrix> {
// Steps 1-7.
self.upcast::<DOMMatrixReadOnly>().rotate_self(rotX, rotY, rotZ);
// Step 8.
Root::from_ref(&self)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotatefromvectorself
fn RotateFromVectorSelf(&self, x: f64, y: f64) -> Root<DOMMatrix> {
// Step 1.
self.upcast::<DOMMatrixReadOnly>().rotate_from_vector_self(x, y);
// Step 2.
Root::from_ref(&self)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateaxisangleself
fn RotateAxisAngleSelf(&self, x: f64, y: f64, z: f64, angle: f64) -> Root<DOMMatrix> {
// Steps 1-2.
self.upcast::<DOMMatrixReadOnly>().rotate_axis_angle_self(x, y, z, angle);
// Step 3.
Root::from_ref(&self)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewxself
fn SkewXSelf(&self, sx: f64) -> Root<DOMMatrix> {
// Step 1.
self.upcast::<DOMMatrixReadOnly>().skew_x_self(sx);
// Step 2.
Root::from_ref(&self)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewyself
fn SkewYSelf(&self, sy: f64) -> Root<DOMMatrix> {
// Step 1.
self.upcast::<DOMMatrixReadOnly>().skew_y_self(sy);
// Step 2.
Root::from_ref(&self)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-invertself
fn InvertSelf(&self) -> Root<DOMMatrix> {
// Steps 1-2.
self.upcast::<DOMMatrixReadOnly>().invert_self();
// Step 3.
Root::from_ref(&self)
}
}

View file

@ -0,0 +1,634 @@
/* 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 http://mozilla.org/MPL/2.0/. */
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods};
use dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::{DOMMatrixReadOnlyMethods, Wrap};
use dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
use dom::bindings::error;
use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::Root;
use dom::bindings::reflector::{reflect_dom_object, Reflectable, Reflector};
use dom::dommatrix::DOMMatrix;
use dom::dompoint::DOMPoint;
use euclid::{Matrix4D, Point4D, Radians};
use std::cell::Cell;
use std::f64;
use style::refcell::Ref;
#[dom_struct]
pub struct DOMMatrixReadOnly {
reflector_: Reflector,
matrix: DOMRefCell<Matrix4D<f64>>,
is2D: Cell<bool>,
}
impl DOMMatrixReadOnly {
#[allow(unrooted_must_root)]
pub fn new(global: GlobalRef, is2D: bool, matrix: Matrix4D<f64>) -> Root<Self> {
let dommatrix = Self::new_inherited(is2D, matrix);
reflect_dom_object(box dommatrix, global, Wrap)
}
pub fn new_inherited(is2D: bool, matrix: Matrix4D<f64>) -> Self {
DOMMatrixReadOnly {
reflector_: Reflector::new(),
matrix: DOMRefCell::new(matrix),
is2D: Cell::new(is2D),
}
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly
pub fn Constructor(global: GlobalRef) -> Fallible<Root<Self>> {
Ok(Self::new(global, true, Matrix4D::identity()))
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly-numbersequence
pub fn Constructor_(global: GlobalRef, entries: Vec<f64>) -> Fallible<Root<Self>> {
entries_to_matrix(&entries[..])
.map(|(is2D, matrix)| {
Self::new(global, is2D, matrix)
})
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-frommatrix
pub fn FromMatrix(global: GlobalRef, other: &DOMMatrixInit) -> Fallible<Root<Self>> {
dommatrixinit_to_matrix(&other)
.map(|(is2D, matrix)| {
Self::new(global, is2D, matrix)
})
}
pub fn matrix(&self) -> Ref<Matrix4D<f64>> {
self.matrix.borrow()
}
pub fn is_2d(&self) -> bool {
self.is2D.get()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m11
pub fn set_m11(&self, value: f64) {
self.matrix.borrow_mut().m11 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m12
pub fn set_m12(&self, value: f64) {
self.matrix.borrow_mut().m12 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m13
pub fn set_m13(&self, value: f64) {
self.matrix.borrow_mut().m13 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m14
pub fn set_m14(&self, value: f64) {
self.matrix.borrow_mut().m14 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m21
pub fn set_m21(&self, value: f64) {
self.matrix.borrow_mut().m21 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m22
pub fn set_m22(&self, value: f64) {
self.matrix.borrow_mut().m22 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m23
pub fn set_m23(&self, value: f64) {
self.matrix.borrow_mut().m23 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m24
pub fn set_m24(&self, value: f64) {
self.matrix.borrow_mut().m24 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m31
pub fn set_m31(&self, value: f64) {
self.matrix.borrow_mut().m31 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m32
pub fn set_m32(&self, value: f64) {
self.matrix.borrow_mut().m32 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m33
pub fn set_m33(&self, value: f64) {
self.matrix.borrow_mut().m33 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m34
pub fn set_m34(&self, value: f64) {
self.matrix.borrow_mut().m34 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m41
pub fn set_m41(&self, value: f64) {
self.matrix.borrow_mut().m41 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m42
pub fn set_m42(&self, value: f64) {
self.matrix.borrow_mut().m42 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m43
pub fn set_m43(&self, value: f64) {
self.matrix.borrow_mut().m43 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m44
pub fn set_m44(&self, value: f64) {
self.matrix.borrow_mut().m44 = value;
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-multiplyself
pub fn multiply_self(&self, other: &DOMMatrixInit) -> Fallible<()> {
// Step 1.
dommatrixinit_to_matrix(&other).map(|(is2D, other_matrix)| {
// Step 2.
let mut matrix = self.matrix.borrow_mut();
*matrix = other_matrix.post_mul(&matrix);
// Step 3.
if !is2D {
self.is2D.set(false);
}
// Step 4 in DOMMatrix.MultiplySelf
})
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-premultiplyself
pub fn pre_multiply_self(&self, other: &DOMMatrixInit) -> Fallible<()> {
// Step 1.
dommatrixinit_to_matrix(&other).map(|(is2D, other_matrix)| {
// Step 2.
let mut matrix = self.matrix.borrow_mut();
*matrix = other_matrix.pre_mul(&matrix);
// Step 3.
if !is2D {
self.is2D.set(false);
}
// Step 4 in DOMMatrix.PreMultiplySelf
})
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-translateself
pub fn translate_self(&self, tx: f64, ty: f64, tz: f64) {
// Step 1.
let translation = Matrix4D::create_translation(tx, ty, tz);
let mut matrix = self.matrix.borrow_mut();
*matrix = translation.post_mul(&matrix);
// Step 2.
if tz != 0.0 {
self.is2D.set(false);
}
// Step 3 in DOMMatrix.TranslateSelf
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scaleself
pub fn scale_self(&self, scaleX: f64, scaleY: Option<f64>, scaleZ: f64,
mut originX: f64, mut originY: f64, mut originZ: f64) {
// Step 1.
self.translate_self(originX, originY, originZ);
// Step 2.
let scaleY = scaleY.unwrap_or(scaleX);
// Step 3.
{
let scale3D = Matrix4D::create_scale(scaleX, scaleY, scaleZ);
let mut matrix = self.matrix.borrow_mut();
*matrix = scale3D.post_mul(&matrix);
}
// Step 4.
originX = -originX;
originY = -originY;
originZ = -originZ;
// Step 5.
self.translate_self(originX, originY, originZ);
// Step 6.
if scaleZ != 1.0 || originZ != 0.0 {
self.is2D.set(false);
}
// Step 7 in DOMMatrix.ScaleSelf
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scale3dself
pub fn scale_3d_self(&self, scale: f64, originX: f64, originY: f64, originZ: f64) {
// Step 1.
self.translate_self(originX, originY, originZ);
// Step 2.
{
let scale3D = Matrix4D::create_scale(scale, scale, scale);
let mut matrix = self.matrix.borrow_mut();
*matrix = scale3D.post_mul(&matrix);
}
// Step 3.
self.translate_self(-originX, -originY, -originZ);
// Step 4.
if scale != 1.0 {
self.is2D.set(false);
}
// Step 5 in DOMMatrix.Scale3dSelf
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateself
pub fn rotate_self(&self, mut rotX: f64, mut rotY: Option<f64>, mut rotZ: Option<f64>) {
// Step 1.
if rotY.is_none() && rotZ.is_none() {
rotZ = Some(rotX);
rotX = 0.0;
rotY = Some(0.0);
}
// Step 2.
let rotY = rotY.unwrap_or(0.0);
// Step 3.
let rotZ = rotZ.unwrap_or(0.0);
// Step 4.
if rotX != 0.0 || rotY != 0.0 {
self.is2D.set(false);
}
if rotZ != 0.0 {
// Step 5.
let rotation = Matrix4D::create_rotation(0.0, 0.0, 1.0, Radians::new(rotZ.to_radians()));
let mut matrix = self.matrix.borrow_mut();
*matrix = rotation.post_mul(&matrix);
}
if rotY != 0.0 {
// Step 6.
let rotation = Matrix4D::create_rotation(0.0, 1.0, 0.0, Radians::new(rotY.to_radians()));
let mut matrix = self.matrix.borrow_mut();
*matrix = rotation.post_mul(&matrix);
}
if rotX != 0.0 {
// Step 7.
let rotation = Matrix4D::create_rotation(1.0, 0.0, 0.0, Radians::new(rotX.to_radians()));
let mut matrix = self.matrix.borrow_mut();
*matrix = rotation.post_mul(&matrix);
}
// Step 8 in DOMMatrix.RotateSelf
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotatefromvectorself
pub fn rotate_from_vector_self(&self, x: f64, y: f64) {
// don't do anything when the rotation angle is zero or undefined
if y != 0.0 || x < 0.0 {
// Step 1.
let rotZ = Radians::new(f64::atan2(y, x));
let rotation = Matrix4D::create_rotation(0.0, 0.0, 1.0, rotZ);
let mut matrix = self.matrix.borrow_mut();
*matrix = rotation.post_mul(&matrix);
}
// Step 2 in DOMMatrix.RotateFromVectorSelf
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateaxisangleself
pub fn rotate_axis_angle_self(&self, x: f64, y: f64, z: f64, angle: f64) {
// Step 1.
let (norm_x, norm_y, norm_z) = normalize_point(x, y, z);
let rotation = Matrix4D::create_rotation(norm_x, norm_y, norm_z, Radians::new(angle.to_radians()));
let mut matrix = self.matrix.borrow_mut();
*matrix = rotation.post_mul(&matrix);
// Step 2.
if x != 0.0 || y != 0.0 {
self.is2D.set(false);
}
// Step 3 in DOMMatrix.RotateAxisAngleSelf
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewxself
pub fn skew_x_self(&self, sx: f64) {
// Step 1.
let skew = Matrix4D::create_skew(Radians::new(sx.to_radians()), Radians::new(0.0));
let mut matrix = self.matrix.borrow_mut();
*matrix = skew.post_mul(&matrix);
// Step 2 in DOMMatrix.SkewXSelf
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewyself
pub fn skew_y_self(&self, sy: f64) {
// Step 1.
let skew = Matrix4D::create_skew(Radians::new(0.0), Radians::new(sy.to_radians()));
let mut matrix = self.matrix.borrow_mut();
*matrix = skew.post_mul(&matrix);
// Step 2 in DOMMatrix.SkewYSelf
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-invertself
pub fn invert_self(&self) {
let mut matrix = self.matrix.borrow_mut();
// Step 1.
*matrix = matrix.inverse().unwrap_or_else(|| {
// Step 2.
self.is2D.set(false);
Matrix4D::row_major(f64::NAN, f64::NAN, f64::NAN, f64::NAN,
f64::NAN, f64::NAN, f64::NAN, f64::NAN,
f64::NAN, f64::NAN, f64::NAN, f64::NAN,
f64::NAN, f64::NAN, f64::NAN, f64::NAN)
})
// Step 3 in DOMMatrix.InvertSelf
}
}
impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m11
fn M11(&self) -> f64 {
self.matrix.borrow().m11
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m12
fn M12(&self) -> f64 {
self.matrix.borrow().m12
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m13
fn M13(&self) -> f64 {
self.matrix.borrow().m13
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m14
fn M14(&self) -> f64 {
self.matrix.borrow().m14
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m21
fn M21(&self) -> f64 {
self.matrix.borrow().m21
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m22
fn M22(&self) -> f64 {
self.matrix.borrow().m22
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m23
fn M23(&self) -> f64 {
self.matrix.borrow().m23
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m24
fn M24(&self) -> f64 {
self.matrix.borrow().m24
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m31
fn M31(&self) -> f64 {
self.matrix.borrow().m31
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m32
fn M32(&self) -> f64 {
self.matrix.borrow().m32
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m33
fn M33(&self) -> f64 {
self.matrix.borrow().m33
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m34
fn M34(&self) -> f64 {
self.matrix.borrow().m34
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m41
fn M41(&self) -> f64 {
self.matrix.borrow().m41
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m42
fn M42(&self) -> f64 {
self.matrix.borrow().m42
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m43
fn M43(&self) -> f64 {
self.matrix.borrow().m43
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m44
fn M44(&self) -> f64 {
self.matrix.borrow().m44
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-a
fn A(&self) -> f64 {
self.M11()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-b
fn B(&self) -> f64 {
self.M12()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-c
fn C(&self) -> f64 {
self.M21()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-d
fn D(&self) -> f64 {
self.M22()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-e
fn E(&self) -> f64 {
self.M41()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-f
fn F(&self) -> f64 {
self.M42()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-is2d
fn Is2D(&self) -> bool {
self.is2D.get()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-isidentity
fn IsIdentity(&self) -> bool {
let matrix = self.matrix.borrow();
matrix.m12 == 0.0 && matrix.m13 == 0.0 && matrix.m14 == 0.0 && matrix.m21 == 0.0 &&
matrix.m23 == 0.0 && matrix.m24 == 0.0 && matrix.m31 == 0.0 && matrix.m32 == 0.0 &&
matrix.m34 == 0.0 && matrix.m41 == 0.0 && matrix.m42 == 0.0 && matrix.m43 == 0.0 &&
matrix.m11 == 1.0 && matrix.m22 == 1.0 && matrix.m33 == 1.0 && matrix.m44 == 1.0
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-translate
fn Translate(&self, tx: f64, ty: f64, tz: f64) -> Root<DOMMatrix> {
DOMMatrix::from_readonly(self.global().r(), self).TranslateSelf(tx, ty, tz)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale
fn Scale(&self, scaleX: f64, scaleY: Option<f64>, scaleZ: f64,
originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
DOMMatrix::from_readonly(self.global().r(), self).ScaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale3d
fn Scale3d(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> Root<DOMMatrix> {
DOMMatrix::from_readonly(self.global().r(), self).Scale3dSelf(scale, originX, originY, originZ)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotate
fn Rotate(&self, rotX: f64, rotY: Option<f64>, rotZ: Option<f64>) -> Root<DOMMatrix> {
DOMMatrix::from_readonly(self.global().r(), self).RotateSelf(rotX, rotY, rotZ)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotatefromvector
fn RotateFromVector(&self, x: f64, y: f64) -> Root<DOMMatrix> {
DOMMatrix::from_readonly(self.global().r(), self).RotateFromVectorSelf(x, y)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotateaxisangle
fn RotateAxisAngle(&self, x: f64, y: f64, z: f64, angle: f64) -> Root<DOMMatrix> {
DOMMatrix::from_readonly(self.global().r(), self).RotateAxisAngleSelf(x, y, z, angle)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewx
fn SkewX(&self, sx: f64) -> Root<DOMMatrix> {
DOMMatrix::from_readonly(self.global().r(), self).SkewXSelf(sx)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewy
fn SkewY(&self, sy: f64) -> Root<DOMMatrix> {
DOMMatrix::from_readonly(self.global().r(), self).SkewYSelf(sy)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-multiply
fn Multiply(&self, other: &DOMMatrixInit) -> Fallible<Root<DOMMatrix>> {
DOMMatrix::from_readonly(self.global().r(), self).MultiplySelf(&other)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx
fn FlipX(&self) -> Root<DOMMatrix> {
let is2D = self.is2D.get();
let flip = Matrix4D::row_major(-1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
let matrix = flip.post_mul(&self.matrix.borrow());
DOMMatrix::new(self.global().r(), is2D, matrix)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipy
fn FlipY(&self) -> Root<DOMMatrix> {
let is2D = self.is2D.get();
let flip = Matrix4D::row_major(1.0, 0.0, 0.0, 0.0,
0.0, -1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
let matrix = flip.post_mul(&self.matrix.borrow());
DOMMatrix::new(self.global().r(), is2D, matrix)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-inverse
fn Inverse(&self) -> Root<DOMMatrix> {
DOMMatrix::from_readonly(self.global().r(), self).InvertSelf()
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-transformpoint
fn TransformPoint(&self, point: &DOMPointInit) -> Root<DOMPoint> {
let matrix = self.matrix.borrow();
let result = matrix.transform_point4d(&Point4D::new(point.x, point.y, point.z, point.w));
DOMPoint::new(self.global().r(), result.x as f64, result.y as f64, result.z as f64, result.w as f64)
}
}
// https://drafts.fxtf.org/geometry-1/#create-a-2d-matrix
fn create_2d_matrix(entries: &[f64]) -> Matrix4D<f64> {
Matrix4D::row_major(entries[0], entries[1], 0.0, 0.0,
entries[2], entries[3], 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
entries[4], entries[5], 0.0, 1.0)
}
// https://drafts.fxtf.org/geometry-1/#create-a-3d-matrix
fn create_3d_matrix(entries: &[f64]) -> Matrix4D<f64> {
Matrix4D::row_major(entries[0], entries[1], entries[2], entries[3],
entries[4], entries[5], entries[6], entries[7],
entries[8], entries[9], entries[10], entries[11],
entries[12], entries[13], entries[14], entries[15])
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly-numbersequence
pub fn entries_to_matrix(entries: &[f64]) -> Fallible<(bool, Matrix4D<f64>)> {
if entries.len() == 6 {
Ok((true, create_2d_matrix(&entries)))
} else if entries.len() == 16 {
Ok((false, create_3d_matrix(&entries)))
} else {
let err_msg = format!("Expected 6 or 16 entries, but found {}.", entries.len());
Err(error::Error::Type(err_msg.to_owned()))
}
}
// https://drafts.fxtf.org/geometry-1/#validate-and-fixup
pub fn dommatrixinit_to_matrix(dict: &DOMMatrixInit) -> Fallible<(bool, Matrix4D<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() ||
dict.is2D.is_some() && dict.is2D.unwrap() &&
(dict.m31 != 0.0 || dict.m32 != 0.0 || dict.m13 != 0.0 || dict.m23 != 0.0 ||
dict.m43 != 0.0 || dict.m14 != 0.0 || dict.m24 != 0.0 || dict.m34 != 0.0 ||
dict.m33 != 1.0 || dict.m44 != 1.0) {
Err(error::Error::Type("Invalid matrix initializer.".to_owned()))
} else {
let mut is2D = dict.is2D;
// Step 2.
let m11 = dict.m11.unwrap_or(dict.a.unwrap_or(1.0));
// Step 3.
let m12 = dict.m12.unwrap_or(dict.b.unwrap_or(0.0));
// Step 4.
let m21 = dict.m21.unwrap_or(dict.c.unwrap_or(0.0));
// Step 5.
let m22 = dict.m22.unwrap_or(dict.d.unwrap_or(1.0));
// Step 6.
let m41 = dict.m41.unwrap_or(dict.e.unwrap_or(0.0));
// Step 7.
let m42 = dict.m42.unwrap_or(dict.f.unwrap_or(0.0));
// Step 8.
if is2D.is_none() &&
(dict.m31 != 0.0 || dict.m32 != 0.0 || dict.m13 != 0.0 ||
dict.m23 != 0.0 || dict.m43 != 0.0 || dict.m14 != 0.0 ||
dict.m24 != 0.0 || dict.m34 != 0.0 ||
dict.m33 != 1.0 || dict.m44 != 1.0) {
is2D = Some(false);
}
// Step 9.
if is2D.is_none() {
is2D = Some(true);
}
let matrix = Matrix4D::row_major(m11, m12, dict.m13, dict.m14,
m21, m22, dict.m23, dict.m24,
dict.m31, dict.m32, dict.m33, dict.m34,
m41, m42, dict.m43, dict.m44);
Ok((is2D.unwrap(), matrix))
}
}
#[inline]
fn normalize_point(x: f64, y: f64, z: f64) -> (f64, f64, f64) {
let len = (x * x + y * y + z * z).sqrt();
if len == 0.0 {
(0.0, 0.0, 0.0)
} else {
(x / len, y / len, z / len)
}
}

View file

@ -250,6 +250,8 @@ pub mod documentfragment;
pub mod documenttype;
pub mod domexception;
pub mod domimplementation;
pub mod dommatrix;
pub mod dommatrixreadonly;
pub mod domparser;
pub mod dompoint;
pub mod dompointreadonly;

View file

@ -0,0 +1,106 @@
/* 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 http://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.
*/
[Constructor,
// Constructor(DOMString transformList),
Constructor(sequence<unrestricted double> numberSequence)
// Exposed=(Window,Worker)
]
interface DOMMatrix : DOMMatrixReadOnly {
[NewObject, Throws] static DOMMatrix fromMatrix(optional DOMMatrixInit other);
// [NewObject] static DOMMatrix fromFloat32Array(Float32Array array32);
// [NewObject] static DOMMatrix fromFloat64Array(Float64Array array64);
// These attributes are simple aliases for certain elements of the 4x4 matrix
inherit attribute unrestricted double a;
inherit attribute unrestricted double b;
inherit attribute unrestricted double c;
inherit attribute unrestricted double d;
inherit attribute unrestricted double e;
inherit attribute unrestricted double f;
inherit attribute unrestricted double m11;
inherit attribute unrestricted double m12;
inherit attribute unrestricted double m13;
inherit attribute unrestricted double m14;
inherit attribute unrestricted double m21;
inherit attribute unrestricted double m22;
inherit attribute unrestricted double m23;
inherit attribute unrestricted double m24;
inherit attribute unrestricted double m31;
inherit attribute unrestricted double m32;
inherit attribute unrestricted double m33;
inherit attribute unrestricted double m34;
inherit attribute unrestricted double m41;
inherit attribute unrestricted double m42;
inherit attribute unrestricted double m43;
inherit attribute unrestricted double m44;
// Mutable transform methods
[Throws] DOMMatrix multiplySelf(optional DOMMatrixInit other);
[Throws] DOMMatrix preMultiplySelf(optional DOMMatrixInit other);
DOMMatrix translateSelf(optional unrestricted double tx = 0,
optional unrestricted double ty = 0,
optional unrestricted double tz = 0);
DOMMatrix scaleSelf(optional unrestricted double scaleX = 1,
optional unrestricted double scaleY,
optional unrestricted double scaleZ = 1,
optional unrestricted double originX = 0,
optional unrestricted double originY = 0,
optional unrestricted double originZ = 0);
DOMMatrix scale3dSelf(optional unrestricted double scale = 1,
optional unrestricted double originX = 0,
optional unrestricted double originY = 0,
optional unrestricted double originZ = 0);
DOMMatrix rotateSelf(optional unrestricted double rotX = 0,
optional unrestricted double rotY,
optional unrestricted double rotZ);
DOMMatrix rotateFromVectorSelf(optional unrestricted double x = 0,
optional unrestricted double y = 0);
DOMMatrix rotateAxisAngleSelf(optional unrestricted double x = 0,
optional unrestricted double y = 0,
optional unrestricted double z = 0,
optional unrestricted double angle = 0);
DOMMatrix skewXSelf(optional unrestricted double sx = 0);
DOMMatrix skewYSelf(optional unrestricted double sy = 0);
DOMMatrix invertSelf();
// DOMMatrix setMatrixValue(DOMString transformList);
};
dictionary DOMMatrixInit {
unrestricted double a;
unrestricted double b;
unrestricted double c;
unrestricted double d;
unrestricted double e;
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 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;
};

View file

@ -0,0 +1,88 @@
/* 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 http://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.
*/
[Constructor,
// Constructor(DOMString transformList)
Constructor(sequence<unrestricted double> numberSequence),
// Exposed=(Window,Worker)
]
interface DOMMatrixReadOnly {
[NewObject, Throws] static DOMMatrixReadOnly fromMatrix(optional DOMMatrixInit other);
// [NewObject] static DOMMatrixReadOnly fromFloat32Array(Float32Array array32);
// [NewObject] static DOMMatrixReadOnly fromFloat64Array(Float64Array array64);
// These attributes are simple aliases for certain elements of the 4x4 matrix
readonly attribute unrestricted double a;
readonly attribute unrestricted double b;
readonly attribute unrestricted double c;
readonly attribute unrestricted double d;
readonly attribute unrestricted double e;
readonly attribute unrestricted double f;
readonly attribute unrestricted double m11;
readonly attribute unrestricted double m12;
readonly attribute unrestricted double m13;
readonly attribute unrestricted double m14;
readonly attribute unrestricted double m21;
readonly attribute unrestricted double m22;
readonly attribute unrestricted double m23;
readonly attribute unrestricted double m24;
readonly attribute unrestricted double m31;
readonly attribute unrestricted double m32;
readonly attribute unrestricted double m33;
readonly attribute unrestricted double m34;
readonly attribute unrestricted double m41;
readonly attribute unrestricted double m42;
readonly attribute unrestricted double m43;
readonly attribute unrestricted double m44;
readonly attribute boolean is2D;
readonly attribute boolean isIdentity;
// Immutable transform methods
DOMMatrix translate(optional unrestricted double tx = 0,
optional unrestricted double ty = 0,
optional unrestricted double tz = 0);
DOMMatrix scale(optional unrestricted double scaleX = 1,
optional unrestricted double scaleY,
optional unrestricted double scaleZ = 1,
optional unrestricted double originX = 0,
optional unrestricted double originY = 0,
optional unrestricted double originZ = 0);
DOMMatrix scale3d(optional unrestricted double scale = 1,
optional unrestricted double originX = 0,
optional unrestricted double originY = 0,
optional unrestricted double originZ = 0);
DOMMatrix rotate(optional unrestricted double rotX = 0,
optional unrestricted double rotY,
optional unrestricted double rotZ);
DOMMatrix rotateFromVector(optional unrestricted double x = 0,
optional unrestricted double y = 0);
DOMMatrix rotateAxisAngle(optional unrestricted double x = 0,
optional unrestricted double y = 0,
optional unrestricted double z = 0,
optional unrestricted double angle = 0);
DOMMatrix skewX(optional unrestricted double sx = 0);
DOMMatrix skewY(optional unrestricted double sy = 0);
[Throws] DOMMatrix multiply(optional DOMMatrixInit other);
DOMMatrix flipX();
DOMMatrix flipY();
DOMMatrix inverse();
DOMPoint transformPoint(optional DOMPointInit point);
// Float32Array toFloat32Array();
// Float64Array toFloat64Array();
// stringifier;
// serializer = { attribute };
};

View file

@ -1,8 +1,5 @@
[DOMMatrix-001.htm]
type: testharness
[testConstructor0]
expected: FAIL
[testConstructor1]
expected: FAIL
@ -12,15 +9,9 @@
[testConstructor3]
expected: FAIL
[testConstructor4]
expected: FAIL
[testConstructor5]
expected: FAIL
[testConstructor6]
expected: FAIL
[testConstructor7]
expected: FAIL
@ -36,18 +27,9 @@
[testConstructor11]
expected: FAIL
[testConstructor12]
expected: FAIL
[testConstructor13]
expected: FAIL
[testConstructorIllegal0]
expected: FAIL
[testConstructorIllegal1]
expected: FAIL
[testConstructorIllegal2]
expected: FAIL

View file

@ -1,38 +0,0 @@
[DOMMatrix-002.htm]
type: testharness
[test translate() doesn't mutate]
expected: FAIL
[test scale() doesn't mutate]
expected: FAIL
[test scale3d() doesn't mutate]
expected: FAIL
[test rotate() doesn't mutate]
expected: FAIL
[test rotateFromVector() doesn't mutate]
expected: FAIL
[test rotateAxisAngle() doesn't mutate]
expected: FAIL
[test skewX() doesn't mutate]
expected: FAIL
[test skewY() doesn't mutate]
expected: FAIL
[test multiply() doesn't mutate]
expected: FAIL
[test flipX() doesn't mutate]
expected: FAIL
[test flipY() doesn't mutate]
expected: FAIL
[test inverse() doesn't mutate]
expected: FAIL

View file

@ -6,21 +6,9 @@
[test scale() without offsets]
expected: FAIL
[test scale() with offsets]
expected: FAIL
[test scale3d()]
expected: FAIL
[test rotate() 2d]
expected: FAIL
[test rotate()]
expected: FAIL
[test rotateFromVector()]
expected: FAIL
[test rotateAxisAngle() ]
expected: FAIL
@ -29,13 +17,3 @@
[test skewY()]
expected: FAIL
[test multiply with inverse is identity]
expected: FAIL
[test flipX()]
expected: FAIL
[test flipY()]
expected: FAIL

View file

@ -1,7 +1,5 @@
[DOMMatrix-001.xht]
type: testharness
[testConstructor0]
expected: FAIL
[testConstructor1]
expected: FAIL
@ -12,15 +10,9 @@
[testConstructor3]
expected: FAIL
[testConstructor4]
expected: FAIL
[testConstructor5]
expected: FAIL
[testConstructor6]
expected: FAIL
[testConstructor7]
expected: FAIL
@ -36,18 +28,9 @@
[testConstructor11]
expected: FAIL
[testConstructor12]
expected: FAIL
[testConstructor13]
expected: FAIL
[testConstructorIllegal0]
expected: FAIL
[testConstructorIllegal1]
expected: FAIL
[testConstructorIllegal2]
expected: FAIL

View file

@ -0,0 +1,19 @@
[DOMMatrix-003.xht]
type: testharness
[test translate()]
expected: FAIL
[test scale() without offsets]
expected: FAIL
[test rotate() 2d]
expected: FAIL
[test rotateAxisAngle() ]
expected: FAIL
[test skewX()]
expected: FAIL
[test skewY()]
expected: FAIL

View file

@ -1,7 +1,5 @@
[DOMMatrix-001.xht]
type: testharness
[testConstructor0]
expected: FAIL
[testConstructor1]
expected: FAIL
@ -12,15 +10,9 @@
[testConstructor3]
expected: FAIL
[testConstructor4]
expected: FAIL
[testConstructor5]
expected: FAIL
[testConstructor6]
expected: FAIL
[testConstructor7]
expected: FAIL
@ -36,18 +28,9 @@
[testConstructor11]
expected: FAIL
[testConstructor12]
expected: FAIL
[testConstructor13]
expected: FAIL
[testConstructorIllegal0]
expected: FAIL
[testConstructorIllegal1]
expected: FAIL
[testConstructorIllegal2]
expected: FAIL

View file

@ -0,0 +1,19 @@
[DOMMatrix-003.xht]
type: testharness
[test translate()]
expected: FAIL
[test scale() without offsets]
expected: FAIL
[test rotate() 2d]
expected: FAIL
[test rotateAxisAngle() ]
expected: FAIL
[test skewX()]
expected: FAIL
[test skewY()]
expected: FAIL

View file

@ -21,6 +21,8 @@ test_interfaces([
"CloseEvent",
"CSS",
"CSSStyleDeclaration",
"DOMMatrix",
"DOMMatrixReadOnly",
"DOMPoint",
"DOMPointReadOnly",
"DOMQuad",