Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: third_party/WebKit/Source/core/input/InputDeviceCapabilities.h

Issue 2675793005: Track constant InputDeviceCapabilities objects per-window. (Closed)
Patch Set: test tidying Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef InputDeviceCapabilities_h 5 #ifndef InputDeviceCapabilities_h
6 #define InputDeviceCapabilities_h 6 #define InputDeviceCapabilities_h
7 7
8 #include "bindings/core/v8/ScriptWrappable.h" 8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "core/CoreExport.h" 9 #include "core/CoreExport.h"
10 #include "core/input/InputDeviceCapabilitiesInit.h" 10 #include "core/input/InputDeviceCapabilitiesInit.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class CORE_EXPORT InputDeviceCapabilities final 14 class CORE_EXPORT InputDeviceCapabilities final
15 : public GarbageCollected<InputDeviceCapabilities>, 15 : public GarbageCollected<InputDeviceCapabilities>,
16 public ScriptWrappable { 16 public ScriptWrappable {
17 DEFINE_WRAPPERTYPEINFO(); 17 DEFINE_WRAPPERTYPEINFO();
18 18
19 public: 19 public:
20 // This return a static local InputDeviceCapabilities pointer which has
21 // firesTouchEvents set to be true.
22 static InputDeviceCapabilities* firesTouchEventsSourceCapabilities();
23
24 // This return a static local InputDeviceCapabilities pointer which has
25 // firesTouchEvents set to be false.
26 static InputDeviceCapabilities* doesntFireTouchEventsSourceCapabilities();
27
28 static InputDeviceCapabilities* create(bool firesTouchEvents) { 20 static InputDeviceCapabilities* create(bool firesTouchEvents) {
29 return new InputDeviceCapabilities(firesTouchEvents); 21 return new InputDeviceCapabilities(firesTouchEvents);
30 } 22 }
31 23
32 static InputDeviceCapabilities* create( 24 static InputDeviceCapabilities* create(
33 const InputDeviceCapabilitiesInit& initializer) { 25 const InputDeviceCapabilitiesInit& initializer) {
34 return new InputDeviceCapabilities(initializer); 26 return new InputDeviceCapabilities(initializer);
35 } 27 }
36 28
37 bool firesTouchEvents() const { return m_firesTouchEvents; } 29 bool firesTouchEvents() const { return m_firesTouchEvents; }
38 30
39 DEFINE_INLINE_TRACE() {} 31 DEFINE_INLINE_TRACE() {}
40 32
41 private: 33 private:
42 InputDeviceCapabilities(bool firesTouchEvents); 34 InputDeviceCapabilities(bool firesTouchEvents);
43 InputDeviceCapabilities(const InputDeviceCapabilitiesInit&); 35 InputDeviceCapabilities(const InputDeviceCapabilitiesInit&);
44 36
45 // Whether this device dispatches touch events. This mainly lets developers 37 // Whether this device dispatches touch events. This mainly lets developers
46 // avoid handling both touch and mouse events dispatched for a single user 38 // avoid handling both touch and mouse events dispatched for a single user
47 // action. 39 // action.
48 bool m_firesTouchEvents; 40 bool m_firesTouchEvents;
49 }; 41 };
50 42
43 // Grouping constant-valued InputDeviceCapabilities objects together,
44 // which is kept and used by each 'view' (DOMWindow) that dispatches
45 // events parameterized over InputDeviceCapabilities.
46 //
47 // TODO(sof): lazily instantiate InputDeviceCapabilities instances upon
48 // UIEvent access instead. This would allow internal tracking of such
49 // capabilities by value.
50 class InputDeviceCapabilitiesConstants final
51 : public GarbageCollected<InputDeviceCapabilitiesConstants> {
52 public:
53 // Returns an InputDeviceCapabilities which has
54 // |firesTouchEvents| set to value of |firesTouch|.
55 InputDeviceCapabilities* firesTouchEvents(bool firesTouch);
56
57 DEFINE_INLINE_TRACE() {
58 visitor->trace(m_firesTouchEvents);
59 visitor->trace(m_doesntFireTouchEvents);
60 }
61
62 private:
63 Member<InputDeviceCapabilities> m_firesTouchEvents;
64 Member<InputDeviceCapabilities> m_doesntFireTouchEvents;
65 };
66
51 } // namespace blink 67 } // namespace blink
52 68
53 #endif // InputDeviceCapabilities_h 69 #endif // InputDeviceCapabilities_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698