Bug 1387594 - Stop getting the font smoothing background color from the theme. r?mattwoodrow
MozReview-Commit-ID: 2r1B8SvEkEl
--- a/gfx/src/nsITheme.h
+++ b/gfx/src/nsITheme.h
@@ -141,20 +141,16 @@ public:
virtual bool WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType)
{ return false; }
virtual bool NeedToClearBackgroundBehindWidget(nsIFrame* aFrame,
uint8_t aWidgetType)
{ return false; }
- virtual bool WidgetProvidesFontSmoothingBackgroundColor(nsIFrame* aFrame,
- uint8_t aWidgetType, nscolor* aColor)
- { return false; }
-
/**
* ThemeGeometryType values are used for describing themed nsIFrames in
* calls to nsIWidget::UpdateThemeGeometries. We don't simply pass the
* -moz-appearance value ("widget type") of the frame because the widget may
* want to treat different frames with the same -moz-appearance differently
* based on other properties of the frame. So we give the theme a first look
* at the frame in nsITheme::ThemeGeometryTypeForWidget and pass the
* returned ThemeGeometryType along to the widget.
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -434,17 +434,16 @@ class PaintedLayerData {
public:
PaintedLayerData() :
mAnimatedGeometryRoot(nullptr),
mASR(nullptr),
mReferenceFrame(nullptr),
mLayer(nullptr),
mSolidColor(NS_RGBA(0, 0, 0, 0)),
mIsSolidColorInVisibleRegion(false),
- mFontSmoothingBackgroundColor(NS_RGBA(0,0,0,0)),
mNeedComponentAlpha(false),
mForceTransparentSurface(false),
mHideAllLayersBelow(false),
mOpaqueForAnimatedGeometryRootParent(false),
mDisableFlattening(false),
mBackfaceHidden(false),
mShouldPaintOnContentSide(false),
mImage(nullptr),
@@ -590,21 +589,16 @@ public:
* region.
*/
nscolor mSolidColor;
/**
* True if every pixel in mVisibleRegion will have color mSolidColor.
*/
bool mIsSolidColorInVisibleRegion;
/**
- * The target background color for smoothing fonts that are drawn on top of
- * transparent parts of the layer.
- */
- nscolor mFontSmoothingBackgroundColor;
- /**
* True if there is any text visible in the layer that's over
* transparent pixels in the layer.
*/
bool mNeedComponentAlpha;
/**
* Set if the layer should be treated as transparent, even if its entire
* area is covered by opaque display items. For example, this needs to
* be set if something is going to "punch holes" in the layer by clearing
@@ -1483,17 +1477,16 @@ protected:
};
class PaintedDisplayItemLayerUserData : public LayerUserData
{
public:
PaintedDisplayItemLayerUserData() :
mMaskClipCount(0),
mForcedBackgroundColor(NS_RGBA(0,0,0,0)),
- mFontSmoothingBackgroundColor(NS_RGBA(0,0,0,0)),
mXScale(1.f), mYScale(1.f),
mAppUnitsPerDevPixel(0),
mTranslation(0, 0),
mAnimatedGeometryRootPosition(0, 0) {}
/**
* Record the number of clips in the PaintedLayer's mask layer.
* Should not be reset when the layer is recycled since it is used to track
@@ -1503,22 +1496,16 @@ public:
/**
* A color that should be painted over the bounds of the layer's visible
* region before any other content is painted.
*/
nscolor mForcedBackgroundColor;
/**
- * The target background color for smoothing fonts that are drawn on top of
- * transparent parts of the layer.
- */
- nscolor mFontSmoothingBackgroundColor;
-
- /**
* The resolution scale used.
*/
float mXScale, mYScale;
/**
* The appunits per dev pixel for the items in this layer.
*/
nscoord mAppUnitsPerDevPixel;
@@ -3278,18 +3265,16 @@ void ContainerState::FinishPaintedLayerD
AppendToString(str, data->mLayer->GetValidRegion());
printf_stderr("Invalidating layer %p: %s\n", data->mLayer, str.get());
}
#endif
data->mLayer->InvalidateWholeLayer();
}
userData->mForcedBackgroundColor = backgroundColor;
- userData->mFontSmoothingBackgroundColor = data->mFontSmoothingBackgroundColor;
-
// use a mask layer for rounded rect clipping.
// data->mCommonClipCount may be -1 if we haven't put any actual
// drawable items in this layer (i.e. it's only catching events).
int32_t commonClipCount;
commonClipCount = std::max(0, data->mCommonClipCount);
SetupMaskLayer(layer, data->mItemClip, commonClipCount);
// copy commonClipCount to the entry
FrameLayerBuilder::PaintedLayerItemsEntry* entry = mLayerBuilder->
@@ -3487,22 +3472,16 @@ PaintedLayerData::Accumulate(ContainerSt
mImage = static_cast<nsDisplayImageContainer*>(aItem);
FLB_LOG_PAINTED_LAYER_DECISION(this, " Tracking image: nsDisplayImageContainer covers the layer\n");
} else if (mImage) {
FLB_LOG_PAINTED_LAYER_DECISION(this, " No longer tracking image\n");
mImage = nullptr;
}
bool isFirstVisibleItem = mVisibleRegion.IsEmpty();
- if (isFirstVisibleItem) {
- nscolor fontSmoothingBGColor;
- if (aItem->ProvidesFontSmoothingBackgroundColor(&fontSmoothingBGColor)) {
- mFontSmoothingBackgroundColor = fontSmoothingBGColor;
- }
- }
Maybe<nscolor> uniformColor = aItem->IsUniform(aState->mBuilder);
// Some display items have to exist (so they can set forceTransparentSurface
// below) but don't draw anything. They'll return true for isUniform but
// a color with opacity 0.
if (!uniformColor || NS_GET_A(*uniformColor) > 0) {
// Make sure that the visible area is covered by uniform pixels. In
@@ -6155,21 +6134,16 @@ FrameLayerBuilder::DrawPaintedLayer(Pain
if (aClip == DrawRegionClip::DRAW) {
gfxUtils::ClipToRegion(aContext, aRegionToDraw);
}
DrawForcedBackgroundColor(aDrawTarget, aRegionToDraw.GetBounds(),
userData->mForcedBackgroundColor);
}
- if (NS_GET_A(userData->mFontSmoothingBackgroundColor) > 0) {
- aContext->SetFontSmoothingBackgroundColor(
- Color::FromABGR(userData->mFontSmoothingBackgroundColor));
- }
-
// make the origin of the context coincide with the origin of the
// PaintedLayer
gfxContextMatrixAutoSaveRestore saveMatrix(aContext);
nsIntPoint offset = GetTranslationForPaintedLayer(aLayer);
nsPresContext* presContext = entry->mContainerLayerFrame->PresContext();
if (!userData->mVisibilityComputedRegion.Contains(aDirtyRegion) &&
!layerBuilder->GetContainingPaintedLayerData()) {
@@ -6224,18 +6198,16 @@ FrameLayerBuilder::DrawPaintedLayer(Pain
offset, userData->mXScale, userData->mYScale,
entry->mCommonClipCount);
if (gfxPrefs::GfxLoggingPaintedPixelCountEnabled()) {
aLayer->Manager()->AddPaintedPixelCount(
aRegionToDraw.GetBounds().Area());
}
}
- aContext->SetFontSmoothingBackgroundColor(Color());
-
bool isActiveLayerManager = !aLayer->Manager()->IsInactiveLayerManager();
if (presContext->GetPaintFlashing() && isActiveLayerManager) {
gfxContextAutoSaveRestore save(aContext);
if (shouldDrawRectsSeparately) {
if (aClip == DrawRegionClip::DRAW) {
gfxUtils::ClipToRegion(aContext, aRegionToDraw);
}
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -3905,23 +3905,16 @@ Maybe<nscolor>
nsDisplayThemedBackground::IsUniform(nsDisplayListBuilder* aBuilder) {
if (mAppearance == NS_THEME_WIN_BORDERLESS_GLASS ||
mAppearance == NS_THEME_WIN_GLASS) {
return Some(NS_RGBA(0,0,0,0));
}
return Nothing();
}
-bool
-nsDisplayThemedBackground::ProvidesFontSmoothingBackgroundColor(nscolor* aColor)
-{
- nsITheme* theme = mFrame->PresContext()->GetTheme();
- return theme->WidgetProvidesFontSmoothingBackgroundColor(mFrame, mAppearance, aColor);
-}
-
nsRect
nsDisplayThemedBackground::GetPositioningArea()
{
return mBackgroundRect;
}
void
nsDisplayThemedBackground::Paint(nsDisplayListBuilder* aBuilder,
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -1879,19 +1879,16 @@ public:
* to the nearest viewport.
*/
virtual bool ShouldFixToViewport(nsDisplayListBuilder* aBuilder)
{ return false; }
virtual bool ClearsBackground()
{ return false; }
- virtual bool ProvidesFontSmoothingBackgroundColor(nscolor* aColor)
- { return false; }
-
/**
* Returns true if all layers that can be active should be forced to be
* active. Requires setting the pref layers.force-active=true.
*/
static bool ForceActiveLayers();
/**
* @return LAYER_NONE if BuildLayer will return null. In this case
@@ -3350,17 +3347,16 @@ public:
const nsRect& aBackgroundRect);
virtual ~nsDisplayThemedBackground();
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) override;
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
bool* aSnap) override;
virtual mozilla::Maybe<nscolor> IsUniform(nsDisplayListBuilder* aBuilder) override;
- virtual bool ProvidesFontSmoothingBackgroundColor(nscolor* aColor) override;
virtual bool MustPaintOnContentSide() const override { return true; }
/**
* GetBounds() returns the background painting area.
*/
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) override;
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
NS_DISPLAY_DECL_NAME("ThemedBackground", TYPE_THEMED_BACKGROUND)
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -3060,22 +3060,16 @@ nsTreeBodyFrame::PaintRow(int32_t
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());
if (theme && theme->ThemeSupportsWidget(aPresContext, nullptr, appearance)) {
- nscolor color;
- if (theme->WidgetProvidesFontSmoothingBackgroundColor(this, appearance,
- &color)) {
- // Set the font smoothing background color provided by the widget.
- aRenderingContext.SetFontSmoothingBackgroundColor(ToDeviceColor(color));
- }
nsRect dirty;
dirty.IntersectRect(rowRect, aDirtyRect);
theme->DrawWidgetBackground(&aRenderingContext, this, appearance, rowRect,
dirty);
} else {
result &= PaintBackgroundLayer(rowContext, aPresContext, aRenderingContext,
rowRect, aDirtyRect);
}
--- a/widget/cocoa/VibrancyManager.h
+++ b/widget/cocoa/VibrancyManager.h
@@ -89,22 +89,16 @@ public:
* Return the fill color that should be drawn on top of the cleared window
* parts. Usually this would be drawn by -[NSVisualEffectView drawRect:].
* The returned color is opaque if the system-wide "Reduce transparency"
* preference is set.
*/
NSColor* VibrancyFillColorForType(VibrancyType aType);
/**
- * Return the font smoothing background color that should be used for text
- * drawn on top of the vibrant window parts.
- */
- NSColor* VibrancyFontSmoothingBackgroundColorForType(VibrancyType aType);
-
- /**
* Check whether the operating system supports vibrancy at all.
* You may only create a VibrancyManager instance if this returns true.
* @return Whether VibrancyManager can be used on this OS.
*/
static bool SystemSupportsVibrancy();
protected:
void ClearVibrantRegion(const LayoutDeviceIntRegion& aVibrantRegion) const;
--- a/widget/cocoa/VibrancyManager.mm
+++ b/widget/cocoa/VibrancyManager.mm
@@ -68,31 +68,16 @@ VibrancyManager::VibrancyFillColorForTyp
// -[NSVisualEffectView _currentFillColor] is the color that our view
// would draw during its drawRect implementation, if we hadn't
// disabled that.
return AdjustedColor([view _currentFillColor], aType);
}
return [NSColor whiteColor];
}
-@interface NSView(FontSmoothingBackgroundColor)
-- (NSColor*)fontSmoothingBackgroundColor;
-@end
-
-NSColor*
-VibrancyManager::VibrancyFontSmoothingBackgroundColorForType(VibrancyType aType)
-{
- NSView* view = mVibrantRegions.LookupOrAdd(uint32_t(aType))->GetAnyView();
-
- if (view && [view respondsToSelector:@selector(fontSmoothingBackgroundColor)]) {
- return [view fontSmoothingBackgroundColor];
- }
- return [NSColor clearColor];
-}
-
static void
DrawRectNothing(id self, SEL _cmd, NSRect aRect)
{
// The super implementation would clear the background.
// That's fine for views that are placed below their content, but our
// setup is different: Our drawn content is drawn to mContainerView, which
// sits below this EffectView. So we must not clear the background here,
// because we'd erase that drawn content.
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -236,17 +236,16 @@ class WidgetRenderingContext;
- (void)postRender:(NSOpenGLContext *)aGLContext;
- (BOOL)isCoveringTitlebar;
- (void)viewWillStartLiveResize;
- (void)viewDidEndLiveResize;
- (NSColor*)vibrancyFillColorForThemeGeometryType:(nsITheme::ThemeGeometryType)aThemeGeometryType;
-- (NSColor*)vibrancyFontSmoothingBackgroundColorForThemeGeometryType:(nsITheme::ThemeGeometryType)aThemeGeometryType;
// Simple gestures support
//
// XXX - The swipeWithEvent, beginGestureWithEvent, magnifyWithEvent,
// rotateWithEvent, and endGestureWithEvent methods are part of a
// PRIVATE interface exported by nsResponder and reverse-engineering
// was necessary to obtain the methods' prototypes. Thus, Apple may
// change the interface in the future without notice.
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2694,26 +2694,16 @@ nsChildView::VibrancyFillColorForThemeGe
{
if (VibrancyManager::SystemSupportsVibrancy()) {
return EnsureVibrancyManager().VibrancyFillColorForType(
ThemeGeometryTypeToVibrancyType(aThemeGeometryType));
}
return [NSColor whiteColor];
}
-NSColor*
-nsChildView::VibrancyFontSmoothingBackgroundColorForThemeGeometryType(nsITheme::ThemeGeometryType aThemeGeometryType)
-{
- if (VibrancyManager::SystemSupportsVibrancy()) {
- return EnsureVibrancyManager().VibrancyFontSmoothingBackgroundColorForType(
- ThemeGeometryTypeToVibrancyType(aThemeGeometryType));
- }
- return [NSColor clearColor];
-}
-
mozilla::VibrancyManager&
nsChildView::EnsureVibrancyManager()
{
MOZ_ASSERT(mView, "Only call this once we have a view!");
if (!mVibrancyManager) {
mVibrancyManager = MakeUnique<VibrancyManager>(*this, mView);
}
return *mVibrancyManager;
@@ -3721,24 +3711,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
- (NSColor*)vibrancyFillColorForThemeGeometryType:(nsITheme::ThemeGeometryType)aThemeGeometryType
{
if (!mGeckoChild) {
return [NSColor whiteColor];
}
return mGeckoChild->VibrancyFillColorForThemeGeometryType(aThemeGeometryType);
}
-- (NSColor*)vibrancyFontSmoothingBackgroundColorForThemeGeometryType:(nsITheme::ThemeGeometryType)aThemeGeometryType
-{
- if (!mGeckoChild) {
- return [NSColor clearColor];
- }
- return mGeckoChild->VibrancyFontSmoothingBackgroundColorForThemeGeometryType(aThemeGeometryType);
-}
-
- (LayoutDeviceIntRegion)nativeDirtyRegionWithBoundingRect:(NSRect)aRect
{
LayoutDeviceIntRect boundingRect = mGeckoChild->CocoaPointsToDevPixels(aRect);
const NSRect *rects;
NSInteger count;
[self getRectsBeingDrawn:&rects count:&count];
if (count > MAX_RECTS_IN_REGION) {
--- a/widget/cocoa/nsNativeThemeCocoa.h
+++ b/widget/cocoa/nsNativeThemeCocoa.h
@@ -77,18 +77,16 @@ public:
NS_IMETHOD ThemeChanged() override;
bool ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, uint8_t aWidgetType) override;
bool WidgetIsContainer(uint8_t aWidgetType) override;
bool ThemeDrawsFocusForWidget(uint8_t aWidgetType) override;
bool ThemeNeedsComboboxDropmarker() override;
virtual bool WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType) override;
virtual bool NeedToClearBackgroundBehindWidget(nsIFrame* aFrame,
uint8_t aWidgetType) override;
- virtual bool WidgetProvidesFontSmoothingBackgroundColor(nsIFrame* aFrame, uint8_t aWidgetType,
- nscolor* aColor) override;
virtual ThemeGeometryType ThemeGeometryTypeForWidget(nsIFrame* aFrame,
uint8_t aWidgetType) override;
virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) override;
void DrawProgress(CGContextRef context, const HIRect& inBoxRect,
bool inIsIndeterminate, bool inIsHorizontal,
double inValue, double inMaxValue, nsIFrame* aFrame);
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -3808,62 +3808,16 @@ nsNativeThemeCocoa::NeedToClearBackgroun
return true;
case NS_THEME_DIALOG:
return IsWindowSheet(aFrame);
default:
return false;
}
}
-static nscolor ConvertNSColor(NSColor* aColor)
-{
- NSColor* deviceColor = [aColor colorUsingColorSpaceName:NSDeviceRGBColorSpace];
- return NS_RGBA((unsigned int)([deviceColor redComponent] * 255.0),
- (unsigned int)([deviceColor greenComponent] * 255.0),
- (unsigned int)([deviceColor blueComponent] * 255.0),
- (unsigned int)([deviceColor alphaComponent] * 255.0));
-}
-
-bool
-nsNativeThemeCocoa::WidgetProvidesFontSmoothingBackgroundColor(nsIFrame* aFrame,
- uint8_t aWidgetType,
- nscolor* aColor)
-{
- switch (aWidgetType) {
- case NS_THEME_MAC_SOURCE_LIST:
- case NS_THEME_MAC_SOURCE_LIST_SELECTION:
- case NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION:
- case NS_THEME_MAC_VIBRANCY_LIGHT:
- case NS_THEME_MAC_VIBRANCY_DARK:
- case NS_THEME_TOOLTIP:
- case NS_THEME_MENUPOPUP:
- case NS_THEME_MENUITEM:
- case NS_THEME_CHECKMENUITEM:
- case NS_THEME_DIALOG:
- {
- if ((aWidgetType == NS_THEME_DIALOG && !IsWindowSheet(aFrame)) ||
- ((aWidgetType == NS_THEME_MAC_SOURCE_LIST_SELECTION ||
- aWidgetType == NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION) &&
- !IsInSourceList(aFrame))) {
- return false;
- }
- ChildView* childView = ChildViewForFrame(aFrame);
- if (childView) {
- ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType);
- NSColor* color = [childView vibrancyFontSmoothingBackgroundColorForThemeGeometryType:type];
- *aColor = ConvertNSColor(color);
- return true;
- }
- return false;
- }
- default:
- return false;
- }
-}
-
nsITheme::ThemeGeometryType
nsNativeThemeCocoa::ThemeGeometryTypeForWidget(nsIFrame* aFrame, uint8_t aWidgetType)
{
switch (aWidgetType) {
case NS_THEME_WINDOW_TITLEBAR:
return eThemeGeometryTypeTitlebar;
case NS_THEME_TOOLBAR:
return eThemeGeometryTypeToolbar;