Chromium side of maxTouchPoints implementation.
Intent to implement-and-ship: https://groups.google.com/a/chromium.org/forum/#!searchin/blink-dev/maxTouchPoints/blink-dev/ayzxdztUlOQ/rd-z_Jo3ocIJ
navigator.maxTouchPoints is defined in the W3C Pointer Events
standard draft:
http://www.w3.org/TR/pointerevents/#widl-Navigator-maxTouchPoints
Depends on blink revision 160153:
https://src.chromium.org/viewvc/blink?view=revision&revision=160153
BUG=248918
Review URL: https://codereview.chromium.org/26764002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231203 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/AUTHORS b/AUTHORS
index 7dd6f26b..98591fb 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -249,6 +249,7 @@
Sanne Wouda <[email protected]>
Sathish Kuppuswamy <[email protected]>
Satoshi Matsuzaki <[email protected]>
+Scott Blomquist <[email protected]>
Sean Bryant <[email protected]>
Seo Sanghyeon <[email protected]>
Seokju Kwon <[email protected]>
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index f5cff79..ea394e66 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -611,10 +611,12 @@
prefs.device_supports_mouse = false;
#endif
- prefs.touch_adjustment_enabled =
- !command_line.HasSwitch(switches::kDisableTouchAdjustment);
- prefs.compositor_touch_hit_testing =
- !command_line.HasSwitch(cc::switches::kDisableCompositorTouchHitTesting);
+ prefs.pointer_events_max_touch_points = ui::MaxTouchPoints();
+
+ prefs.touch_adjustment_enabled =
+ !command_line.HasSwitch(switches::kDisableTouchAdjustment);
+ prefs.compositor_touch_hit_testing =
+ !command_line.HasSwitch(cc::switches::kDisableCompositorTouchHitTesting);
#if defined(OS_MACOSX) || defined(OS_CHROMEOS)
bool default_enable_scroll_animator = true;
diff --git a/content/public/common/common_param_traits_macros.h b/content/public/common/common_param_traits_macros.h
index 28ef622..384a53a 100644
--- a/content/public/common/common_param_traits_macros.h
+++ b/content/public/common/common_param_traits_macros.h
@@ -160,6 +160,7 @@
IPC_STRUCT_TRAITS_MEMBER(device_supports_touch)
IPC_STRUCT_TRAITS_MEMBER(device_supports_mouse)
IPC_STRUCT_TRAITS_MEMBER(touch_adjustment_enabled)
+ IPC_STRUCT_TRAITS_MEMBER(pointer_events_max_touch_points)
IPC_STRUCT_TRAITS_MEMBER(fixed_position_creates_stacking_context)
IPC_STRUCT_TRAITS_MEMBER(sync_xhr_in_documents_enabled)
IPC_STRUCT_TRAITS_MEMBER(deferred_image_decoding_enabled)
diff --git a/content/renderer/web_preferences.cc b/content/renderer/web_preferences.cc
index 180fbe71..71c0ca0d 100644
--- a/content/renderer/web_preferences.cc
+++ b/content/renderer/web_preferences.cc
@@ -298,6 +298,7 @@
WebRuntimeFeatures::enableLazyLayout(prefs.lazy_layout_enabled);
WebRuntimeFeatures::enableTouch(prefs.touch_enabled);
+ settings->setMaxTouchPoints(prefs.pointer_events_max_touch_points);
settings->setDeviceSupportsTouch(prefs.device_supports_touch);
settings->setDeviceSupportsMouse(prefs.device_supports_mouse);
settings->setEnableTouchAdjustment(prefs.touch_adjustment_enabled);
diff --git a/ui/base/touch/touch_device.cc b/ui/base/touch/touch_device.cc
index de7785cb4..944ba17 100644
--- a/ui/base/touch/touch_device.cc
+++ b/ui/base/touch/touch_device.cc
@@ -12,4 +12,8 @@
return false;
}
+int MaxTouchPoints() {
+ return 0;
+}
+
} // namespace ui
diff --git a/ui/base/touch/touch_device.h b/ui/base/touch/touch_device.h
index 8cc4b7d..b06c564 100644
--- a/ui/base/touch/touch_device.h
+++ b/ui/base/touch/touch_device.h
@@ -9,9 +9,23 @@
namespace ui {
+// TODO(sblom): This is non-standard, and should be removed before
+// RuntimeEnabledFlags::PointerEventsMaxTouchPoints is marked stable.
+// Tracked by: http://crbug.com/308649
+const int kMaxTouchPointsUnknown = -1;
+
// Returns true if a touch device is available.
UI_EXPORT bool IsTouchDevicePresent();
+// Returns the maximum number of simultaneous touch contacts supported
+// by the device. In the case of devices with multiple digitizers (e.g.
+// multiple touchscreens), the value MUST be the maximum of the set of
+// maximum supported contacts by each individual digitizer.
+// For example, suppose a device has 3 touchscreens, which support 2, 5,
+// and 10 simultaneous touch contacts, respectively. This returns 10.
+// http://www.w3.org/TR/pointerevents/#widl-Navigator-maxTouchPoints
+UI_EXPORT int MaxTouchPoints();
+
} // namespace ui
#endif // UI_BASE_TOUCH_TOUCH_DEVICE_H_
diff --git a/ui/base/touch/touch_device_android.cc b/ui/base/touch/touch_device_android.cc
index 39e34c2..2b359c0 100644
--- a/ui/base/touch/touch_device_android.cc
+++ b/ui/base/touch/touch_device_android.cc
@@ -10,4 +10,17 @@
return true;
}
+// Looks like the best we can do here is detect 1, 2+, or 5+ by
+// feature detecting:
+// FEATURE_TOUCHSCREEN (1),
+// FEATURE_TOUCHSCREEN_MULTITOUCH (2),
+// FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT (2+), or
+// FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHANDS (5+)
+//
+// Probably start from the biggest and detect down the list until we
+// find one that's supported and return its value.
+int MaxTouchPoints() {
+ return kMaxTouchPointsUnknown;
+}
+
} // namespace ui
diff --git a/ui/base/touch/touch_device_aurax11.cc b/ui/base/touch/touch_device_aurax11.cc
index 04d435e4..d3b6df4 100644
--- a/ui/base/touch/touch_device_aurax11.cc
+++ b/ui/base/touch/touch_device_aurax11.cc
@@ -11,4 +11,8 @@
return ui::TouchFactory::GetInstance()->IsTouchDevicePresent();
}
+int MaxTouchPoints() {
+ return kMaxTouchPointsUnknown;
+}
+
} // namespace ui
diff --git a/ui/base/touch/touch_device_ozone.cc b/ui/base/touch/touch_device_ozone.cc
index 7cb2ecb..d97a70b 100644
--- a/ui/base/touch/touch_device_ozone.cc
+++ b/ui/base/touch/touch_device_ozone.cc
@@ -11,4 +11,8 @@
return true;
}
+int MaxTouchPoints() {
+ return kMaxTouchPointsUnknown;
+}
+
} // namespace ui
diff --git a/ui/base/touch/touch_device_win.cc b/ui/base/touch/touch_device_win.cc
index c07fbe9..ba5c260 100644
--- a/ui/base/touch/touch_device_win.cc
+++ b/ui/base/touch/touch_device_win.cc
@@ -14,4 +14,8 @@
((value & NID_INTEGRATED_TOUCH) || (value & NID_EXTERNAL_TOUCH));
}
+int MaxTouchPoints() {
+ return GetSystemMetrics(SM_MAXIMUMTOUCHES);
+}
+
} // namespace ui
diff --git a/webkit/common/webpreferences.cc b/webkit/common/webpreferences.cc
index 58e1ed4..5bb5e58 100644
--- a/webkit/common/webpreferences.cc
+++ b/webkit/common/webpreferences.cc
@@ -90,6 +90,7 @@
device_supports_touch(false),
device_supports_mouse(true),
touch_adjustment_enabled(true),
+ pointer_events_max_touch_points(0),
fixed_position_creates_stacking_context(false),
sync_xhr_in_documents_enabled(true),
deferred_image_decoding_enabled(false),
diff --git a/webkit/common/webpreferences.h b/webkit/common/webpreferences.h
index c7614f3..bb15a082 100644
--- a/webkit/common/webpreferences.h
+++ b/webkit/common/webpreferences.h
@@ -140,6 +140,7 @@
bool device_supports_touch;
bool device_supports_mouse;
bool touch_adjustment_enabled;
+ int pointer_events_max_touch_points;
bool fixed_position_creates_stacking_context;
bool sync_xhr_in_documents_enabled;
bool deferred_image_decoding_enabled;