Bug 651858 - Address comments; pending-r=roc
authorMs2ger <ms2ger@gmail.com>
Tue, 05 Jul 2011 12:15:17 +0200
changeset 72313 df68fdf2f727c9177bb66d61a535563d8f0eb2e3
parent 72312 26cce0d3e1030a3ede35b55e257dcf1e36539153
child 72314 a0b12f9bb58dae54af5f51c980fdbc4284da69b6
push id20695
push userMs2ger@gmail.com
push dateTue, 05 Jul 2011 10:25:33 +0000
treeherdermozilla-central@a0b12f9bb58d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs651858
milestone7.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 651858 - Address comments; pending-r=roc
content/canvas/src/nsCanvasRenderingContext2D.cpp
content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
content/html/content/src/nsHTMLCanvasElement.cpp
dom/interfaces/canvas/nsIDOMCanvasRenderingContext2D.idl
--- a/content/canvas/src/nsCanvasRenderingContext2D.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp
@@ -3004,189 +3004,16 @@ nsCanvasRenderingContext2D::MakeTextRun(
     gfxFontGroup* currentFontStyle = GetCurrentFontStyle();
     if (!currentFontStyle)
         return nsnull;
     return gfxTextRunCache::MakeTextRun(aText, aLength, currentFontStyle,
                                         mThebes, aAppUnitsPerDevUnit, aFlags);
 }
 
 
-NS_IMETHODIMP
-nsCanvasRenderingContext2D::MozDrawText(const nsAString& textToDraw)
-{
-    const PRUnichar* textdata;
-    textToDraw.GetData(&textdata);
-
-    PRUint32 textrunflags = 0;
-
-    PRUint32 aupdp;
-    GetAppUnitsValues(&aupdp, NULL);
-
-    gfxTextRunCache::AutoTextRun textRun =
-        MakeTextRun(textdata, textToDraw.Length(), aupdp, textrunflags);
-
-    if(!textRun.get())
-        return NS_ERROR_FAILURE;
-
-    gfxPoint pt(0.0f,0.0f);
-
-    // Fill color is text color
-    ApplyStyle(STYLE_FILL);
-
-    textRun->Draw(mThebes,
-                  pt,
-                  /* offset = */ 0,
-                  textToDraw.Length(),
-                  nsnull,
-                  nsnull);
-
-    return Redraw();
-}
-
-NS_IMETHODIMP
-nsCanvasRenderingContext2D::MozMeasureText(const nsAString& textToMeasure, float *retVal)
-{
-    nsCOMPtr<nsIDOMTextMetrics> metrics;
-    nsresult rv;
-    rv = MeasureText(textToMeasure, getter_AddRefs(metrics));
-    if (NS_FAILED(rv))
-        return rv;
-    return metrics->GetWidth(retVal);
-}
-
-NS_IMETHODIMP
-nsCanvasRenderingContext2D::MozPathText(const nsAString& textToPath)
-{
-    const PRUnichar* textdata;
-    textToPath.GetData(&textdata);
-
-    PRUint32 textrunflags = 0;
-
-    PRUint32 aupdp;
-    GetAppUnitsValues(&aupdp, NULL);
-
-    gfxTextRunCache::AutoTextRun textRun =
-        MakeTextRun(textdata, textToPath.Length(), aupdp, textrunflags);
-
-    if(!textRun.get())
-        return NS_ERROR_FAILURE;
-
-    gfxPoint pt(0.0f,0.0f);
-
-    textRun->DrawToPath(mThebes,
-                        pt,
-                        /* offset = */ 0,
-                        textToPath.Length(),
-                        nsnull,
-                        nsnull);
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsCanvasRenderingContext2D::MozTextAlongPath(const nsAString& textToDraw, PRBool stroke)
-{
-    // Most of this code is copied from its svg equivalent
-    nsRefPtr<gfxFlattenedPath> path(mThebes->GetFlattenedPath());
-
-    const PRUnichar* textdata;
-    textToDraw.GetData(&textdata);
-
-    PRUint32 textrunflags = 0;
-
-    PRUint32 aupdp;
-    GetAppUnitsValues(&aupdp, NULL);
-
-    gfxTextRunCache::AutoTextRun textRun =
-        MakeTextRun(textdata, textToDraw.Length(), aupdp, textrunflags);
-
-    if(!textRun.get())
-        return NS_ERROR_FAILURE;
-
-    struct PathChar
-    {
-        PRBool draw;
-        gfxFloat angle;
-        gfxPoint pos;
-        PathChar() : draw(PR_FALSE), angle(0.0), pos(0.0,0.0) {}
-    };
-
-    gfxFloat length = path->GetLength();
-    PRUint32 strLength = textToDraw.Length();
-
-    PathChar *cp = new PathChar[strLength];
-
-    if (!cp) {
-        return NS_ERROR_OUT_OF_MEMORY;
-    }
-
-    gfxPoint position(0.0,0.0);
-    gfxFloat x = position.x;
-
-    gfxTextRun::ClusterIterator iter(textRun.get());
-    while (iter.NextCluster()) {
-        gfxFloat halfAdvance = iter.ClusterAdvance(nsnull) / (2.0 * aupdp);
-        if (x + halfAdvance > length) {
-            break;
-        }
-
-        if (x + halfAdvance >= 0) {
-            cp[iter.Position()].draw = PR_TRUE;
-            gfxPoint pt = path->FindPoint(gfxPoint(x + halfAdvance, position.y),
-                                          &(cp[iter.Position()].angle));
-            cp[iter.Position()].pos =
-                pt - gfxPoint(cos(cp[iter.Position()].angle),
-                              sin(cp[iter.Position()].angle)) * halfAdvance;
-        }
-
-        x += 2 * halfAdvance;
-    }
-
-    if (stroke) {
-        ApplyStyle(STYLE_STROKE);
-        mThebes->NewPath();
-    } else {
-        ApplyStyle(STYLE_FILL);
-    }
-
-    iter.Reset();
-    while (iter.NextCluster()) {
-        // Skip non-visible characters
-        if (!cp[iter.Position()].draw) {
-            continue;
-        }
-
-        gfxMatrix matrix = mThebes->CurrentMatrix();
-
-        gfxMatrix rot;
-        rot.Rotate(cp[iter.Position()].angle);
-        mThebes->Multiply(rot);
-
-        rot.Invert();
-        rot.Scale(aupdp,aupdp);
-        gfxPoint pt = rot.Transform(cp[iter.Position()].pos);
-
-        if (stroke) {
-            textRun->DrawToPath(mThebes, pt,
-                                iter.Position(), iter.ClusterLength(),
-                                nsnull, nsnull);
-        } else {
-            textRun->Draw(mThebes, pt, iter.Position(), iter.ClusterLength(),
-                          nsnull, nsnull);
-        }
-        mThebes->SetMatrix(matrix);
-    }
-
-    if (stroke)
-        mThebes->Stroke();
-
-    delete [] cp;
-
-    return Redraw();
-}
-
 //
 // line caps/joins
 //
 NS_IMETHODIMP
 nsCanvasRenderingContext2D::SetLineWidth(float width)
 {
     if (!FloatValidate(width) || width <= 0.0)
         return NS_OK;
--- a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
@@ -3425,40 +3425,16 @@ gfxFontGroup *nsCanvasRenderingContext2D
     }
             
     NS_ASSERTION(NS_SUCCEEDED(rv), "Default canvas font is invalid");
   }
 
   return CurrentState().fontGroup;
 }
 
