Title: [268086] trunk
Revision
268086
Author
[email protected]
Date
2020-10-06 16:44:47 -0700 (Tue, 06 Oct 2020)

Log Message

CSS hover and "pointer: fine" media queries do not evaluate to true with iOS 13.4 mouse support
https://bugs.webkit.org/show_bug.cgi?id=209292
<rdar://problem/60663124>

Reviewed by Tim Horton.

Source/WebCore:

On iOS, the primary pointer will always be touch input, so the `hover`/`pointer` media query
should never change. If a mouse is connected, however, `any-hover`/`any-pointer` should
change as now there is at least one device that supports `hover`/`fine`. Note that in the
case of `any-pointer` this means that both `coarse` and `fine` will apply. Catalyst assumes
that there is always a mouse connected.

Spec: https://drafts.csswg.org/mediaqueries-4/#any-input

* css/MediaQueryEvaluator.cpp:
(WebCore::anyHoverEvaluate):
(WebCore::anyPointerEvaluate):

* page/ChromeClient.h:
* loader/EmptyClients.h:
(WebCore::EmptyChromeClient::hoverSupportedByAnyAvailablePointingDevice const): Added.
(WebCore::EmptyChromeClient::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
Provide a way for WebCore to get the current state of whether there are any mouse devices.
Refactor logic in `anyHoverEvaluate` and `anyPointerEvaluate` to move platform code into the
respective `WebKit::WebPage` file.

* page/PointerCharacteristics.h: Added.
Enum for `Coarse` and `Fine`.

* platform/PlatformScreen.h:
Export additional functions for use in WebKit.

* Headers.cmake:
* WebCore.xcodeproj/project.pbxproj:

Source/WebKit:

On iOS, the primary pointer will always be touch input, so the `hover`/`pointer` media query
should never change. If a mouse is connected, however, `any-hover`/`any-pointer` should
change as now there is at least one device that supports `hover`/`fine`. Note that in the
case of `any-pointer` this means that both `coarse` and `fine` will apply. Catalyst assumes
that there is always a mouse connected.

Spec: https://drafts.csswg.org/mediaqueries-4/#any-input

* UIProcess/ios/WKMouseDeviceObserver.h: Added.
* UIProcess/ios/WKMouseDeviceObserver.mm: Added.
(+[WKMouseDeviceObserver sharedInstance]):
(-[WKMouseDeviceObserver dealloc]):
(-[WKMouseDeviceObserver start]):
(-[WKMouseDeviceObserver stop]):
(-[WKMouseDeviceObserver mousePointerDevicesDidChange:]):
(-[WKMouseDeviceObserver _setHasMouseDeviceForTesting:]):
Use `BackBoardServices` to listen for mouse devices changes and notify all WebProcess.

* UIProcess/WebProcessProxy.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::WebProcessProxy):
(WebKit::WebProcessProxy::platformInitialize): Added.
(WebKit::WebProcessProxy::~WebProcessProxy):
(WebKit::WebProcessProxy::platformDestroy): Added.
* UIProcess/ios/WebProcessProxyIOS.mm:
(WebKit::WebProcessProxy::platformInitialize): Added.
(WebKit::WebProcessProxy::platformDestroy): Added.
(WebKit::WebProcessProxy::notifyHasMouseDeviceChanged): Added.
Tell the shared `WKMouseDeviceObserver` to start listening for mouse device changes when
creating the WebProcess so that the shared `WKMouseDeviceObserver` knows to notify all
instances when mouse devices change. Make `allProcesses` into a `private static` member
function so that it can also be used in `UIProcess/ios/WebProcessProxyIOS.mm`.

* Shared/WebProcessCreationParameters.h:
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
Use the current state of the shared `WKMouseDeviceObserver` when creating WebProcess instead
of sending a `SetHasMouseDevice` message immediately after the WebProcess is created.

* WebProcess/WebProcess.messages.in:
* WebProcess/WebProcess.h:
(WebKit::WebProcess::hasMouseDevice const): Added.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::setHasMouseDevice): Added.
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):
Update style (including `any-hover` and `any-pointer`) whenever mouse devices change.

* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::hoverSupportedByAnyAvailablePointingDevice const): Added.
(WebKit::WebChromeClient::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/gtk/WebPageGtk.cpp:
(WebKit::WebPage::hoverSupportedByAnyAvailablePointingDevice const): Added.
(WebKit::WebPage::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::hasMouseDevice): Added.
(WebKit::WebPage::hoverSupportedByAnyAvailablePointingDevice const): Added.
(WebKit::WebPage::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::hoverSupportedByAnyAvailablePointingDevice const): Added.
(WebKit::WebPage::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
* WebProcess/WebPage/playstation/WebPagePlayStation.cpp:
(WebKit::WebPage::hoverSupportedByAnyAvailablePointingDevice const): Added.
(WebKit::WebPage::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
* WebProcess/WebPage/win/WebPageWin.cpp:
(WebKit::WebPage::hoverSupportedByAnyAvailablePointingDevice const): Added.
(WebKit::WebPage::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
* WebProcess/WebPage/wpe/WebPageWPE.cpp:
(WebKit::WebPage::hoverSupportedByAnyAvailablePointingDevice const): Added.
(WebKit::WebPage::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
Provide a way for WebCore to get the current state of whether there are any mouse devices.
Refactor logic in `WebCore::anyHoverEvaluate` and `WebCore::anyPointerEvaluate` to move
platform code into the respective `WebPage` file.

* Configurations/WebKit.xcconfig:
* Platform/spi/ios/BackBoardServicesSPI.h:
* Platform/spi/ios/BaseBoardSPI.h: Added.
* SourcesCocoa.txt:
* WebKit.xcodeproj/project.pbxproj:

Source/WebKitLegacy/ios:

* WebCoreSupport/WebChromeClientIOS.h:
(WebChromeClientIOS::hoverSupportedByAnyAvailablePointingDevice const): Added.
(WebChromeClientIOS::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
Mouse devices are not supported.

Source/WebKitLegacy/mac:

* WebCoreSupport/WebChromeClient.h:
(WebChromeClient::hoverSupportedByAnyAvailablePointingDevice const): Added.
(WebChromeClient::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
Mouse devices are always supported.

Source/WebKitLegacy/win:

* WebCoreSupport/WebChromeClient.h:
(WebChromeClient::hoverSupportedByAnyAvailablePointingDevice const): Added.
(WebChromeClient::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
Mouse devices are always supported.

Tools:

* TestWebKitAPI/cocoa/TestWKWebView.h:
* TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[TestWKWebView evaluateMediaQuery:]): Added.
Create helper function for synchronously testing media queries.

* TestWebKitAPI/Tests/WebKitCocoa/iOSMouseSupport.mm:
(iOSMouseSupport.MouseInitiallyDisconnected): Added.
(iOSMouseSupport.MouseInitiallyConnected): Added.
(iOSMouseSupport.MouseLaterDisconnected): Added.
(iOSMouseSupport.MouseLaterConnected): Added.
(iOSMouseSupport.MouseAlwaysConnected): Added.

WebKitLibraries:

* WebKitPrivateFrameworkStubs/iOS/13/BackBoardServices.framework/BackBoardServices.tbd: Added.
* WebKitPrivateFrameworkStubs/iOS/14/BackBoardServices.framework/BackBoardServices.tbd: Added.
Use `BackBoardServices` to listen for mouse devices changes.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (268085 => 268086)


--- trunk/Source/WebCore/ChangeLog	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebCore/ChangeLog	2020-10-06 23:44:47 UTC (rev 268086)
@@ -1,3 +1,40 @@
+2020-10-06  Devin Rousso  <[email protected]>
+
+        CSS hover and "pointer: fine" media queries do not evaluate to true with iOS 13.4 mouse support
+        https://bugs.webkit.org/show_bug.cgi?id=209292
+        <rdar://problem/60663124>
+
+        Reviewed by Tim Horton.
+
+        On iOS, the primary pointer will always be touch input, so the `hover`/`pointer` media query
+        should never change. If a mouse is connected, however, `any-hover`/`any-pointer` should
+        change as now there is at least one device that supports `hover`/`fine`. Note that in the
+        case of `any-pointer` this means that both `coarse` and `fine` will apply. Catalyst assumes
+        that there is always a mouse connected.
+
+        Spec: https://drafts.csswg.org/mediaqueries-4/#any-input
+
+        * css/MediaQueryEvaluator.cpp:
+        (WebCore::anyHoverEvaluate):
+        (WebCore::anyPointerEvaluate):
+
+        * page/ChromeClient.h:
+        * loader/EmptyClients.h:
+        (WebCore::EmptyChromeClient::hoverSupportedByAnyAvailablePointingDevice const): Added.
+        (WebCore::EmptyChromeClient::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
+        Provide a way for WebCore to get the current state of whether there are any mouse devices.
+        Refactor logic in `anyHoverEvaluate` and `anyPointerEvaluate` to move platform code into the
+        respective `WebKit::WebPage` file.
+
+        * page/PointerCharacteristics.h: Added.
+        Enum for `Coarse` and `Fine`.
+
+        * platform/PlatformScreen.h:
+        Export additional functions for use in WebKit.
+
+        * Headers.cmake:
+        * WebCore.xcodeproj/project.pbxproj:
+
 2020-10-06  James Darpinian  <[email protected]>
 
         Support EXT_texture_compression_rgtc WebGL extension

Modified: trunk/Source/WebCore/Headers.cmake (268085 => 268086)


--- trunk/Source/WebCore/Headers.cmake	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebCore/Headers.cmake	2020-10-06 23:44:47 UTC (rev 268086)
@@ -854,6 +854,7 @@
     page/PerformanceLoggingClient.h
     page/PlugInClient.h
     page/PointerCaptureController.h
+    page/PointerCharacteristics.h
     page/PointerLockController.h
     page/PostMessageOptions.h
     page/PrewarmInformation.h

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (268085 => 268086)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-10-06 23:44:47 UTC (rev 268086)
@@ -2858,6 +2858,7 @@
 		94E839561DFB2BC4007BC6A7 /* JSCSSNamespaceRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 94E839541DFB2BA6007BC6A7 /* JSCSSNamespaceRule.h */; };
 		952076051F2675FE007D2AAB /* CallTracer.h in Headers */ = {isa = PBXBuildFile; fileRef = 952076011F2675F9007D2AAB /* CallTracer.h */; };
 		952076061F2675FE007D2AAB /* CallTracerTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 952076021F2675F9007D2AAB /* CallTracerTypes.h */; };
+		95DF9D25252BEDB2000D7F46 /* PointerCharacteristics.h in Headers */ = {isa = PBXBuildFile; fileRef = 95DF9D23252BED99000D7F46 /* PointerCharacteristics.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9705997A107D975200A50A7C /* PolicyChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059976107D975200A50A7C /* PolicyChecker.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		970B728A144FFAC600F00A37 /* EventInterfaces.h in Headers */ = {isa = PBXBuildFile; fileRef = 970B7289144FFAC600F00A37 /* EventInterfaces.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		970B72A6145008EB00F00A37 /* EventHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 970B72A5145008EB00F00A37 /* EventHeaders.h */; };
@@ -11462,6 +11463,7 @@
 		952076001F2675F9007D2AAB /* CallTracer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CallTracer.cpp; sourceTree = "<group>"; };
 		952076011F2675F9007D2AAB /* CallTracer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CallTracer.h; sourceTree = "<group>"; };
 		952076021F2675F9007D2AAB /* CallTracerTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CallTracerTypes.h; sourceTree = "<group>"; };
+		95DF9D23252BED99000D7F46 /* PointerCharacteristics.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PointerCharacteristics.h; sourceTree = "<group>"; };
 		96ABA42214BCB80E00D56204 /* GraphicsContextGLOpenGLCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextGLOpenGLCommon.cpp; sourceTree = "<group>"; };
 		97059975107D975200A50A7C /* PolicyChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyChecker.cpp; sourceTree = "<group>"; };
 		97059976107D975200A50A7C /* PolicyChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyChecker.h; sourceTree = "<group>"; };
@@ -21742,6 +21744,7 @@
 				31D591B116697A6C00E6BF02 /* PlugInClient.h */,
 				71B5AB2521F1D9E300376E5C /* PointerCaptureController.cpp */,
 				71B5AB2421F1D9E200376E5C /* PointerCaptureController.h */,
+				95DF9D23252BED99000D7F46 /* PointerCharacteristics.h */,
 				5CFC434E192406A900A0D3B5 /* PointerLockController.cpp */,
 				5CFC434F192406A900A0D3B5 /* PointerLockController.h */,
 				3772B09516535856000A49CA /* PopupOpeningObserver.h */,
@@ -33435,6 +33438,7 @@
 				BCBB8ABA13F1AFB000734DF0 /* PODIntervalTree.h in Headers */,
 				BCBB8ABB13F1AFB000734DF0 /* PODRedBlackTree.h in Headers */,
 				71B5AB2621F1D9F400376E5C /* PointerCaptureController.h in Headers */,
+				95DF9D25252BEDB2000D7F46 /* PointerCharacteristics.h in Headers */,
 				317D3FF3215599F40034E3B9 /* PointerEvent.h in Headers */,
 				B2B1F7170D00CAA8004AEA64 /* PointerEventsHitRules.h in Headers */,
 				71EADCD822087E720065A45F /* PointerID.h in Headers */,

Modified: trunk/Source/WebCore/css/MediaQueryEvaluator.cpp (268085 => 268086)


--- trunk/Source/WebCore/css/MediaQueryEvaluator.cpp	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebCore/css/MediaQueryEvaluator.cpp	2020-10-06 23:44:47 UTC (rev 268086)
@@ -33,6 +33,8 @@
 #include "CSSPrimitiveValue.h"
 #include "CSSToLengthConversionData.h"
 #include "CSSValueKeywords.h"
+#include "Chrome.h"
+#include "ChromeClient.h"
 #include "Frame.h"
 #include "FrameView.h"
 #include "Logging.h"
@@ -730,22 +732,16 @@
     return keyword == CSSValueHover;
 }
 
-static bool anyHoverEvaluate(CSSValue* value, const CSSToLengthConversionData&, Frame&, MediaFeaturePrefix)
+static bool anyHoverEvaluate(CSSValue* value, const CSSToLengthConversionData&, Frame& frame, MediaFeaturePrefix)
 {
-    if (!is<CSSPrimitiveValue>(value)) {
-#if ENABLE(TOUCH_EVENTS)
-        return !screenHasTouchDevice();
-#else
-        return true;
-#endif
-    }
+    auto* page = frame.page();
+    bool hoverSupportedByAnyAvailablePointingDevice = page && page->chrome().client().hoverSupportedByAnyAvailablePointingDevice();
 
+    if (!is<CSSPrimitiveValue>(value))
+        return hoverSupportedByAnyAvailablePointingDevice;
+
     auto keyword = downcast<CSSPrimitiveValue>(*value).valueID();
-#if ENABLE(TOUCH_EVENTS)
-    if (screenHasTouchDevice())
-        return keyword == CSSValueNone;
-#endif
-    return keyword == CSSValueHover;
+    return hoverSupportedByAnyAvailablePointingDevice ? (keyword == CSSValueHover) : (keyword == CSSValueNone);
 }
 
 static bool pointerEvaluate(CSSValue* value, const CSSToLengthConversionData&, Frame& frame, MediaFeaturePrefix)
@@ -765,17 +761,22 @@
     return keyword == CSSValueFine;
 }
 
-static bool anyPointerEvaluate(CSSValue* value, const CSSToLengthConversionData&, Frame&, MediaFeaturePrefix)
+static bool anyPointerEvaluate(CSSValue* value, const CSSToLengthConversionData&, Frame& frame, MediaFeaturePrefix)
 {
+    auto* page = frame.page();
+    auto pointerCharacteristicsOfAllAvailablePointingDevices = page ? page->chrome().client().pointerCharacteristicsOfAllAvailablePointingDevices() : OptionSet<PointerCharacteristics>();
+
     if (!is<CSSPrimitiveValue>(value))
-        return true;
+        return !pointerCharacteristicsOfAllAvailablePointingDevices.isEmpty();
 
     auto keyword = downcast<CSSPrimitiveValue>(*value).valueID();
-#if ENABLE(TOUCH_EVENTS)
-    if (screenHasTouchDevice())
-        return keyword == CSSValueCoarse;
-#endif
-    return keyword == CSSValueFine;
+    if (keyword == CSSValueFine)
+        return pointerCharacteristicsOfAllAvailablePointingDevices.contains(PointerCharacteristics::Fine);
+    if (keyword == CSSValueCoarse)
+        return pointerCharacteristicsOfAllAvailablePointingDevices.contains(PointerCharacteristics::Coarse);
+    if (keyword == CSSValueNone)
+        return pointerCharacteristicsOfAllAvailablePointingDevices.isEmpty();
+    return false;
 }
 
 static bool prefersDarkInterfaceEvaluate(CSSValue* value, const CSSToLengthConversionData&, Frame& frame, MediaFeaturePrefix)

Modified: trunk/Source/WebCore/loader/EmptyClients.h (268085 => 268086)


--- trunk/Source/WebCore/loader/EmptyClients.h	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebCore/loader/EmptyClients.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -102,6 +102,9 @@
 
     KeyboardUIMode keyboardUIMode() final { return KeyboardAccessDefault; }
 
+    bool hoverSupportedByAnyAvailablePointingDevice() const final { return false; }
+    OptionSet<PointerCharacteristics> pointerCharacteristicsOfAllAvailablePointingDevices() const final { return { }; }
+
     void invalidateRootView(const IntRect&) final { }
     void invalidateContentsAndRootView(const IntRect&) override { }
     void invalidateContentsForSlowScroll(const IntRect&) final { }

Modified: trunk/Source/WebCore/page/ChromeClient.h (268085 => 268086)


--- trunk/Source/WebCore/page/ChromeClient.h	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebCore/page/ChromeClient.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -39,6 +39,7 @@
 #include "ImageBuffer.h"
 #include "InputMode.h"
 #include "MediaProducer.h"
+#include "PointerCharacteristics.h"
 #include "PopupMenu.h"
 #include "PopupMenuClient.h"
 #include "RegistrableDomain.h"
@@ -178,6 +179,9 @@
     virtual void setStatusbarText(const String&) = 0;
     virtual KeyboardUIMode keyboardUIMode() = 0;
 
+    virtual bool hoverSupportedByAnyAvailablePointingDevice() const = 0;
+    virtual OptionSet<PointerCharacteristics> pointerCharacteristicsOfAllAvailablePointingDevices() const = 0;
+
     virtual bool supportsImmediateInvalidation() { return false; }
     virtual void invalidateRootView(const IntRect&) = 0;
     virtual void invalidateContentsAndRootView(const IntRect&) = 0;

Added: trunk/Source/WebCore/page/PointerCharacteristics.h (0 => 268086)


--- trunk/Source/WebCore/page/PointerCharacteristics.h	                        (rev 0)
+++ trunk/Source/WebCore/page/PointerCharacteristics.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+enum class PointerCharacteristics : uint8_t {
+    Coarse = 1 << 0,
+    Fine = 1 << 1,
+};
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/platform/PlatformScreen.h (268085 => 268086)


--- trunk/Source/WebCore/platform/PlatformScreen.h	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebCore/platform/PlatformScreen.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -152,8 +152,8 @@
 
 #if ENABLE(TOUCH_EVENTS)
 #if PLATFORM(GTK) || PLATFORM(WPE)
-bool screenHasTouchDevice();
-bool screenIsTouchPrimaryInputDevice();
+WEBCORE_EXPORT bool screenHasTouchDevice();
+WEBCORE_EXPORT bool screenIsTouchPrimaryInputDevice();
 #else
 constexpr bool screenHasTouchDevice() { return true; }
 constexpr bool screenIsTouchPrimaryInputDevice() { return true; }

Modified: trunk/Source/WebKit/ChangeLog (268085 => 268086)


--- trunk/Source/WebKit/ChangeLog	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/ChangeLog	2020-10-06 23:44:47 UTC (rev 268086)
@@ -1,3 +1,96 @@
+2020-10-06  Devin Rousso  <[email protected]>
+
+        CSS hover and "pointer: fine" media queries do not evaluate to true with iOS 13.4 mouse support
+        https://bugs.webkit.org/show_bug.cgi?id=209292
+        <rdar://problem/60663124>
+
+        Reviewed by Tim Horton.
+
+        On iOS, the primary pointer will always be touch input, so the `hover`/`pointer` media query
+        should never change. If a mouse is connected, however, `any-hover`/`any-pointer` should
+        change as now there is at least one device that supports `hover`/`fine`. Note that in the
+        case of `any-pointer` this means that both `coarse` and `fine` will apply. Catalyst assumes
+        that there is always a mouse connected.
+
+        Spec: https://drafts.csswg.org/mediaqueries-4/#any-input
+
+        * UIProcess/ios/WKMouseDeviceObserver.h: Added.
+        * UIProcess/ios/WKMouseDeviceObserver.mm: Added.
+        (+[WKMouseDeviceObserver sharedInstance]):
+        (-[WKMouseDeviceObserver dealloc]):
+        (-[WKMouseDeviceObserver start]):
+        (-[WKMouseDeviceObserver stop]):
+        (-[WKMouseDeviceObserver mousePointerDevicesDidChange:]):
+        (-[WKMouseDeviceObserver _setHasMouseDeviceForTesting:]):
+        Use `BackBoardServices` to listen for mouse devices changes and notify all WebProcess.
+
+        * UIProcess/WebProcessProxy.h:
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::WebProcessProxy):
+        (WebKit::WebProcessProxy::platformInitialize): Added.
+        (WebKit::WebProcessProxy::~WebProcessProxy):
+        (WebKit::WebProcessProxy::platformDestroy): Added.
+        * UIProcess/ios/WebProcessProxyIOS.mm:
+        (WebKit::WebProcessProxy::platformInitialize): Added.
+        (WebKit::WebProcessProxy::platformDestroy): Added.
+        (WebKit::WebProcessProxy::notifyHasMouseDeviceChanged): Added.
+        Tell the shared `WKMouseDeviceObserver` to start listening for mouse device changes when
+        creating the WebProcess so that the shared `WKMouseDeviceObserver` knows to notify all
+        instances when mouse devices change. Make `allProcesses` into a `private static` member
+        function so that it can also be used in `UIProcess/ios/WebProcessProxyIOS.mm`.
+
+        * Shared/WebProcessCreationParameters.h:
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode const):
+        (WebKit::WebProcessCreationParameters::decode):
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess):
+        Use the current state of the shared `WKMouseDeviceObserver` when creating WebProcess instead
+        of sending a `SetHasMouseDevice` message immediately after the WebProcess is created.
+
+        * WebProcess/WebProcess.messages.in:
+        * WebProcess/WebProcess.h:
+        (WebKit::WebProcess::hasMouseDevice const): Added.
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::setHasMouseDevice): Added.
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+        Update style (including `any-hover` and `any-pointer`) whenever mouse devices change.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::hoverSupportedByAnyAvailablePointingDevice const): Added.
+        (WebKit::WebChromeClient::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/gtk/WebPageGtk.cpp:
+        (WebKit::WebPage::hoverSupportedByAnyAvailablePointingDevice const): Added.
+        (WebKit::WebPage::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::hasMouseDevice): Added.
+        (WebKit::WebPage::hoverSupportedByAnyAvailablePointingDevice const): Added.
+        (WebKit::WebPage::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::hoverSupportedByAnyAvailablePointingDevice const): Added.
+        (WebKit::WebPage::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
+        * WebProcess/WebPage/playstation/WebPagePlayStation.cpp:
+        (WebKit::WebPage::hoverSupportedByAnyAvailablePointingDevice const): Added.
+        (WebKit::WebPage::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
+        * WebProcess/WebPage/win/WebPageWin.cpp:
+        (WebKit::WebPage::hoverSupportedByAnyAvailablePointingDevice const): Added.
+        (WebKit::WebPage::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
+        * WebProcess/WebPage/wpe/WebPageWPE.cpp:
+        (WebKit::WebPage::hoverSupportedByAnyAvailablePointingDevice const): Added.
+        (WebKit::WebPage::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
+        Provide a way for WebCore to get the current state of whether there are any mouse devices.
+        Refactor logic in `WebCore::anyHoverEvaluate` and `WebCore::anyPointerEvaluate` to move
+        platform code into the respective `WebPage` file.
+
+        * Configurations/WebKit.xcconfig:
+        * Platform/spi/ios/BackBoardServicesSPI.h:
+        * Platform/spi/ios/BaseBoardSPI.h: Added.
+        * SourcesCocoa.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+
 2020-10-06  Simon Fraser  <[email protected]>
 
         Redundant rendering updates can be scheduled from inside Page::updateRendering()

Modified: trunk/Source/WebKit/Configurations/WebKit.xcconfig (268085 => 268086)


--- trunk/Source/WebKit/Configurations/WebKit.xcconfig	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/Configurations/WebKit.xcconfig	2020-10-06 23:44:47 UTC (rev 268086)
@@ -60,6 +60,10 @@
 WK_ASSERTION_SERVICES_LDFLAGS_appletvsimulator = -framework AssertionServices;
 WK_ASSERTION_SERVICES_LDFLAGS_maccatalyst = -framework AssertionServices;
 
+WK_BACKBOARD_SERVICES_LDFLAGS = $(WK_BACKBOARD_SERVICES_LDFLAGS_$(WK_PLATFORM_NAME));
+WK_BACKBOARD_SERVICES_LDFLAGS_iphoneos = -framework BackBoardServices;
+WK_BACKBOARD_SERVICES_LDFLAGS_iphonesimulator = -framework BackBoardServices;
+
 WK_RUNNINGBOARD_SERVICES_LDFLAGS = $(WK_RUNNINGBOARD_SERVICES_LDFLAGS_$(WK_COCOA_TOUCH));
 WK_RUNNINGBOARD_SERVICES_LDFLAGS_cocoatouch = -framework RunningBoardServices;
 
@@ -123,7 +127,7 @@
 WK_AUTHKIT_LDFLAGS_macosx = $(WK_AUTHKIT_LDFLAGS$(WK_MACOS_1015));
 WK_AUTHKIT_LDFLAGS_MACOS_SINCE_1015 = -framework AuthKit;
 
-FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework IOSurface -framework WebKitLegacy -lnetwork $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_ASSERTION_SERVICES_LDFLAGS) $(WK_RUNNINGBOARD_SERVICES_LDFLAGS) $(WK_AUTHKIT_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_LIBSANDBOX_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_SECURITY_INTERFACE_LDFLAGS) $(WK_UIKIT_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS) $(WK_WEBINSPECTORUI_LDFLAGS);
+FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework IOSurface -framework WebKitLegacy -lnetwork $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_ASSERTION_SERVICES_LDFLAGS) $(WK_BACKBOARD_SERVICES_LDFLAGS) $(WK_RUNNINGBOARD_SERVICES_LDFLAGS) $(WK_AUTHKIT_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_LIBSANDBOX_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_SECURITY_INTERFACE_LDFLAGS) $(WK_UIKIT_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS) $(WK_WEBINSPECTORUI_LDFLAGS);
 
 // Prevent C++ standard library basic_stringstream, operator new, delete and their related exception types from being exported as weak symbols.
 UNEXPORTED_SYMBOL_LDFLAGS = -Wl,-unexported_symbol -Wl,__ZTISt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTISt9exception -Wl,-unexported_symbol -Wl,__ZTSSt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTSSt9exception -Wl,-unexported_symbol -Wl,__ZdlPvS_ -Wl,-unexported_symbol -Wl,__ZnwmPv -Wl,-unexported_symbol -Wl,__Znwm -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC2EOS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC1EOS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEaSEDn -Wl,-unexported_symbol -Wl,__ZNKSt3__18functionIFvN7WebCore12PolicyActionEEEclES2_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEE4swapERS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC1ERKS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC2ERKS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEE
 ED1Ev -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEED2Ev -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEaSERKS4_ -Wl,-unexported_symbol -Wl,__ZTVNSt3__117bad_function_callE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE0_NS_13basic_istreamIcS2_EE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE0_NS_14basic_iostreamIcS2_EE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE16_NS_13basic_ostreamIcS2_EE -Wl,-unexported_symbol -Wl,__ZTTNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE -Wl,-unexported_symbol -Wl,__ZTVNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEEE -Wl,-unexported_symbol -Wl,__ZTVNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEE
 NS_9allocatorIcEEEE8_NS_13basic_ostreamIcS2_EE;

Modified: trunk/Source/WebKit/Platform/spi/ios/BackBoardServicesSPI.h (268085 => 268086)


--- trunk/Source/WebKit/Platform/spi/ios/BackBoardServicesSPI.h	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/Platform/spi/ios/BackBoardServicesSPI.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -27,11 +27,27 @@
 
 #import <BackBoardServices/BKSAnimationFence.h>
 #import <BackBoardServices/BKSAnimationFence_Private.h>
+#import <BackBoardServices/BKSMousePointerService.h>
 
 #else
 
+#import "BaseBoardSPI.h"
+
 @interface BKSAnimationFenceHandle : NSObject
 - (mach_port_t)CAPort;
 @end
 
+@class BKSMousePointerDevice;
+
+@protocol BKSMousePointerDeviceObserver <NSObject>
+@optional
+- (void)mousePointerDevicesDidConnect:(NSSet<BKSMousePointerDevice *> *)mousePointerDevices;
+- (void)mousePointerDevicesDidDisconnect:(NSSet<BKSMousePointerDevice *> *)mousePointerDevices;
+@end
+
+@interface BKSMousePointerService : NSObject
++ (BKSMousePointerService *)sharedInstance;
+- (id<BSInvalidatable>)addPointerDeviceObserver:(id<BKSMousePointerDeviceObserver>)observer;
+@end
+
 #endif // USE(APPLE_INTERNAL_SDK)

Copied: trunk/Source/WebKit/Platform/spi/ios/BaseBoardSPI.h (from rev 268085, trunk/Source/WebKit/Platform/spi/ios/BackBoardServicesSPI.h) (0 => 268086)


--- trunk/Source/WebKit/Platform/spi/ios/BaseBoardSPI.h	                        (rev 0)
+++ trunk/Source/WebKit/Platform/spi/ios/BaseBoardSPI.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <BaseBoard/BSInvalidatable.h>
+
+#else
+
+@protocol BSInvalidatable <NSObject>
+- (void)invalidate;
+@end
+
+#endif // USE(APPLE_INTERNAL_SDK)

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (268085 => 268086)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2020-10-06 23:44:47 UTC (rev 268086)
@@ -85,6 +85,9 @@
 #endif
     encoder << textCheckerState;
     encoder << fullKeyboardAccessEnabled;
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+    encoder << hasMouseDevice;
+#endif
     encoder << defaultRequestTimeoutInterval;
     encoder << backForwardCacheCapacity;
 #if PLATFORM(COCOA)
@@ -294,6 +297,10 @@
         return false;
     if (!decoder.decode(parameters.fullKeyboardAccessEnabled))
         return false;
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+    if (!decoder.decode(parameters.hasMouseDevice))
+        return false;
+#endif
     if (!decoder.decode(parameters.defaultRequestTimeoutInterval))
         return false;
     if (!decoder.decode(parameters.backForwardCacheCapacity))

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (268085 => 268086)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -117,6 +117,9 @@
     bool shouldSuppressMemoryPressureHandler { false };
     bool shouldUseFontSmoothing { true };
     bool fullKeyboardAccessEnabled { false };
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+    bool hasMouseDevice { false };
+#endif
     bool memoryCacheDisabled { false };
     bool attrStyleEnabled { false };
     bool useGPUProcessForMediaEnabled { false };

Modified: trunk/Source/WebKit/SourcesCocoa.txt (268085 => 268086)


--- trunk/Source/WebKit/SourcesCocoa.txt	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2020-10-06 23:44:47 UTC (rev 268086)
@@ -460,6 +460,7 @@
 UIProcess/ios/WKGeolocationProviderIOSObjCSecurityOrigin.mm
 UIProcess/ios/WKHighlightLongPressGestureRecognizer.mm
 UIProcess/ios/WKKeyboardScrollingAnimator.mm
+UIProcess/ios/WKMouseDeviceObserver.mm
 UIProcess/ios/WKMouseGestureRecognizer.mm
 UIProcess/ios/WKPasswordView.mm
 UIProcess/ios/WKPDFPageNumberIndicator.mm

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (268085 => 268086)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-10-06 23:44:47 UTC (rev 268086)
@@ -40,6 +40,7 @@
 #import "TextChecker.h"
 #import "UserInterfaceIdiom.h"
 #import "WKBrowsingContextControllerInternal.h"
+#import "WKMouseDeviceObserver.h"
 #import "WebBackForwardCache.h"
 #import "WebMemoryPressureHandler.h"
 #import "WebPageGroup.h"
@@ -505,6 +506,10 @@
 #if HAVE(CATALYST_USER_INTERFACE_IDIOM_AND_SCALE_FACTOR)
     parameters.overrideUserInterfaceIdiomAndScale = { _UIApplicationCatalystUserInterfaceIdiom(), _UIApplicationCatalystScaleFactor() };
 #endif
+
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+    parameters.hasMouseDevice = [[WKMouseDeviceObserver sharedInstance] hasMouseDevice];
+#endif
 }
 
 void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationParameters& parameters)

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (268085 => 268086)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2020-10-06 23:44:47 UTC (rev 268086)
@@ -109,7 +109,7 @@
 #endif
 }
 
