Bug 1278480 - prevent null pointer dereference. r?kats
MozReview-Commit-ID: LhntDa5Fqqi
--- a/gfx/layers/apz/util/TouchActionHelper.cpp
+++ b/gfx/layers/apz/util/TouchActionHelper.cpp
@@ -42,16 +42,23 @@ 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 +75,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;