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 664804 87374b8d2f981b5b715c5367a9782c39fbadb312
parent 664803 cd540549eb0aa213c5208b339f456950ddbded14
child 664805 34c5432b3d9cc1b429ce267c43658ddbdddf44b9
push id79812
push userbmo:mstange@themasta.com
push dateThu, 14 Sep 2017 12:15:40 +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);