From 4ba7371861901f55627f7acd073eba5a13ace777 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Mon, 25 Jul 2016 20:35:03 -0400 Subject: [PATCH] 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: 3SRxAfTeMR --- gfx/layers/apz/util/APZCCallbackHelper.cpp | 33 +++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index cf251387b266..9fca092443e4 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -554,6 +554,24 @@ GetRootDocumentElementFor(nsIWidget* aWidget) 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. @@ -564,19 +582,6 @@ PrepareForSetTargetAPZCNotification(nsIWidget* aWidget, const LayoutDeviceIntPoint& aRefPoint, nsTArray* 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); @@ -739,6 +744,8 @@ APZCCallbackHelper::SendSetTargetAPZCNotification(nsIWidget* aWidget, sLastTargetAPZCNotificationInputBlock = aInputBlockId; if (nsIPresShell* shell = aDocument->GetShell()) { if (nsIFrame* rootFrame = shell->GetRootFrame()) { + rootFrame = UpdateRootFrameForTouchTargetDocument(rootFrame); + bool waitForRefresh = false; nsTArray targets;