-NS_IMETHODIMP
-nsCanvasRenderingContext2DAzure::MozDrawText(const nsAString& textToDraw)
-{
-  return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
-}
-
-NS_IMETHODIMP
-nsCanvasRenderingContext2DAzure::MozMeasureText(const nsAString& textToMeasure, float *retVal)
-{
-  return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
-}
-
-NS_IMETHODIMP
-nsCanvasRenderingContext2DAzure::MozPathText(const nsAString& textToPath)
-{
-  return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
-}
-
-NS_IMETHODIMP
-nsCanvasRenderingContext2DAzure::MozTextAlongPath(const nsAString& textToDraw, PRBool stroke)
-{
-  return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
-}
-
 //
 // line caps/joins
 //
 NS_IMETHODIMP
 nsCanvasRenderingContext2DAzure::SetLineWidth(float width)
 {
   if (!FloatValidate(width) || width <= 0.0) {
     return NS_OK;
@@ -3959,36 +3935,37 @@ nsCanvasRenderingContext2DAzure::DrawWin
   // we're drawing; aX and aY are drawn to 0,0 in current user
   // space.
   RedrawUser(gfxRect(0, 0, aW, aH));
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsCanvasRenderingContext2DAzure::AsyncDrawXULElement(nsIDOMXULElement* aElem, float aX, float aY,
-                                                float aW, float aH,
-                                                const nsAString& aBGColor,
-                                                PRUint32 flags)
+nsCanvasRenderingContext2DAzure::AsyncDrawXULElement(nsIDOMXULElement* aElem,
+                                                     float aX, float aY,
+                                                     float aW, float aH,
+                                                     const nsAString& aBGColor,
+                                                     PRUint32 flags)
 {
-#if 0
     NS_ENSURE_ARG(aElem != nsnull);
 
     // We can't allow web apps to call this until we fix at least the
     // following potential security issues:
     // -- rendering cross-domain IFRAMEs and then extracting the results
     // -- rendering the user's theme and then extracting the results
     // -- rendering native anonymous content (e.g., file input paths;
     // scrollbars should be allowed)
     if (!nsContentUtils::IsCallerTrustedForRead()) {
         // not permitted to use DrawWindow
         // XXX ERRMSG we need to report an error to developers here! (bug 329026)
         return NS_ERROR_DOM_SECURITY_ERR;
     }
 
+#if 0
     nsCOMPtr<nsIFrameLoaderOwner> loaderOwner = do_QueryInterface(aElem);
     if (!loaderOwner)
         return NS_ERROR_FAILURE;
 
     nsRefPtr<nsFrameLoader> frameloader = loaderOwner->GetFrameLoader();
     if (!frameloader)
         return NS_ERROR_FAILURE;
 
--- a/content/html/content/src/nsHTMLCanvasElement.cpp
+++ b/content/html/content/src/nsHTMLCanvasElement.cpp
@@ -725,20 +725,17 @@ nsHTMLCanvasElement::RenderContextsExter
 }
 
 nsresult NS_NewCanvasRenderingContext2DThebes(nsIDOMCanvasRenderingContext2D** aResult);
 nsresult NS_NewCanvasRenderingContext2DAzure(nsIDOMCanvasRenderingContext2D** aResult);
 
 nsresult
 NS_NewCanvasRenderingContext2D(nsIDOMCanvasRenderingContext2D** aResult)
 {
-  PRBool azure = PR_FALSE;
-  nsresult rv = Preferences::GetBool("gfx.canvas.azure.enabled", &azure);
-
-  if (azure) {
+  if (Preferences::GetBool("gfx.canvas.azure.enabled", PR_FALSE)) {
     nsresult rv = NS_NewCanvasRenderingContext2DAzure(aResult);
     // If Azure fails, fall back to a classic canvas.
     if (NS_SUCCEEDED(rv)) {
       return rv;
     }
   }
 
   return NS_NewCanvasRenderingContext2DThebes(aResult);
--- a/dom/interfaces/canvas/nsIDOMCanvasRenderingContext2D.idl
+++ b/dom/interfaces/canvas/nsIDOMCanvasRenderingContext2D.idl
@@ -57,17 +57,17 @@ interface nsIDOMCanvasPattern : nsISuppo
 };
 
 [scriptable, uuid(2d01715c-ec7d-424a-ab85-e0fd70c8665c)]
 interface nsIDOMTextMetrics : nsISupports
 {
   readonly attribute float width;
 };
 
-[scriptable, uuid(bf5e52a3-6ec1-4a6e-8364-9f9222ec8edb)]
+[scriptable, uuid(274213a8-df51-4b52-bfad-d306a1d5f642)]
 interface nsIDOMCanvasRenderingContext2D : nsISupports
 {
   // back-reference to the canvas element for which
   // this context was created
   readonly attribute nsIDOMHTMLCanvasElement canvas;
 
   // state
   void save();
@@ -158,21 +158,17 @@ enum CanvasMultiGetterType {
                                  "center" */
   attribute DOMString textBaseline; /* "alphabetic" (default), "top", "hanging",
                                     "middle", "ideographic", "bottom" */
 
   void fillText(in DOMString text, in float x, in float y, [optional] in float maxWidth);
   void strokeText(in DOMString text, in float x, in float y, [optional] in float maxWidth);
   nsIDOMTextMetrics measureText(in DOMString text);
 
-  attribute DOMString mozTextStyle; 
-  void mozDrawText(in DOMString textToDraw);
-  float mozMeasureText(in DOMString textToMeasure);
-  void mozPathText(in DOMString textToPath);
-  void mozTextAlongPath(in DOMString textToDraw, in boolean stroke);
+  attribute DOMString mozTextStyle;
 
   // image api
 
   [optional_argc] void drawImage(in nsIDOMElement image,
                                  in float a1, in float a2,
                                  [optional] in float a3,
                                  [optional] in float a4,
                                  [optional] in float a5,