Bug 1387594 - Set the font smoothing background color based on the -moz-font-smoothing-background-color property. r?mattwoodrow draft
authorMarkus Stange <mstange@themasta.com>
Thu, 17 Aug 2017 15:59:04 -0400
changeset 663845 434ce3a4b235fc86ea225927a959aa002cfb1b16
parent 663844 8b3194c28285fc5cb1e564f6d0ea672ac141b529
child 663846 03f2501233224644f49ffc69b3f2b546c7ee0558
push id79540
push userbmo:mstange@themasta.com
push dateWed, 13 Sep 2017 12:47:31 +0000
reviewersmattwoodrow
bugs1387594
milestone57.0a1
Bug 1387594 - Set the font smoothing background color based on the -moz-font-smoothing-background-color property. r?mattwoodrow MozReview-Commit-ID: B3PVIvMswf8
layout/generic/nsTextFrame.cpp
layout/xul/nsTextBoxFrame.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -7277,17 +7277,20 @@ nsTextFrame::PaintText(const PaintTextPa
   params.textStyle = &textPaintStyle;
   params.textColor = foregroundColor;
   params.textStrokeColor = textStrokeColor;
   params.textStrokeWidth = textPaintStyle.GetWebkitTextStrokeWidth();
   params.clipEdges = &clipEdges;
   params.drawSoftHyphen = (GetStateBits() & TEXT_HYPHEN_BREAK) != 0;
   params.contextPaint = aParams.contextPaint;
   params.callbacks = aParams.callbacks;
+  aParams.context->SetFontSmoothingBackgroundColor(
+    Color::FromABGR(StyleUserInterface()->mFontSmoothingBackgroundColor));
   DrawText(range, textBaselinePt, params);
+  aParams.context->SetFontSmoothingBackgroundColor(Color());
 }
 
 static void
 DrawTextRun(const gfxTextRun* aTextRun,
             const gfxPoint& aTextBaselinePt,
             gfxTextRun::Range aRange,
             const nsTextFrame::DrawTextRunParams& aParams)
 {
--- a/layout/xul/nsTextBoxFrame.cpp
+++ b/layout/xul/nsTextBoxFrame.cpp
@@ -527,16 +527,18 @@ nsTextBoxFrame::DrawText(gfxContext&    
         PresContext()->PresShell()->CreateReferenceRenderingContext();
     DrawTarget* refDrawTarget = refContext->GetDrawTarget();
 
     CalculateUnderline(refDrawTarget, *fontMet);
 
     nscolor c = aOverrideColor ? *aOverrideColor : StyleColor()->mColor;
     ColorPattern color(ToDeviceColor(c));
     aRenderingContext.SetColor(Color::FromABGR(c));
+    aRenderingContext.SetFontSmoothingBackgroundColor(
+        Color::FromABGR(StyleUserInterface()->mFontSmoothingBackgroundColor));
 
     nsresult rv = NS_ERROR_FAILURE;
 
     if (mState & NS_FRAME_IS_BIDI) {
       presContext->SetBidiEnabled();
       nsBidiLevel level = nsBidiPresUtils::BidiLevelFromStyle(StyleContext());
       if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
           // We let the RenderText function calculate the mnemonic's
@@ -598,16 +600,18 @@ nsTextBoxFrame::DrawText(gfxContext&    
       fontMet->GetStrikeout(offset, size);
       params.color = strikeColor;
       params.lineSize.height = presContext->AppUnitsToGfxUnits(size);
       params.offset = presContext->AppUnitsToGfxUnits(offset);
       params.decoration = NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH;
       params.style = strikeStyle;
       nsCSSRendering::PaintDecorationLine(this, *drawTarget, params);
     }
+
+    aRenderingContext.SetFontSmoothingBackgroundColor(Color());
 }
 
 void
 nsTextBoxFrame::CalculateUnderline(DrawTarget* aDrawTarget,
                                    nsFontMetrics& aFontMetrics)
 {
     if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
          // Calculate all fields of mAccessKeyInfo which
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -3059,16 +3059,18 @@ nsTreeBodyFrame::PaintRow(int32_t       
   nsITheme* theme = nullptr;
   auto appearance = rowContext->StyleDisplay()->mAppearance;
   if (appearance) {
     theme = aPresContext->GetTheme();
   }
 
   // Save the current font smoothing background color in case we change it.
   Color originalColor(aRenderingContext.GetFontSmoothingBackgroundColor());
+  aRenderingContext.SetFontSmoothingBackgroundColor(
+    ToDeviceColor(rowContext->StyleUserInterface()->mFontSmoothingBackgroundColor));
   if (theme && theme->ThemeSupportsWidget(aPresContext, nullptr, appearance)) {
     nsRect dirty;
     dirty.IntersectRect(rowRect, aDirtyRect);
     theme->DrawWidgetBackground(&aRenderingContext, this, appearance, rowRect,
                                 dirty);
   } else {
     result &= PaintBackgroundLayer(rowContext, aPresContext, aRenderingContext,
                                    rowRect, aDirtyRect);