Bug 802658 - Part 2: Apply matrix transform to text bounds; r=Bas
authorAnthony Jones <ajones@mozilla.com>
Sun, 28 Oct 2012 21:52:21 +0100
changeset 111773 278e17fa10e7d2df13659ee9fa2c2ddbda14c603
parent 111772 1d7fc5c44ee2c6536dadd9ef904f6a8989e1d387
child 111774 3e2ec828f0513590e226c8ea6051d800ba4dee14
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersBas
bugs802658
milestone19.0a1
Bug 802658 - Part 2: Apply matrix transform to text bounds; r=Bas
content/canvas/src/CanvasRenderingContext2D.cpp
layout/reftests/canvas/802658-1-ref.html
layout/reftests/canvas/802658-1.html
layout/reftests/canvas/reftest.list
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -3055,17 +3055,19 @@ struct NS_STACK_CLASS CanvasBidiProcesso
       if (!glyphBuf.size()) {
         // This may happen for glyph runs for a 0 size font.
         continue;
       }
 
       buffer.mGlyphs = &glyphBuf.front();
       buffer.mNumGlyphs = glyphBuf.size();
 
-      Rect bounds(mBoundingBox.x, mBoundingBox.y, mBoundingBox.width, mBoundingBox.height);
+      Rect bounds = mCtx->mTarget->GetTransform().
+        TransformBounds(Rect(mBoundingBox.x, mBoundingBox.y,
+                             mBoundingBox.width, mBoundingBox.height));
       if (mOp == CanvasRenderingContext2D::TEXT_DRAW_OPERATION_FILL) {
         AdjustedTarget(mCtx, &bounds)->
           FillGlyphs(scaledFont, buffer,
                      CanvasGeneralPattern().
                        ForStyle(mCtx, CanvasRenderingContext2D::STYLE_FILL, mCtx->mTarget),
                      DrawOptions(mState->globalAlpha, mCtx->UsedOperation()));
       } else if (mOp == CanvasRenderingContext2D::TEXT_DRAW_OPERATION_STROKE) {
         RefPtr<Path> path = scaledFont->GetPathForGlyphs(buffer, mCtx->mTarget);
new file mode 100644
--- /dev/null
+++ b/layout/reftests/canvas/802658-1-ref.html
@@ -0,0 +1,25 @@
+<!docytpe html>
+<html>
+<head>
+<meta charset="UTF-8" />
+<script>
+window.onload=function(){
+
+var c=document.getElementById("myCanvas").getContext("2d");
+
+c.font="35px sans-serif";
+
+c.shadowBlur=60;
+c.shadowColor="blue";
+
+c.fillText("ABCDEFG",100,100);
+
+
+
+}
+</script>
+</head>
+<body>
+<canvas id="myCanvas" height=400 width=400 style="border:1px solid black"></canvas>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/canvas/802658-1.html
@@ -0,0 +1,26 @@
+<!docytpe html>
+<html>
+<head>
+<meta charset="UTF-8" />
+<script>
+window.onload=function(){
+
+var c=document.getElementById("myCanvas").getContext("2d");
+
+c.font="35px sans-serif";
+
+c.translate(100,100);
+c.shadowBlur=60;
+c.shadowColor="blue";
+
+c.fillText("ABCDEFG",0,0);
+
+
+
+}
+</script>
+</head>
+<body>
+<canvas id="myCanvas" height=400 width=400 style="border:1px solid black"></canvas>
+</body>
+</html>
\ No newline at end of file
--- a/layout/reftests/canvas/reftest.list
+++ b/layout/reftests/canvas/reftest.list
@@ -85,8 +85,10 @@ fails-if(OSX==10.6) == 672646-alpha-radi
 == transformed-clip.html transformed-clip-ref.html
 == transformed-gradient.html transformed-gradient-ref.html
 == transformed-path.html transformed-path.html
 
 == 749467-1.html 749467-1-ref.html
 
 # You get a little bit of rounding fuzz on OSX from transforming the paths between user space and device space
 fuzzy-if(azureQuartz,2,113) fuzzy-if(d2d,12,17) == 784573-1.html 784573-1-ref.html
+
+== 802658-1.html 802658-1-ref.html