Title: [264004] trunk/Source
Revision
264004
Author
beid...@apple.com
Date
2020-07-06 18:34:49 -0700 (Mon, 06 Jul 2020)

Log Message

Get rid of concept of "initial connected gamepads"
https://bugs.webkit.org/show_bug.cgi?id=214010

Reviewed by Tim Horton.

Source/WebCore:

No new tests (Refactor, no behavior change)

When a page starts using gamepads and some were already connected, this concept
was meant to manage when the already-connected gamepads could be revealed to the page.

It obviously wasn't needed, as only the HID provider used them (GameController provider didn't)

Instead, we should just always include a "does this event make gamepads visible?" bit.

This cleans up a lot of weird code gets both providers working closer to each other.

* Modules/gamepad/GamepadManager.cpp:
(WebCore::GamepadManager::platformGamepadConnected):
(WebCore::GamepadManager::platformGamepadInputActivity):
* Modules/gamepad/GamepadManager.h:

* platform/gamepad/GamepadProvider.cpp:
(WebCore::GamepadProvider::dispatchPlatformGamepadInputActivity):

* platform/gamepad/GamepadProviderClient.h:
(WebCore::GamepadProviderClient::setInitialConnectedGamepads): Deleted.

* platform/gamepad/cocoa/GameControllerGamepadProvider.mm:
(WebCore::GameControllerGamepadProvider::controllerDidConnect):
(WebCore::GameControllerGamepadProvider::makeInvisibileGamepadsVisible):

* platform/gamepad/mac/HIDGamepadProvider.cpp:
(WebCore::HIDGamepadProvider::HIDGamepadProvider):
(WebCore::HIDGamepadProvider::initialGamepadsConnectedTimerFired):
(WebCore::HIDGamepadProvider::openAndScheduleManager):
(WebCore::HIDGamepadProvider::closeAndUnscheduleManager):
(WebCore::HIDGamepadProvider::deviceAdded):
(WebCore::HIDGamepadProvider::deviceRemoved):
(WebCore::HIDGamepadProvider::inputNotificationTimerFired):
(WebCore::HIDGamepadProvider::connectionDelayTimerFired): Deleted.
* platform/gamepad/mac/HIDGamepadProvider.h:

* testing/MockGamepadProvider.cpp:
(WebCore::MockGamepadProvider::connectMockGamepad):

Source/WebKit:

* Scripts/webkit/messages.py:

* UIProcess/Gamepad/UIGamepadProvider.cpp:
(WebKit::UIGamepadProvider::gamepadSyncTimerFired):
(WebKit::UIGamepadProvider::platformGamepadConnected):
(WebKit::UIGamepadProvider::platformGamepadInputActivity):
(WebKit::UIGamepadProvider::setInitialConnectedGamepads): Deleted.
* UIProcess/Gamepad/UIGamepadProvider.h:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::gamepadActivity):
* UIProcess/WebPageProxy.h:

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::gamepadConnected):
(WebKit::WebProcessPool::setInitialConnectedGamepads): Deleted.
* UIProcess/WebProcessPool.h:

* WebProcess/Gamepad/WebGamepadProvider.cpp:
(WebKit::WebGamepadProvider::gamepadConnected):
(WebKit::WebGamepadProvider::gamepadActivity):
* WebProcess/Gamepad/WebGamepadProvider.h:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::gamepadActivity):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::gamepadConnected):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (264003 => 264004)


