Bug 1421885 - Part 2: Don't compute APZ touch-action regions on platforms that don't support touch gestures. r=kats
authorMatt Woodrow <mwoodrow@mozilla.com>
Tue, 10 Jul 2018 15:20:38 +1200
changeset 425555 0c55071115c23017c733aa421862beda1e6af20e
parent 425554 b01200eb6ad4dccd9266a71c29f57a0c255737cd
child 425577 a675c5d7eb76887a3e4b24548d621c9cc05a1545
child 425578 641b02da59616e7f83213eb65a12514cf58b059e
push id34258
push usertoros@mozilla.com
push dateTue, 10 Jul 2018 09:43:53 +0000
treeherdermozilla-central@0c55071115c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1421885
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1421885 - Part 2: Don't compute APZ touch-action regions on platforms that don't support touch gestures. r=kats MozReview-Commit-ID: DA5lj6BXh92
layout/generic/nsFrame.cpp
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -103,16 +103,17 @@
 #include "mozilla/EventStateManager.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/ServoStyleSet.h"
 #include "mozilla/ServoStyleSetInlines.h"
 #include "mozilla/css/ImageLoader.h"
+#include "mozilla/dom/TouchEvent.h"
 #include "mozilla/gfx/Tools.h"
 #include "mozilla/layers/WebRenderUserData.h"
 #include "nsPrintfCString.h"
 #include "ActiveLayerTracker.h"
 
 #include "nsITheme.h"
 #include "nsThemeConstants.h"
 
@@ -11252,64 +11253,70 @@ nsIFrame::GetCompositorHitTestInfo(nsDis
     // If the frame is a plugin frame and wants to handle wheel events as
     // default action, we should add the frame to dispatch-to-content region.
     nsPluginFrame* pluginFrame = do_QueryFrame(this);
     if (pluginFrame && pluginFrame->WantsToHandleWheelEventAsDefaultAction()) {
       result |= CompositorHitTestInfo::eDispatchToContent;
     }
   }
 
