Bug 791434 - Paint text shadows with the right alpha. r=roc a=akeybl
authorCameron McCormack <cam@mcc.id.au>
Fri, 28 Sep 2012 13:45:24 +1000
changeset 106981 b39c9b4810916b576299e214d93c53a79e89878e
parent 106980 6db116c397b12890391775eeea01d9e7a006e01d
child 106982 260a27f882b5e2cc59db7d5e923cdb990914ab98
push idunknown
push userunknown
push dateunknown
reviewersroc, akeybl
bugs791434
milestone17.0a2
Bug 791434 - Paint text shadows with the right alpha. r=roc a=akeybl
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
@@ -5293,29 +5293,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(20px, 100px, 100px, 20px); font: 128px Ahem; color: #7f7f7f">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(20px, 100px, 100px, 20px); font: 128px Ahem; color: transparent; text-shadow: rgba(0, 0, 0, 0.5) 0px 0px 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