--- trunk/Source/WebCore/ChangeLog	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebCore/ChangeLog	2020-07-07 01:34:49 UTC (rev 264004)
@@ -1,3 +1,50 @@
+2020-07-06  Brady Eidson  <beid...@apple.com>
+
+        Get rid of concept of "initial connected gamepads"
+        https://bugs.webkit.org/show_bug.cgi?id=214010
+
+        Reviewed by Tim Horton.
+
+        No new tests (Refactor, no behavior change)
+
+        When a page starts using gamepads and some were already connected, this concept
+        was meant to manage when the already-connected gamepads could be revealed to the page.
+        
+        It obviously wasn't needed, as only the HID provider used them (GameController provider didn't)
+        
+        Instead, we should just always include a "does this event make gamepads visible?" bit.
+        
+        This cleans up a lot of weird code gets both providers working closer to each other.
+        
+        * Modules/gamepad/GamepadManager.cpp:
+        (WebCore::GamepadManager::platformGamepadConnected):
+        (WebCore::GamepadManager::platformGamepadInputActivity):
+        * Modules/gamepad/GamepadManager.h:
+        
+        * platform/gamepad/GamepadProvider.cpp:
+        (WebCore::GamepadProvider::dispatchPlatformGamepadInputActivity):
+        
+        * platform/gamepad/GamepadProviderClient.h:
+        (WebCore::GamepadProviderClient::setInitialConnectedGamepads): Deleted.
+        
+        * platform/gamepad/cocoa/GameControllerGamepadProvider.mm:
+        (WebCore::GameControllerGamepadProvider::controllerDidConnect):
+        (WebCore::GameControllerGamepadProvider::makeInvisibileGamepadsVisible):
+        
+        * platform/gamepad/mac/HIDGamepadProvider.cpp:
+        (WebCore::HIDGamepadProvider::HIDGamepadProvider):
+        (WebCore::HIDGamepadProvider::initialGamepadsConnectedTimerFired):
+        (WebCore::HIDGamepadProvider::openAndScheduleManager):
+        (WebCore::HIDGamepadProvider::closeAndUnscheduleManager):
+        (WebCore::HIDGamepadProvider::deviceAdded):
+        (WebCore::HIDGamepadProvider::deviceRemoved):
+        (WebCore::HIDGamepadProvider::inputNotificationTimerFired):
+        (WebCore::HIDGamepadProvider::connectionDelayTimerFired): Deleted.
+        * platform/gamepad/mac/HIDGamepadProvider.h:
+        
+        * testing/MockGamepadProvider.cpp:
+        (WebCore::MockGamepadProvider::connectMockGamepad):
+
 2020-07-06  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Web process sometimes crashes when translating an article on spiegel.de

Modified: trunk/Source/WebCore/Modules/gamepad/GamepadManager.cpp (264003 => 264004)


--- trunk/Source/WebCore/Modules/gamepad/GamepadManager.cpp	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebCore/Modules/gamepad/GamepadManager.cpp	2020-07-07 01:34:49 UTC (rev 264004)
@@ -57,8 +57,11 @@
 {
 }
 
-void GamepadManager::platformGamepadConnected(PlatformGamepad& platformGamepad)
+void GamepadManager::platformGamepadConnected(PlatformGamepad& platformGamepad, EventMakesGamepadsVisible eventVisibility)
 {
+    if (eventVisibility == EventMakesGamepadsVisible::No)
+        return;
+
     // Notify blind Navigators and Windows about all gamepads except for this one.
     for (auto* gamepad : GamepadProvider::singleton().platformGamepads()) {
         if (!gamepad || gamepad == &platformGamepad)
@@ -113,9 +116,9 @@
     }
 }
 