-static HashMap<ProcessIdentifier, WebProcessProxy*>& allProcesses()
+HashMap<ProcessIdentifier, WebProcessProxy*>& WebProcessProxy::allProcesses()
 {
     ASSERT(isMainThreadOrCheckDisabled());
     static NeverDestroyed<HashMap<ProcessIdentifier, WebProcessProxy*>> map;
@@ -210,8 +210,16 @@
     ASSERT_UNUSED(result, result.isNewEntry);
 
     WebPasteboardProxy::singleton().addWebProcessProxy(*this);
+
+    platformInitialize();
 }
 
+#if !PLATFORM(IOS_FAMILY)
+void WebProcessProxy::platformInitialize()
+{
+}
+#endif
+
 WebProcessProxy::~WebProcessProxy()
 {
     RELEASE_ASSERT(isMainThreadOrCheckDisabled());
@@ -240,8 +248,16 @@
 #if PLATFORM(MAC)
     HighPerformanceGPUManager::singleton().removeProcessRequiringHighPerformance(this);
 #endif
+
+    platformDestroy();
 }
 
+#if !PLATFORM(IOS_FAMILY)
+void WebProcessProxy::platformDestroy()
+{
+}
+#endif
+
 void WebProcessProxy::setIsInProcessCache(bool value)
 {
     if (value) {

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (268085 => 268086)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -211,6 +211,10 @@
 
     static bool fullKeyboardAccessEnabled();
 
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+    static void notifyHasMouseDeviceChanged();
+#endif
+
     void fetchWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, CompletionHandler<void(WebsiteData)>&&);
     void deleteWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, WallTime modifiedSince, CompletionHandler<void()>&&);
     void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebsiteDataType>, const Vector<WebCore::SecurityOriginData>&, CompletionHandler<void()>&&);
