Bug 791434 - Paint text shadows with the right alpha. r=roc
authorCameron McCormack <cam@mcc.id.au>
Tue, 18 Sep 2012 08:24:02 +1000
changeset 107958 7eabbf24ef96c224539879ec927e49d1e5aa5151
parent 107948 ec54f1bf1c83ead2cb15f2273c2da837c83a319c
child 107959 3ca1f19e4c2a80361f8ec868997cb78c3ba1e5a1
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersroc
bugs791434
milestone18.0a1
Bug 791434 - Paint text shadows with the right alpha. r=roc
layout/generic/nsTextFrameThebes.cpp
layout/reftests/text-shadow/basic-opacity-ref.html
layout/reftests/text-shadow/basic-opacity.html
layout/reftests/text-shadow/blur-opacity-ref.html
layout/reftests/text-shadow/blur-opacity.html
layout/reftests/text-shadow/reftest.list
--- a/layout/generic/nsTextFrameThebes.cpp
+++ b/layout/generic/nsTextFrameThebes.cpp
@@ -5314,29 +5314,31 @@ nsTextFrame::PaintOneShadow(uint32_t aOf
     shadowColor = aShadowDetails->mColor;
     decorationOverrideColor = &shadowColor;
   } else {
     shadowColor = aForegroundColor;
     decorationOverrideColor = nullptr;
   }
 
   aCtx->Save();
-  aCtx->NewPath(); 
+  aCtx->NewPath();
   aCtx->SetColor(gfxRGBA(shadowColor));
 
   // Draw the text onto our alpha-only surface to capture the alpha values.
   // Remember that the box blur context has a device offset on it, so we don't need to
   // translate any coordinates to fit on the surface.
   gfxFloat advanceWidth;
   gfxRect dirtyRect(aDirtyRect.x, aDirtyRect.y,
                     aDirtyRect.width, aDirtyRect.height);
   DrawText(shadowContext, dirtyRect, aFramePt + shadowOffset,
            aTextBaselinePt + shadowOffset, aOffset, aLength, *aProvider,
-           nsTextPaintStyle(this), shadowColor, aClipEdges, advanceWidth,
-           (GetStateBits() & TEXT_HYPHEN_BREAK) != 0, decorationOverrideColor);
+           nsTextPaintStyle(this),
+           aCtx == shadowContext ? shadowColor : NS_RGB(0, 0, 0), aClipEdges,
+           advanceWidth, (GetStateBits() & TEXT_HYPHEN_BREAK) != 0,
+           decorationOverrideColor);
 
   contextBoxBlur.DoPaint();
   aCtx->Restore();
 }
 
 // Paints selection backgrounds and text in the correct colors. Also computes
 // aAllTypes, the union of all selection types that are applying to this text.
 bool
new file mode 100644
--- /dev/null
+++ b/layout/reftests/text-shadow/basic-opacity-ref.html
@@ -0,0 +1,2 @@
+<div style="position: absolute; top: 33px; left: 33px; color: rgba(0, 0, 255, 0.2); z-index: 0;">Hello</div>
+<div style="position: absolute; top: 30px; left: 30px; color: green; z-index: 1;">Hello</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/text-shadow/basic-opacity.html
@@ -0,0 +1,1 @@
+<div style="position: absolute; top: 30px; left: 30px; color: green; text-shadow: rgba(0, 0, 255, 0.2) 3px 3px;">Hello</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/text-shadow/blur-opacity-ref.html
@@ -0,0 +1,7 @@
+<style>
+@font-face {
+  font-family: Ahem;
+  src: url(../fonts/Ahem.ttf);
+}
+</style>
+<div style="position: absolute; clip: rect(8px, 16px, 16px, 8px); font: 16px Ahem; color: transparent; text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 0px">a</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/text-shadow/blur-opacity.html
@@ -0,0 +1,7 @@
+<style>
+@font-face {
+  font-family: Ahem;
+  src: url(../fonts/Ahem.ttf);
+}
+</style>
+<div style="position: absolute; clip: rect(8px, 16px, 16px, 8px); font: 16px Ahem; color: transparent; text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px">a</div>
--- a/layout/reftests/text-shadow/reftest.list
+++ b/layout/reftests/text-shadow/reftest.list
@@ -1,16 +1,18 @@
 == basic.xul basic-ref.xul
 random-if(Android) == basic-negcoord.xul basic-negcoord-ref.xul
 != blur.xul blur-notref.xul
 == color-inherit.xul color-inherit-ref.xul
 == multiple-noblur.xul multiple-noblur-ref.xul
+HTTP(..) == blur-opacity.html blur-opacity-ref.html
 
 == basic.html basic-ref.html
 == basic-negcoord.html basic-negcoord-ref.html
+== basic-opacity.html basic-opacity-ref.html
 != blur.html blur-notref.html
 == color-inherit.html color-inherit-ref.html
 == color-parserorder.html color-parserorder-ref.html
 == decorations-multiple-zorder.html decorations-multiple-zorder-ref.html
 == multiple-noblur.html multiple-noblur-ref.html
 == quirks-decor-noblur.html quirks-decor-noblur-ref.html
 == standards-decor-noblur.html standards-decor-noblur-ref.html
 == padding-decoration.html padding-decoration-ref.html