Bug 1592739 - Stop clearing the background behind vibrant -moz-appearance items. r=mattwoodrow

Now that there is no Gecko-contributed background color in the window any more,
there's nothing that needs to be cleared away. This simplifies things.

Differential Revision: https://phabricator.services.mozilla.com/D51464
This commit is contained in:
Markus Stange 2020-06-11 18:46:39 +00:00
parent 5b4290385d
commit f0b3aa554a
6 changed files with 3 additions and 134 deletions

View File

@ -168,11 +168,6 @@ class nsITheme : public nsISupports {
return false;
}
virtual bool NeedToClearBackgroundBehindWidget(nsIFrame* aFrame,
StyleAppearance aWidgetType) {
return false;
}
/**
* ThemeGeometryType values are used for describing themed nsIFrames in
* calls to nsIWidget::UpdateThemeGeometries. We don't simply pass the

View File

@ -34,7 +34,6 @@ DECLARE_DISPLAY_ITEM_TYPE(CHECKED_CHECKBOX,
TYPE_RENDERS_NO_IMAGES | TYPE_IS_CONTENTFUL)
DECLARE_DISPLAY_ITEM_TYPE(CHECKED_RADIOBUTTON,
TYPE_RENDERS_NO_IMAGES | TYPE_IS_CONTENTFUL)
DECLARE_DISPLAY_ITEM_TYPE(CLEAR_BACKGROUND, TYPE_RENDERS_NO_IMAGES)
DECLARE_DISPLAY_ITEM_TYPE(COLUMN_RULE, TYPE_RENDERS_NO_IMAGES)
DECLARE_DISPLAY_ITEM_TYPE(COMBOBOX_FOCUS, TYPE_RENDERS_NO_IMAGES)
DECLARE_DISPLAY_ITEM_TYPE(COMPOSITOR_HITTEST_INFO, TYPE_RENDERS_NO_IMAGES)

View File

@ -710,7 +710,7 @@ void nsDisplayListBuilder::SetGlassDisplayItem(nsDisplayItem* aItem) {
bool nsDisplayListBuilder::NeedToForceTransparentSurfaceForItem(
nsDisplayItem* aItem) {
return aItem == mGlassDisplayItem || aItem->ClearsBackground();
return aItem == mGlassDisplayItem;
}
AnimatedGeometryRoot* nsDisplayListBuilder::WrapAGRForFrame(
@ -3551,13 +3551,6 @@ bool nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
}
if (isThemed) {
nsITheme* theme = presContext->Theme();
if (theme->NeedToClearBackgroundBehindWidget(
aFrame, aFrame->StyleDisplay()->mAppearance) &&
aBuilder->IsInChromeDocumentOrPopup() && !aBuilder->IsInTransform()) {
bgItemList.AppendNewToTop<nsDisplayClearBackground>(aBuilder, aFrame);
}
nsDisplayThemedBackground* bgItem = CreateThemedBackground(
aBuilder, aFrame, aSecondaryReferenceFrame, bgRect);
@ -4662,48 +4655,6 @@ void nsDisplayBackgroundColor::WriteDebugInfo(std::stringstream& aStream) {
aStream << " backgroundRect" << mBackgroundRect;
}
already_AddRefed<Layer> nsDisplayClearBackground::BuildLayer(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) {
RefPtr<ColorLayer> layer = static_cast<ColorLayer*>(
aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, this));
if (!layer) {
layer = aManager->CreateColorLayer();
if (!layer) {
return nullptr;
}
}
layer->SetColor(DeviceColor());
layer->SetMixBlendMode(gfx::CompositionOp::OP_SOURCE);
bool snap;
nsRect bounds = GetBounds(aBuilder, &snap);
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
layer->SetBounds(bounds.ToNearestPixels(appUnitsPerDevPixel)); // XXX Do we
// need to
// respect the
// parent
// layer's
// scale here?
return layer.forget();
}
bool nsDisplayClearBackground::CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
const StackingContextHelper& aSc,
mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder) {
LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(
nsRect(ToReferenceFrame(), mFrame->GetSize()),
mFrame->PresContext()->AppUnitsPerDevPixel());
aBuilder.PushClearRect(wr::ToLayoutRect(bounds));
return true;
}
nsRect nsDisplayOutline::GetBounds(nsDisplayListBuilder* aBuilder,
bool* aSnap) const {
*aSnap = false;

View File

@ -2762,8 +2762,6 @@ class nsDisplayItem : public nsDisplayItemBase {
return false;
}
virtual bool ClearsBackground() 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.
@ -5040,49 +5038,6 @@ class nsDisplayTableBackgroundColor : public nsDisplayBackgroundColor {
nsIFrame* mAncestorFrame;
};
class nsDisplayClearBackground : public nsPaintedDisplayItem {
public:
nsDisplayClearBackground(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
: nsPaintedDisplayItem(aBuilder, aFrame) {}
NS_DISPLAY_DECL_NAME("ClearBackground", TYPE_CLEAR_BACKGROUND)
nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const override {
*aSnap = true;
return nsRect(ToReferenceFrame(), Frame()->GetSize());
}
nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
bool* aSnap) const override {
*aSnap = false;
return GetBounds(aBuilder, aSnap);
}
mozilla::Maybe<nscolor> IsUniform(
nsDisplayListBuilder* aBuilder) const override {
return mozilla::Some(NS_RGBA(0, 0, 0, 0));
}
bool ClearsBackground() const override { return true; }
LayerState GetLayerState(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aParameters) override {
return mozilla::LayerState::LAYER_ACTIVE_FORCE;
}
already_AddRefed<Layer> BuildLayer(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aContainerParameters) override;
bool CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
const StackingContextHelper& aSc,
mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder) override;
};
/**
* The standard display item to paint the outer CSS box-shadows of a frame.
*/