-void GamepadManager::platformGamepadInputActivity(bool shouldMakeGamepadVisible)
+void GamepadManager::platformGamepadInputActivity(EventMakesGamepadsVisible eventVisibility)
 {
-    if (!shouldMakeGamepadVisible)
+    if (eventVisibility == EventMakesGamepadsVisible::No)
         return;
 
     if (m_gamepadBlindNavigators.isEmpty() && m_gamepadBlindDOMWindows.isEmpty())

Modified: trunk/Source/WebCore/Modules/gamepad/GamepadManager.h (264003 => 264004)


--- trunk/Source/WebCore/Modules/gamepad/GamepadManager.h	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebCore/Modules/gamepad/GamepadManager.h	2020-07-07 01:34:49 UTC (rev 264004)
@@ -44,9 +44,9 @@
 public:
     static GamepadManager& singleton();
 
-    void platformGamepadConnected(PlatformGamepad&) final;
+    void platformGamepadConnected(PlatformGamepad&, EventMakesGamepadsVisible) final;
     void platformGamepadDisconnected(PlatformGamepad&) final;
-    void platformGamepadInputActivity(bool shouldMakeGamepadVisible) final;
+    void platformGamepadInputActivity(EventMakesGamepadsVisible) final;
 
     void registerNavigator(NavigatorGamepad*);
     void unregisterNavigator(NavigatorGamepad*);

Modified: trunk/Source/WebCore/platform/gamepad/GamepadProvider.cpp (264003 => 264004)


--- trunk/Source/WebCore/platform/gamepad/GamepadProvider.cpp	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebCore/platform/gamepad/GamepadProvider.cpp	2020-07-07 01:34:49 UTC (rev 264004)
@@ -53,7 +53,7 @@
 void GamepadProvider::dispatchPlatformGamepadInputActivity()
 {
     for (auto& client : m_clients)
-        client->platformGamepadInputActivity(m_shouldMakeGamepadsVisible);
+        client->platformGamepadInputActivity(m_shouldMakeGamepadsVisible ? EventMakesGamepadsVisible::Yes : EventMakesGamepadsVisible::No);
 
     m_shouldMakeGamepadsVisible = false;
 }

Modified: trunk/Source/WebCore/platform/gamepad/GamepadProviderClient.h (264003 => 264004)


--- trunk/Source/WebCore/platform/gamepad/GamepadProviderClient.h	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebCore/platform/gamepad/GamepadProviderClient.h	2020-07-07 01:34:49 UTC (rev 264004)
@@ -33,14 +33,18 @@
 
 class PlatformGamepad;
 
+enum class EventMakesGamepadsVisible : bool {
+    No,
+    Yes,
+};
+
 class GamepadProviderClient {
 public:
     virtual ~GamepadProviderClient() = default;
 
-    virtual void setInitialConnectedGamepads(const Vector<PlatformGamepad*>&) { }
-    virtual void platformGamepadConnected(PlatformGamepad&) = 0;
+    virtual void platformGamepadConnected(PlatformGamepad&, EventMakesGamepadsVisible) = 0;
     virtual void platformGamepadDisconnected(PlatformGamepad&) = 0;
-    virtual void platformGamepadInputActivity(bool shouldMakeGamepadVisible) = 0;
+    virtual void platformGamepadInputActivity(EventMakesGamepadsVisible) = 0;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/gamepad/cocoa/GameControllerGamepadProvider.mm (264003 => 264004)


--- trunk/Source/WebCore/platform/gamepad/cocoa/GameControllerGamepadProvider.mm	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebCore/platform/gamepad/cocoa/GameControllerGamepadProvider.mm	2020-07-07 01:34:49 UTC (rev 264004)
@@ -73,7 +73,7 @@
     makeInvisibileGamepadsVisible();
 
     for (auto& client : m_clients)
-        client->platformGamepadConnected(*m_gamepadVector[index]);
+        client->platformGamepadConnected(*m_gamepadVector[index], EventMakesGamepadsVisible::Yes);
 }
 
 void GameControllerGamepadProvider::controllerDidDisconnect(GCController *controller)
@@ -151,7 +151,7 @@
 {
     for (auto* gamepad : m_invisibleGamepads) {
         for (auto& client : m_clients)
-            client->platformGamepadConnected(*gamepad);
+            client->platformGamepadConnected(*gamepad, EventMakesGamepadsVisible::Yes);
     }
 
     m_invisibleGamepads.clear();

Modified: trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.cpp (264003 => 264004)


--- trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.cpp	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.cpp	2020-07-07 01:34:49 UTC (rev 264004)
@@ -81,8 +81,7 @@
 }
 
 HIDGamepadProvider::HIDGamepadProvider()
-    : m_shouldDispatchCallbacks(false)
-    , m_connectionDelayTimer(*this, &HIDGamepadProvider::connectionDelayTimerFired)
+    : m_initialGamepadsConnectedTimer(*this, &HIDGamepadProvider::initialGamepadsConnectedTimerFired)
     , m_inputNotificationTimer(*this, &HIDGamepadProvider::inputNotificationTimerFired)
 {
     m_manager = adoptCF(IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone));
@@ -122,12 +121,9 @@
     return index;
 }
 
-void HIDGamepadProvider::connectionDelayTimerFired()
+void HIDGamepadProvider::initialGamepadsConnectedTimerFired()
 {
-    m_shouldDispatchCallbacks = true;
-
-    for (auto* client : m_clients)
-        client->setInitialConnectedGamepads(m_gamepadVector);
+    m_initialGamepadsConnected = true;
 }
 
 void HIDGamepadProvider::openAndScheduleManager()
@@ -137,7 +133,7 @@
     ASSERT(m_gamepadVector.isEmpty());
     ASSERT(m_gamepadMap.isEmpty());
 
-    m_shouldDispatchCallbacks = false;
+    m_initialGamepadsConnected = false;
 
     IOHIDManagerScheduleWithRunLoop(m_manager.get(), CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
     IOHIDManagerOpen(m_manager.get(), kIOHIDOptionsTypeNone);
@@ -144,7 +140,7 @@
 
     // Any connections we are notified of within the connectionDelayInterval of listening likely represent
     // devices that were already connected, so we suppress notifying clients of these.
-    m_connectionDelayTimer.startOneShot(connectionDelayInterval);
+    m_initialGamepadsConnectedTimer.startOneShot(connectionDelayInterval);
 }
 
 void HIDGamepadProvider::closeAndUnscheduleManager()
@@ -157,7 +153,7 @@
     m_gamepadVector.clear();
     m_gamepadMap.clear();
 
-    m_connectionDelayTimer.stop();
+    m_initialGamepadsConnectedTimer.stop();
 }
 
 void HIDGamepadProvider::startMonitoringGamepads(GamepadProviderClient& client)
