Bug 791434 - Paint text shadows with the right alpha. r=roc a=akeybl
☠☠ backed out by 3440e0b0cdb3 ☠ ☠
authorCameron McCormack <cam@mcc.id.au>
Tue, 18 Sep 2012 08:24:02 +1000
changeset 106944 a853c1b3957b0dd8bc3382cd369d85c14a57e13a
parent 106943 6a76216bc0ff89a420824de75b17faddc26a9e50
child 106945 285474e7e7f0b318ce3a47d14a0fdd118469de45
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(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