Bug 1229979 - (Part 1) Make the color of decoration line shadow be as same as the color of the text shadow. r=jfkthame
authorKuoE0 <kuoe0.tw@gmail.com>
Wed, 06 Sep 2017 14:31:36 +0800
changeset 429745 861ff7ec8bd42eb22aca56932ccc59b1bacd45b1
parent 429744 874f4d1c9ba13ff88229121a6116f32bc2199bf2
child 429746 aed45fc622627c0811dc4ef206f5dc44bcf3dca5
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1229979
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1229979 - (Part 1) Make the color of decoration line shadow be as same as the color of the text shadow. r=jfkthame 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
@@ -6489,25 +6489,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)
     };
@@ -6533,17 +6526,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.