@@ -195,21 +191,18 @@
     m_gamepadVector[index] = gamepad.get();
     m_gamepadMap.set(device, WTFMove(gamepad));
 
-    if (!m_shouldDispatchCallbacks) {
+    if (!m_initialGamepadsConnected) {
         // This added device is the result of us starting to monitor gamepads.
         // We'll get notified of all connected devices during this current spin of the runloop
-        // and we don't want to tell the client about any of them.
-        // The m_connectionDelayTimer fires in a subsequent spin of the runloop after which
-        // any connection events are actual new devices.
-        m_connectionDelayTimer.startOneShot(0_s);
-
-        LOG(Gamepad, "Device %p was added while suppressing callbacks, so this should be an 'already connected' event", device);
-
-        return;
+        // and the client should be told they were already connected.
+        // The m_initialGamepadsConnectedTimer fires in a subsequent spin of the runloop after which
+        // any connection events are actual new devices and can trigger gamepad visibility.
+        if (!m_initialGamepadsConnectedTimer.isActive())
+            m_initialGamepadsConnectedTimer.startOneShot(0_s);
     }
 
     for (auto& client : m_clients)
-        client->platformGamepadConnected(*m_gamepadVector[index]);
+        client->platformGamepadConnected(*m_gamepadVector[index], m_initialGamepadsConnected ? EventMakesGamepadsVisible::Yes : EventMakesGamepadsVisible::No);
 }
 
 void HIDGamepadProvider::deviceRemoved(IOHIDDeviceRef device)
@@ -219,10 +212,6 @@
     std::unique_ptr<HIDGamepad> removedGamepad = removeGamepadForDevice(device);
     ASSERT(removedGamepad);
 
-    // Any time we get a device removed callback we know it's a real event and not an 'already connected' event.
-    // We should always stop suppressing callbacks when we receive such an event.
-    m_shouldDispatchCallbacks = true;
-
     for (auto& client : m_clients)
         client->platformGamepadDisconnected(*removedGamepad);
 }
@@ -248,8 +237,11 @@
 
 void HIDGamepadProvider::inputNotificationTimerFired()
 {
-    if (!m_shouldDispatchCallbacks)
+    if (!m_initialGamepadsConnected) {
+        if (!m_inputNotificationTimer.isActive())
+            m_inputNotificationTimer.startOneShot(0_s);
         return;
+    }
 
     dispatchPlatformGamepadInputActivity();
 }

Modified: trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.h (264003 => 264004)


--- trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.h	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.h	2020-07-07 01:34:49 UTC (rev 264004)
@@ -64,7 +64,7 @@
     void openAndScheduleManager();
     void closeAndUnscheduleManager();
 
-    void connectionDelayTimerFired();
+    void initialGamepadsConnectedTimerFired();
     void inputNotificationTimerFired();
 
     unsigned indexForNewlyConnectedDevice();
@@ -74,9 +74,9 @@
 
     RetainPtr<IOHIDManagerRef> m_manager;
 
-    bool m_shouldDispatchCallbacks;
+    bool m_initialGamepadsConnected { false };
 
-    Timer m_connectionDelayTimer;
+    Timer m_initialGamepadsConnectedTimer;
     Timer m_inputNotificationTimer;
 };
 

Modified: trunk/Source/WebCore/testing/MockGamepadProvider.cpp (264003 => 264004)


--- trunk/Source/WebCore/testing/MockGamepadProvider.cpp	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebCore/testing/MockGamepadProvider.cpp	2020-07-07 01:34:49 UTC (rev 264004)
@@ -87,7 +87,7 @@
     m_connectedGamepadVector[index] = m_mockGamepadVector[index].get();
 
     for (auto& client : m_clients)
-        client->platformGamepadConnected(*m_connectedGamepadVector[index]);
+        client->platformGamepadConnected(*m_connectedGamepadVector[index], EventMakesGamepadsVisible::Yes);
 
     return true;
 }

Modified: trunk/Source/WebKit/ChangeLog (264003 => 264004)


