Bug 1422950 - Move the area calculation to the display item constructor to hit the ToReferenceFrame fastpath. r=mstange

MozReview-Commit-ID: 6ROpprO26JV
This commit is contained in:
Kartikaya Gupta
2017-12-04 15:47:29 -05:00
parent 00d0b6cf49
commit 2075a2d6da
3 changed files with 32 additions and 32 deletions

View File

@@ -3650,8 +3650,8 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder,
CompositorHitTestInfo info = CompositorHitTestInfo::eVisibleToHitTest
| CompositorHitTestInfo::eDispatchToContent;
nsDisplayCompositorHitTestInfo* hitInfo =
new (aBuilder) nsDisplayCompositorHitTestInfo(aBuilder, mScrolledFrame, info, 1);
hitInfo->SetArea(mScrollPort + aBuilder->ToReferenceFrame(mOuter));
new (aBuilder) nsDisplayCompositorHitTestInfo(aBuilder, mScrolledFrame, info, 1,
Some(mScrollPort + aBuilder->ToReferenceFrame(mOuter)));
AppendInternalItemToTop(scrolledContent, hitInfo, zIndex);
}
if (aBuilder->IsBuildingLayerEventRegions()) {

View File

@@ -4944,7 +4944,8 @@ nsDisplayEventReceiver::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder&
nsDisplayCompositorHitTestInfo::nsDisplayCompositorHitTestInfo(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
mozilla::gfx::CompositorHitTestInfo aHitTestInfo,
uint32_t aIndex)
uint32_t aIndex,
const mozilla::Maybe<nsRect>& aArea)
: nsDisplayEventReceiver(aBuilder, aFrame)
, mHitTestInfo(aHitTestInfo)
, mIndex(aIndex)
@@ -4962,12 +4963,29 @@ nsDisplayCompositorHitTestInfo::nsDisplayCompositorHitTestInfo(nsDisplayListBuil
MOZ_ASSERT(mHitTestInfo & CompositorHitTestInfo::eScrollbar);
mScrollTarget = Some(aBuilder->GetCurrentScrollbarTarget());
}
}
void
nsDisplayCompositorHitTestInfo::SetArea(const nsRect& aArea)
{
mArea = Some(aArea);
if (aArea.isSome()) {
mArea = *aArea;
} else {
nsIScrollableFrame* scrollFrame = nsLayoutUtils::GetScrollableFrameFor(mFrame);
if (scrollFrame) {
// If the frame is content of a scrollframe, then we need to pick up the
// area corresponding to the overflow rect as well. Otherwise the parts of
// the overflow that are not occupied by descendants get skipped and the
// APZ code sends touch events to the content underneath instead.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1127773#c15.
mArea = mFrame->GetScrollableOverflowRect();
} else {
mArea = nsRect(nsPoint(0, 0), mFrame->GetSize());
}
// Note that it's important to do this call to ToReferenceFrame here in the
// nsDisplayCompositorHitTestInfo constructor, because then we'll hit the good
// fast path (because aBuilder will already have the info we want cached).
// This is as opposed to, say, calling it in CreateWebRenderCommands where
// we would not hit the fast path.
mArea += aBuilder->ToReferenceFrame(mFrame);
}
}
bool
@@ -4977,31 +4995,13 @@ nsDisplayCompositorHitTestInfo::CreateWebRenderCommands(mozilla::wr::DisplayList
mozilla::layers::WebRenderLayerManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder)
{
if (mArea.isNothing()) {
nsRect borderBox;
nsIScrollableFrame* scrollFrame = nsLayoutUtils::GetScrollableFrameFor(mFrame);
if (scrollFrame) {
// If the frame is content of a scrollframe, then we need to pick up the
// area corresponding to the overflow rect as well. Otherwise the parts of
// the overflow that are not occupied by descendants get skipped and the
// APZ code sends touch events to the content underneath instead.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1127773#c15.
borderBox = mFrame->GetScrollableOverflowRect();
} else {
borderBox = nsRect(nsPoint(0, 0), mFrame->GetSize());
}
if (borderBox.IsEmpty()) {
return true;
}
mArea = Some(borderBox + aDisplayListBuilder->ToReferenceFrame(mFrame));
if (mArea.IsEmpty()) {
return true;
}
MOZ_ASSERT(mArea.isSome());
wr::LayoutRect rect = aSc.ToRelativeLayoutRect(
LayoutDeviceRect::FromAppUnits(
*mArea,
mArea,
mFrame->PresContext()->AppUnitsPerDevPixel()));
// XXX: eventually this scrollId computation and the SetHitTestInfo

View File

@@ -4358,7 +4358,8 @@ class nsDisplayCompositorHitTestInfo : public nsDisplayEventReceiver {
public:
nsDisplayCompositorHitTestInfo(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
mozilla::gfx::CompositorHitTestInfo aHitTestInfo,
uint32_t aIndex = 0);
uint32_t aIndex = 0,
const mozilla::Maybe<nsRect>& aArea = mozilla::Nothing());
#ifdef NS_BUILD_REFCNT_LOGGING
virtual ~nsDisplayCompositorHitTestInfo()
@@ -4368,7 +4369,6 @@ public:
#endif
mozilla::gfx::CompositorHitTestInfo HitTestInfo() const { return mHitTestInfo; }
void SetArea(const nsRect& aArea);
bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
@@ -4385,7 +4385,7 @@ public:
private:
mozilla::gfx::CompositorHitTestInfo mHitTestInfo;
mozilla::Maybe<mozilla::layers::FrameMetrics::ViewID> mScrollTarget;
mozilla::Maybe<nsRect> mArea;
nsRect mArea;
uint32_t mIndex;
mozilla::Maybe<int32_t> mOverrideZIndex;
};