Bug 1287576 - Extract a helper method to update a frame to the touch target document's root frame. No functional changes. r?botond
MozReview-Commit-ID: Inj3OG8BWWC
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -549,39 +549,44 @@ GetRootDocumentElementFor(nsIWidget* aWi
if (nsIPresShell* shell = view->GetPresShell()) {
MOZ_ASSERT(shell->GetDocument());
return shell->GetDocument()->GetDocumentElement();
}
}
return nullptr;
}
+static nsIFrame*
+UpdateRootFrameForTouchTargetDocument(nsIFrame* aRootFrame)
+{
+#if defined(MOZ_ANDROID_APZ)
+ // Re-target so that the hit test is performed relative to the frame for the
+ // Root Content Document instead of the Root Document which are different in
+ // Android. See bug 1229752 comment 16 for an explanation of why this is necessary.
+ if (nsIDocument* doc = aRootFrame->PresContext()->PresShell()->GetTouchEventTargetDocument()) {
+ if (nsIPresShell* shell = doc->GetShell()) {
+ if (nsIFrame* frame = shell->GetRootFrame()) {
+ return frame;
+ }
+ }
+ }
+#endif
+ return aRootFrame;
+}
+
// Determine the scrollable target frame for the given point and add it to
// the target list. If the frame doesn't have a displayport, set one.
// Return whether or not a displayport was set.
static bool
PrepareForSetTargetAPZCNotification(nsIWidget* aWidget,
const ScrollableLayerGuid& aGuid,
nsIFrame* aRootFrame,
const LayoutDeviceIntPoint& aRefPoint,
nsTArray<ScrollableLayerGuid>* aTargets)
{
-#if defined(MOZ_ANDROID_APZ)
- // Re-target so that the hit test is performed relative to the frame for the
- // Root Content Document instead of the Root Document which are different in
- // Android. See bug 1229752 comment 16 for an explanation of why this is necessary.
- if (nsIDocument* doc = aRootFrame->PresContext()->PresShell()->GetTouchEventTargetDocument()) {
- if (nsIPresShell* shell = doc->GetShell()) {
- if(nsIFrame* frame = shell->GetRootFrame()) {
- aRootFrame = frame;
- }
- }
- }
-#endif
-
ScrollableLayerGuid guid(aGuid.mLayersId, 0, FrameMetrics::NULL_SCROLL_ID);
nsPoint point =
nsLayoutUtils::GetEventCoordinatesRelativeTo(aWidget, aRefPoint, aRootFrame);
nsIFrame* target =
nsLayoutUtils::GetFrameForPoint(aRootFrame, point, nsLayoutUtils::IGNORE_ROOT_SCROLL_FRAME);
nsIScrollableFrame* scrollAncestor = target
? nsLayoutUtils::GetAsyncScrollableAncestorFrame(target)
: aRootFrame->PresContext()->PresShell()->GetRootScrollFrameAsScrollable();
@@ -734,16 +739,18 @@ APZCCallbackHelper::SendSetTargetAPZCNot
// race the original confirmation (which needs to go through a layers
// transaction).
APZCCH_LOG("Not resending target APZC confirmation for input block %" PRIu64 "\n", aInputBlockId);
return;
}
sLastTargetAPZCNotificationInputBlock = aInputBlockId;
if (nsIPresShell* shell = aDocument->GetShell()) {
if (nsIFrame* rootFrame = shell->GetRootFrame()) {
+ rootFrame = UpdateRootFrameForTouchTargetDocument(rootFrame);
+
bool waitForRefresh = false;
nsTArray<ScrollableLayerGuid> targets;
if (const WidgetTouchEvent* touchEvent = aEvent.AsTouchEvent()) {
for (size_t i = 0; i < touchEvent->mTouches.Length(); i++) {
waitForRefresh |= PrepareForSetTargetAPZCNotification(aWidget, aGuid,
rootFrame, touchEvent->mTouches[i]->mRefPoint, &targets);
}