tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

IAPZHitTester.h (3596B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      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_IAPZHitTester_h
      8 #define mozilla_layers_IAPZHitTester_h
      9 
     10 #include "HitTestingTreeNode.h"  // for HitTestingTreeNodeAutoLock
     11 #include "mozilla/RefPtr.h"
     12 #include "mozilla/gfx/CompositorHitTestInfo.h"
     13 #include "mozilla/layers/LayersTypes.h"
     14 
     15 namespace mozilla {
     16 namespace layers {
     17 
     18 class AsyncPanZoomController;
     19 class APZCTreeManager;
     20 
     21 class IAPZHitTester {
     22 public:
     23  virtual ~IAPZHitTester() = default;
     24 
     25  // Not a constructor because we want external code to be able to pass a hit
     26  // tester to the APZCTreeManager constructor, which will then initialize it.
     27  void Initialize(APZCTreeManager* aTreeManager) {
     28    mTreeManager = aTreeManager;
     29  }
     30 
     31  // Represents the results of an APZ hit test.
     32  struct HitTestResult {
     33    // The APZC targeted by the hit test.
     34    RefPtr<AsyncPanZoomController> mTargetApzc;
     35    // The applicable hit test flags.
     36    gfx::CompositorHitTestInfo mHitResult;
     37    // The layers id of the content that was hit.
     38    // This effectively identifiers the process that was hit for
     39    // Fission purposes.
     40    LayersId mLayersId;
     41    // If a scrollbar was hit, this will be populated with the
     42    // scrollbar node. The AutoLock allows accessing the scrollbar
     43    // node without having to hold the tree lock.
     44    HitTestingTreeNodeAutoLock mScrollbarNode;
     45    // If content that is fixed to the root-content APZC was hit,
     46    // the sides of the viewport to which the content is fixed.
     47    SideBits mFixedPosSides = SideBits::eNone;
     48    // If a fixed/sticky position element was hit, this will be populated with
     49    // the hit-testing tree node. The AutoLock allows accessing the node
     50    // without having to hold the tree lock.
     51    HitTestingTreeNodeAutoLock mNode;
     52    // This is set to true If mTargetApzc is overscrolled and the
     53    // event targeted the gap space ("gutter") created by the overscroll.
     54    bool mHitOverscrollGutter = false;
     55 
     56    HitTestResult() = default;
     57    // Make it move-only.
     58    HitTestResult(HitTestResult&&) = default;
     59    HitTestResult& operator=(HitTestResult&&) = default;
     60  };
     61 
     62  virtual HitTestResult GetAPZCAtPoint(
     63      const ScreenPoint& aHitTestPoint,
     64      const RecursiveMutexAutoLock& aProofOfTreeLock) = 0;
     65 
     66  HitTestResult CloneHitTestResult(RecursiveMutexAutoLock& aProofOfTreeLock,
     67                                   const HitTestResult& aHitTestResult) const;
     68 
     69 protected:
     70  APZCTreeManager* mTreeManager = nullptr;
     71 
     72  // We are a friend of APZCTreeManager but our derived classes
     73  // are not. Wrap a few private members of APZCTreeManager for
     74  // use by derived classes.
     75  RecursiveMutex& GetTreeLock();
     76  LayersId GetRootLayersId() const;
     77  HitTestingTreeNode* GetRootNode() const;
     78  HitTestingTreeNode* FindRootNodeForLayersId(LayersId aLayersId) const;
     79  AsyncPanZoomController* FindRootApzcForLayersId(LayersId aLayersId) const;
     80  already_AddRefed<HitTestingTreeNode> GetTargetNode(
     81      const ScrollableLayerGuid& aGuid,
     82      ScrollableLayerGuid::Comparator aComparator);
     83  void InitializeHitTestingTreeNodeAutoLock(
     84      HitTestingTreeNodeAutoLock& aAutoLock,
     85      const RecursiveMutexAutoLock& aProofOfTreeLock,
     86      RefPtr<HitTestingTreeNode>& aNode) const;
     87 };
     88 
     89 }  // namespace layers
     90 }  // namespace mozilla
     91 
     92 #endif  // mozilla_layers_IAPZHitTester_h