@@ -410,6 +414,11 @@
     void validateFreezerStatus();
 
 private:
+    static HashMap<WebCore::ProcessIdentifier, WebProcessProxy*>& allProcesses();
+
+    void platformInitialize();
+    void platformDestroy();
+
     // IPC message handlers.
     void updateBackForwardItem(const BackForwardListItemState&);
     void didDestroyFrame(WebCore::FrameIdentifier);

Copied: trunk/Source/WebKit/UIProcess/ios/WKMouseDeviceObserver.h (from rev 268085, trunk/Source/WebKit/UIProcess/ios/WebProcessProxyIOS.mm) (0 => 268086)


--- trunk/Source/WebKit/UIProcess/ios/WKMouseDeviceObserver.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/ios/WKMouseDeviceObserver.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+
+#import "BackBoardServicesSPI.h"
+
+namespace WebKit {
+class WebProcessProxy;
+}
+
+@interface WKMouseDeviceObserver : NSObject<BKSMousePointerDeviceObserver>
+
++ (WKMouseDeviceObserver *)sharedInstance;
+
+- (void)start;
+- (void)stop;
+
+@property (nonatomic, readonly) BOOL hasMouseDevice;
+
+- (void)_setHasMouseDeviceForTesting:(BOOL)hasMouseDevice;
+
+@end
+
+#endif // HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)

Added: trunk/Source/WebKit/UIProcess/ios/WKMouseDeviceObserver.mm (0 => 268086)


