Index: third_party/WebKit/Source/core/input/InputDeviceCapabilities.cpp |
diff --git a/third_party/WebKit/Source/core/input/InputDeviceCapabilities.cpp b/third_party/WebKit/Source/core/input/InputDeviceCapabilities.cpp |
index f112e2aad697939cb503e712893d2f30c205afb7..62fba31e21d26baa21df56ad18fd041e9a7327f6 100644 |
--- a/third_party/WebKit/Source/core/input/InputDeviceCapabilities.cpp |
+++ b/third_party/WebKit/Source/core/input/InputDeviceCapabilities.cpp |
@@ -4,27 +4,45 @@ |
#include "core/input/InputDeviceCapabilities.h" |
-namespace blink { |
+#include "core/frame/DOMWindow.h" |
-InputDeviceCapabilities::InputDeviceCapabilities(bool firesTouchEvents) { |
- m_firesTouchEvents = firesTouchEvents; |
-} |
+namespace blink { |
InputDeviceCapabilities::InputDeviceCapabilities( |
const InputDeviceCapabilitiesInit& initializer) { |
m_firesTouchEvents = initializer.firesTouchEvents(); |
} |
-InputDeviceCapabilities* InputDeviceCapabilitiesConstants::firesTouchEvents( |
- bool firesTouch) { |
- if (firesTouch) { |
- if (!m_firesTouchEvents) |
- m_firesTouchEvents = InputDeviceCapabilities::create(true); |
- return m_firesTouchEvents; |
- } |
- if (!m_doesntFireTouchEvents) |
- m_doesntFireTouchEvents = InputDeviceCapabilities::create(false); |
- return m_doesntFireTouchEvents; |
+InputDeviceCapabilities::InputDeviceCapabilities( |
+ InputDeviceCapabilities::Descriptor descriptor) |
+ : m_firesTouchEvents(descriptor & FiresTouchEvents) {} |
+ |
+InputDeviceCapabilities* InputDeviceCapabilitiesValue::getCapabilities( |
+ DOMWindow* window) { |
+ if (m_capabilities) |
+ return m_capabilities; |
+ |
+ if (m_descriptor == InputDeviceCapabilities::Null) |
+ return nullptr; |
+ |
+ if (window) |
+ m_capabilities = window->getInputDeviceCapabilities()->get(m_descriptor); |
+ else |
+ m_capabilities = InputDeviceCapabilities::create(m_descriptor); |
+ |
+ return m_capabilities; |
+} |
+ |
+InputDeviceCapabilities* InputDeviceCapabilitiesConstants::get( |
+ InputDeviceCapabilities::Descriptor descriptor) { |
+ if (descriptor == InputDeviceCapabilities::Null) |
+ return nullptr; |
+ Member<InputDeviceCapabilities>& result = m_doesntFireTouchEvents; |
+ if (descriptor & InputDeviceCapabilities::FiresTouchEvents) |
+ result = m_firesTouchEvents; |
+ if (!result) |
+ result = InputDeviceCapabilities::create(descriptor); |
+ return result; |
} |
} // namespace blink |