--- trunk/Source/WebKit/ChangeLog	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/ChangeLog	2020-07-07 01:34:49 UTC (rev 264004)
@@ -1,3 +1,43 @@
+2020-07-06  Brady Eidson  <beid...@apple.com>
+
+        Get rid of concept of "initial connected gamepads"
+        https://bugs.webkit.org/show_bug.cgi?id=214010
+
+        Reviewed by Tim Horton.
+
+        * Scripts/webkit/messages.py:
+
+        * UIProcess/Gamepad/UIGamepadProvider.cpp:
+        (WebKit::UIGamepadProvider::gamepadSyncTimerFired):
+        (WebKit::UIGamepadProvider::platformGamepadConnected):
+        (WebKit::UIGamepadProvider::platformGamepadInputActivity):
+        (WebKit::UIGamepadProvider::setInitialConnectedGamepads): Deleted.
+        * UIProcess/Gamepad/UIGamepadProvider.h:
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::gamepadActivity):
+        * UIProcess/WebPageProxy.h:
+
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::gamepadConnected):
+        (WebKit::WebProcessPool::setInitialConnectedGamepads): Deleted.
+        * UIProcess/WebProcessPool.h:
+
+        * WebProcess/Gamepad/WebGamepadProvider.cpp:
+        (WebKit::WebGamepadProvider::gamepadConnected):
+        (WebKit::WebGamepadProvider::gamepadActivity):
+        * WebProcess/Gamepad/WebGamepadProvider.h:
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::gamepadActivity):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::gamepadConnected):
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+
 2020-07-06  Chris Dumez  <cdu...@apple.com>
 
         Regression(r249303) Crash under NetworkLoad::NetworkLoad()

Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (264003 => 264004)


--- trunk/Source/WebKit/Scripts/webkit/messages.py	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py	2020-07-07 01:34:49 UTC (rev 264004)
@@ -599,6 +599,7 @@
         'WebCore::ShareDataWithParsedURL': ['<WebCore/ShareData.h>'],
         'WebCore::FontChanges': ['<WebCore/FontAttributeChanges.h>'],
         'WebCore::FrameLoadType': ['<WebCore/FrameLoaderTypes.h>'],
+        'WebCore::EventMakesGamepadsVisible': ['<WebCore/GamepadProviderClient.h>'],
         'WebCore::GenericCueData': ['<WebCore/InbandGenericCue.h>'],
         'WebCore::GrammarDetail': ['<WebCore/TextCheckerClient.h>'],
         'WebCore::HasInsecureContent': ['<WebCore/FrameLoaderTypes.h>'],

Modified: trunk/Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.cpp (264003 => 264004)


--- trunk/Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.cpp	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.cpp	2020-07-07 01:34:49 UTC (rev 264004)
@@ -65,7 +65,7 @@
     if (!webPageProxy || !m_processPoolsUsingGamepads.contains(&webPageProxy->process().processPool()))
         return;
 
-    webPageProxy->gamepadActivity(snapshotGamepads(), m_shouldMakeGamepadsVisibleOnSync);
+    webPageProxy->gamepadActivity(snapshotGamepads(), m_shouldMakeGamepadsVisibleOnSync ? EventMakesGamepadsVisible::Yes : EventMakesGamepadsVisible::No);
     m_shouldMakeGamepadsVisibleOnSync = false;
 }
 
@@ -82,26 +82,10 @@
     m_gamepadSyncTimer.startOneShot(maximumGamepadUpdateInterval);
 }
 
-void UIGamepadProvider::setInitialConnectedGamepads(const Vector<PlatformGamepad*>& initialGamepads)
+void UIGamepadProvider::platformGamepadConnected(PlatformGamepad& gamepad, EventMakesGamepadsVisible eventVisibility)
 {
-    ASSERT(!m_hasInitialGamepads);
+    LOG(Gamepad, "UIGamepadProvider::platformGamepadConnected - Index %i attached (visibility: %i)\n", gamepad.index(), (int)eventVisibility);
 
-    m_gamepads.resize(initialGamepads.size());
-
-    for (auto* gamepad : initialGamepads) {
-        if (!gamepad)
-            continue;
-        m_gamepads[gamepad->index()] = makeUnique<UIGamepad>(*gamepad);
-    }
-
-    for (auto& pool : m_processPoolsUsingGamepads)
-        pool->setInitialConnectedGamepads(m_gamepads);
-
-    m_hasInitialGamepads = true;
-}
-
-void UIGamepadProvider::platformGamepadConnected(PlatformGamepad& gamepad)
-{
     if (m_gamepads.size() <= gamepad.index())
         m_gamepads.grow(gamepad.index() + 1);
 
@@ -111,7 +95,7 @@
     scheduleGamepadStateSync();
 
     for (auto& pool : m_processPoolsUsingGamepads)
-        pool->gamepadConnected(*m_gamepads[gamepad.index()]);
+        pool->gamepadConnected(*m_gamepads[gamepad.index()], eventVisibility);
 }
 
 void UIGamepadProvider::platformGamepadDisconnected(PlatformGamepad& gamepad)
@@ -127,7 +111,7 @@
         pool->gamepadDisconnected(*disconnectedGamepad);
 }
 
