Bug 1305963 - Add EnsureTarget for GetMozCurrentTransform and GetMozCurrentTransformInverse. r=nical, a=gchang
authorEthan Lin <ethlin@mozilla.com>
Sun, 02 Oct 2016 23:55:00 -0400
changeset 355994 6acd130cd76ffadcd116faf622e224635ee259f5
parent 355993 57ad439e58a9fcfabbedd269e27aa2223e67795f
child 355995 4bc6e299b3bbdccee27280e22886ca81f82e89cf
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, gchang
bugs1305963
milestone51.0a2
Bug 1305963 - Add EnsureTarget for GetMozCurrentTransform and GetMozCurrentTransformInverse. r=nical, a=gchang
dom/canvas/CanvasRenderingContext2D.cpp
dom/canvas/CanvasRenderingContext2D.h
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -2266,18 +2266,20 @@ CanvasRenderingContext2D::SetMozCurrentT
   if (ObjectToMatrix(aCx, aCurrentTransform, newCTM, aError) && newCTM.IsFinite()) {
     mTarget->SetTransform(newCTM);
   }
 }
 
 void
 CanvasRenderingContext2D::GetMozCurrentTransform(JSContext* aCx,
                                                  JS::MutableHandle<JSObject*> aResult,
-                                                 ErrorResult& aError) const
-{
+                                                 ErrorResult& aError)
+{
+  EnsureTarget();
+
   MatrixToJSObject(aCx, mTarget ? mTarget->GetTransform() : Matrix(),
                    aResult, aError);
 }
 
 void
 CanvasRenderingContext2D::SetMozCurrentTransformInverse(JSContext* aCx,
                                                         JS::Handle<JSObject*> aCurrentTransform,
                                                         ErrorResult& aError)
@@ -2295,18 +2297,20 @@ CanvasRenderingContext2D::SetMozCurrentT
       mTarget->SetTransform(newCTMInverse);
     }
   }
 }
 
 void
 CanvasRenderingContext2D::GetMozCurrentTransformInverse(JSContext* aCx,
                                                         JS::MutableHandle<JSObject*> aResult,
-                                                        ErrorResult& aError) const
-{
+                                                        ErrorResult& aError)
+{
+  EnsureTarget();
+
   if (!mTarget) {
     MatrixToJSObject(aCx, Matrix(), aResult, aError);
     return;
   }
 
   Matrix ctm = mTarget->GetTransform();
 
   if (!ctm.Invert()) {
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -348,23 +348,23 @@ public:
   void Arc(double aX, double aY, double aRadius, double aStartAngle,
            double aEndAngle, bool aAnticlockwise, mozilla::ErrorResult& aError);
   void Ellipse(double aX, double aY, double aRadiusX, double aRadiusY,
                double aRotation, double aStartAngle, double aEndAngle,
                bool aAnticlockwise, ErrorResult& aError);
 
   void GetMozCurrentTransform(JSContext* aCx,
                               JS::MutableHandle<JSObject*> aResult,
-                              mozilla::ErrorResult& aError) const;
+                              mozilla::ErrorResult& aError);
   void SetMozCurrentTransform(JSContext* aCx,
                               JS::Handle<JSObject*> aCurrentTransform,
                               mozilla::ErrorResult& aError);
   void GetMozCurrentTransformInverse(JSContext* aCx,
                                      JS::MutableHandle<JSObject*> aResult,
-                                     mozilla::ErrorResult& aError) const;
+                                     mozilla::ErrorResult& aError);
   void SetMozCurrentTransformInverse(JSContext* aCx,
                                      JS::Handle<JSObject*> aCurrentTransform,
                                      mozilla::ErrorResult& aError);
   void GetFillRule(nsAString& aFillRule);
   void SetFillRule(const nsAString& aFillRule);
   void GetMozDash(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
                   mozilla::ErrorResult& aError);
   void SetMozDash(JSContext* aCx, const JS::Value& aMozDash,