Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * vim: set ts=2 sw=2 et tw=78:
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 :
8 : /* Description of TouchManager class.
9 : * Incapsulate code related with work of touch events.
10 : */
11 :
12 : #ifndef TouchManager_h_
13 : #define TouchManager_h_
14 :
15 : #include "mozilla/BasicEvents.h"
16 : #include "mozilla/dom/Touch.h"
17 : #include "mozilla/TouchEvents.h"
18 : #include "nsRefPtrHashtable.h"
19 :
20 : class nsIDocument;
21 :
22 : namespace mozilla {
23 : class PresShell;
24 :
25 32 : class TouchManager {
26 : public:
27 : // Initialize and release static variables
28 : static void InitializeStatics();
29 : static void ReleaseStatics();
30 :
31 : void Init(PresShell* aPresShell, nsIDocument* aDocument);
32 : void Destroy();
33 :
34 : bool PreHandleEvent(mozilla::WidgetEvent* aEvent,
35 : nsEventStatus* aStatus,
36 : bool& aTouchIsNew,
37 : bool& aIsHandlingUserInput,
38 : nsCOMPtr<nsIContent>& aCurrentEventContent);
39 :
40 : static already_AddRefed<nsIContent> GetAnyCapturedTouchTarget();
41 : static bool HasCapturedTouch(int32_t aId);
42 : static already_AddRefed<dom::Touch> GetCapturedTouch(int32_t aId);
43 : static bool ShouldConvertTouchToPointer(const dom::Touch* aTouch,
44 : const WidgetTouchEvent* aEvent);
45 : private:
46 : void EvictTouches();
47 : static void EvictTouchPoint(RefPtr<dom::Touch>& aTouch,
48 : nsIDocument* aLimitToDocument = nullptr);
49 : static void AppendToTouchList(WidgetTouchEvent::TouchArray* aTouchList);
50 :
51 : RefPtr<PresShell> mPresShell;
52 : nsCOMPtr<nsIDocument> mDocument;
53 :
54 0 : struct TouchInfo
55 : {
56 : RefPtr<mozilla::dom::Touch> mTouch;
57 : nsCOMPtr<nsIContent> mNonAnonymousTarget;
58 : bool mConvertToPointer;
59 : };
60 : static nsDataHashtable<nsUint32HashKey, TouchInfo>* sCaptureTouchList;
61 : };
62 :
63 : } // namespace mozilla
64 :
65 : #endif /* !defined(TouchManager_h_) */
|