Bug 1415225 - Stop setting the EventRegionsOverride flag on root layers. r?botond,mattwoodrow draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 09 Nov 2017 09:03:52 -0500
changeset 695603 6204ca90cb3be06bc1291c4e6230f82e8c553c1f
parent 695602 5c7a212730643b7a7474abcabee550d62ecb300e
child 695604 fa60af083cf5f63faeb16b3d8d3c1c824da5b787
push id88473
push userkgupta@mozilla.com
push dateThu, 09 Nov 2017 14:05:50 +0000
reviewersbotond, mattwoodrow
bugs1415225
milestone58.0a1
Bug 1415225 - Stop setting the EventRegionsOverride flag on root layers. r?botond,mattwoodrow As with the previous patch, instead of setting the override on the root layer, we set the flag on the nsDisplayListBuilder before building the display list, and the flag automatically forces all event regions display items to use their dispatch-to-content region instead of any other regions. Both the WebRender and non-WebRender codepaths were setting the override flag on their root layers and don't need to any more. MozReview-Commit-ID: 1cz0ahqwkOm
gfx/layers/wr/WebRenderCommandBuilder.cpp
layout/base/nsLayoutUtils.cpp
layout/painting/nsDisplayList.cpp
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -75,22 +75,16 @@ WebRenderCommandBuilder::BuildWebRenderC
       StackingContextHelper pageRootSc(sc, aBuilder);
       CreateWebRenderCommandsFromDisplayList(aDisplayList, aDisplayListBuilder,
                                              pageRootSc, aBuilder, aResourceUpdates);
     }
 
     // Make a "root" layer data that has everything else as descendants
     mLayerScrollData.emplace_back();
     mLayerScrollData.back().InitializeRoot(mLayerScrollData.size() - 1);
-    if (aDisplayListBuilder->IsBuildingLayerEventRegions()) {
-      nsIPresShell* shell = aDisplayListBuilder->RootReferenceFrame()->PresShell();
-      if (nsLayoutUtils::HasDocumentLevelListenersForApzAwareEvents(shell)) {
-        mLayerScrollData.back().SetEventRegionsOverride(EventRegionsOverride::ForceDispatchToContent);
-      }
-    }
     auto callback = [&aScrollData](FrameMetrics::ViewID aScrollId) -> bool {
       return aScrollData.HasMetadataFor(aScrollId);
     };
     if (Maybe<ScrollMetadata> rootMetadata = nsLayoutUtils::GetRootMetadata(
           aDisplayListBuilder, mManager, ContainerLayerParameters(), callback)) {
       mLayerScrollData.back().AppendScrollMetadata(aScrollData, rootMetadata.ref());
     }
     // Append the WebRenderLayerScrollData items into WebRenderScrollData
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -3775,16 +3775,19 @@ nsLayoutUtils::PaintFrame(gfxContext* aR
           id = nsLayoutUtils::FindOrCreateIDFor(element);
         }
       }
 
       nsDisplayListBuilder::AutoCurrentScrollParentIdSetter idSetter(&builder, id);
 
       builder.SetVisibleRect(visibleRect);
       builder.SetIsBuilding(true);
+      builder.SetAncestorHasApzAwareEventHandler(
+          builder.IsBuildingLayerEventRegions() &&
+          nsLayoutUtils::HasDocumentLevelListenersForApzAwareEvents(presShell));
 
       const bool paintedPreviously =
         aFrame->HasProperty(nsIFrame::ModifiedFrameList());
 
       // Attempt to do a partial build and merge into the existing list.
       // This calls BuildDisplayListForStacking context on a subset of the
       // viewport.
       bool merged = false;
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -2476,22 +2476,16 @@ already_AddRefed<LayerManager> nsDisplay
       layerManager->SetUserData(&gLayerManagerLayerBuilder, oldBuilder);
       return nullptr;
     }
     // Root is being scaled up by the X/Y resolution. Scale it back down.
     root->SetPostScale(1.0f/containerParameters.mXScale,
                        1.0f/containerParameters.mYScale);
     root->SetScaleToResolution(presShell->ScaleToResolution(),
         containerParameters.mXScale);
-    if (aBuilder->IsBuildingLayerEventRegions() &&
-        nsLayoutUtils::HasDocumentLevelListenersForApzAwareEvents(presShell)) {
-      root->SetEventRegionsOverride(EventRegionsOverride::ForceDispatchToContent);
-    } else {
-      root->SetEventRegionsOverride(EventRegionsOverride::NoOverride);
-    }
 
     auto callback = [root](FrameMetrics::ViewID aScrollId) -> bool {
       return nsLayoutUtils::ContainsMetricsWithId(root, aScrollId);
     };
     if (Maybe<ScrollMetadata> rootMetadata = nsLayoutUtils::GetRootMetadata(
           aBuilder, root->Manager(), containerParameters, callback)) {
       root->SetScrollMetadata(rootMetadata.value());
     }