Skip to content

Commit

Permalink
Bug 1387594 - Stop getting the font smoothing background color from t…
Browse files Browse the repository at this point in the history
…he theme. r=mattwoodrow

MozReview-Commit-ID: 2r1B8SvEkEl
  • Loading branch information
mstange authored and emilio committed Sep 14, 2017
1 parent 2e951f2 commit b5fdbfc
Show file tree
Hide file tree
Showing 11 changed files with 0 additions and 139 deletions.
4 changes: 0 additions & 4 deletions gfx/src/nsITheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 0 additions & 28 deletions layout/painting/FrameLayerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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),
Expand All @@ -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.
*/
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -3499,12 +3484,6 @@ PaintedLayerData::Accumulate(ContainerState* aState,
}

bool isFirstVisibleItem = mVisibleRegion.IsEmpty();
if (isFirstVisibleItem) {
nscolor fontSmoothingBGColor;
if (aItem->ProvidesFontSmoothingBackgroundColor(&fontSmoothingBGColor)) {
mFontSmoothingBackgroundColor = fontSmoothingBGColor;
}
}

Maybe<nscolor> uniformColor = aItem->IsUniform(aState->mBuilder);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -6254,8 +6228,6 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer,
}
}

aContext->SetFontSmoothingBackgroundColor(Color());

bool isActiveLayerManager = !aLayer->Manager()->IsInactiveLayerManager();

if (presContext->GetPaintFlashing() && isActiveLayerManager) {
Expand Down
7 changes: 0 additions & 7 deletions layout/painting/nsDisplayList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 0 additions & 6 deletions layout/painting/nsDisplayList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -3488,7 +3483,6 @@ class nsDisplayThemedBackground : public nsDisplayItem {
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
bool* aSnap) const override;
virtual mozilla::Maybe<nscolor> IsUniform(nsDisplayListBuilder* aBuilder) const override;
virtual bool ProvidesFontSmoothingBackgroundColor(nscolor* aColor) const override;
virtual bool MustPaintOnContentSide() const override { return true; }

/**
Expand Down
6 changes: 0 additions & 6 deletions layout/xul/tree/nsTreeBodyFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 0 additions & 6 deletions widget/cocoa/VibrancyManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 0 additions & 15 deletions widget/cocoa/VibrancyManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 0 additions & 1 deletion widget/cocoa/nsChildView.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ class WidgetRenderingContext;
- (void)viewDidEndLiveResize;

- (NSColor*)vibrancyFillColorForThemeGeometryType:(nsITheme::ThemeGeometryType)aThemeGeometryType;
- (NSColor*)vibrancyFontSmoothingBackgroundColorForThemeGeometryType:(nsITheme::ThemeGeometryType)aThemeGeometryType;

// Simple gestures support
//
Expand Down
18 changes: 0 additions & 18 deletions widget/cocoa/nsChildView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions widget/cocoa/nsNativeThemeCocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
46 changes: 0 additions & 46 deletions widget/cocoa/nsNativeThemeCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit b5fdbfc

Please sign in to comment.