From b5fdbfc62c62aa023bfcb19d0626cf7ddafd3c78 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Thu, 17 Aug 2017 15:58:31 -0400 Subject: [PATCH] Bug 1387594 - Stop getting the font smoothing background color from the theme. r=mattwoodrow MozReview-Commit-ID: 2r1B8SvEkEl --- gfx/src/nsITheme.h | 4 --- layout/painting/FrameLayerBuilder.cpp | 28 ---------------- layout/painting/nsDisplayList.cpp | 7 ---- layout/painting/nsDisplayList.h | 6 ---- layout/xul/tree/nsTreeBodyFrame.cpp | 6 ---- widget/cocoa/VibrancyManager.h | 6 ---- widget/cocoa/VibrancyManager.mm | 15 --------- widget/cocoa/nsChildView.h | 1 - widget/cocoa/nsChildView.mm | 18 ----------- widget/cocoa/nsNativeThemeCocoa.h | 2 -- widget/cocoa/nsNativeThemeCocoa.mm | 46 --------------------------- 11 files changed, 139 deletions(-) diff --git a/gfx/src/nsITheme.h b/gfx/src/nsITheme.h index ae072c9eeb144..99d3094810b47 100644 --- a/gfx/src/nsITheme.h +++ b/gfx/src/nsITheme.h @@ -146,10 +146,6 @@ class nsITheme: public nsISupports { 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 diff --git a/layout/painting/FrameLayerBuilder.cpp b/layout/painting/FrameLayerBuilder.cpp index c4e257b79aae3..e2abb9a4cdf0c 100644 --- a/layout/painting/FrameLayerBuilder.cpp +++ b/layout/painting/FrameLayerBuilder.cpp @@ -439,7 +439,6 @@ class PaintedLayerData { mLayer(nullptr), mSolidColor(NS_RGBA(0, 0, 0, 0)), mIsSolidColorInVisibleRegion(false), - mFontSmoothingBackgroundColor(NS_RGBA(0,0,0,0)), mNeedComponentAlpha(false), mForceTransparentSurface(false), mHideAllLayersBelow(false), @@ -594,11 +593,6 @@ class PaintedLayerData { * 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. @@ -1495,7 +1489,6 @@ class PaintedDisplayItemLayerUserData : public LayerUserData 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), @@ -1514,12 +1507,6 @@ class PaintedDisplayItemLayerUserData : public LayerUserData */ 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. */ @@ -3290,8 +3277,6 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB } 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). @@ -3499,12 +3484,6 @@ PaintedLayerData::Accumulate(ContainerState* aState, } bool isFirstVisibleItem = mVisibleRegion.IsEmpty(); - if (isFirstVisibleItem) { - nscolor fontSmoothingBGColor; - if (aItem->ProvidesFontSmoothingBackgroundColor(&fontSmoothingBGColor)) { - mFontSmoothingBackgroundColor = fontSmoothingBGColor; - } - } Maybe uniformColor = aItem->IsUniform(aState->mBuilder); @@ -6185,11 +6164,6 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer, 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); @@ -6254,8 +6228,6 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer, } } - aContext->SetFontSmoothingBackgroundColor(Color()); - bool isActiveLayerManager = !aLayer->Manager()->IsInactiveLayerManager(); if (presContext->GetPaintFlashing() && isActiveLayerManager) { diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index a66ae8ad4719f..7a2b1180632aa 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -3985,13 +3985,6 @@ nsDisplayThemedBackground::IsUniform(nsDisplayListBuilder* aBuilder) const return Nothing(); } -bool -nsDisplayThemedBackground::ProvidesFontSmoothingBackgroundColor(nscolor* aColor) const -{ - nsITheme* theme = mFrame->PresContext()->GetTheme(); - return theme->WidgetProvidesFontSmoothingBackgroundColor(mFrame, mAppearance, aColor); -} - nsRect nsDisplayThemedBackground::GetPositioningArea() const { diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index 8f36b4e16c467..cafd43380557d 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -1954,11 +1954,6 @@ class nsDisplayItem : public nsDisplayItemLink { return false; } - virtual bool ProvidesFontSmoothingBackgroundColor(nscolor* aColor) const - { - 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. @@ -3488,7 +3483,6 @@ class nsDisplayThemedBackground : public nsDisplayItem { virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder, bool* aSnap) const override; virtual mozilla::Maybe IsUniform(nsDisplayListBuilder* aBuilder) const override; - virtual bool ProvidesFontSmoothingBackgroundColor(nscolor* aColor) const override; virtual bool MustPaintOnContentSide() const override { return true; } /** diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index 81c68afd6d29b..b6e91862eb40d 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -3060,12 +3060,6 @@ nsTreeBodyFrame::PaintRow(int32_t aRowIndex, // 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, diff --git a/widget/cocoa/VibrancyManager.h b/widget/cocoa/VibrancyManager.h index 7a7ea3af1390f..4532f3e675a4d 100644 --- a/widget/cocoa/VibrancyManager.h +++ b/widget/cocoa/VibrancyManager.h @@ -93,12 +93,6 @@ class VibrancyManager { */ 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. diff --git a/widget/cocoa/VibrancyManager.mm b/widget/cocoa/VibrancyManager.mm index b6176de2bd237..8c890915aa475 100644 --- a/widget/cocoa/VibrancyManager.mm +++ b/widget/cocoa/VibrancyManager.mm @@ -73,21 +73,6 @@ - (NSColor*)_currentFillColor; 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) { diff --git a/widget/cocoa/nsChildView.h b/widget/cocoa/nsChildView.h index f4c4abe996d08..e8de4f85a77d5 100644 --- a/widget/cocoa/nsChildView.h +++ b/widget/cocoa/nsChildView.h @@ -241,7 +241,6 @@ class WidgetRenderingContext; - (void)viewDidEndLiveResize; - (NSColor*)vibrancyFillColorForThemeGeometryType:(nsITheme::ThemeGeometryType)aThemeGeometryType; -- (NSColor*)vibrancyFontSmoothingBackgroundColorForThemeGeometryType:(nsITheme::ThemeGeometryType)aThemeGeometryType; // Simple gestures support // diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index b6d5fe0621214..1693c974025f0 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -2697,16 +2697,6 @@ static void MakeRegionsNonOverlapping(Region& aFirst, Regions& ... aRest) return [NSColor whiteColor]; } -NSColor* -nsChildView::VibrancyFontSmoothingBackgroundColorForThemeGeometryType(nsITheme::ThemeGeometryType aThemeGeometryType) -{ - if (VibrancyManager::SystemSupportsVibrancy()) { - return EnsureVibrancyManager().VibrancyFontSmoothingBackgroundColorForType( - ThemeGeometryTypeToVibrancyType(aThemeGeometryType)); - } - return [NSColor clearColor]; -} - mozilla::VibrancyManager& nsChildView::EnsureVibrancyManager() { @@ -3724,14 +3714,6 @@ - (NSColor*)vibrancyFillColorForThemeGeometryType:(nsITheme::ThemeGeometryType)a 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); diff --git a/widget/cocoa/nsNativeThemeCocoa.h b/widget/cocoa/nsNativeThemeCocoa.h index f34a4e1987f35..faff74e488107 100644 --- a/widget/cocoa/nsNativeThemeCocoa.h +++ b/widget/cocoa/nsNativeThemeCocoa.h @@ -82,8 +82,6 @@ class nsNativeThemeCocoa : private nsNativeTheme, 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; diff --git a/widget/cocoa/nsNativeThemeCocoa.mm b/widget/cocoa/nsNativeThemeCocoa.mm index 69d43b02ac17f..4544ea230bc85 100644 --- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -3813,52 +3813,6 @@ static float VerticalAlignFactor(nsIFrame *aFrame) } } -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) {