LCOV - code coverage report
Current view: top level - gfx/layers/apz/util - ActiveElementManager.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 1 100.0 %
Date: 2017-07-14 16:53:18 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef mozilla_layers_ActiveElementManager_h
       7             : #define mozilla_layers_ActiveElementManager_h
       8             : 
       9             : #include "nsCOMPtr.h"
      10             : #include "nsISupportsImpl.h"
      11             : 
      12             : namespace mozilla {
      13             : 
      14             : class CancelableRunnable;
      15             : 
      16             : namespace dom {
      17             : class Element;
      18             : class EventTarget;
      19             : } // namespace dom
      20             : 
      21             : namespace layers {
      22             : 
      23             : /**
      24             :  * Manages setting and clearing the ':active' CSS pseudostate in the presence
      25             :  * of touch input.
      26             :  */
      27             : class ActiveElementManager {
      28             :   ~ActiveElementManager();
      29             : public:
      30           2 :   NS_INLINE_DECL_REFCOUNTING(ActiveElementManager)
      31             : 
      32             :   ActiveElementManager();
      33             : 
      34             :   /**
      35             :    * Specify the target of a touch. Typically this should be called right
      36             :    * after HandleTouchStart(), but in cases where the APZ needs to wait for
      37             :    * a content response the HandleTouchStart() may be delayed, in which case
      38             :    * this function can be called first.
      39             :    * |aTarget| may be nullptr.
      40             :    */
      41             :   void SetTargetElement(dom::EventTarget* aTarget);
      42             :   /**
      43             :    * Handle a touch-start state notification from APZ. This notification
      44             :    * may be delayed until after touch listeners have responded to the APZ.
      45             :    * @param aCanBePan whether the touch can be a pan
      46             :    */
      47             :   void HandleTouchStart(bool aCanBePan);
      48             :   /**
      49             :    * Clear the active element.
      50             :    */
      51             :   void ClearActivation();
      52             :   /**
      53             :    * Handle a touch-end or touch-cancel event.
      54             :    * @param aWasClick whether the touch was a click
      55             :    */
      56             :   void HandleTouchEndEvent(bool aWasClick);
      57             :   /**
      58             :    * Handle a touch-end state notification from APZ. This notification may be
      59             :    * delayed until after touch listeners have responded to the APZ.
      60             :    */
      61             :   void HandleTouchEnd();
      62             :   /**
      63             :    * @return true iff the currently active element (or one of its ancestors)
      64             :    * actually had a style for the :active pseudo-class. The currently active
      65             :    * element is the root element if no other elements are active.
      66             :    */
      67             :   bool ActiveElementUsesStyle() const;
      68             : private:
      69             :   /**
      70             :    * The target of the first touch point in the current touch block.
      71             :    */
      72             :   nsCOMPtr<dom::Element> mTarget;
      73             :   /**
      74             :    * Whether the current touch block can be a pan. Set in HandleTouchStart().
      75             :    */
      76             :   bool mCanBePan;
      77             :   /**
      78             :    * Whether mCanBePan has been set for the current touch block.
      79             :    * We need to keep track of this to allow HandleTouchStart() and
      80             :    * SetTargetElement() to be called in either order.
      81             :    */
      82             :   bool mCanBePanSet;
      83             :   /**
      84             :    * A task for calling SetActive() after a timeout.
      85             :    */
      86             :   RefPtr<CancelableRunnable> mSetActiveTask;
      87             :   /**
      88             :    * See ActiveElementUsesStyle() documentation.
      89             :    */
      90             :   bool mActiveElementUsesStyle;
      91             : 
      92             :   // Helpers
      93             :   void TriggerElementActivation();
      94             :   void SetActive(dom::Element* aTarget);
      95             :   void ResetActive();
      96             :   void ResetTouchBlockState();
      97             :   void SetActiveTask(const nsCOMPtr<dom::Element>& aTarget);
      98             :   void CancelTask();
      99             : };
     100             : 
     101             : } // namespace layers
     102             : } // namespace mozilla
     103             : 
     104             : #endif /* mozilla_layers_ActiveElementManager_h */

Generated by: LCOV version 1.13