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 GFX_HITTESTINFO_H
8 #define GFX_HITTESTINFO_H
9 
10 #include "mozilla/gfx/CompositorHitTestInfo.h"
11 #include "mozilla/layers/ScrollableLayerGuid.h"
12 #include "nsRect.h"
13 
14 class nsIFrame;
15 class nsDisplayListBuilder;
16 
17 namespace mozilla {
18 
19 struct ActiveScrolledRoot;
20 
21 /**
22  * A helper class that manages compositor hit testing information.
23  */
24 class HitTestInfo {
25  public:
26   using CompositorHitTestInfo = gfx::CompositorHitTestInfo;
27   using ViewID = layers::ScrollableLayerGuid::ViewID;
28 
29   ViewID GetViewId(wr::DisplayListBuilder& aBuilder,
30                    const ActiveScrolledRoot* aASR) const;
31 
32   void Initialize(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame);
33   void InitializeScrollTarget(nsDisplayListBuilder* aBuilder);
34 
SetAreaAndInfo(const nsRect & aArea,const CompositorHitTestInfo & aInfo)35   void SetAreaAndInfo(const nsRect& aArea, const CompositorHitTestInfo& aInfo) {
36     mArea = aArea;
37     mInfo = aInfo;
38   }
39 
40   static void Shutdown();
41 
Area()42   const nsRect& Area() const { return mArea; }
Info()43   const CompositorHitTestInfo& Info() const { return mInfo; }
44 
45   static const HitTestInfo& Empty();
46 
47  private:
48   nsRect mArea;
49   CompositorHitTestInfo mInfo;
50   mozilla::Maybe<ViewID> mScrollTarget;
51 };
52 
53 }  // namespace mozilla
54 
55 #endif
56