Bug 1415225 - Move the EventRegionsOverride field to be on RefLayers only. r=botond
☠☠ backed out by 95985f660be1 ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 08 Nov 2017 20:47:19 -0500
changeset 441701 8cfef302b7102e2953f61020a26c26313cebc4e4
parent 441700 8ae80d7421d5b01d9e6ef8a7ce1c62a2f0b71149
child 441702 9e671058653199248a401a379f787fef0ccced89
push id8133
push userryanvm@gmail.com
push dateThu, 09 Nov 2017 23:33:01 +0000
treeherdermozilla-beta@7ca33aee2c1d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1415225
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1415225 - Move the EventRegionsOverride field to be on RefLayers only. r=botond We now set EventRegionsOverride flags on ref layers only, so there's no need to have the APIs to set it on container layers in general. MozReview-Commit-ID: EX57VvaZv8A
gfx/layers/LayerMetricsWrapper.h
gfx/layers/Layers.cpp
gfx/layers/Layers.h
gfx/layers/LayersTypes.h
gfx/layers/apz/src/APZCTreeManager.cpp
gfx/layers/ipc/LayerTransactionParent.cpp
gfx/layers/ipc/LayersMessages.ipdlh
layout/ipc/RenderFrameParent.cpp
--- a/gfx/layers/LayerMetricsWrapper.h
+++ b/gfx/layers/LayerMetricsWrapper.h
@@ -399,18 +399,18 @@ public:
 
     return 1.0f;
   }
 
   EventRegionsOverride GetEventRegionsOverride() const
   {
     MOZ_ASSERT(IsValid());
 
-    if (mLayer->AsContainerLayer()) {
-      return mLayer->AsContainerLayer()->GetEventRegionsOverride();
+    if (mLayer->AsRefLayer()) {
+      return mLayer->AsRefLayer()->GetEventRegionsOverride();
     }
     return EventRegionsOverride::NoOverride;
   }
 
   const ScrollThumbData& GetScrollThumbData() const
   {
     MOZ_ASSERT(IsValid());
 
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -835,18 +835,17 @@ ContainerLayer::ContainerLayer(LayerMana
     mPreYScale(1.0f),
     mInheritedXScale(1.0f),
     mInheritedYScale(1.0f),
     mPresShellResolution(1.0f),
     mScaleToResolution(false),
     mUseIntermediateSurface(false),
     mSupportsComponentAlphaChildren(false),
     mMayHaveReadbackChild(false),
-    mChildrenChanged(false),
-    mEventRegionsOverride(EventRegionsOverride::NoOverride)
+    mChildrenChanged(false)
 {
 }
 
 ContainerLayer::~ContainerLayer()
 {
 }
 
 bool
@@ -1030,18 +1029,17 @@ ContainerLayer::RepositionChild(Layer* a
   return true;
 }
 
 void
 ContainerLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
 {
   aAttrs = ContainerLayerAttributes(mPreXScale, mPreYScale,
                                     mInheritedXScale, mInheritedYScale,
-                                    mPresShellResolution, mScaleToResolution,
-                                    mEventRegionsOverride);
+                                    mPresShellResolution, mScaleToResolution);
 }
 
 bool
 ContainerLayer::Creates3DContextWithExtendingChildren()
 {
   if (Extend3DContext()) {
     return false;
   }
@@ -2057,22 +2055,16 @@ ContainerLayer::PrintInfo(std::stringstr
     aStream << " [usesTmpSurf]";
   }
   if (1.0 != mPreXScale || 1.0 != mPreYScale) {
     aStream << nsPrintfCString(" [preScale=%g, %g]", mPreXScale, mPreYScale).get();
   }
   if (mScaleToResolution) {
     aStream << nsPrintfCString(" [presShellResolution=%g]", mPresShellResolution).get();
   }
-  if (mEventRegionsOverride & EventRegionsOverride::ForceDispatchToContent) {
-    aStream << " [force-dtc]";
-  }
-  if (mEventRegionsOverride & EventRegionsOverride::ForceEmptyHitRegion) {
-    aStream << " [force-ehr]";
-  }
 }
 
 void
 ContainerLayer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
 {
   Layer::DumpPacket(aPacket, aParent);
   // Get this layer data
   using namespace layerscope;
@@ -2239,16 +2231,22 @@ ImageLayer::DumpPacket(layerscope::Layer
 
 void
 RefLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
 {
   ContainerLayer::PrintInfo(aStream, aPrefix);
   if (0 != mId) {
     AppendToString(aStream, mId, " [id=", "]");
   }
+  if (mEventRegionsOverride & EventRegionsOverride::ForceDispatchToContent) {
+    aStream << " [force-dtc]";
+  }
+  if (mEventRegionsOverride & EventRegionsOverride::ForceEmptyHitRegion) {
+    aStream << " [force-ehr]";
+  }
 }
 
 void
 RefLayer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
 {
   Layer::DumpPacket(aPacket, aParent);
   // Get this layer data
   using namespace layerscope;
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -2310,30 +2310,16 @@ public:
    * content flag set.
    */
   static bool HasOpaqueAncestorLayer(Layer* aLayer);
 
   void SetChildrenChanged(bool aVal) {
     mChildrenChanged = aVal;
   }
 
-  void SetEventRegionsOverride(EventRegionsOverride aVal) {
-    if (mEventRegionsOverride == aVal) {
-      return;
-    }
-
-    MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) EventRegionsOverride", this));
-    mEventRegionsOverride = aVal;
-    Mutated();
-  }
-
-  EventRegionsOverride GetEventRegionsOverride() const {
-    return mEventRegionsOverride;
-  }
-
   // If |aRect| is null, the entire layer should be considered invalid for
   // compositing.
   virtual void SetInvalidCompositeRect(const gfx::IntRect* aRect) {}
 
 protected:
   friend class ReadbackProcessor;
 
   // Note that this is not virtual, and is based on the implementation of
@@ -2413,17 +2399,16 @@ protected:
   // Whether the compositor should scale to mPresShellResolution.
   bool mScaleToResolution;
   bool mUseIntermediateSurface;
   bool mSupportsComponentAlphaChildren;
   bool mMayHaveReadbackChild;
   // This is updated by ComputeDifferences. This will be true if we need to invalidate
   // the intermediate surface.
   bool mChildrenChanged;
-  EventRegionsOverride mEventRegionsOverride;
 };
 
 /**
  * A generic layer that references back to its display item.
  *
  * In order to not throw away information early in the pipeline from layout -> webrender,
  * we'd like a generic layer type that can represent all the nsDisplayItems instead of
  * creating a new layer type for each nsDisplayItem for Webrender. Another option
@@ -2833,16 +2818,35 @@ public:
       return;
     }
 
     mFirstChild = mLastChild = aLayer;
     aLayer->SetParent(this);
   }
 
   /**
+   * CONSTRUCTION PHASE ONLY
+   * Set flags that indicate how event regions in the child layer tree need
+   * to be overridden because of properties of the parent layer tree.
+   */
+  void SetEventRegionsOverride(EventRegionsOverride aVal) {
+    if (mEventRegionsOverride == aVal) {
+      return;
+    }
+
+    MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) EventRegionsOverride", this));
+    mEventRegionsOverride = aVal;
+    Mutated();
+  }
+
+  EventRegionsOverride GetEventRegionsOverride() const {
+    return mEventRegionsOverride;
+  }
+
+  /**
    * DRAWING PHASE ONLY
    * |aLayer| is the same as the argument to ConnectReferentLayer().
    */
   void DetachReferentLayer(Layer* aLayer)
   {
     mFirstChild = mLastChild = nullptr;
     aLayer->SetParent(nullptr);
   }
@@ -2856,25 +2860,28 @@ public:
    * DRAWING PHASE ONLY
    */
   virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) override;
 
   MOZ_LAYER_DECL_NAME("RefLayer", TYPE_REF)
 
 protected:
   RefLayer(LayerManager* aManager, void* aImplData)
-    : ContainerLayer(aManager, aImplData) , mId(0)
+    : ContainerLayer(aManager, aImplData)
+    , mId(0)
+    , mEventRegionsOverride(EventRegionsOverride::NoOverride)
   {}
 
   virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
 
   virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
 
   // 0 is a special value that means "no ID".
   uint64_t mId;
+  EventRegionsOverride mEventRegionsOverride;
 };
 
 void SetAntialiasingFlags(Layer* aLayer, gfx::DrawTarget* aTarget);
 
 #ifdef MOZ_DUMP_PAINTING
 void WriteSnapshotToDumpFile(Layer* aLayer, gfx::DataSourceSurface* aSurf);
 void WriteSnapshotToDumpFile(LayerManager* aManager, gfx::DataSourceSurface* aSurf);
 void WriteSnapshotToDumpFile(Compositor* aCompositor, gfx::DrawTarget* aTarget);
