Bug 1267438 - Use the layer's scrolled clip during compositor hit testing. r=mstange
MozReview-Commit-ID: 2nodwaZHeWZ
--- 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;