Bug 1257288 - Have APZ hit testing respect scroll clips. r=kats

MozReview-Commit-ID: AZU5TEMvySG

--HG--
extra : rebase_source : f435fa574a52bdf90690c1ede739f248d2f0d99f
This commit is contained in:
Botond Ballo 2016-04-20 18:38:25 -04:00
parent ff18651ad3
commit 54e53e75c4
2 changed files with 50 additions and 4 deletions

View File

@ -366,17 +366,22 @@ public:
return region;
}
const Maybe<ParentLayerIntRect>& GetClipRect() const
Maybe<ParentLayerIntRect> GetClipRect() const
{
MOZ_ASSERT(IsValid());
static const Maybe<ParentLayerIntRect> sNoClipRect = Nothing();
Maybe<ParentLayerIntRect> result;
// The layer can have a clip rect, which is considered to apply
// only to the bottommost LayerMetrics.
if (AtBottomLayer()) {
return mLayer->GetClipRect();
result = mLayer->GetClipRect();
}
return sNoClipRect;
// The scroll metadata can have a clip rect as well.
result = IntersectMaybeRects(result, Metadata().GetClipRect());
return result;
}
float GetPresShellResolution() const

View File

@ -535,3 +535,44 @@ TEST_F(APZHitTestingTester, Bug1148350) {
check.Call("Tapped with interleaved transform");
}
TEST_F(APZHitTestingTester, HitTestingRespectsScrollClip_Bug1257288) {
// Create the layer tree.
const char* layerTreeSyntax = "c(tt)";
// LayerID 0 12
nsIntRegion layerVisibleRegion[] = {
nsIntRegion(IntRect(0,0,200,200)),
nsIntRegion(IntRect(0,0,200,200)),
nsIntRegion(IntRect(0,0,200,100))
};
root = CreateLayerTree(layerTreeSyntax, layerVisibleRegion, nullptr, lm, layers);
// Add root scroll metadata to the first painted layer.
SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID, CSSRect(0,0,200,200));
// Add root and subframe scroll metadata to the second painted layer.
// Give the subframe metadata a scroll clip corresponding to the subframe's
// composition bounds.
// Importantly, give the layer a layer clip which leaks outside of the
// subframe's composition bounds.
ScrollMetadata rootMetadata = BuildScrollMetadata(
FrameMetrics::START_SCROLL_ID, CSSRect(0,0,200,200),
ParentLayerRect(0,0,200,200));
ScrollMetadata subframeMetadata = BuildScrollMetadata(
FrameMetrics::START_SCROLL_ID + 1, CSSRect(0,0,200,200),
ParentLayerRect(0,0,200,100));
subframeMetadata.SetClipRect(Some(ParentLayerIntRect(0,0,200,100)));
layers[2]->SetScrollMetadata({subframeMetadata, rootMetadata});
layers[2]->SetClipRect(Some(ParentLayerIntRect(0,0,200,200)));
SetEventRegionsBasedOnBottommostMetrics(layers[2]);
// Build the hit testing tree.
ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
// Pan on a region that's inside layers[2]'s layer clip, but outside
// its subframe metadata's scroll clip.
Pan(manager, mcc, 120, 110);
// Test that the subframe hasn't scrolled.
EXPECT_EQ(CSSPoint(0,0), ApzcOf(layers[2], 0)->GetFrameMetrics().GetScrollOffset());
}