mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1257288 - Improve the APZ gtest infrastructure to make writing multi-FrameMetrics tests easier. r=kats
MozReview-Commit-ID: L9QN0FhLwRU --HG-- extra : rebase_source : 8b5a5fca7f26c78b53280647a88de285a2208fd8
This commit is contained in:
parent
a278e42605
commit
ff18651ad3
@ -57,8 +57,10 @@ protected:
|
||||
RefPtr<TestAPZCTreeManager> manager;
|
||||
|
||||
protected:
|
||||
static void SetScrollableFrameMetrics(Layer* aLayer, FrameMetrics::ViewID aScrollId,
|
||||
CSSRect aScrollableRect = CSSRect(-1, -1, -1, -1)) {
|
||||
static ScrollMetadata BuildScrollMetadata(FrameMetrics::ViewID aScrollId,
|
||||
const CSSRect& aScrollableRect,
|
||||
const ParentLayerRect& aCompositionBounds)
|
||||
{
|
||||
ScrollMetadata metadata;
|
||||
FrameMetrics& metrics = metadata.GetMetrics();
|
||||
metrics.SetScrollId(aScrollId);
|
||||
@ -66,26 +68,43 @@ protected:
|
||||
if (aScrollId == FrameMetrics::START_SCROLL_ID) {
|
||||
metrics.SetIsLayersIdRoot(true);
|
||||
}
|
||||
IntRect layerBound = aLayer->GetVisibleRegion().ToUnknownRegion().GetBounds();
|
||||
metrics.SetCompositionBounds(ParentLayerRect(layerBound.x, layerBound.y,
|
||||
layerBound.width, layerBound.height));
|
||||
metrics.SetCompositionBounds(aCompositionBounds);
|
||||
metrics.SetScrollableRect(aScrollableRect);
|
||||
metrics.SetScrollOffset(CSSPoint(0, 0));
|
||||
metrics.SetPageScrollAmount(LayoutDeviceIntSize(50, 100));
|
||||
metrics.SetAllowVerticalScrollWithWheel(true);
|
||||
aLayer->SetScrollMetadata(metadata);
|
||||
aLayer->SetClipRect(Some(ViewAs<ParentLayerPixel>(layerBound)));
|
||||
if (!aScrollableRect.IsEqualEdges(CSSRect(-1, -1, -1, -1))) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
static void SetEventRegionsBasedOnBottommostMetrics(Layer* aLayer)
|
||||
{
|
||||
const FrameMetrics& metrics = aLayer->GetScrollMetadata(0).GetMetrics();
|
||||
CSSRect scrollableRect = metrics.GetScrollableRect();
|
||||
if (!scrollableRect.IsEqualEdges(CSSRect(-1, -1, -1, -1))) {
|
||||
// The purpose of this is to roughly mimic what layout would do in the
|
||||
// case of a scrollable frame with the event regions and clip. This lets
|
||||
// us exercise the hit-testing code in APZCTreeManager
|
||||
EventRegions er = aLayer->GetEventRegions();
|
||||
IntRect scrollRect = RoundedToInt(aScrollableRect * metrics.LayersPixelsPerCSSPixel()).ToUnknownRect();
|
||||
er.mHitRegion = nsIntRegion(IntRect(layerBound.TopLeft(), scrollRect.Size()));
|
||||
IntRect scrollRect = RoundedToInt(
|
||||
scrollableRect * metrics.LayersPixelsPerCSSPixel()).ToUnknownRect();
|
||||
er.mHitRegion = nsIntRegion(IntRect(
|
||||
RoundedToInt(metrics.GetCompositionBounds().TopLeft().ToUnknownPoint()),
|
||||
scrollRect.Size()));
|
||||
aLayer->SetEventRegions(er);
|
||||
}
|
||||
}
|
||||
|
||||
static void SetScrollableFrameMetrics(Layer* aLayer, FrameMetrics::ViewID aScrollId,
|
||||
CSSRect aScrollableRect = CSSRect(-1, -1, -1, -1)) {
|
||||
ParentLayerIntRect compositionBounds = ViewAs<ParentLayerPixel>(
|
||||
aLayer->GetVisibleRegion().ToUnknownRegion().GetBounds());
|
||||
ScrollMetadata metadata = BuildScrollMetadata(aScrollId, aScrollableRect,
|
||||
ParentLayerRect(compositionBounds));
|
||||
aLayer->SetScrollMetadata(metadata);
|
||||
aLayer->SetClipRect(Some(compositionBounds));
|
||||
SetEventRegionsBasedOnBottommostMetrics(aLayer);
|
||||
}
|
||||
|
||||
void SetScrollHandoff(Layer* aChild, Layer* aParent) {
|
||||
ScrollMetadata metadata = aChild->GetScrollMetadata(0);
|
||||
metadata.GetMetrics().SetScrollParentId(aParent->GetFrameMetrics(0).GetScrollId());
|
||||
@ -97,6 +116,11 @@ protected:
|
||||
return (TestAsyncPanZoomController*)aLayer->GetAsyncPanZoomController(0);
|
||||
}
|
||||
|
||||
static TestAsyncPanZoomController* ApzcOf(Layer* aLayer, uint32_t aIndex) {
|
||||
EXPECT_LT(aIndex, aLayer->GetScrollMetadataCount());
|
||||
return (TestAsyncPanZoomController*)aLayer->GetAsyncPanZoomController(aIndex);
|
||||
}
|
||||
|
||||
void CreateSimpleScrollingLayer() {
|
||||
const char* layerTreeSyntax = "t";
|
||||
nsIntRegion layerVisibleRegion[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user