Bug 1278480 - prevent null pointer dereference. r?bugmail.mozilla@staktrace.com draft
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Wed, 08 Jun 2016 12:02:43 +0300
changeset 376556 cdea8fed2cf84748204d7ff14d4429f07f337171
parent 375369 3e8ee3599a67edd971770af4982ad4b0fe77f073
child 523187 a9b1296878a59e91377f3d31a5523cb7bb7aac02
push id20615
push userBogdan.Postelnicu@softvision.ro
push dateWed, 08 Jun 2016 09:04:45 +0000
reviewersbugmail.mozilla
bugs1278480
milestone49.0a1
Bug 1278480 - prevent null pointer dereference. r?bugmail.mozilla@staktrace.com MozReview-Commit-ID: LhntDa5Fqqi
gfx/layers/apz/util/TouchActionHelper.cpp
--- a/gfx/layers/apz/util/TouchActionHelper.cpp
+++ b/gfx/layers/apz/util/TouchActionHelper.cpp
@@ -42,16 +42,22 @@ TouchActionHelper::UpdateAllowedBehavior
     }
   }
 }
 
 mozilla::layers::TouchBehaviorFlags
 TouchActionHelper::GetAllowedTouchBehavior(nsIWidget* aWidget, const LayoutDeviceIntPoint& aPoint)
 {
   nsView *view = nsView::GetViewFor(aWidget);
+  TouchBehaviorFlags behavior = AllowedTouchBehavior::VERTICAL_PAN | AllowedTouchBehavior::HORIZONTAL_PAN |
+                                AllowedTouchBehavior::PINCH_ZOOM | AllowedTouchBehavior::DOUBLE_TAP_ZOOM;
+
+  if (!view)
+    return behavior;
+
   nsIFrame *viewFrame = view->GetFrame();
 
   nsPoint relativePoint =
     nsLayoutUtils::GetEventCoordinatesRelativeTo(aWidget, aPoint, viewFrame);
 
   nsIFrame *target = nsLayoutUtils::GetFrameForPoint(viewFrame, relativePoint, nsLayoutUtils::IGNORE_ROOT_SCROLL_FRAME);
   nsIScrollableFrame *nearestScrollableParent = nsLayoutUtils::GetNearestScrollableFrame(target, 0);
   nsIFrame* nearestScrollableFrame = do_QueryFrame(nearestScrollableParent);
@@ -68,18 +74,16 @@ TouchActionHelper::GetAllowedTouchBehavi
 
   // Currently we support only two touch behaviors: panning and zooming.
   // For panning we walk up until we meet the first scrollable element (the element that supports panning)
   // or root element.
   // For zooming we walk up until the root element since Firefox currently supports only zooming of the
   // root frame but not the subframes.
 
   bool considerPanning = true;
-  TouchBehaviorFlags behavior = AllowedTouchBehavior::VERTICAL_PAN | AllowedTouchBehavior::HORIZONTAL_PAN |
-                                AllowedTouchBehavior::PINCH_ZOOM | AllowedTouchBehavior::DOUBLE_TAP_ZOOM;
 
   for (nsIFrame *frame = target; frame && frame->GetContent() && behavior; frame = frame->GetParent()) {
     UpdateAllowedBehavior(nsLayoutUtils::GetTouchActionFromFrame(frame), considerPanning, behavior);
 
     if (frame == nearestScrollableFrame) {
       // We met the scrollable element, after it we shouldn't consider touch-action
       // values for the purpose of panning but only for zooming.
       considerPanning = false;