WebKit Bugzilla
Attachment 370502 Details for
Bug 139681
: Touch support is reported even when the device doesn't have a touch screen
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
wkgtk-touch-events.diff (text/plain), 14.98 KB, created by
Carlos Garcia Campos
on 2019-05-23 06:12:08 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2019-05-23 06:12:08 PDT
Size:
14.98 KB
patch
obsolete
>diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 839b0fd34cf..0e3bde0e681 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2019-05-23 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ Touch support is reported even when the device doesn't have a touch screen >+ https://bugs.webkit.org/show_bug.cgi?id=139681 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Remove expectations for tests that are passing now. >+ >+ * platform/gtk/TestExpectations: >+ > 2019-05-21 Myles C. Maxfield <mmaxfield@apple.com> > > font-optical-sizing applies the wrong variation value >diff --git a/LayoutTests/platform/gtk/TestExpectations b/LayoutTests/platform/gtk/TestExpectations >index 334e851bb01..6a4cdd1fbd3 100644 >--- a/LayoutTests/platform/gtk/TestExpectations >+++ b/LayoutTests/platform/gtk/TestExpectations >@@ -820,17 +820,6 @@ webkit.org/b/141423 fast/css/font-shorthand-from-longhands.html [ Failure ] > webkit.org/b/141423 fast/css/font-shorthand-line-height.html [ Failure ] > webkit.org/b/141423 fast/css/getComputedStyle/computed-style-font.html [ Failure ] > >-#Pointer and hover media queries. >-webkit.org/b/141466 fast/media/mq-any-hover-matchMedia.html [ Failure ] >-webkit.org/b/141466 fast/media/mq-any-hover-styling.html [ Failure ] >-webkit.org/b/141466 fast/media/mq-any-pointer-matchMedia.html [ Failure ] >-webkit.org/b/141466 fast/media/mq-any-pointer-styling.html [ Failure ] >-webkit.org/b/141466 fast/media/mq-hover-matchMedia.html [ Failure ] >-webkit.org/b/141466 fast/media/mq-hover-styling.html [ Failure ] >-webkit.org/b/141466 fast/media/mq-pointer-matchMedia.html [ Failure ] >-webkit.org/b/141466 fast/media/mq-pointer-styling.html [ Failure ] >-webkit.org/b/141466 fast/media/mq-pointer.html [ Failure ] >- > webkit.org/b/116259 http/tests/cache/willsendrequest-returns-null-for-memory-cache-load.html [ Failure ] > > webkit.org/b/141467 fast/multicol/pagination/LeftToRight-tb-hittest.html [ Failure ] >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 65957a86b22..c1cf3f28f82 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,34 @@ >+2019-05-23 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ Touch support is reported even when the device doesn't have a touch screen >+ https://bugs.webkit.org/show_bug.cgi?id=139681 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add screenHasTouchDevice() and screenIsTouchPrimaryInputDevice() to PlatformScreen and use it to decide whether >+ to expose touch events functionality or not. >+ >+ * bindings/js/WebCoreBuiltinNames.h: >+ * css/MediaQueryEvaluator.cpp: >+ (WebCore::hoverEvaluate): Use screenIsTouchPrimaryInputDevice() when touch events are enabled at build time. >+ (WebCore::anyHoverEvaluate): Use screenHasTouchDevice() when touch events are enabled at build time. >+ (WebCore::pointerEvaluate): Use screenIsTouchPrimaryInputDevice() when touch events are enabled at build time. >+ (WebCore::anyPointerEvaluate): Use screenHasTouchDevice() when touch events are enabled at build time. >+ * dom/GlobalEventHandlers.idl: Make touch event attributes enabled at runtime. >+ * page/RuntimeEnabledFeatures.cpp: >+ (WebCore::RuntimeEnabledFeatures::touchEventsEnabled const): Return whether touch events are enabled. >+ * page/RuntimeEnabledFeatures.h: >+ (WebCore::RuntimeEnabledFeatures::setTouchEventsEnabled): Force touch events to be enabled or disabled. >+ * platform/PlatformScreen.h: >+ (WebCore::screenHasTouchDevice): Just return true when touch events are enabled at build time for non-gtk ports. >+ (WebCore::screenIsTouchPrimaryInputDevice): Ditto. >+ * platform/gtk/PlatformScreenGtk.cpp: >+ (WebCore::screenHasTouchDevice): >+ (WebCore::screenIsTouchPrimaryInputDevice): >+ (WebCore::isTouchDevice): >+ (WebCore::deviceAddedCallback): >+ (WebCore::deviceRemovedCallback): >+ > 2019-05-21 Jer Noble <jer.noble@apple.com> > > Media controls don't show in WK2 video fullscreen sometimes >diff --git a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >index 0a3fa837ac6..f5b5322c7b9 100644 >--- a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >+++ b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >@@ -276,6 +276,11 @@ namespace WebCore { > macro(matchingElementInFlatTree) \ > macro(mediaStreamTrackConstraints) \ > macro(openDatabase) \ >+ macro(ontouchcancel) \ >+ macro(ontouchend) \ >+ macro(ontouchmove) \ >+ macro(ontouchstart) \ >+ macro(ontouchforcechange) \ > macro(onvrdisplayactivate) \ > macro(onvrdisplayblur) \ > macro(onvrdisplayconnect) \ >diff --git a/Source/WebCore/css/MediaQueryEvaluator.cpp b/Source/WebCore/css/MediaQueryEvaluator.cpp >index 527052b3d2b..6ee00de7f27 100644 >--- a/Source/WebCore/css/MediaQueryEvaluator.cpp >+++ b/Source/WebCore/css/MediaQueryEvaluator.cpp >@@ -693,7 +693,7 @@ static bool hoverEvaluate(CSSValue* value, const CSSToLengthConversionData&, Fra > { > if (!is<CSSPrimitiveValue>(value)) { > #if ENABLE(TOUCH_EVENTS) >- return false; >+ return !screenIsTouchPrimaryInputDevice(); > #else > return true; > #endif >@@ -701,15 +701,28 @@ static bool hoverEvaluate(CSSValue* value, const CSSToLengthConversionData&, Fra > > auto keyword = downcast<CSSPrimitiveValue>(*value).valueID(); > #if ENABLE(TOUCH_EVENTS) >- return keyword == CSSValueNone; >-#else >- return keyword == CSSValueHover; >+ if (screenIsTouchPrimaryInputDevice()) >+ return keyword == CSSValueNone; > #endif >+ return keyword == CSSValueHover; > } > >-static bool anyHoverEvaluate(CSSValue* value, const CSSToLengthConversionData& cssToLengthConversionData, Frame& frame, MediaFeaturePrefix prefix) >+static bool anyHoverEvaluate(CSSValue* value, const CSSToLengthConversionData&, Frame&, MediaFeaturePrefix) > { >- return hoverEvaluate(value, cssToLengthConversionData, frame, prefix); >+ if (!is<CSSPrimitiveValue>(value)) { >+#if ENABLE(TOUCH_EVENTS) >+ return !screenHasTouchDevice(); >+#else >+ return true; >+#endif >+ } >+ >+ auto keyword = downcast<CSSPrimitiveValue>(*value).valueID(); >+#if ENABLE(TOUCH_EVENTS) >+ if (screenHasTouchDevice()) >+ return keyword == CSSValueNone; >+#endif >+ return keyword == CSSValueHover; > } > > static bool pointerEvaluate(CSSValue* value, const CSSToLengthConversionData&, Frame&, MediaFeaturePrefix) >@@ -719,15 +732,23 @@ static bool pointerEvaluate(CSSValue* value, const CSSToLengthConversionData&, F > > auto keyword = downcast<CSSPrimitiveValue>(*value).valueID(); > #if ENABLE(TOUCH_EVENTS) >- return keyword == CSSValueCoarse; >-#else >- return keyword == CSSValueFine; >+ if (screenIsTouchPrimaryInputDevice()) >+ return keyword == CSSValueCoarse; > #endif >+ return keyword == CSSValueFine; > } > >-static bool anyPointerEvaluate(CSSValue* value, const CSSToLengthConversionData& cssToLengthConversionData, Frame& frame, MediaFeaturePrefix prefix) >+static bool anyPointerEvaluate(CSSValue* value, const CSSToLengthConversionData&, Frame&, MediaFeaturePrefix) > { >- return pointerEvaluate(value, cssToLengthConversionData, frame, prefix); >+ if (!is<CSSPrimitiveValue>(value)) >+ return true; >+ >+ auto keyword = downcast<CSSPrimitiveValue>(*value).valueID(); >+#if ENABLE(TOUCH_EVENTS) >+ if (screenHasTouchDevice()) >+ return keyword == CSSValueCoarse; >+#endif >+ return keyword == CSSValueFine; > } > > static bool prefersDarkInterfaceEvaluate(CSSValue* value, const CSSToLengthConversionData&, Frame& frame, MediaFeaturePrefix) >diff --git a/Source/WebCore/dom/GlobalEventHandlers.idl b/Source/WebCore/dom/GlobalEventHandlers.idl >index 54a7f28cbb1..770aa9c3a74 100644 >--- a/Source/WebCore/dom/GlobalEventHandlers.idl >+++ b/Source/WebCore/dom/GlobalEventHandlers.idl >@@ -123,11 +123,11 @@ > > [NotEnumerable] attribute EventHandler onsearch; > [NotEnumerable] attribute EventHandler onwheel; >- [NotEnumerable, Conditional=TOUCH_EVENTS] attribute EventHandler ontouchcancel; >- [NotEnumerable, Conditional=TOUCH_EVENTS] attribute EventHandler ontouchend; >- [NotEnumerable, Conditional=TOUCH_EVENTS] attribute EventHandler ontouchmove; >- [NotEnumerable, Conditional=TOUCH_EVENTS] attribute EventHandler ontouchstart; >- [NotEnumerable, Conditional=TOUCH_EVENTS] attribute EventHandler ontouchforcechange; >+ [NotEnumerable, Conditional=TOUCH_EVENTS, EnabledAtRuntime=TouchEvents] attribute EventHandler ontouchcancel; >+ [NotEnumerable, Conditional=TOUCH_EVENTS, EnabledAtRuntime=TouchEvents] attribute EventHandler ontouchend; >+ [NotEnumerable, Conditional=TOUCH_EVENTS, EnabledAtRuntime=TouchEvents] attribute EventHandler ontouchmove; >+ [NotEnumerable, Conditional=TOUCH_EVENTS, EnabledAtRuntime=TouchEvents] attribute EventHandler ontouchstart; >+ [NotEnumerable, Conditional=TOUCH_EVENTS, EnabledAtRuntime=TouchEvents] attribute EventHandler ontouchforcechange; > [NotEnumerable, Conditional=MOUSE_FORCE_EVENTS] attribute EventHandler onwebkitmouseforcechanged; > [NotEnumerable, Conditional=MOUSE_FORCE_EVENTS] attribute EventHandler onwebkitmouseforcedown; > [NotEnumerable, Conditional=MOUSE_FORCE_EVENTS] attribute EventHandler onwebkitmouseforcewillbegin; >diff --git a/Source/WebCore/page/RuntimeEnabledFeatures.cpp b/Source/WebCore/page/RuntimeEnabledFeatures.cpp >index 159a92aebde..e09b20ef54e 100644 >--- a/Source/WebCore/page/RuntimeEnabledFeatures.cpp >+++ b/Source/WebCore/page/RuntimeEnabledFeatures.cpp >@@ -33,6 +33,7 @@ > #include "RuntimeEnabledFeatures.h" > > #include "MediaPlayer.h" >+#include "PlatformScreen.h" > #include <JavaScriptCore/Options.h> > #include <wtf/NeverDestroyed.h> > >@@ -63,4 +64,11 @@ bool RuntimeEnabledFeatures::spectreGadgetsEnabled() const > return JSC::Options::enableSpectreGadgets(); > } > >+#if ENABLE(TOUCH_EVENTS) >+bool RuntimeEnabledFeatures::touchEventsEnabled() const >+{ >+ return m_touchEventsEnabled.valueOr(screenHasTouchDevice()); >+} >+#endif >+ > } // namespace WebCore >diff --git a/Source/WebCore/page/RuntimeEnabledFeatures.h b/Source/WebCore/page/RuntimeEnabledFeatures.h >index 3b49857f289..a40c7624929 100644 >--- a/Source/WebCore/page/RuntimeEnabledFeatures.h >+++ b/Source/WebCore/page/RuntimeEnabledFeatures.h >@@ -347,6 +347,8 @@ public: > #if ENABLE(TOUCH_EVENTS) > bool mouseEventsSimulationEnabled() const { return m_mouseEventsSimulationEnabled; } > void setMouseEventsSimulationEnabled(bool isEnabled) { m_mouseEventsSimulationEnabled = isEnabled; } >+ bool touchEventsEnabled() const; >+ void setTouchEventsEnabled(bool isEnabled) { m_touchEventsEnabled = isEnabled; } > #endif > > bool referrerPolicyAttributeEnabled() const { return m_referrerPolicyAttributeEnabled; } >@@ -531,6 +533,7 @@ private: > > #if ENABLE(TOUCH_EVENTS) > bool m_mouseEventsSimulationEnabled { false }; >+ Optional<bool> m_touchEventsEnabled; > #endif > > bool m_isITPDatabaseEnabled { false }; >diff --git a/Source/WebCore/platform/PlatformScreen.h b/Source/WebCore/platform/PlatformScreen.h >index c6990f73499..c5527d3c054 100644 >--- a/Source/WebCore/platform/PlatformScreen.h >+++ b/Source/WebCore/platform/PlatformScreen.h >@@ -122,4 +122,14 @@ WEBCORE_EXPORT float screenScaleFactor(UIScreen * = nullptr); > > #endif > >+#if ENABLE(TOUCH_EVENTS) >+#if PLATFORM(GTK) >+bool screenHasTouchDevice(); >+bool screenIsTouchPrimaryInputDevice(); >+#else >+bool screenHasTouchDevice() { return true; } >+bool screenIsTouchPrimaryInputDevice() { return true; } >+#endif >+#endif >+ > } // namespace WebCore >diff --git a/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp b/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp >index 395dfe546c4..1129b4bb944 100644 >--- a/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp >+++ b/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp >@@ -41,7 +41,9 @@ > #include <cmath> > #include <gtk/gtk.h> > #include <wtf/HashMap.h> >+#include <wtf/HashSet.h> > #include <wtf/NeverDestroyed.h> >+#include <wtf/glib/GUniquePtr.h> > > namespace WebCore { > >@@ -195,4 +197,112 @@ bool screenSupportsExtendedColor(Widget*) > return false; > } > >+#if ENABLE(TOUCH_EVENTS) >+#ifdef GTK_API_VERSION_2 >+bool screenHasTouchDevice() >+{ >+ return false; >+} >+ >+bool screenIsTouchPrimaryInputDevice() >+{ >+ return false; >+} >+#else // GTK_API_VERSION_2 >+#if !GTK_CHECK_VERSION(3, 20, 0) >+static void deviceAddedCallback(GdkDeviceManager*, GdkDevice*); >+static void deviceRemovedCallback(GdkDeviceManager*, GdkDevice*); >+ >+static HashSet<GdkDevice*>& touchDevices() >+{ >+ static LazyNeverDestroyed<HashSet<GdkDevice*>> touchDeviceSet; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [] { >+ touchDeviceSet.construct(); >+ >+ auto* display = gdk_display_get_default(); >+ if (!display) >+ return; >+ >+ auto* deviceManager = gdk_display_get_device_manager(display); >+ if (!deviceManager) >+ return; >+ >+ GUniquePtr<GList> devices(gdk_device_manager_list_devices(deviceManager, GDK_DEVICE_TYPE_SLAVE)); >+ for (GList* it = devices.get(); it; it = g_list_next(it)) { >+ auto* device = GDK_DEVICE(it->data); >+ if (gdk_device_get_source(device) == GDK_SOURCE_TOUCHSCREEN) >+ touchDeviceSet->add(device); >+ } >+ >+ g_signal_connect(deviceManager, "device-added", G_CALLBACK(deviceAddedCallback), nullptr); >+ g_signal_connect(deviceManager, "device-removed", G_CALLBACK(deviceRemovedCallback), nullptr); >+ }); >+ >+ return touchDeviceSet; >+} >+ >+static inline bool isTouchDevice(GdkDevice* device) >+{ >+ return gdk_device_get_device_type(device) == GDK_DEVICE_TYPE_SLAVE && gdk_device_get_source(device) == GDK_SOURCE_TOUCHSCREEN; >+} >+ >+static void deviceAddedCallback(GdkDeviceManager*, GdkDevice* device) >+{ >+ if (!isTouchDevice(device)) >+ return; >+ >+ ASSERT(!touchDevices().contains(device)); >+ touchDevices().add(device); >+} >+ >+static void deviceRemovedCallback(GdkDeviceManager*, GdkDevice* device) >+{ >+ if (!isTouchDevice(device)) >+ return; >+ >+ ASSERT(touchDevices().contains(device)); >+ touchDevices().remove(device); >+} >+#endif // !GTK_CHECK_VERSION(3, 20, 0) >+ >+bool screenHasTouchDevice() >+{ >+#if GTK_CHECK_VERSION(3, 20, 0) >+ auto* display = gdk_display_get_default(); >+ if (!display) >+ return true; >+ >+ auto* seat = gdk_display_get_default_seat(display); >+ return seat ? gdk_seat_get_capabilities(seat) & GDK_SEAT_CAPABILITY_TOUCH : true; >+#else >+ return !touchDevices().isEmpty(); >+#endif >+} >+ >+bool screenIsTouchPrimaryInputDevice() >+{ >+ auto* display = gdk_display_get_default(); >+ if (!display) >+ return true; >+ >+#if GTK_CHECK_VERSION(3, 20, 0) >+ auto* seat = gdk_display_get_default_seat(display); >+ if (!seat) >+ return true; >+ >+ auto* device = gdk_seat_get_pointer(seat); >+#else >+ auto* deviceManager = gdk_display_get_device_manager(display); >+ if (!deviceManager) >+ return true; >+ >+ auto* device = gdk_device_manager_get_client_pointer(deviceManager); >+#endif >+ >+ return device ? gdk_device_get_source(device) == GDK_SOURCE_TOUCHSCREEN : true; >+} >+#endif // !GTK_API_VERSION_2 >+#endif // ENABLE(TOUCH_EVENTS) >+ > } // namespace WebCore
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mcatanzaro
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 139681
:
243496
| 370502