1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_dom_webkitcssmatrix_h__
8 #define mozilla_dom_webkitcssmatrix_h__
9 
10 #include "mozilla/dom/DOMMatrix.h"
11 
12 namespace mozilla {
13 namespace dom {
14 
15 class WebKitCSSMatrix final : public DOMMatrix {
16  public:
WebKitCSSMatrix(nsISupports * aParent,bool aIsServo)17   WebKitCSSMatrix(nsISupports* aParent, bool aIsServo)
18       : DOMMatrix(aParent, aIsServo) {}
19 
WebKitCSSMatrix(nsISupports * aParent,const DOMMatrixReadOnly & other)20   WebKitCSSMatrix(nsISupports* aParent, const DOMMatrixReadOnly& other)
21       : DOMMatrix(aParent, other) {}
22 
23   static bool FeatureEnabled(JSContext* aCx, JSObject* aObj);
24 
25   static already_AddRefed<WebKitCSSMatrix> Constructor(
26       const GlobalObject& aGlobal, ErrorResult& aRv);
27   static already_AddRefed<WebKitCSSMatrix> Constructor(
28       const GlobalObject& aGlobal, const nsAString& aTransformList,
29       ErrorResult& aRv);
30   static already_AddRefed<WebKitCSSMatrix> Constructor(
31       const GlobalObject& aGlobal, const DOMMatrixReadOnly& aOther,
32       ErrorResult& aRv);
33 
GetParentObject()34   nsISupports* GetParentObject() const { return mParent; }
35   virtual JSObject* WrapObject(JSContext* aCx,
36                                JS::Handle<JSObject*> aGivenProto) override;
37 
38   WebKitCSSMatrix* SetMatrixValue(const nsAString& aTransformList,
39                                   ErrorResult& aRv);
40 
41   already_AddRefed<WebKitCSSMatrix> Multiply(
42       const WebKitCSSMatrix& aOther) const;
43   already_AddRefed<WebKitCSSMatrix> Inverse(ErrorResult& aRv) const;
44   already_AddRefed<WebKitCSSMatrix> Translate(double aTx, double aTy,
45                                               double aTz) const;
46   already_AddRefed<WebKitCSSMatrix> Scale(double aScaleX,
47                                           const Optional<double>& aScaleY,
48                                           double aScaleZ) const;
49   already_AddRefed<WebKitCSSMatrix> Rotate(double aRotX,
50                                            const Optional<double>& aRotY,
51                                            const Optional<double>& aRotZ) const;
52   already_AddRefed<WebKitCSSMatrix> RotateAxisAngle(double aX, double aY,
53                                                     double aZ,
54                                                     double aAngle) const;
55   already_AddRefed<WebKitCSSMatrix> SkewX(double aSx) const;
56   already_AddRefed<WebKitCSSMatrix> SkewY(double aSy) const;
57 
58  protected:
59   WebKitCSSMatrix* Rotate3dSelf(double aRotX, double aRotY, double aRotZ);
60 
61   WebKitCSSMatrix* InvertSelfThrow(ErrorResult& aRv);
62 };
63 
64 }  // namespace dom
65 }  // namespace mozilla
66 
67 #endif /* mozilla_dom_webkitcssmatrix_h__ */
68