--- trunk/Source/WebKit/UIProcess/ios/WKMouseDeviceObserver.mm	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/ios/WKMouseDeviceObserver.mm	2020-10-06 23:44:47 UTC (rev 268086)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKMouseDeviceObserver.h"
+
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+
+#import "WebProcessProxy.h"
+#import <wtf/RetainPtr.h>
+
+@implementation WKMouseDeviceObserver {
+    BOOL _hasMouseDevice;
+    RetainPtr<id<BSInvalidatable>> _token;
+}
+
++ (WKMouseDeviceObserver *)sharedInstance
+{
+    static WKMouseDeviceObserver *instance;
+    if (!instance)
+        instance = [[WKMouseDeviceObserver alloc] init];
+    return instance;
+}
+
+- (void)dealloc
+{
+    [self stop];
+
+    [super dealloc];
+}
+
+#pragma mark - BKSMousePointerDeviceObserver state
+
+- (void)start
+{
+    if (_token)
+        return;
+
+    _token = [[BKSMousePointerService sharedInstance] addPointerDeviceObserver:self];
+}
+
+- (void)stop
+{
+    if (!_token)
+        return;
+
+    [_token invalidate];
+    _token = nil;
+}
+
+#pragma mark - BKSMousePointerDeviceObserver handlers
+
+- (void)mousePointerDevicesDidChange:(NSSet<BKSMousePointerDevice *> *)mousePointerDevices
+{
+    BOOL hasMouseDevice = mousePointerDevices.count > 0;
+    if (hasMouseDevice == _hasMouseDevice)
+        return;
+
+    _hasMouseDevice = hasMouseDevice;
+
+    WebKit::WebProcessProxy::notifyHasMouseDeviceChanged();
+}
+
+#pragma mark - Testing
+
+- (void)_setHasMouseDeviceForTesting:(BOOL)hasMouseDevice
+{
+    _hasMouseDevice = hasMouseDevice;
+
+    WebKit::WebProcessProxy::notifyHasMouseDeviceChanged();
+}
+
+@end
+
+#endif // HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)

Modified: trunk/Source/WebKit/UIProcess/ios/WebProcessProxyIOS.mm (268085 => 268086)


--- trunk/Source/WebKit/UIProcess/ios/WebProcessProxyIOS.mm	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/UIProcess/ios/WebProcessProxyIOS.mm	2020-10-06 23:44:47 UTC (rev 268086)
@@ -30,10 +30,38 @@
 
 #import "AccessibilitySupportSPI.h"
 #import "WKFullKeyboardAccessWatcher.h"
+#import "WKMouseDeviceObserver.h"
 #import "WebProcessMessages.h"
 
 namespace WebKit {
 
+void WebProcessProxy::platformInitialize()
+{
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+    if (WebProcessProxy::allProcesses().size() == 1)
+        [[WKMouseDeviceObserver sharedInstance] start];
+#endif
+}
+
+void WebProcessProxy::platformDestroy()
+{
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+    if (WebProcessProxy::allProcesses().isEmpty())
+        [[WKMouseDeviceObserver sharedInstance] stop];
+#endif
+}
+
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+
+void WebProcessProxy::notifyHasMouseDeviceChanged()
+{
+    bool hasMouseDevice = [[WKMouseDeviceObserver sharedInstance] hasMouseDevice];
+    for (auto* webProcessProxy : WebProcessProxy::allProcesses().values())
+        webProcessProxy->send(Messages::WebProcess::SetHasMouseDevice(hasMouseDevice), 0);
+}
+
+#endif // HAVE(UIKIT_WITH_MOUSE_SUPPORT)
+
 bool WebProcessProxy::fullKeyboardAccessEnabled()
 {
 #if ENABLE(FULL_KEYBOARD_ACCESS)

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (268085 => 268086)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-10-06 23:44:47 UTC (rev 268086)
@@ -1379,6 +1379,8 @@
 		93BDEB01171DD7AF00BFEE1B /* WKPageLoadTypesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 93BDEB00171DD7AF00BFEE1B /* WKPageLoadTypesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		93E6A4EE1BC5DD3900F8A0E7 /* _WKHitTestResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E6A4ED1BC5DD3900F8A0E7 /* _WKHitTestResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		93F549B41E3174B7000E7239 /* WKSnapshotConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F549B31E3174B7000E7239 /* WKSnapshotConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		950F2880252414EA00B74F1C /* WKMouseDeviceObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 950F287E252414E900B74F1C /* WKMouseDeviceObserver.h */; };
+		95C943912523C0D00054F3D5 /* BaseBoardSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 95C943902523C0D00054F3D5 /* BaseBoardSPI.h */; };
 		99036AE223A949CF0000B06A /* _WKInspectorDebuggableInfoInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 99036AE123A949CE0000B06A /* _WKInspectorDebuggableInfoInternal.h */; };
 		99036AE523A958750000B06A /* APIDebuggableInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 99036AE323A958740000B06A /* APIDebuggableInfo.h */; };
 		99036AE923A970870000B06A /* DebuggableInfoData.h in Headers */ = {isa = PBXBuildFile; fileRef = 99036AE723A970870000B06A /* DebuggableInfoData.h */; };
@@ -4425,6 +4427,9 @@
 		93E6A4ED1BC5DD3900F8A0E7 /* _WKHitTestResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKHitTestResult.h; sourceTree = "<group>"; };
 		93F549B31E3174B7000E7239 /* WKSnapshotConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKSnapshotConfiguration.h; sourceTree = "<group>"; };
 		93F549B51E3174DA000E7239 /* WKSnapshotConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKSnapshotConfiguration.mm; sourceTree = "<group>"; };
+		950F287E252414E900B74F1C /* WKMouseDeviceObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKMouseDeviceObserver.h; path = ios/WKMouseDeviceObserver.h; sourceTree = "<group>"; };
+		950F287F252414EA00B74F1C /* WKMouseDeviceObserver.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKMouseDeviceObserver.mm; path = ios/WKMouseDeviceObserver.mm; sourceTree = "<group>"; };
+		95C943902523C0D00054F3D5 /* BaseBoardSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseBoardSPI.h; sourceTree = "<group>"; };
 		99036AE123A949CE0000B06A /* _WKInspectorDebuggableInfoInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspectorDebuggableInfoInternal.h; sourceTree = "<group>"; };
 		99036AE323A958740000B06A /* APIDebuggableInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIDebuggableInfo.h; sourceTree = "<group>"; };
 		99036AE423A958740000B06A /* APIDebuggableInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIDebuggableInfo.cpp; sourceTree = "<group>"; };
@@ -7021,6 +7026,8 @@
 				933DF82F1B3BC0B400AEA9E3 /* WKImagePreviewViewController.mm */,
 				2DD5E127210ADC7A00DB6012 /* WKKeyboardScrollingAnimator.h */,
 				2DD5E126210ADC7A00DB6012 /* WKKeyboardScrollingAnimator.mm */,
+				950F287E252414E900B74F1C /* WKMouseDeviceObserver.h */,
+				950F287F252414EA00B74F1C /* WKMouseDeviceObserver.mm */,
 				2DB94297234E7A7F00E776AD /* WKMouseGestureRecognizer.h */,
 				2DB94298234E7A7F00E776AD /* WKMouseGestureRecognizer.mm */,
 				A15EEDE41E301CEE000069B0 /* WKPasswordView.h */,
@@ -10381,6 +10388,7 @@
 			children = (
 				CE1A0BCC1A48E6C60054EF74 /* AssertionServicesSPI.h */,
 				CDA041F31ACE2105004A13EC /* BackBoardServicesSPI.h */,
+				95C943902523C0D00054F3D5 /* BaseBoardSPI.h */,
 				2D4AF0882044C3C4006C8817 /* FrontBoardServicesSPI.h */,
 				A13B3DA1207F39DE0090C58D /* MobileWiFiSPI.h */,
 				3178AF9720E2A7F80074DE94 /* PDFKitSPI.h */,
@@ -10747,6 +10755,7 @@
 				290F4272172A0C7400939FF0 /* AuxiliaryProcessSupplement.h in Headers */,
 				CDA041F41ACE2105004A13EC /* BackBoardServicesSPI.h in Headers */,
 				46A2B6091E5676A600C3DEDA /* BackgroundProcessResponsivenessTimer.h in Headers */,
+				95C943912523C0D00054F3D5 /* BaseBoardSPI.h in Headers */,
 				E164A2F2191AF14E0010737D /* BlobDataFileReferenceWithSandboxExtension.h in Headers */,
 				E170876C16D6CA6900F99226 /* BlobRegistryProxy.h in Headers */,
 				4F601432155C5AA2001FBDE0 /* BlockingResponseMap.h in Headers */,
@@ -11604,6 +11613,7 @@
 				5CABDC8622C40FDE001EDE8E /* WKMessageListener.h in Headers */,
 				C11E1694212B87C500985FF6 /* WKMockDisplay.h in Headers */,
 				411A8DDB20DDD1AC0060D34F /* WKMockMediaDevice.h in Headers */,
+				950F2880252414EA00B74F1C /* WKMouseDeviceObserver.h in Headers */,
 				2DB94299234E7A7F00E776AD /* WKMouseGestureRecognizer.h in Headers */,
 				BC4075FE124FF0270068F20A /* WKMutableArray.h in Headers */,
 				BC407600124FF0270068F20A /* WKMutableDictionary.h in Headers */,

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (268085 => 268086)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2020-10-06 23:44:47 UTC (rev 268086)
@@ -506,6 +506,16 @@
     return m_page.keyboardUIMode();
 }
 
