OLD | NEW |
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 #include "core/input/InputDeviceCapabilities.h" | 5 #include "core/input/InputDeviceCapabilities.h" |
6 | 6 |
| 7 #include "core/frame/DOMWindow.h" |
| 8 |
7 namespace blink { | 9 namespace blink { |
8 | 10 |
9 InputDeviceCapabilities::InputDeviceCapabilities(bool firesTouchEvents) { | |
10 m_firesTouchEvents = firesTouchEvents; | |
11 } | |
12 | |
13 InputDeviceCapabilities::InputDeviceCapabilities( | 11 InputDeviceCapabilities::InputDeviceCapabilities( |
14 const InputDeviceCapabilitiesInit& initializer) { | 12 const InputDeviceCapabilitiesInit& initializer) { |
15 m_firesTouchEvents = initializer.firesTouchEvents(); | 13 m_firesTouchEvents = initializer.firesTouchEvents(); |
16 } | 14 } |
17 | 15 |
18 InputDeviceCapabilities* InputDeviceCapabilitiesConstants::firesTouchEvents( | 16 InputDeviceCapabilities::InputDeviceCapabilities( |
19 bool firesTouch) { | 17 InputDeviceCapabilities::Descriptor descriptor) |
20 if (firesTouch) { | 18 : m_firesTouchEvents(descriptor & FiresTouchEvents) {} |
21 if (!m_firesTouchEvents) | 19 |
22 m_firesTouchEvents = InputDeviceCapabilities::create(true); | 20 InputDeviceCapabilities* InputDeviceCapabilitiesValue::getCapabilities( |
23 return m_firesTouchEvents; | 21 DOMWindow* window) { |
24 } | 22 if (m_capabilities) |
25 if (!m_doesntFireTouchEvents) | 23 return m_capabilities; |
26 m_doesntFireTouchEvents = InputDeviceCapabilities::create(false); | 24 |
27 return m_doesntFireTouchEvents; | 25 if (m_descriptor == InputDeviceCapabilities::Null) |
| 26 return nullptr; |
| 27 |
| 28 if (window) |
| 29 m_capabilities = window->getInputDeviceCapabilities()->get(m_descriptor); |
| 30 else |
| 31 m_capabilities = InputDeviceCapabilities::create(m_descriptor); |
| 32 |
| 33 return m_capabilities; |
| 34 } |
| 35 |
| 36 InputDeviceCapabilities* InputDeviceCapabilitiesConstants::get( |
| 37 InputDeviceCapabilities::Descriptor descriptor) { |
| 38 if (descriptor == InputDeviceCapabilities::Null) |
| 39 return nullptr; |
| 40 Member<InputDeviceCapabilities>& result = m_doesntFireTouchEvents; |
| 41 if (descriptor & InputDeviceCapabilities::FiresTouchEvents) |
| 42 result = m_firesTouchEvents; |
| 43 if (!result) |
| 44 result = InputDeviceCapabilities::create(descriptor); |
| 45 return result; |
28 } | 46 } |
29 | 47 |
30 } // namespace blink | 48 } // namespace blink |
OLD | NEW |