Bug 1229979 - (Part 1) Make the color of decoration line shadow be as same as the color of the text shadow. draft
authorKuoE0 <kuoe0.tw@gmail.com>
Wed, 06 Sep 2017 14:31:36 +0800
changeset 662254 298adebec1da020fac27952c8e73c20bcb1fcb86
parent 660422 d8e238b811d3dc74515065ae8cab6c74baf0295f
child 662255 261f6fd5e9de424f7e4f626768d6b1996a2332e5
push id79011
push userbmo:kuoe0@mozilla.com
push dateMon, 11 Sep 2017 09:38:12 +0000
bugs1229979
milestone57.0a1
Bug 1229979 - (Part 1) Make the color of decoration line shadow be as same as the color of the text shadow. Multi-color shadow is not allowed in spec. We could use the same color of the text as the color of the decoration line when we paint the shadow. MozReview-Commit-ID: AK9NoseSE0h
layout/generic/nsTextFrame.cpp
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -6531,25 +6531,18 @@ nsTextFrame::PaintOneShadow(const PaintS
   nsContextBoxBlur contextBoxBlur;
   const auto A2D = PresContext()->AppUnitsPerDevPixel();
   gfxContext* shadowContext = contextBoxBlur.Init(
     shadowRect, 0, blurRadius, A2D, aParams.context,
     LayoutDevicePixel::ToAppUnits(aParams.dirtyRect, A2D), nullptr, aBlurFlags);
   if (!shadowContext)
     return;
 
-  nscolor shadowColor;
-  const nscolor* decorationOverrideColor;
-  if (aShadowDetails->mHasColor) {
-    shadowColor = aShadowDetails->mColor;
-    decorationOverrideColor = &shadowColor;
-  } else {
-    shadowColor = aParams.foregroundColor;
-    decorationOverrideColor = nullptr;
-  }
+  nscolor shadowColor = aShadowDetails->mHasColor ? aShadowDetails->mColor
+                                                  : aParams.foregroundColor;
 
   if (aParams.textDrawer) {
     wr::TextShadow wrShadow;
 
     wrShadow.offset = {
       PresContext()->AppUnitsToFloatDevPixels(aShadowDetails->mXOffset),
       PresContext()->AppUnitsToFloatDevPixels(aShadowDetails->mYOffset)
     };
@@ -6575,17 +6568,18 @@ nsTextFrame::PaintOneShadow(const PaintS
   params.dirtyRect = aParams.dirtyRect;
   params.framePt = aParams.framePt + shadowOffset;
   params.provider = aParams.provider;
   params.textStyle = &textPaintStyle;
   params.textColor =
     aParams.context == shadowContext ? shadowColor : NS_RGB(0, 0, 0);
   params.clipEdges = aParams.clipEdges;
   params.drawSoftHyphen = (GetStateBits() & TEXT_HYPHEN_BREAK) != 0;
-  params.decorationOverrideColor = decorationOverrideColor;
+  // Multi-color shadow is not allowed, so we use the same color of the text color.
+  params.decorationOverrideColor = &params.textColor;
   DrawText(aParams.range, aParams.textBaselinePt + shadowOffset, params);
 
   contextBoxBlur.DoPaint();
   aParams.context->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.