--- a/gfx/layers/LayersTypes.h
+++ b/gfx/layers/LayersTypes.h
@@ -198,17 +198,17 @@ struct EventRegions {
   {
     nsCString result = mHitRegion.ToString();
     result.AppendLiteral(";dispatchToContent=");
     result.Append(mDispatchToContentHitRegion.ToString());
     return result;
   }
 };
 
-// Bit flags that go on a ContainerLayer (or RefLayer) and override the
+// Bit flags that go on a RefLayer and override the
 // event regions in the entire subtree below. This is needed for propagating
 // various flags across processes since the child-process layout code doesn't
 // know about parent-process listeners or CSS rules.
 enum EventRegionsOverride {
   // The default, no flags set
   NoOverride             = 0,
   // Treat all hit regions in the subtree as dispatch-to-content
   ForceDispatchToContent = (1 << 0),
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -646,16 +646,20 @@ template<class ScrollNode> static EventR
 GetEventRegionsOverride(HitTestingTreeNode* aParent,
                        const ScrollNode& aLayer)
 {
   // Make it so that if the flag is set on the layer tree, it automatically
   // propagates to all the nodes in the corresponding subtree rooted at that
   // layer in the hit-test tree. This saves having to walk up the tree every
   // we want to see if a hit-test node is affected by this flag.
   EventRegionsOverride result = aLayer.GetEventRegionsOverride();
+  if (result != EventRegionsOverride::NoOverride) {
+    // Overrides should only ever get set for ref layers.
+    MOZ_ASSERT(aLayer.GetReferentId());
+  }
   if (aParent) {
     result |= aParent->GetEventRegionsOverride();
   }
   return result;
 }
 
 void
 APZCTreeManager::StartScrollbarDrag(const ScrollableLayerGuid& aGuid,
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -604,20 +604,16 @@ LayerTransactionParent::SetLayerAttribut
       return false;
     }
     const ContainerLayerAttributes& attrs =
       specific.get_ContainerLayerAttributes();
     containerLayer->SetPreScale(attrs.preXScale(), attrs.preYScale());
     containerLayer->SetInheritedScale(attrs.inheritedXScale(), attrs.inheritedYScale());
     containerLayer->SetScaleToResolution(attrs.scaleToResolution(),
                                          attrs.presShellResolution());
-    if (attrs.eventRegionsOverride() != containerLayer->GetEventRegionsOverride()) {
-      UpdateHitTestingTree(layer, "event regions override changed");
-      containerLayer->SetEventRegionsOverride(attrs.eventRegionsOverride());
-    }
     break;
   }
   case Specific::TColorLayerAttributes: {
     MOZ_LAYERS_LOG(("[ParentSide]   color layer"));
 
     ColorLayer* colorLayer = layer->AsColorLayer();
     if (!colorLayer) {
       return false;
--- a/gfx/layers/ipc/LayersMessages.ipdlh
+++ b/gfx/layers/ipc/LayersMessages.ipdlh
@@ -282,34 +282,31 @@ struct PaintedLayerAttributes {
 };
 struct ContainerLayerAttributes {
   float preXScale;
   float preYScale;
   float inheritedXScale;
   float inheritedYScale;
   float presShellResolution;
   bool scaleToResolution;
-  EventRegionsOverride eventRegionsOverride;
 };
 
 struct GlyphArray
 {
   LayerColor color;
   Glyph[] glyphs;
 };
 
 // XXX - Bas - Hack warning! This is using a raw pointer to a ScaledFont*
 // and won't work with e10s.
 struct TextLayerAttributes      { IntRect bounds; GlyphArray[] glyphs; uintptr_t scaledFont; };
 struct ColorLayerAttributes     { LayerColor color; IntRect bounds; };
 struct CanvasLayerAttributes    { SamplingFilter samplingFilter; IntRect bounds; };
 struct RefLayerAttributes {
   uint64_t id;
-  // TODO: Once bug 1132895 is fixed we shouldn't need to propagate the override
-  // explicitly here.
   EventRegionsOverride eventRegionsOverride;
 };
 struct ImageLayerAttributes     { SamplingFilter samplingFilter; IntSize scaleToSize; ScaleMode scaleMode; };
 struct BorderLayerAttributes {
   LayerRect rect;
   BorderColors colors;
   BorderCorners corners;
   BorderWidths widths;
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -369,18 +369,18 @@ nsDisplayRemote::nsDisplayRemote(nsDispl
 }
 
 already_AddRefed<Layer>
 nsDisplayRemote::BuildLayer(nsDisplayListBuilder* aBuilder,
                             LayerManager* aManager,
                             const ContainerLayerParameters& aContainerParameters)
 {
   RefPtr<Layer> layer = mRemoteFrame->BuildLayer(aBuilder, mFrame, aManager, this, aContainerParameters);
-  if (layer && layer->AsContainerLayer()) {
-    layer->AsContainerLayer()->SetEventRegionsOverride(mEventRegionsOverride);
+  if (layer && layer->AsRefLayer()) {
+    layer->AsRefLayer()->SetEventRegionsOverride(mEventRegionsOverride);
   }
   return layer.forget();
 }
 
 bool
 nsDisplayRemote::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
                                          mozilla::wr::IpcResourceUpdateQueue& aResources,
                                          const StackingContextHelper& aSc,