+bool WebChromeClient::hoverSupportedByAnyAvailablePointingDevice() const
+{
+    return m_page.hoverSupportedByAnyAvailablePointingDevice();
+}
+
+OptionSet<PointerCharacteristics> WebChromeClient::pointerCharacteristicsOfAllAvailablePointingDevices() const
+{
+    return m_page.pointerCharacteristicsOfAllAvailablePointingDevices();
+}
+
 #if ENABLE(POINTER_LOCK)
 
 bool WebChromeClient::requestPointerLock()

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (268085 => 268086)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -112,6 +112,9 @@
 
     WebCore::KeyboardUIMode keyboardUIMode() final;
 
+    bool hoverSupportedByAnyAvailablePointingDevice() const final;
+    OptionSet<WebCore::PointerCharacteristics> pointerCharacteristicsOfAllAvailablePointingDevices() const final;
+
     // HostWindow member function finals.
     void invalidateRootView(const WebCore::IntRect&) final;
     void invalidateContentsAndRootView(const WebCore::IntRect&) final;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (268085 => 268086)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -75,6 +75,7 @@
 #include <WebCore/PageIdentifier.h>
 #include <WebCore/PageOverlay.h>
 #include <WebCore/PluginData.h>
+#include <WebCore/PointerCharacteristics.h>
 #include <WebCore/PointerID.h>
 #include <WebCore/RenderingMode.h>
 #include <WebCore/SecurityPolicyViolationEvent.h>
@@ -415,6 +416,9 @@
     String platformUserAgent(const URL&) const;
     WebCore::KeyboardUIMode keyboardUIMode();
 
+    bool hoverSupportedByAnyAvailablePointingDevice() const;
+    OptionSet<WebCore::PointerCharacteristics> pointerCharacteristicsOfAllAvailablePointingDevices() const;
+
     void didInsertMenuElement(WebCore::HTMLMenuElement&);
     void didRemoveMenuElement(WebCore::HTMLMenuElement&);
     void didInsertMenuItemElement(WebCore::HTMLMenuItemElement&);

Modified: trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp (268085 => 268086)


--- trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp	2020-10-06 23:44:47 UTC (rev 268086)
@@ -43,6 +43,8 @@
 #include <WebCore/NotImplemented.h>
 #include <WebCore/Page.h>
 #include <WebCore/PlatformKeyboardEvent.h>
+#include <WebCore/PlatformScreen.h>
+#include <WebCore/PointerCharacteristics.h>
 #include <WebCore/RenderTheme.h>
 #include <WebCore/Settings.h>
 #include <WebCore/SharedBuffer.h>
@@ -129,6 +131,24 @@
     return WebCore::standardUserAgentForURL(url);
 }
 
+bool WebPage::hoverSupportedByAnyAvailablePointingDevice() const
+{
+#if ENABLE(TOUCH_EVENTS)
+    return !screenHasTouchDevice();
+#else
+    return true;
+#endif
+}
+
+OptionSet<PointerCharacteristics> WebPage::pointerCharacteristicsOfAllAvailablePointingDevices() const
+{
+#if ENABLE(TOUCH_EVENTS)
+    if (screenHasTouchDevice())
+        return PointerCharacteristics::Coarse;
+#endif
+    return PointerCharacteristics::Fine;
+}
+
 void WebPage::getCenterForZoomGesture(const IntPoint& centerInViewCoordinates, CompletionHandler<void(WebCore::IntPoint&&)>&& completionHandler)
 {
     IntPoint result = mainFrameView()->rootViewToContents(centerInViewCoordinates);

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (268085 => 268086)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-10-06 23:44:47 UTC (rev 268086)
@@ -116,6 +116,7 @@
 #import <WebCore/PlatformKeyboardEvent.h>
 #import <WebCore/PlatformMouseEvent.h>
 #import <WebCore/PointerCaptureController.h>
+#import <WebCore/PointerCharacteristics.h>
 #import <WebCore/Quirks.h>
 #import <WebCore/Range.h>
 #import <WebCore/RenderBlock.h>
@@ -3988,6 +3989,30 @@
     return String();
 }
 
+static bool hasMouseDevice()
+{
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+    return WebProcess::singleton().hasMouseDevice();
+#elif HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(MACCATALYST)
+    return true;
+#else
+    return false;
+#endif
+}
+
+bool WebPage::hoverSupportedByAnyAvailablePointingDevice() const
+{
+    return hasMouseDevice();
+}
+
+OptionSet<PointerCharacteristics> WebPage::pointerCharacteristicsOfAllAvailablePointingDevices() const
+{
+    OptionSet<PointerCharacteristics> result(PointerCharacteristics::Coarse);
+    if (hasMouseDevice())
+        result.add(PointerCharacteristics::Fine);
+    return result;
+}
+
 void WebPage::hardwareKeyboardAvailabilityChanged(bool keyboardIsAttached)
 {
     m_keyboardIsAttached = keyboardIsAttached;

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (268085 => 268086)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2020-10-06 23:44:47 UTC (rev 268086)
@@ -83,6 +83,7 @@
 #import <WebCore/PageOverlayController.h>
 #import <WebCore/PlatformKeyboardEvent.h>
 #import <WebCore/PluginDocument.h>
+#import <WebCore/PointerCharacteristics.h>
 #import <WebCore/RenderElement.h>
 #import <WebCore/RenderObject.h>
 #import <WebCore/RenderStyle.h>
@@ -830,6 +831,16 @@
     return String();
 }
 
+bool WebPage::hoverSupportedByAnyAvailablePointingDevice() const
+{
+    return true;
+}
+
+OptionSet<PointerCharacteristics> WebPage::pointerCharacteristicsOfAllAvailablePointingDevices() const
+{
+    return PointerCharacteristics::Fine;
+}
+
 void WebPage::performImmediateActionHitTestAtLocation(WebCore::FloatPoint locationInViewCoordinates)
 {
     layoutIfNeeded();

Modified: trunk/Source/WebKit/WebProcess/WebPage/playstation/WebPagePlayStation.cpp (268085 => 268086)


--- trunk/Source/WebKit/WebProcess/WebPage/playstation/WebPagePlayStation.cpp	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebProcess/WebPage/playstation/WebPagePlayStation.cpp	2020-10-06 23:44:47 UTC (rev 268086)
@@ -27,6 +27,7 @@
 #include "WebPage.h"
 
 #include <WebCore/NotImplemented.h>
+#include <WebCore/PointerCharacteristics.h>
 #include <WebCore/Settings.h>
 #include <WebCore/UserAgent.h>
 
@@ -65,6 +66,16 @@
     return WebCore::standardUserAgentForURL(url);
 }
 
+bool WebPage::hoverSupportedByAnyAvailablePointingDevice() const
+{
+    return true;
+}
+
+OptionSet<PointerCharacteristics> WebPage::pointerCharacteristicsOfAllAvailablePointingDevices() const
+{
+    return PointerCharacteristics::Fine;
+}
+
 bool WebPage::handleEditingKeyboardEvent(WebCore::KeyboardEvent& event)
 {
     notImplemented();

Modified: trunk/Source/WebKit/WebProcess/WebPage/win/WebPageWin.cpp (268085 => 268086)


--- trunk/Source/WebKit/WebProcess/WebPage/win/WebPageWin.cpp	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebProcess/WebPage/win/WebPageWin.cpp	2020-10-06 23:44:47 UTC (rev 268086)
@@ -43,6 +43,7 @@
 #include <WebCore/NotImplemented.h>
 #include <WebCore/Page.h>
 #include <WebCore/PlatformKeyboardEvent.h>
+#include <WebCore/PointerCharacteristics.h>
 #include <WebCore/Settings.h>
 #include <WebCore/SharedBuffer.h>
 #include <WebCore/UserAgent.h>
@@ -115,6 +116,16 @@
     return { };
 }
 
+bool WebPage::hoverSupportedByAnyAvailablePointingDevice() const
+{
+    return true;
+}
+
+OptionSet<PointerCharacteristics> WebPage::pointerCharacteristicsOfAllAvailablePointingDevices() const
+{
+    return PointerCharacteristics::Fine;
+}
+
 static const unsigned CtrlKey = 1 << 0;
 static const unsigned AltKey = 1 << 1;
 static const unsigned ShiftKey = 1 << 2;

Modified: trunk/Source/WebKit/WebProcess/WebPage/wpe/WebPageWPE.cpp (268085 => 268086)


--- trunk/Source/WebKit/WebProcess/WebPage/wpe/WebPageWPE.cpp	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebProcess/WebPage/wpe/WebPageWPE.cpp	2020-10-06 23:44:47 UTC (rev 268086)
@@ -30,6 +30,8 @@
 #include "WebPageProxy.h"
 #include "WebPageProxyMessages.h"
 #include <WebCore/NotImplemented.h>
+#include <WebCore/PlatformScreen.h>
+#include <WebCore/PointerCharacteristics.h>
 
 namespace WebKit {
 using namespace WebCore;
@@ -73,4 +75,22 @@
     return String();
 }
 
