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

Unified Diff: third_party/WebKit/Source/core/input/InputDeviceCapabilities.cpp

Issue 2678683002: Delay instantiating InputDeviceCapabilities until accessed. (Closed)
Patch Set: rebased 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698