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 {
17 public:
WebKitCSSMatrix(nsISupports * aParent)18   explicit WebKitCSSMatrix(nsISupports* aParent)
19     : DOMMatrix(aParent)
20   {}
21 
WebKitCSSMatrix(nsISupports * aParent,const DOMMatrixReadOnly & other)22   WebKitCSSMatrix(nsISupports* aParent, const DOMMatrixReadOnly& other)
23     : DOMMatrix(aParent, other)
24   {}
25 
26   static bool FeatureEnabled(JSContext* aCx, JSObject* aObj);
27 
28   static already_AddRefed<WebKitCSSMatrix>
29   Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
30   static already_AddRefed<WebKitCSSMatrix>
31   Constructor(const GlobalObject& aGlobal,
32               const nsAString& aTransformList, ErrorResult& aRv);
33   static already_AddRefed<WebKitCSSMatrix>
34   Constructor(const GlobalObject& aGlobal,
35               const DOMMatrixReadOnly& aOther, ErrorResult& aRv);
36 
GetParentObject()37   nsISupports* GetParentObject() const { return mParent; }
38   virtual JSObject* WrapObject(JSContext* aCx,
39                                JS::Handle<JSObject*> aGivenProto) override;
40 
41   WebKitCSSMatrix* SetMatrixValue(const nsAString& aTransformList,
42                                   ErrorResult& aRv);
43 
44   already_AddRefed<WebKitCSSMatrix> Multiply(const WebKitCSSMatrix& aOther) const;
45   already_AddRefed<WebKitCSSMatrix> Inverse(ErrorResult& aRv) const;
46   already_AddRefed<WebKitCSSMatrix> Translate(double aTx,
47                                               double aTy,
48                                               double aTz) const;
49   already_AddRefed<WebKitCSSMatrix> Scale(double aScaleX,
50                                           const Optional<double>& aScaleY,
51                                           double aScaleZ) const;
52   already_AddRefed<WebKitCSSMatrix> Rotate(double aRotX,
53                                            const Optional<double>& aRotY,
54                                            const Optional<double>& aRotZ) const;
55   already_AddRefed<WebKitCSSMatrix> RotateAxisAngle(double aX,
56                                                     double aY,
57                                                     double aZ,
58                                                     double aAngle) const;
59   already_AddRefed<WebKitCSSMatrix> SkewX(double aSx) const;
60   already_AddRefed<WebKitCSSMatrix> SkewY(double aSy) const;
61 protected:
62   WebKitCSSMatrix* Rotate3dSelf(double aRotX,
63                                 double aRotY,
64                                 double aRotZ);
65 
66   WebKitCSSMatrix* InvertSelfThrow(ErrorResult& aRv);
67 };
68 
69 } // namespace dom
70 } // namespace mozilla
71 
72 #endif /* mozilla_dom_webkitcssmatrix_h__ */
73