-void UIGamepadProvider::platformGamepadInputActivity(bool shouldMakeGamepadsVisible)
+void UIGamepadProvider::platformGamepadInputActivity(EventMakesGamepadsVisible eventVisibility)
 {
     auto platformGamepads = GamepadProvider::singleton().platformGamepads();
     ASSERT(platformGamepads.size() == m_gamepads.size());
@@ -142,7 +126,7 @@
         m_gamepads[i]->updateFromPlatformGamepad(*platformGamepads[i]);
     }
 
-    if (shouldMakeGamepadsVisible)
+    if (eventVisibility == EventMakesGamepadsVisible::Yes)
         m_shouldMakeGamepadsVisibleOnSync = true;
 
     scheduleGamepadStateSync();

Modified: trunk/Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.h (264003 => 264004)


--- trunk/Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.h	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.h	2020-07-07 01:34:49 UTC (rev 264004)
@@ -70,10 +70,9 @@
     void platformStopMonitoringInput();
     void platformStartMonitoringInput();
 
-    void setInitialConnectedGamepads(const Vector<WebCore::PlatformGamepad*>&) final;
-    void platformGamepadConnected(WebCore::PlatformGamepad&) final;
+    void platformGamepadConnected(WebCore::PlatformGamepad&, WebCore::EventMakesGamepadsVisible) final;
     void platformGamepadDisconnected(WebCore::PlatformGamepad&) final;
-    void platformGamepadInputActivity(bool shouldMakeGamepadsVisible) final;
+    void platformGamepadInputActivity(WebCore::EventMakesGamepadsVisible) final;
 
     void scheduleGamepadStateSync();
     void gamepadSyncTimerFired();
@@ -85,7 +84,6 @@
     RunLoop::Timer<UIGamepadProvider> m_gamepadSyncTimer;
 
     bool m_isMonitoringGamepads { false };
-    bool m_hasInitialGamepads { false };
     bool m_shouldMakeGamepadsVisibleOnSync { false };
 };
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (264003 => 264004)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-07-07 01:34:49 UTC (rev 264004)
@@ -7920,9 +7920,9 @@
 
 #if ENABLE(GAMEPAD)
 
-void WebPageProxy::gamepadActivity(const Vector<GamepadData>& gamepadDatas, bool shouldMakeGamepadsVisible)
+void WebPageProxy::gamepadActivity(const Vector<GamepadData>& gamepadDatas, EventMakesGamepadsVisible eventVisibility)
 {
-    send(Messages::WebPage::GamepadActivity(gamepadDatas, shouldMakeGamepadsVisible));
+    send(Messages::WebPage::GamepadActivity(gamepadDatas, eventVisibility));
 }
 
 #endif

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (264003 => 264004)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-07-07 01:34:49 UTC (rev 264004)
@@ -229,6 +229,7 @@
 
 enum class AutoplayEvent : uint8_t;
 enum class DOMPasteAccessResponse : uint8_t;
+enum class EventMakesGamepadsVisible : bool;
 enum class LockBackForwardList : bool;
 enum class HasInsecureContent : bool;
 enum class MouseEventPolicy : uint8_t;
@@ -1569,7 +1570,7 @@
     bool isAlwaysOnLoggingAllowed() const;
 
 #if ENABLE(GAMEPAD)
-    void gamepadActivity(const Vector<GamepadData>&, bool shouldMakeGamepadsVisible);
+    void gamepadActivity(const Vector<GamepadData>&, WebCore::EventMakesGamepadsVisible);
 #endif
 
     void isLoadingChanged() { activityStateDidChange(WebCore::ActivityState::IsLoading); }

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (264003 => 264004)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2020-07-07 01:34:49 UTC (rev 264004)
@@ -1957,10 +1957,10 @@
         UIGamepadProvider::singleton().processPoolStoppedUsingGamepads(*this);
 }
 
-void WebProcessPool::gamepadConnected(const UIGamepad& gamepad)
+void WebProcessPool::gamepadConnected(const UIGamepad& gamepad, EventMakesGamepadsVisible eventVisibility)
 {
     for (auto& process : m_processesUsingGamepads)
-        process->send(Messages::WebProcess::GamepadConnected(gamepad.fullGamepadData()), 0);
+        process->send(Messages::WebProcess::GamepadConnected(gamepad.fullGamepadData(), eventVisibility), 0);
 }
 
 void WebProcessPool::gamepadDisconnected(const UIGamepad& gamepad)
@@ -1969,20 +1969,6 @@
         process->send(Messages::WebProcess::GamepadDisconnected(gamepad.index()), 0);
 }
 
