summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/src/IAPZHitTester.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /gfx/layers/apz/src/IAPZHitTester.h
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/layers/apz/src/IAPZHitTester.h')
-rw-r--r--gfx/layers/apz/src/IAPZHitTester.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/gfx/layers/apz/src/IAPZHitTester.h b/gfx/layers/apz/src/IAPZHitTester.h
new file mode 100644
index 0000000000..8822b40ea8
--- /dev/null
+++ b/gfx/layers/apz/src/IAPZHitTester.h
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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 http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_layers_IAPZHitTester_h
+#define mozilla_layers_IAPZHitTester_h
+
+#include "HitTestingTreeNode.h" // for HitTestingTreeNodeAutoLock
+#include "mozilla/RefPtr.h"
+#include "mozilla/gfx/CompositorHitTestInfo.h"
+#include "mozilla/layers/LayersTypes.h"
+
+namespace mozilla {
+namespace layers {
+
+class AsyncPanZoomController;
+class APZCTreeManager;
+
+class IAPZHitTester {
+ public:
+ virtual ~IAPZHitTester() = default;
+
+ // Not a constructor because we want external code to be able to pass a hit
+ // tester to the APZCTreeManager constructor, which will then initialize it.
+ void Initialize(APZCTreeManager* aTreeManager) {
+ mTreeManager = aTreeManager;
+ }
+
+ // Represents the results of an APZ hit test.
+ struct HitTestResult {
+ // The APZC targeted by the hit test.
+ RefPtr<AsyncPanZoomController> mTargetApzc;
+ // The applicable hit test flags.
+ gfx::CompositorHitTestInfo mHitResult;
+ // The layers id of the content that was hit.
+ // This effectively identifiers the process that was hit for
+ // Fission purposes.
+ LayersId mLayersId;
+ // If a scrollbar was hit, this will be populated with the
+ // scrollbar node. The AutoLock allows accessing the scrollbar
+ // node without having to hold the tree lock.
+ HitTestingTreeNodeAutoLock mScrollbarNode;
+ // If content that is fixed to the root-content APZC was hit,
+ // the sides of the viewport to which the content is fixed.
+ SideBits mFixedPosSides = SideBits::eNone;
+ // If a fixed/sticky position element was hit, this will be populated with
+ // the hit-testing tree node. The AutoLock allows accessing the node
+ // without having to hold the tree lock.
+ HitTestingTreeNodeAutoLock mNode;
+ // This is set to true If mTargetApzc is overscrolled and the
+ // event targeted the gap space ("gutter") created by the overscroll.
+ bool mHitOverscrollGutter = false;
+
+ HitTestResult() = default;
+ // Make it move-only.
+ HitTestResult(HitTestResult&&) = default;
+ HitTestResult& operator=(HitTestResult&&) = default;
+ };
+
+ virtual HitTestResult GetAPZCAtPoint(
+ const ScreenPoint& aHitTestPoint,
+ const RecursiveMutexAutoLock& aProofOfTreeLock) = 0;
+
+ HitTestResult CloneHitTestResult(RecursiveMutexAutoLock& aProofOfTreeLock,
+ const HitTestResult& aHitTestResult) const;
+
+ protected:
+ APZCTreeManager* mTreeManager = nullptr;
+
+ // We are a friend of APZCTreeManager but our derived classes
+ // are not. Wrap a few private members of APZCTreeManager for
+ // use by derived classes.
+ LayersId GetRootLayersId() const;
+ HitTestingTreeNode* GetRootNode() const;
+ HitTestingTreeNode* FindRootNodeForLayersId(LayersId aLayersId) const;
+ AsyncPanZoomController* FindRootApzcForLayersId(LayersId aLayersId) const;
+ already_AddRefed<HitTestingTreeNode> GetTargetNode(
+ const ScrollableLayerGuid& aGuid,
+ ScrollableLayerGuid::Comparator aComparator);
+ void InitializeHitTestingTreeNodeAutoLock(
+ HitTestingTreeNodeAutoLock& aAutoLock,
+ const RecursiveMutexAutoLock& aProofOfTreeLock,
+ RefPtr<HitTestingTreeNode>& aNode) const;
+};
+
+} // namespace layers
+} // namespace mozilla
+
+#endif // mozilla_layers_IAPZHitTester_h