Bug 1267438 - Use the layer's scrolled clip during compositor hit testing. r=mstange draft
authorBotond Ballo <botond@mozilla.com>
Wed, 04 May 2016 17:30:26 -0400
changeset 364617 cda1645407959eb39ff3e880078836d35686a8d8
parent 364616 e7f1ddd9ce664317247da1b9f569ac04e383ca47
child 364618 d3ad1e0ab2690bb9e55a593ea6d979e234e71e9f
push id17504
push userbballo@mozilla.com
push dateFri, 06 May 2016 23:44:30 +0000
reviewersmstange
bugs1267438
milestone49.0a1
Bug 1267438 - Use the layer's scrolled clip during compositor hit testing. r=mstange MozReview-Commit-ID: 2nodwaZHeWZ
gfx/layers/LayerMetricsWrapper.h
gfx/layers/Layers.cpp
gfx/layers/Layers.h
--- a/gfx/layers/LayerMetricsWrapper.h
+++ b/gfx/layers/LayerMetricsWrapper.h
@@ -367,20 +367,24 @@ public:
   }
 
   Maybe<ParentLayerIntRect> GetClipRect() const
   {
     MOZ_ASSERT(IsValid());
 
     Maybe<ParentLayerIntRect> result;
 
-    // The layer can have a clip rect, which is considered to apply
-    // only to the bottommost LayerMetrics.
+    // The layer can have a clip rect and a scrolled clip, which are considered
+    // to apply only to the bottommost LayerMetricsWrapper.
+    // TODO: These actually apply in a different coordinate space than the
+    // scroll clip of the bottommost metrics, so we shouldn't be intersecting
+    // them with the scroll clip; bug 1269537 tracks fixing this.
     if (AtBottomLayer()) {
       result = mLayer->GetClipRect();
+      result = IntersectMaybeRects(result, mLayer->GetScrolledClipRect());
     }
 
     // The scroll metadata can have a clip rect as well.
     result = IntersectMaybeRects(result, Metadata().GetClipRect());
 
     return result;
   }
 
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -846,16 +846,22 @@ Layer::CalculateScissorRect(const Render
   }
 
   if (container) {
     scissor.MoveBy(-container->GetIntermediateSurfaceRect().TopLeft());
   }
   return currentClip.Intersect(scissor);
 }
 
+Maybe<ParentLayerIntRect>
+Layer::GetScrolledClipRect() const
+{
+  return mScrolledClip ? Some(mScrolledClip->GetClipRect()) : Nothing();
+}
+
 const ScrollMetadata&
 Layer::GetScrollMetadata(uint32_t aIndex) const
 {
   MOZ_ASSERT(aIndex < GetScrollMetadataCount());
   return mScrollMetadata[aIndex];
 }
 
 const FrameMetrics&
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -1297,16 +1297,17 @@ public:
     }
   }
 
   // These getters can be used anytime.
   float GetOpacity() { return mOpacity; }
   gfx::CompositionOp GetMixBlendMode() const { return mMixBlendMode; }
   const Maybe<ParentLayerIntRect>& GetClipRect() const { return mClipRect; }
   const Maybe<LayerClip>& GetScrolledClip() const { return mScrolledClip; }
+  Maybe<ParentLayerIntRect> GetScrolledClipRect() const;
   uint32_t GetContentFlags() { return mContentFlags; }
   const gfx::IntRect& GetLayerBounds() const { return mLayerBounds; }
   const LayerIntRegion& GetVisibleRegion() const { return mVisibleRegion; }
   const ScrollMetadata& GetScrollMetadata(uint32_t aIndex) const;
   const FrameMetrics& GetFrameMetrics(uint32_t aIndex) const;
   uint32_t GetScrollMetadataCount() const { return mScrollMetadata.Length(); }
   const nsTArray<ScrollMetadata>& GetAllScrollMetadata() { return mScrollMetadata; }
   bool HasScrollableFrameMetrics() const;