-void WebProcessPool::setInitialConnectedGamepads(const Vector<std::unique_ptr<UIGamepad>>& gamepads)
-{
-    Vector<GamepadData> gamepadDatas;
-    gamepadDatas.grow(gamepads.size());
-    for (size_t i = 0; i < gamepads.size(); ++i) {
-        if (!gamepads[i])
-            continue;
-        gamepadDatas[i] = gamepads[i]->fullGamepadData();
-    }
-
-    for (auto& process : m_processesUsingGamepads)
-        process->send(Messages::WebProcess::SetInitialGamepads(gamepadDatas), 0);
-}
-
 #endif // ENABLE(GAMEPAD)
 
 void WebProcessPool::setJavaScriptConfigurationFileEnabled(bool flag)

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (264003 => 264004)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.h	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h	2020-07-07 01:34:49 UTC (rev 264004)
@@ -92,6 +92,7 @@
 
 namespace WebCore {
 class RegistrableDomain;
+enum class EventMakesGamepadsVisible : bool;
 struct MockMediaDevice;
 }
 
@@ -463,10 +464,8 @@
     void synthesizeAppIsBackground(bool background);
     
 #if ENABLE(GAMEPAD)
-    void gamepadConnected(const UIGamepad&);
+    void gamepadConnected(const UIGamepad&, WebCore::EventMakesGamepadsVisible);
     void gamepadDisconnected(const UIGamepad&);
-
-    void setInitialConnectedGamepads(const Vector<std::unique_ptr<UIGamepad>>&);
 #endif
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit/WebProcess/Gamepad/WebGamepadProvider.cpp (264003 => 264004)


--- trunk/Source/WebKit/WebProcess/Gamepad/WebGamepadProvider.cpp	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/WebProcess/Gamepad/WebGamepadProvider.cpp	2020-07-07 01:34:49 UTC (rev 264004)
@@ -67,8 +67,10 @@
     }
 }
 
-void WebGamepadProvider::gamepadConnected(const GamepadData& gamepadData)
+void WebGamepadProvider::gamepadConnected(const GamepadData& gamepadData, EventMakesGamepadsVisible eventVisibility)
 {
+    LOG(Gamepad, "WebGamepadProvider::gamepadConnected - Index %i attached (visibility: %i)\n", gamepadData.index(), (int)eventVisibility);
+
     if (m_gamepads.size() <= gamepadData.index()) {
         m_gamepads.resize(gamepadData.index() + 1);
         m_rawGamepads.resize(gamepadData.index() + 1);
@@ -80,7 +82,7 @@
     m_rawGamepads[gamepadData.index()] = m_gamepads[gamepadData.index()].get();
 
     for (auto* client : m_clients)
-        client->platformGamepadConnected(*m_gamepads[gamepadData.index()]);
+        client->platformGamepadConnected(*m_gamepads[gamepadData.index()], eventVisibility);
 }
 
 void WebGamepadProvider::gamepadDisconnected(unsigned index)
@@ -94,7 +96,7 @@
         client->platformGamepadDisconnected(*disconnectedGamepad);
 }
 
-void WebGamepadProvider::gamepadActivity(const Vector<GamepadData>& gamepadDatas, bool shouldMakeGamepadsVisible)
+void WebGamepadProvider::gamepadActivity(const Vector<GamepadData>& gamepadDatas, EventMakesGamepadsVisible eventVisibility)
 {
     ASSERT(m_gamepads.size() == gamepadDatas.size());
 
@@ -104,7 +106,7 @@
     }
 
     for (auto* client : m_clients)
-        client->platformGamepadInputActivity(shouldMakeGamepadsVisible);
+        client->platformGamepadInputActivity(eventVisibility);
 }
 
 void WebGamepadProvider::startMonitoringGamepads(GamepadProviderClient& client)

Modified: trunk/Source/WebKit/WebProcess/Gamepad/WebGamepadProvider.h (264003 => 264004)


--- trunk/Source/WebKit/WebProcess/Gamepad/WebGamepadProvider.h	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/WebProcess/Gamepad/WebGamepadProvider.h	2020-07-07 01:34:49 UTC (rev 264004)
@@ -32,6 +32,10 @@
 #include <wtf/HashSet.h>
 #include <wtf/Vector.h>
 
