Commit ec29ea95 authored by Connor Brewster's avatar Connor Brewster
Browse files

Bug 1178765 - Part 4: Force a display list rebuild when backdrop-filter pref is toggled r=mstange

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

--HG--
extra : moz-landing-system : lando
parent 04d4ece0
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -3963,16 +3963,11 @@ nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext,
      DisplayListChecker toBeMergedChecker;
      DisplayListChecker afterMergeChecker;

      // If we transition between wrapping the RCD-RSF contents into an async
      // zoom container vs. not, we need to rebuild the display list. This only
      // happens when the zooming or container scrolling prefs are toggled
      // (manually by the user, or during test setup).
      // If a pref is toggled that adds or removes display list items,
      // we need to rebuild the display list. The pref may be toggled
      // manually by the user, or during test setup.
      bool shouldAttemptPartialUpdate = useRetainedBuilder;
      bool didBuildAsyncZoomContainer =
          builder->ShouldBuildAsyncZoomContainer();
      builder->UpdateShouldBuildAsyncZoomContainer();
      if (builder->ShouldBuildAsyncZoomContainer() !=
          didBuildAsyncZoomContainer) {
      if (builder->ShouldRebuildDisplayListDueToPrefChange()) {
        shouldAttemptPartialUpdate = false;
      }

+34 −1
Original line number Diff line number Diff line
@@ -1273,13 +1273,14 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
      mPartialBuildFailed(false),
      mIsInActiveDocShell(false),
      mBuildAsyncZoomContainer(false),
      mBuildBackdropRootContainer(false),
      mHitTestArea(),
      mHitTestInfo(CompositorHitTestInvisibleToHit) {
  MOZ_COUNT_CTOR(nsDisplayListBuilder);

  mBuildCompositorHitTestInfo = mAsyncPanZoomEnabled && IsForPainting();

  UpdateShouldBuildAsyncZoomContainer();
  ShouldRebuildDisplayListDueToPrefChange();

  static_assert(
      static_cast<uint32_t>(DisplayItemType::TYPE_MAX) < (1 << TYPE_BITS),
@@ -1509,6 +1510,38 @@ void nsDisplayListBuilder::UpdateShouldBuildAsyncZoomContainer() {
      !StaticPrefs::layout_scroll_root_frame_containers();
}

void nsDisplayListBuilder::UpdateShouldBuildBackdropRootContainer() {
  mBuildBackdropRootContainer =
      StaticPrefs::layout_css_backdrop_filter_enabled();
}

// Certain prefs may cause display list items to be added or removed when they
// are toggled. In those cases, we need to fully rebuild the display list.
bool nsDisplayListBuilder::ShouldRebuildDisplayListDueToPrefChange() {
  bool shouldRebuild = false;

  // If we transition between wrapping the RCD-RSF contents into an async
  // zoom container vs. not, we need to rebuild the display list. This only
  // happens when the zooming or container scrolling prefs are toggled
  // (manually by the user, or during test setup).
  bool didBuildAsyncZoomContainer = mBuildAsyncZoomContainer;
  UpdateShouldBuildAsyncZoomContainer();
  if (didBuildAsyncZoomContainer != mBuildAsyncZoomContainer) {
    shouldRebuild = true;
  }

  // If backdrop-filter is enabled, backdrop root containers are added to the
  // display list. When the pref is toggled these containers may be added or
  // removed, so the display list should be rebuilt.
  bool didBuildBackdropRootContainer = mBuildBackdropRootContainer;
  UpdateShouldBuildBackdropRootContainer();
  if (didBuildBackdropRootContainer != mBuildBackdropRootContainer) {
    shouldRebuild = true;
  }

  return shouldRebuild;
}

bool nsDisplayListBuilder::MarkOutOfFlowFrameForDisplay(nsIFrame* aDirtyFrame,
                                                        nsIFrame* aFrame) {
  MOZ_ASSERT(aFrame->GetParent() == aDirtyFrame);
+5 −0
Original line number Diff line number Diff line
@@ -1743,6 +1743,10 @@ class nsDisplayListBuilder {
  }
  void UpdateShouldBuildAsyncZoomContainer();

  void UpdateShouldBuildBackdropRootContainer();

  bool ShouldRebuildDisplayListDueToPrefChange();

  /**
   * Represents a region composed of frame/rect pairs.
   * WeakFrames are used to track whether a rect still belongs to the region.
@@ -2020,6 +2024,7 @@ class nsDisplayListBuilder {
  bool mPartialBuildFailed;
  bool mIsInActiveDocShell;
  bool mBuildAsyncZoomContainer;
  bool mBuildBackdropRootContainer;

  nsRect mHitTestArea;
  CompositorHitTestInfo mHitTestInfo;