Bug 1387594 - Set the font smoothing background color based on the -moz-font-smoothing-background-color property. r?mattwoodrow
MozReview-Commit-ID: B3PVIvMswf8
--- 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);