+bool WebPage::hoverSupportedByAnyAvailablePointingDevice() const
+{
+#if ENABLE(TOUCH_EVENTS)
+    return !screenHasTouchDevice();
+#else
+    return true;
+#endif
+}
+
+OptionSet<PointerCharacteristics> WebPage::pointerCharacteristicsOfAllAvailablePointingDevices() const
+{
+#if ENABLE(TOUCH_EVENTS)
+    if (screenHasTouchDevice())
+        return PointerCharacteristics::Coarse;
+#endif
+    return PointerCharacteristics::Fine;
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (268085 => 268086)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2020-10-06 23:44:47 UTC (rev 268086)
@@ -1050,6 +1050,20 @@
     MessagePort::notifyMessageAvailable(identifier);
 }
 
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+
+void WebProcess::setHasMouseDevice(bool hasMouseDevice)
+{
+    if (hasMouseDevice == m_hasMouseDevice)
+        return;
+
+    m_hasMouseDevice = hasMouseDevice;
+
+    Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment();
+}
+
+#endif // HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+
 #if ENABLE(GAMEPAD)
 
 void WebProcess::setInitialGamepads(const Vector<WebKit::GamepadData>& gamepadDatas)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (268085 => 268086)


--- trunk/Source/WebKit/WebProcess/WebProcess.h	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -187,6 +187,11 @@
 
     bool fullKeyboardAccessEnabled() const { return m_fullKeyboardAccessEnabled; }
 
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+    bool hasMouseDevice() const { return m_hasMouseDevice; }
+    void setHasMouseDevice(bool);
+#endif
+
     WebFrame* webFrame(WebCore::FrameIdentifier) const;
     Vector<WebFrame*> webFrames() const;
     void addWebFrame(WebCore::FrameIdentifier, WebFrame*);
@@ -554,6 +559,10 @@
 
     bool m_fullKeyboardAccessEnabled { false };
 
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+    bool m_hasMouseDevice { false };
+#endif
+
     HashMap<WebCore::FrameIdentifier, WebFrame*> m_frameMap;
 
     typedef HashMap<const char*, std::unique_ptr<WebProcessSupplement>, PtrHash<const char*>> WebProcessSupplementMap;

Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (268085 => 268086)


--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2020-10-06 23:44:47 UTC (rev 268086)
@@ -52,6 +52,10 @@
     UserPreferredLanguagesChanged()
     FullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled)
 
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+    SetHasMouseDevice(bool hasMouseDevice)
+#endif
+
     # Plug-ins.
     DidAddPlugInAutoStartOriginHash(uint32_t hash, WallTime expirationTime)
     ResetPlugInAutoStartOriginHashes(HashMap<uint32_t,WallTime> hashes)

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (268085 => 268086)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-10-06 23:44:47 UTC (rev 268086)
@@ -299,6 +299,10 @@
         });
     }
 
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) && PLATFORM(IOS)
+    m_hasMouseDevice = parameters.hasMouseDevice;
+#endif
+
     WebCore::setScreenProperties(parameters.screenProperties);
 
 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)

Modified: trunk/Source/WebKitLegacy/ios/ChangeLog (268085 => 268086)


--- trunk/Source/WebKitLegacy/ios/ChangeLog	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKitLegacy/ios/ChangeLog	2020-10-06 23:44:47 UTC (rev 268086)
@@ -1,3 +1,16 @@
+2020-10-06  Devin Rousso  <[email protected]>
+
+        CSS hover and "pointer: fine" media queries do not evaluate to true with iOS 13.4 mouse support
+        https://bugs.webkit.org/show_bug.cgi?id=209292
+        <rdar://problem/60663124>
+
+        Reviewed by Tim Horton.
+
+        * WebCoreSupport/WebChromeClientIOS.h:
+        (WebChromeClientIOS::hoverSupportedByAnyAvailablePointingDevice const): Added.
+        (WebChromeClientIOS::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
+        Mouse devices are not supported.
+
 2020-09-20  Darin Adler  <[email protected]>
 
         Next step towards eliminating deprecated legacy positions

Modified: trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.h (268085 => 268086)


--- trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.h	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -50,6 +50,9 @@
     void runOpenPanel(WebCore::Frame&, WebCore::FileChooser&) final;
     void showShareSheet(WebCore::ShareDataWithParsedURL&, CompletionHandler<void(bool)>&&) final;
 
+    bool hoverSupportedByAnyAvailablePointingDevice() const final { return false; }
+    OptionSet<WebCore::PointerCharacteristics> pointerCharacteristicsOfAllAvailablePointingDevices() const final { return WebCore::PointerCharacteristics::Coarse; }
+
     void setCursor(const WebCore::Cursor&) final { }
     void setCursorHiddenUntilMouseMoves(bool) final { }
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (268085 => 268086)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2020-10-06 23:44:47 UTC (rev 268086)
@@ -1,3 +1,16 @@
+2020-10-06  Devin Rousso  <[email protected]>
+
+        CSS hover and "pointer: fine" media queries do not evaluate to true with iOS 13.4 mouse support
+        https://bugs.webkit.org/show_bug.cgi?id=209292
+        <rdar://problem/60663124>
+
+        Reviewed by Tim Horton.
+
+        * WebCoreSupport/WebChromeClient.h:
+        (WebChromeClient::hoverSupportedByAnyAvailablePointingDevice const): Added.
+        (WebChromeClient::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
+        Mouse devices are always supported.
+
 2020-10-06  Simon Fraser  <[email protected]>
 
         Redundant rendering updates can be scheduled from inside Page::updateRendering()

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h (268085 => 268086)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -158,6 +158,9 @@
 
     WebCore::KeyboardUIMode keyboardUIMode() final;
 
+    bool hoverSupportedByAnyAvailablePointingDevice() const override { return true; }
+    OptionSet<WebCore::PointerCharacteristics> pointerCharacteristicsOfAllAvailablePointingDevices() const override { return WebCore::PointerCharacteristics::Fine; }
+
     NSResponder *firstResponder() final;
     void makeFirstResponder(NSResponder *) final;
 

Modified: trunk/Source/WebKitLegacy/win/ChangeLog (268085 => 268086)


--- trunk/Source/WebKitLegacy/win/ChangeLog	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKitLegacy/win/ChangeLog	2020-10-06 23:44:47 UTC (rev 268086)
@@ -1,3 +1,16 @@
+2020-10-06  Devin Rousso  <[email protected]>
+
+        CSS hover and "pointer: fine" media queries do not evaluate to true with iOS 13.4 mouse support
+        https://bugs.webkit.org/show_bug.cgi?id=209292
+        <rdar://problem/60663124>
+
+        Reviewed by Tim Horton.
+
+        * WebCoreSupport/WebChromeClient.h:
+        (WebChromeClient::hoverSupportedByAnyAvailablePointingDevice const): Added.
+        (WebChromeClient::pointerCharacteristicsOfAllAvailablePointingDevices const): Added.
+        Mouse devices are always supported.
+
 2020-10-05  Simon Fraser  <[email protected]>
 
         Use the "triggerRenderingUpdate" terminology in ChromeClient

Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h (268085 => 268086)


--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -94,6 +94,9 @@
 
     WebCore::KeyboardUIMode keyboardUIMode() final;
 
+    bool hoverSupportedByAnyAvailablePointingDevice() const final { return true; }
+    OptionSet<WebCore::PointerCharacteristics> pointerCharacteristicsOfAllAvailablePointingDevices() const final { return WebCore::PointerCharacteristics::Fine; }
+
     void invalidateRootView(const WebCore::IntRect&) final;
     void invalidateContentsAndRootView(const WebCore::IntRect&) final;
     void invalidateContentsForSlowScroll(const WebCore::IntRect&) final;

Modified: trunk/Tools/ChangeLog (268085 => 268086)


--- trunk/Tools/ChangeLog	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Tools/ChangeLog	2020-10-06 23:44:47 UTC (rev 268086)
@@ -1,3 +1,23 @@
+2020-10-06  Devin Rousso  <[email protected]>
+
+        CSS hover and "pointer: fine" media queries do not evaluate to true with iOS 13.4 mouse support
+        https://bugs.webkit.org/show_bug.cgi?id=209292
+        <rdar://problem/60663124>
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/cocoa/TestWKWebView.h:
+        * TestWebKitAPI/cocoa/TestWKWebView.mm:
+        (-[TestWKWebView evaluateMediaQuery:]): Added.
+        Create helper function for synchronously testing media queries.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/iOSMouseSupport.mm:
+        (iOSMouseSupport.MouseInitiallyDisconnected): Added.
+        (iOSMouseSupport.MouseInitiallyConnected): Added.
+        (iOSMouseSupport.MouseLaterDisconnected): Added.
+        (iOSMouseSupport.MouseLaterConnected): Added.
+        (iOSMouseSupport.MouseAlwaysConnected): Added.
+
 2020-10-06  Jonathan Bedard  <[email protected]>
 
         [webkitscmpy] Generate Commit object from local repository

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/iOSMouseSupport.mm (268085 => 268086)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/iOSMouseSupport.mm	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/iOSMouseSupport.mm	2020-10-06 23:44:47 UTC (rev 268086)
@@ -300,4 +300,187 @@
 
 #endif // ENABLE(IOS_TOUCH_EVENTS)
 
+#if HAVE(UIKIT_WITH_MOUSE_SUPPORT)
+
+#if PLATFORM(IOS)
+
+@interface WKMouseDeviceObserver
++ (WKMouseDeviceObserver *)sharedInstance;
+- (void)start;
+- (void)_setHasMouseDeviceForTesting:(BOOL)hasMouseDevice;
+@end
+
+TEST(iOSMouseSupport, MouseInitiallyDisconnected)
+{
+    WKMouseDeviceObserver *mouseDeviceObserver = [NSClassFromString(@"WKMouseDeviceObserver") sharedInstance];
+    [mouseDeviceObserver start];
+    [mouseDeviceObserver _setHasMouseDeviceForTesting:NO];
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    [webView synchronouslyLoadHTMLString:@""];
+
+#if ENABLE(TOUCH_EVENTS)
+    EXPECT_FALSE([webView evaluateMediaQuery:@"hover"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"hover: none"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"hover: hover"]);
+#endif
+
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-hover"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-hover: none"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-hover: hover"]);
+
+#if ENABLE(TOUCH_EVENTS)
+    EXPECT_TRUE([webView evaluateMediaQuery:@"pointer"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"pointer: none"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"pointer: coarse"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"pointer: fine"]);
+#endif
+
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-pointer"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-pointer: none"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-pointer: coarse"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-pointer: fine"]);
+}
+
+TEST(iOSMouseSupport, MouseInitiallyConnected)
+{
+    WKMouseDeviceObserver *mouseDeviceObserver = [NSClassFromString(@"WKMouseDeviceObserver") sharedInstance];
+    [mouseDeviceObserver start];
+    [mouseDeviceObserver _setHasMouseDeviceForTesting:YES];
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    [webView synchronouslyLoadHTMLString:@""];
+
+#if ENABLE(TOUCH_EVENTS)
+    EXPECT_FALSE([webView evaluateMediaQuery:@"hover"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"hover: none"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"hover: hover"]);
+#endif
+
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-hover"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-hover: none"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-hover: hover"]);
+
+#if ENABLE(TOUCH_EVENTS)
+    EXPECT_TRUE([webView evaluateMediaQuery:@"pointer"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"pointer: none"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"pointer: coarse"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"pointer: fine"]);
+#endif
+
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-pointer"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-pointer: none"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-pointer: coarse"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-pointer: fine"]);
+}
+
+TEST(iOSMouseSupport, MouseLaterDisconnected)
+{
+    WKMouseDeviceObserver *mouseDeviceObserver = [NSClassFromString(@"WKMouseDeviceObserver") sharedInstance];
+    [mouseDeviceObserver start];
+    [mouseDeviceObserver _setHasMouseDeviceForTesting:YES];
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    [webView synchronouslyLoadHTMLString:@""];
+
+    [mouseDeviceObserver _setHasMouseDeviceForTesting:NO];
+
+#if ENABLE(TOUCH_EVENTS)
+    EXPECT_FALSE([webView evaluateMediaQuery:@"hover"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"hover: none"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"hover: hover"]);
+#endif
+
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-hover"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-hover: none"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-hover: hover"]);
+
+#if ENABLE(TOUCH_EVENTS)
+    EXPECT_TRUE([webView evaluateMediaQuery:@"pointer"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"pointer: none"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"pointer: coarse"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"pointer: fine"]);
+#endif
+
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-pointer"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-pointer: none"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-pointer: coarse"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-pointer: fine"]);
+}
+
+TEST(iOSMouseSupport, MouseLaterConnected)
+{
+    WKMouseDeviceObserver *mouseDeviceObserver = [NSClassFromString(@"WKMouseDeviceObserver") sharedInstance];
+    [mouseDeviceObserver start];
+    [mouseDeviceObserver _setHasMouseDeviceForTesting:NO];
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    [webView synchronouslyLoadHTMLString:@""];
+
+    [mouseDeviceObserver _setHasMouseDeviceForTesting:YES];
+
+#if ENABLE(TOUCH_EVENTS)
+    EXPECT_FALSE([webView evaluateMediaQuery:@"hover"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"hover: none"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"hover: hover"]);
+#endif
+
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-hover"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-hover: none"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-hover: hover"]);
+
+#if ENABLE(TOUCH_EVENTS)
+    EXPECT_TRUE([webView evaluateMediaQuery:@"pointer"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"pointer: none"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"pointer: coarse"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"pointer: fine"]);
+#endif
+
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-pointer"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-pointer: none"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-pointer: coarse"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-pointer: fine"]);
+}
+
+#endif // PLATFORM(IOS)
+
+#if PLATFORM(MACCATALYST)
+
+TEST(iOSMouseSupport, MouseAlwaysConnected)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    [webView synchronouslyLoadHTMLString:@""];
+
+#if ENABLE(TOUCH_EVENTS)
+    EXPECT_FALSE([webView evaluateMediaQuery:@"hover"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"hover: none"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"hover: hover"]);
+#endif
+
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-hover"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-hover: none"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-hover: hover"]);
+
+#if ENABLE(TOUCH_EVENTS)
+    EXPECT_TRUE([webView evaluateMediaQuery:@"pointer"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"pointer: none"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"pointer: coarse"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"pointer: fine"]);
+#endif
+
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-pointer"]);
+    EXPECT_FALSE([webView evaluateMediaQuery:@"any-pointer: none"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-pointer: coarse"]);
+    EXPECT_TRUE([webView evaluateMediaQuery:@"any-pointer: fine"]);
+}
+
+#endif // PLATFORM(MACCATALYST)
+
+#endif // HAVE(UIKIT_WITH_MOUSE_SUPPORT)
+
 #endif // PLATFORM(IOS) || PLATFORM(MACCATALYST)

Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h (268085 => 268086)


--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h	2020-10-06 23:44:47 UTC (rev 268086)
@@ -61,6 +61,7 @@
 - (void)expectElementTagsInOrder:(NSArray<NSString *> *)tagNames;
 - (void)expectElementCount:(NSInteger)count querySelector:(NSString *)querySelector;
 - (void)expectElementTag:(NSString *)tagName toComeBefore:(NSString *)otherTagName;
+- (BOOL)evaluateMediaQuery:(NSString *)query;
 - (NSString *)stringByEvaluatingJavaScript:(NSString *)script;
 - (id)objectByEvaluatingJavaScriptWithUserGesture:(NSString *)script;
 - (id)objectByEvaluatingJavaScript:(NSString *)script;

Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm (268085 => 268086)


--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm	2020-10-06 23:44:47 UTC (rev 268086)
@@ -161,6 +161,11 @@
     [self expectElementTagsInOrder:@[tagName, otherTagName]];
 }
 