+namespace WebCore {
+enum class EventMakesGamepadsVisible : bool;
+}
+
 namespace WebKit {
 
 class SharedMemory;
@@ -43,9 +47,9 @@
 public:
     static WebGamepadProvider& singleton();
 
-    void gamepadConnected(const GamepadData&);
+    void gamepadConnected(const GamepadData&, WebCore::EventMakesGamepadsVisible);
     void gamepadDisconnected(unsigned index);
-    void gamepadActivity(const Vector<GamepadData>&, bool shouldMakeGamepadsVisible);
+    void gamepadActivity(const Vector<GamepadData>&, WebCore::EventMakesGamepadsVisible);
 
     void setInitialGamepads(const Vector<GamepadData>&);
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (264003 => 264004)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-07-07 01:34:49 UTC (rev 264004)
@@ -6624,9 +6624,9 @@
 
 #if ENABLE(GAMEPAD)
 
-void WebPage::gamepadActivity(const Vector<GamepadData>& gamepadDatas, bool shouldMakeGamepadsVisible)
+void WebPage::gamepadActivity(const Vector<GamepadData>& gamepadDatas, EventMakesGamepadsVisible eventVisibilty)
 {
-    WebGamepadProvider::singleton().gamepadActivity(gamepadDatas, shouldMakeGamepadsVisible);
+    WebGamepadProvider::singleton().gamepadActivity(gamepadDatas, eventVisibilty);
 }
 
 #endif

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (264003 => 264004)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-07-07 01:34:49 UTC (rev 264004)
@@ -196,6 +196,7 @@
 enum SyntheticClickType : int8_t;
 enum class DOMPasteAccessResponse : uint8_t;
 enum class DragHandlingMethod : uint8_t;
+enum class EventMakesGamepadsVisible : bool;
 enum class SelectionDirection : uint8_t;
 enum class ShouldTreatAsContinuingLoad : bool;
 enum class TextIndicatorPresentationTransition : uint8_t;
@@ -1175,7 +1176,7 @@
 #endif
 
 #if ENABLE(GAMEPAD)
-    void gamepadActivity(const Vector<GamepadData>&, bool shouldMakeGamepadsVisible);
+    void gamepadActivity(const Vector<GamepadData>&, WebCore::EventMakesGamepadsVisible);
 #endif
     
 #if ENABLE(POINTER_LOCK)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (264003 => 264004)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-07-07 01:34:49 UTC (rev 264004)
@@ -545,7 +545,7 @@
     SetUseIconLoadingClient(bool useIconLoadingClient)
 
 #if ENABLE(GAMEPAD)
-    GamepadActivity(Vector<WebKit::GamepadData> gamepadDatas, bool shouldMakeGamepadsVisible)
+    GamepadActivity(Vector<WebKit::GamepadData> gamepadDatas, enum:bool WebCore::EventMakesGamepadsVisible eventVisibility)
 #endif
 
     FrameBecameRemote(WebCore::FrameIdentifier frameID, struct WebCore::GlobalFrameIdentifier remoteFrameIdentifier, struct WebCore::GlobalWindowIdentifier remoteWindowIdentifier)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (264003 => 264004)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2020-07-07 01:34:49 UTC (rev 264004)
@@ -1049,9 +1049,9 @@
     WebGamepadProvider::singleton().setInitialGamepads(gamepadDatas);
 }
 
-void WebProcess::gamepadConnected(const GamepadData& gamepadData)
+void WebProcess::gamepadConnected(const GamepadData& gamepadData, WebCore::EventMakesGamepadsVisible eventVisibility)
 {
-    WebGamepadProvider::singleton().gamepadConnected(gamepadData);
+    WebGamepadProvider::singleton().gamepadConnected(gamepadData, eventVisibility);
 }
 
 void WebProcess::gamepadDisconnected(unsigned index)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (264003 => 264004)


--- trunk/Source/WebKit/WebProcess/WebProcess.h	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h	2020-07-07 01:34:49 UTC (rev 264004)
@@ -84,6 +84,9 @@
 class RegistrableDomain;
 class ResourceRequest;
 class UserGestureToken;
+
+enum class EventMakesGamepadsVisible : bool;
+
 struct BackForwardItemIdentifier;
 struct MessagePortIdentifier;
 struct MessageWithMessagePorts;
@@ -401,7 +404,7 @@
 
 #if ENABLE(GAMEPAD)
     void setInitialGamepads(const Vector<GamepadData>&);
-    void gamepadConnected(const GamepadData&);
+    void gamepadConnected(const GamepadData&, WebCore::EventMakesGamepadsVisible);
     void gamepadDisconnected(unsigned index);
 #endif
 

Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (264003 => 264004)


--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2020-07-07 00:54:23 UTC (rev 264003)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2020-07-07 01:34:49 UTC (rev 264004)
@@ -100,7 +100,7 @@
 
 #if ENABLE(GAMEPAD)
     SetInitialGamepads(Vector<WebKit::GamepadData> gamepadDatas)
-    GamepadConnected(WebKit::GamepadData gamepadData)
+    GamepadConnected(WebKit::GamepadData gamepadData, enum:bool WebCore::EventMakesGamepadsVisible eventVisibility)
     GamepadDisconnected(unsigned index)
 #endif
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to