-  // Inherit the touch-action flags from the parent, if there is one. We do this
-  // because of how the touch-action on a frame combines the touch-action from
-  // ancestor DOM elements. Refer to the documentation in TouchActionHelper.cpp
-  // for details; this code is meant to be equivalent to that code, but woven
-  // into the top-down recursive display list building process.
-  CompositorHitTestInfo inheritedTouchAction = CompositorHitTestInfo::eInvisibleToHitTest;
-  if (nsDisplayCompositorHitTestInfo* parentInfo = aBuilder->GetCompositorHitTestInfo()) {
-    inheritedTouchAction = (parentInfo->HitTestInfo() & CompositorHitTestInfo::eTouchActionMask);
-  }
-
-  nsIFrame* touchActionFrame = this;
-  if (nsIScrollableFrame* scrollFrame = nsLayoutUtils::GetScrollableFrameFor(this)) {
-    touchActionFrame = do_QueryFrame(scrollFrame);
-    // On scrollframes, stop inheriting the pan-x and pan-y flags; instead,
-    // reset them back to zero to allow panning on the scrollframe unless we
-    // encounter an element that disables it that's inside the scrollframe.
-    // This is equivalent to the |considerPanning| variable in
-    // TouchActionHelper.cpp, but for a top-down traversal.
-    CompositorHitTestInfo panMask = CompositorHitTestInfo::eTouchActionPanXDisabled
-                                  | CompositorHitTestInfo::eTouchActionPanYDisabled;
-    inheritedTouchAction &= ~panMask;
-  }
-
-  result |= inheritedTouchAction;
-
-  const uint32_t touchAction = nsLayoutUtils::GetTouchActionFromFrame(touchActionFrame);
-  // The CSS allows the syntax auto | none | [pan-x || pan-y] | manipulation
-  // so we can eliminate some combinations of things.
-  if (touchAction == NS_STYLE_TOUCH_ACTION_AUTO) {
-    // nothing to do
-  } else if (touchAction & NS_STYLE_TOUCH_ACTION_MANIPULATION) {
-    result |= CompositorHitTestInfo::eTouchActionDoubleTapZoomDisabled;
-  } else {
-    // This path handles the cases none | [pan-x || pan-y] and so both
-    // double-tap and pinch zoom are disabled in here.
-    result |= CompositorHitTestInfo::eTouchActionPinchZoomDisabled
-            | CompositorHitTestInfo::eTouchActionDoubleTapZoomDisabled;
-
-    if (!(touchAction & NS_STYLE_TOUCH_ACTION_PAN_X)) {
-      result |= CompositorHitTestInfo::eTouchActionPanXDisabled;
-    }
-    if (!(touchAction & NS_STYLE_TOUCH_ACTION_PAN_Y)) {
-      result |= CompositorHitTestInfo::eTouchActionPanYDisabled;
-    }
-    if (touchAction & NS_STYLE_TOUCH_ACTION_NONE) {
-      // all the touch-action disabling flags will already have been set above
-      MOZ_ASSERT((result & CompositorHitTestInfo::eTouchActionMask)
-               == CompositorHitTestInfo::eTouchActionMask);
+  nsIDocShell* docShell = nullptr;
+  if (PresShell()->GetDocument()) {
+    docShell = PresShell()->GetDocument()->GetDocShell();
+  }
+  if (dom::TouchEvent::PrefEnabled(docShell)) {
+    // Inherit the touch-action flags from the parent, if there is one. We do this
+    // because of how the touch-action on a frame combines the touch-action from
+    // ancestor DOM elements. Refer to the documentation in TouchActionHelper.cpp
+    // for details; this code is meant to be equivalent to that code, but woven
+    // into the top-down recursive display list building process.
+    CompositorHitTestInfo inheritedTouchAction = CompositorHitTestInfo::eInvisibleToHitTest;
+    if (nsDisplayCompositorHitTestInfo* parentInfo = aBuilder->GetCompositorHitTestInfo()) {
+      inheritedTouchAction = (parentInfo->HitTestInfo() & CompositorHitTestInfo::eTouchActionMask);
+    }
+
+    nsIFrame* touchActionFrame = this;
+    if (nsIScrollableFrame* scrollFrame = nsLayoutUtils::GetScrollableFrameFor(this)) {
+      touchActionFrame = do_QueryFrame(scrollFrame);
+      // On scrollframes, stop inheriting the pan-x and pan-y flags; instead,
+      // reset them back to zero to allow panning on the scrollframe unless we
+      // encounter an element that disables it that's inside the scrollframe.
+      // This is equivalent to the |considerPanning| variable in
+      // TouchActionHelper.cpp, but for a top-down traversal.
+      CompositorHitTestInfo panMask = CompositorHitTestInfo::eTouchActionPanXDisabled
+                                    | CompositorHitTestInfo::eTouchActionPanYDisabled;
+      inheritedTouchAction &= ~panMask;
+    }
+
+    result |= inheritedTouchAction;
+
+    const uint32_t touchAction = nsLayoutUtils::GetTouchActionFromFrame(touchActionFrame);
+    // The CSS allows the syntax auto | none | [pan-x || pan-y] | manipulation
+    // so we can eliminate some combinations of things.
+    if (touchAction == NS_STYLE_TOUCH_ACTION_AUTO) {
+      // nothing to do
+    } else if (touchAction & NS_STYLE_TOUCH_ACTION_MANIPULATION) {
+      result |= CompositorHitTestInfo::eTouchActionDoubleTapZoomDisabled;
+    } else {
+      // This path handles the cases none | [pan-x || pan-y] and so both
+      // double-tap and pinch zoom are disabled in here.
+      result |= CompositorHitTestInfo::eTouchActionPinchZoomDisabled
+              | CompositorHitTestInfo::eTouchActionDoubleTapZoomDisabled;
+
+      if (!(touchAction & NS_STYLE_TOUCH_ACTION_PAN_X)) {
+        result |= CompositorHitTestInfo::eTouchActionPanXDisabled;
+      }
+      if (!(touchAction & NS_STYLE_TOUCH_ACTION_PAN_Y)) {
+        result |= CompositorHitTestInfo::eTouchActionPanYDisabled;
+      }
+      if (touchAction & NS_STYLE_TOUCH_ACTION_NONE) {
+        // all the touch-action disabling flags will already have been set above
+        MOZ_ASSERT((result & CompositorHitTestInfo::eTouchActionMask)
+                 == CompositorHitTestInfo::eTouchActionMask);
+      }
     }
   }
 
   const Maybe<ScrollDirection> scrollDirection = aBuilder->GetCurrentScrollbarDirection();
   if (scrollDirection.isSome()) {
     if (GetContent()->IsXULElement(nsGkAtoms::thumb)) {
       const bool thumbGetsLayer = aBuilder->GetCurrentScrollbarTarget() !=
           layers::FrameMetrics::NULL_SCROLL_ID;