+- (BOOL)evaluateMediaQuery:(NSString *)query
+{
+    return [[self objectByEvaluatingJavaScript:[NSString stringWithFormat:@"window.matchMedia(\"(%@)\").matches", query]] boolValue];
+}
+
 - (id)objectByEvaluatingJavaScript:(NSString *)script
 {
     bool isWaitingForJavaScript = false;

Modified: trunk/WebKitLibraries/ChangeLog (268085 => 268086)


--- trunk/WebKitLibraries/ChangeLog	2020-10-06 23:23:09 UTC (rev 268085)
+++ trunk/WebKitLibraries/ChangeLog	2020-10-06 23:44:47 UTC (rev 268086)
@@ -1,3 +1,15 @@
+2020-10-06  Devin Rousso  <[email protected]>
+
+        CSS hover and "pointer: fine" media queries do not evaluate to true with iOS 13.4 mouse support
+        https://bugs.webkit.org/show_bug.cgi?id=209292
+        <rdar://problem/60663124>
+
+        Reviewed by Tim Horton.
+
+        * WebKitPrivateFrameworkStubs/iOS/13/BackBoardServices.framework/BackBoardServices.tbd: Added.
+        * WebKitPrivateFrameworkStubs/iOS/14/BackBoardServices.framework/BackBoardServices.tbd: Added.
+        Use `BackBoardServices` to listen for mouse devices changes.
+
 2020-10-04  Ryan Hostetler  <[email protected]>
 
         Submission failure with "make: *** No rule to make target `installsrc'. Stop"

Added: trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/13/BackBoardServices.framework/BackBoardServices.tbd (0 => 268086)


--- trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/13/BackBoardServices.framework/BackBoardServices.tbd	                        (rev 0)
+++ trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/13/BackBoardServices.framework/BackBoardServices.tbd	2020-10-06 23:44:47 UTC (rev 268086)
@@ -0,0 +1,9 @@
+--- !tapi-tbd-v3
+archs:           [ x86_64, arm64, arm64e ]
+install-name:    '/System/Library/PrivateFrameworks/BackBoardServices.framework/BackBoardServices'
+objc-constraint: none
+platform: ios
+exports:
+  - archs:           [ x86_64, arm64, arm64e ]
+    objc-classes:    [ BKSMousePointerDevice, BKSMousePointerService ]
+...

Added: trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/14/BackBoardServices.framework/BackBoardServices.tbd (0 => 268086)


--- trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/14/BackBoardServices.framework/BackBoardServices.tbd	                        (rev 0)
+++ trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/14/BackBoardServices.framework/BackBoardServices.tbd	2020-10-06 23:44:47 UTC (rev 268086)
@@ -0,0 +1,9 @@
+--- !tapi-tbd-v3
+archs:           [ x86_64, arm64, arm64e ]
+install-name:    '/System/Library/PrivateFrameworks/BackBoardServices.framework/BackBoardServices'
+objc-constraint: none
+platform: ios
+exports:
+  - archs:           [ x86_64, arm64, arm64e ]
+    objc-classes:    [ BKSMousePointerDevice, BKSMousePointerService ]
+...
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to