Bug 1592739 - Make nsChildView::WidgetPaintsBackground() return true. r=tnikkel

On macOS, the OS window always comes with an opaque background for top level
windows. This is the case even if Gecko determines the root element of the
window to be transparent: Ever since bug 1162649, nsChildView/nsCocoaWindow
ignore calls to SetTransparencyMode for top level windows and always stay opaque.

Returning true from nsChildView::WidgetPaintsBackground() lets us indicate that
we do not need an opaque backstop color to be added at the bottom of the display
list. This backstop color would interfere with vibrant -moz-appearance rendering
under the new vibrancy model.
WidgetPaintsBackground() is only called in one place, in ComputeBackstopColor():

```
nscolor PresShell::ComputeBackstopColor(nsView* aDisplayRoot) {
  nsIWidget* widget = aDisplayRoot->GetWidget();
  if (widget && (widget->GetTransparencyMode() != eTransparencyOpaque ||
                 widget->WidgetPaintsBackground())) {
    // Within a transparent widget, so the backstop color must be
    // totally transparent.
    return NS_RGBA(0, 0, 0, 0);
  }
  // Within an opaque widget (or no widget at all), so the backstop
  // color must be totally opaque. The user's default background
  // as reported by the prescontext is guaranteed to be opaque.
  return GetDefaultBackgroundColorToDraw();
}
```

On Windows 7, the widget returns eTransparencyBorderlessGlass from
GetTransparencyMode(), which also avoids the backstop color.

Differential Revision: https://phabricator.services.mozilla.com/D51458

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Markus Stange 2019-11-05 18:47:21 +00:00
parent 691e7d64a1
commit 4c8859d2b4

View File

@ -487,6 +487,8 @@ class nsChildView final : public nsBaseWidget {
virtual void PrepareWindowEffects() override; virtual void PrepareWindowEffects() override;
virtual void CleanupWindowEffects() override; virtual void CleanupWindowEffects() override;
virtual bool WidgetPaintsBackground() override { return true; }
virtual void AddWindowOverlayWebRenderCommands( virtual void AddWindowOverlayWebRenderCommands(
mozilla::layers::WebRenderBridgeChild* aWrBridge, mozilla::wr::DisplayListBuilder& aBuilder, mozilla::layers::WebRenderBridgeChild* aWrBridge, mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResourceUpdates) override; mozilla::wr::IpcResourceUpdateQueue& aResourceUpdates) override;