View File

@ -416,8 +416,6 @@ class nsNativeThemeCocoa : private nsNativeTheme, public nsITheme {
bool ThemeDrawsFocusForWidget(StyleAppearance aAppearance) override;
bool ThemeNeedsComboboxDropmarker() override;
virtual bool WidgetAppearanceDependsOnWindowFocus(StyleAppearance aAppearance) override;
virtual bool NeedToClearBackgroundBehindWidget(nsIFrame* aFrame,
StyleAppearance aAppearance) override;
virtual ThemeGeometryType ThemeGeometryTypeForWidget(nsIFrame* aFrame,
StyleAppearance aAppearance) override;
virtual Transparency GetWidgetTransparency(nsIFrame* aFrame,

View File

@ -3074,11 +3074,8 @@ Maybe<nsNativeThemeCocoa::WidgetInfo> nsNativeThemeCocoa::ComputeWidgetInfo(
case StyleAppearance::MozMacSourceListSelection:
case StyleAppearance::MozMacActiveSourceListSelection: {
// If we're in XUL tree, we need to rely on the source list's clear
// background display item. If we cleared the background behind the
// selections, the source list would not pick up the right font
// smoothing background. So, to simplify a bit, we only support vibrancy
// if we're in a source list.
// We only support vibrancy for source list selections if we're inside
// a source list, because we need the background to be transparent.
if (VibrancyManager::SystemSupportsVibrancy() && IsInSourceList(aFrame)) {
return Nothing();
}
@ -4281,32 +4278,6 @@ bool nsNativeThemeCocoa::IsWindowSheet(nsIFrame* aFrame) {
return (widget->WindowType() == eWindowType_sheet);
}
bool nsNativeThemeCocoa::NeedToClearBackgroundBehindWidget(nsIFrame* aFrame,
StyleAppearance aAppearance) {
switch (aAppearance) {
case StyleAppearance::MozMacSourceList:
// If we're in a XUL tree, we don't want to clear the background behind the
// selections below, since that would make our source list to not pick up
// the right font smoothing background. But since we don't call this method
// in nsTreeBodyFrame::BuildDisplayList, we never get here.
case StyleAppearance::MozMacSourceListSelection:
case StyleAppearance::MozMacActiveSourceListSelection:
case StyleAppearance::MozMacVibrancyLight:
case StyleAppearance::MozMacVibrancyDark:
case StyleAppearance::MozMacVibrantTitlebarLight:
case StyleAppearance::MozMacVibrantTitlebarDark:
case StyleAppearance::Tooltip:
case StyleAppearance::Menupopup:
case StyleAppearance::Menuitem:
case StyleAppearance::Checkmenuitem:
return true;
case StyleAppearance::Dialog:
return IsWindowSheet(aFrame);
default:
return false;
}
}
nsITheme::ThemeGeometryType nsNativeThemeCocoa::ThemeGeometryTypeForWidget(
nsIFrame* aFrame, StyleAppearance aAppearance) {
switch (aAppearance) {