LCOV - code coverage report
Current view: top level - gfx/layers/apz/public - IAPZCTreeManager.h (source / functions) Hit Total Coverage
Test: output.info Lines: 2 3 66.7 %
Date: 2017-07-14 16:53:18 Functions: 3 5 60.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=99: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_layers_IAPZCTreeManager_h
       8             : #define mozilla_layers_IAPZCTreeManager_h
       9             : 
      10             : #include <stdint.h>                     // for uint64_t, uint32_t
      11             : 
      12             : #include "FrameMetrics.h"               // for FrameMetrics, etc
      13             : #include "mozilla/EventForwards.h"      // for WidgetInputEvent, nsEventStatus
      14             : #include "mozilla/layers/APZUtils.h"    // for HitTestResult
      15             : #include "nsTArrayForwardDeclare.h"     // for nsTArray, nsTArray_Impl, etc
      16             : #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
      17             : #include "Units.h"                      // for CSSPoint, CSSRect, etc
      18             : 
      19             : namespace mozilla {
      20             : class InputData;
      21             : 
      22             : namespace layers {
      23             : 
      24             : class KeyboardMap;
      25             : 
      26             : enum AllowedTouchBehavior {
      27             :   NONE =               0,
      28             :   VERTICAL_PAN =       1 << 0,
      29             :   HORIZONTAL_PAN =     1 << 1,
      30             :   PINCH_ZOOM =         1 << 2,
      31             :   DOUBLE_TAP_ZOOM =    1 << 3,
      32             :   UNKNOWN =            1 << 4
      33             : };
      34             : 
      35             : enum ZoomToRectBehavior : uint32_t {
      36             :   DEFAULT_BEHAVIOR =   0,
      37             :   DISABLE_ZOOM_OUT =   1 << 0,
      38             :   PAN_INTO_VIEW_ONLY = 1 << 1,
      39             :   ONLY_ZOOM_TO_DEFAULT_SCALE  = 1 << 2
      40             : };
      41             : 
      42             : class AsyncDragMetrics;
      43             : 
      44           2 : class IAPZCTreeManager {
      45          17 :   NS_INLINE_DECL_THREADSAFE_VIRTUAL_REFCOUNTING(IAPZCTreeManager)
      46             : 
      47             : public:
      48             : 
      49             :   /**
      50             :    * General handler for incoming input events. Manipulates the frame metrics
      51             :    * based on what type of input it is. For example, a PinchGestureEvent will
      52             :    * cause scaling. This should only be called externally to this class, and
      53             :    * must be called on the controller thread.
      54             :    *
      55             :    * This function transforms |aEvent| to have its coordinates in DOM space.
      56             :    * This is so that the event can be passed through the DOM and content can
      57             :    * handle them. The event may need to be converted to a WidgetInputEvent
      58             :    * by the caller if it wants to do this.
      59             :    *
      60             :    * The following values may be returned by this function:
      61             :    * nsEventStatus_eConsumeNoDefault is returned to indicate the
      62             :    *   APZ is consuming this event and the caller should discard the event with
      63             :    *   extreme prejudice. The exact scenarios under which this is returned is
      64             :    *   implementation-dependent and may vary.
      65             :    * nsEventStatus_eIgnore is returned to indicate that the APZ code didn't
      66             :    *   use this event. This might be because it was directed at a point on
      67             :    *   the screen where there was no APZ, or because the thing the user was
      68             :    *   trying to do was not allowed. (For example, attempting to pan a
      69             :    *   non-pannable document).
      70             :    * nsEventStatus_eConsumeDoDefault is returned to indicate that the APZ
      71             :    *   code may have used this event to do some user-visible thing. Note that
      72             :    *   in some cases CONSUMED is returned even if the event was NOT used. This
      73             :    *   is because we cannot always know at the time of event delivery whether
      74             :    *   the event will be used or not. So we err on the side of sending
      75             :    *   CONSUMED when we are uncertain.
      76             :    *
      77             :    * @param aEvent input event object; is modified in-place
      78             :    * @param aOutTargetGuid returns the guid of the apzc this event was
      79             :    * delivered to. May be null.
      80             :    * @param aOutInputBlockId returns the id of the input block that this event
      81             :    * was added to, if that was the case. May be null.
      82             :    */
      83             :   virtual nsEventStatus ReceiveInputEvent(
      84             :       InputData& aEvent,
      85             :       ScrollableLayerGuid* aOutTargetGuid,
      86             :       uint64_t* aOutInputBlockId) = 0;
      87             : 
      88             :   /**
      89             :    * WidgetInputEvent handler. Transforms |aEvent| (which is assumed to be an
      90             :    * already-existing instance of an WidgetInputEvent which may be an
      91             :    * WidgetTouchEvent) to have its coordinates in DOM space. This is so that the
      92             :    * event can be passed through the DOM and content can handle them.
      93             :    *
      94             :    * NOTE: Be careful of invoking the WidgetInputEvent variant. This can only be
      95             :    * called on the main thread. See widget/InputData.h for more information on
      96             :    * why we have InputData and WidgetInputEvent separated. If this function is
      97             :    * used, the controller thread must be the main thread, or undefined behaviour
      98             :    * may occur.
      99             :    * NOTE: On unix, mouse events are treated as touch and are forwarded
     100             :    * to the appropriate apz as such.
     101             :    *
     102             :    * See documentation for other ReceiveInputEvent above.
     103             :    */
     104             :   nsEventStatus ReceiveInputEvent(
     105             :       WidgetInputEvent& aEvent,
     106             :       ScrollableLayerGuid* aOutTargetGuid,
     107             :       uint64_t* aOutInputBlockId);
     108             : 
     109             :   /**
     110             :    * Set the keyboard shortcuts to use for translating keyboard events.
     111             :    */
     112             :   virtual void SetKeyboardMap(const KeyboardMap& aKeyboardMap) = 0;
     113             : 
     114             :   /**
     115             :    * Kicks an animation to zoom to a rect. This may be either a zoom out or zoom
     116             :    * in. The actual animation is done on the compositor thread after being set
     117             :    * up. |aRect| must be given in CSS pixels, relative to the document.
     118             :    * |aFlags| is a combination of the ZoomToRectBehavior enum values.
     119             :    */
     120             :   virtual void ZoomToRect(
     121             :       const ScrollableLayerGuid& aGuid,
     122             :       const CSSRect& aRect,
     123             :       const uint32_t aFlags = DEFAULT_BEHAVIOR) = 0;
     124             : 
     125             :   /**
     126             :    * If we have touch listeners, this should always be called when we know
     127             :    * definitively whether or not content has preventDefaulted any touch events
     128             :    * that have come in. If |aPreventDefault| is true, any touch events in the
     129             :    * queue will be discarded. This function must be called on the controller
     130             :    * thread.
     131             :    */
     132             :   virtual void ContentReceivedInputBlock(
     133             :       uint64_t aInputBlockId,
     134             :       bool aPreventDefault) = 0;
     135             : 
     136             :   /**
     137             :    * When the event regions code is enabled, this function should be invoked to
     138             :    * to confirm the target of the input block. This is only needed in cases
     139             :    * where the initial input event of the block hit a dispatch-to-content region
     140             :    * but is safe to call for all input blocks. This function should always be
     141             :    * invoked on the controller thread.
     142             :    * The different elements in the array of targets correspond to the targets
     143             :    * for the different touch points. In the case where the touch point has no
     144             :    * target, or the target is not a scrollable frame, the target's |mScrollId|
     145             :    * should be set to FrameMetrics::NULL_SCROLL_ID.
     146             :    */
     147             :   virtual void SetTargetAPZC(
     148             :       uint64_t aInputBlockId,
     149             :       const nsTArray<ScrollableLayerGuid>& aTargets) = 0;
     150             : 
     151             :   /**
     152             :    * Updates any zoom constraints contained in the <meta name="viewport"> tag.
     153             :    * If the |aConstraints| is Nothing() then previously-provided constraints for
     154             :    * the given |aGuid| are cleared.
     155             :    */
     156             :   virtual void UpdateZoomConstraints(
     157             :       const ScrollableLayerGuid& aGuid,
     158             :       const Maybe<ZoomConstraints>& aConstraints) = 0;
     159             : 
     160             :   /**
     161             :    * Cancels any currently running animation. Note that all this does is set the
     162             :    * state of the AsyncPanZoomController back to NOTHING, but it is the
     163             :    * animation's responsibility to check this before advancing.
     164             :    */
     165             :   virtual void CancelAnimation(const ScrollableLayerGuid &aGuid) = 0;
     166             : 
     167             :   virtual void SetDPI(float aDpiValue) = 0;
     168             : 
     169             :   /**
     170             :    * Sets allowed touch behavior values for current touch-session for specific
     171             :    * input block (determined by aInputBlock).
     172             :    * Should be invoked by the widget. Each value of the aValues arrays
     173             :    * corresponds to the different touch point that is currently active.
     174             :    * Must be called after receiving the TOUCH_START event that starts the
     175             :    * touch-session.
     176             :    * This must be called on the controller thread.
     177             :    */
     178             :   virtual void SetAllowedTouchBehavior(
     179             :       uint64_t aInputBlockId,
     180             :       const nsTArray<TouchBehaviorFlags>& aValues) = 0;
     181             : 
     182             :   virtual void StartScrollbarDrag(
     183             :       const ScrollableLayerGuid& aGuid,
     184             :       const AsyncDragMetrics& aDragMetrics) = 0;
     185             : 
     186             :   /**
     187             :    * Function used to disable LongTap gestures.
     188             :    *
     189             :    * On slow running tests, drags and touch events can be misinterpreted
     190             :    * as a long tap. This allows tests to disable long tap gesture detection.
     191             :    */
     192             :   virtual void SetLongTapEnabled(bool aTapGestureEnabled) = 0;
     193             : 
     194             :   /**
     195             :    * Process touch velocity.
     196             :    * Sometimes the touch move event will have a velocity even though no scrolling
     197             :    * is occurring such as when the toolbar is being hidden/shown in Fennec.
     198             :    * This function can be called to have the y axis' velocity queue updated.
     199             :    */
     200             :   virtual void ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY) = 0;
     201             : 
     202             :   // Returns whether or not a wheel event action will be (or was) performed by
     203             :   // APZ. If this returns true, the event must not perform a synchronous
     204             :   // scroll.
     205             :   //
     206             :   // Even if this returns false, all wheel events in APZ-aware widgets must
     207             :   // be sent through APZ so they are transformed correctly for TabParent.
     208             :   static bool WillHandleWheelEvent(WidgetWheelEvent* aEvent);
     209             : 
     210             : protected:
     211             : 
     212             :   // Methods to help process WidgetInputEvents (or manage conversion to/from InputData)
     213             : 
     214             :   virtual void ProcessUnhandledEvent(
     215             :       LayoutDeviceIntPoint* aRefPoint,
     216             :       ScrollableLayerGuid* aOutTargetGuid,
     217             :       uint64_t* aOutFocusSequenceNumber) = 0;
     218             : 
     219             :   virtual void UpdateWheelTransaction(
     220             :       LayoutDeviceIntPoint aRefPoint,
     221             :       EventMessage aEventMessage) = 0;
     222             : 
     223             :   // Discourage destruction outside of decref
     224             : 
     225           0 :   virtual ~IAPZCTreeManager() { }
     226             : };
     227             : 
     228             : } // namespace layers
     229             : } // namespace mozilla
     230             : 
     231             : #endif // mozilla_layers_IAPZCTreeManager_h

Generated by: LCOV version 1.13