author Botond Ballo <>
Fri, 11 Sep 2015 12:52:43 -0400
changeset 294700 fbfb900230fe46a08c37aa9e4d5ac74f61228d38
parent 286904 81beff07c6dc8176f2d78d443a716259fe6be924
child 299739 91d4539e00cecb658604e021675a923c60ef3235
permissions -rw-r--r--
Bug 1202312 - Use mozilla::Function for the ContentReceivedInputBlock callback. r=kats

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

#ifndef mozilla_layers_APZEventState_h
#define mozilla_layers_APZEventState_h

#include <stdint.h>

#include "FrameMetrics.h"     // for ScrollableLayerGuid
#include "Units.h"
#include "mozilla/EventForwards.h"
#include "mozilla/Function.h"
#include "mozilla/layers/GeckoContentController.h"  // for APZStateChange
#include "mozilla/nsRefPtr.h"
#include "nsCOMPtr.h"
#include "nsISupportsImpl.h"  // for NS_INLINE_DECL_REFCOUNTING
#include "nsIWeakReferenceUtils.h"  // for nsWeakPtr

template <class> class nsCOMPtr;
class nsIDocument;
class nsIPresShell;
class nsIWidget;

namespace mozilla {
namespace layers {

class ActiveElementManager;

typedef Function<void(const ScrollableLayerGuid&,
                      uint64_t /* input block id */,
                      bool /* prevent default */)>

 * A content-side component that keeps track of state for handling APZ
 * gestures and sending APZ notifications.
class APZEventState {
  typedef GeckoContentController::APZStateChange APZStateChange;
  typedef FrameMetrics::ViewID ViewID;
  APZEventState(nsIWidget* aWidget,
                ContentReceivedInputBlockCallback&& aCallback);


  void ProcessSingleTap(const CSSPoint& aPoint,
                        Modifiers aModifiers,
                        const ScrollableLayerGuid& aGuid);
  void ProcessLongTap(const nsCOMPtr<nsIPresShell>& aUtils,
                      const CSSPoint& aPoint,
                      Modifiers aModifiers,
                      const ScrollableLayerGuid& aGuid,
                      uint64_t aInputBlockId);
  void ProcessTouchEvent(const WidgetTouchEvent& aEvent,
                         const ScrollableLayerGuid& aGuid,
                         uint64_t aInputBlockId,
                         nsEventStatus aApzResponse);
  void ProcessWheelEvent(const WidgetWheelEvent& aEvent,
                         const ScrollableLayerGuid& aGuid,
                         uint64_t aInputBlockId);
  void ProcessAPZStateChange(const nsCOMPtr<nsIDocument>& aDocument,
                             ViewID aViewId,
                             APZStateChange aChange,
                             int aArg);
  bool SendPendingTouchPreventedResponse(bool aPreventDefault);
  already_AddRefed<nsIWidget> GetWidget() const;
  nsWeakPtr mWidget;
  nsRefPtr<ActiveElementManager> mActiveElementManager;
  ContentReceivedInputBlockCallback mContentReceivedInputBlockCallback;
  bool mPendingTouchPreventedResponse;
  ScrollableLayerGuid mPendingTouchPreventedGuid;
  uint64_t mPendingTouchPreventedBlockId;
  bool mEndTouchIsClick;
  bool mTouchEndCancelled;
  int mActiveAPZTransforms;

} // namespace layers
} // namespace mozilla

#endif /* mozilla_layers_APZEventState_h */