[webkit-changes] [WebKit/WebKit] 745714: WebKit engine support for Badging API

Brady Eidson noreply at github.com
Sat Dec 17 12:32:41 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7457143192d5ea0040dfe29917d9af8dcb49feff
      https://github.com/WebKit/WebKit/commit/7457143192d5ea0040dfe29917d9af8dcb49feff
  Author: Brady Eidson <beidson at apple.com>
  Date:   2022-12-17 (Sat, 17 Dec 2022)

  Changed paths:
    M Source/WTF/Scripts/Preferences/WebPreferences.yaml
    M Source/WTF/wtf/PlatformEnable.h
    M Source/WebCore/CMakeLists.txt
    M Source/WebCore/DerivedSources-input.xcfilelist
    M Source/WebCore/DerivedSources-output.xcfilelist
    M Source/WebCore/DerivedSources.make
    M Source/WebCore/Headers.cmake
    A Source/WebCore/Modules/badge/BadgeClient.h
    A Source/WebCore/Modules/badge/EmptyBadgeClient.h
    A Source/WebCore/Modules/badge/Navigator+Badge.idl
    A Source/WebCore/Modules/badge/NavigatorBadge.idl
    A Source/WebCore/Modules/badge/WorkerBadgeProxy.h
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/loader/EmptyClients.cpp
    M Source/WebCore/page/Navigator.cpp
    M Source/WebCore/page/Navigator.h
    M Source/WebCore/page/Navigator.idl
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    M Source/WebCore/page/PageConfiguration.cpp
    M Source/WebCore/page/PageConfiguration.h
    M Source/WebCore/page/WorkerNavigator.cpp
    M Source/WebCore/page/WorkerNavigator.h
    M Source/WebCore/page/WorkerNavigator.idl
    M Source/WebCore/workers/DedicatedWorkerThread.cpp
    M Source/WebCore/workers/DedicatedWorkerThread.h
    M Source/WebCore/workers/WorkerMessagingProxy.cpp
    M Source/WebCore/workers/WorkerMessagingProxy.h
    M Source/WebCore/workers/WorkerThread.cpp
    M Source/WebCore/workers/WorkerThread.h
    M Source/WebCore/workers/service/context/ServiceWorkerThread.cpp
    M Source/WebCore/workers/service/context/ServiceWorkerThread.h
    M Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp
    M Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h
    M Source/WebCore/workers/shared/context/SharedWorkerThread.cpp
    M Source/WebCore/workers/shared/context/SharedWorkerThread.h
    M Source/WebCore/workers/shared/context/SharedWorkerThreadProxy.cpp
    M Source/WebCore/workers/shared/context/SharedWorkerThreadProxy.h
    M Source/WebKit/Sources.txt
    M Source/WebKit/UIProcess/API/APIUIClient.h
    M Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h
    M Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
    M Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
    M Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreDelegate.h
    M Source/WebKit/UIProcess/Cocoa/UIDelegate.h
    M Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
    M Source/WebKit/UIProcess/WebProcessProxy.cpp
    M Source/WebKit/UIProcess/WebProcessProxy.h
    M Source/WebKit/UIProcess/WebProcessProxy.messages.in
    M Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
    M Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
    M Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreClient.h
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
    M Source/WebKit/WebProcess/Storage/WebSharedWorkerContextManagerConnection.cpp
    A Source/WebKit/WebProcess/WebCoreSupport/WebBadgeClient.cpp
    A Source/WebKit/WebProcess/WebCoreSupport/WebBadgeClient.h
    M Source/WebKit/WebProcess/WebCoreSupport/WebWorkerClient.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebProcess.cpp
    M Source/WebKit/WebProcess/WebProcess.h
    M Source/WebKitLegacy/mac/WebView/WebView.mm
    M Source/WebKitLegacy/win/WebView.cpp
    M Tools/TestWebKitAPI/SourcesCocoa.txt
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    A Tools/TestWebKitAPI/Tests/WebKitCocoa/Badging.mm

  Log Message:
  -----------
  WebKit engine support for Badging API
https://bugs.webkit.org/show_bug.cgi?id=223906
rdar://76241764

Reviewed by Tim Horton and Chris Dumez.

This patch adds engine support for setAppBadge() and setClientBadge() on Navigator objects.
https://w3c.github.io/badging/

When Javascript updates a badge count it is sent to the embedding application via delegate callbacks.

Engine support does not mean browser support.

The standard explicitly calls out that if the User Agent does not intend to do anything with the updated
badge count then the API should not be exposed to JavaScript.
This allows for the best practice of feature detection, so web page JavaScript can put its badge count
data somewhere else that it knows will be used.

As such, WebKit support remains disabled at runtime, and only clients interested in actually using the
badge count will enable it.

This patch implements the feature by exposing a BadgeClient on Page.

The WebContent process implementation of the BadgeClient sends new badge counts to the UI process to
be forwarded along to a delegate.

For the Cocoa port:
- If the badge count update came from a WindowNavigator object, then the new badge count is sent to the
  WKUIDelegate installed on the WKWebView.
- If the badge count update came from a WorkerNavigator object (dedicated, shared, or service), then
  the new badge count is sent to the WKWebsiteDataStoreDelegate installed on the relevant data store.

Almost the entire patch is a mechanical plumbing task of moving the badge count from JS to the API client.

But an unfortunately large amount of this patch is in service of forwarding the WorkerNavigator calls from
the worker threads to the main thread and then to lookup the appropriate Page object.

C'est la vie.

* Source/WTF/Scripts/Preferences/WebPreferences.yaml:
* Source/WTF/wtf/PlatformEnable.h:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Modules/badge/BadgeClient.h: Copied from Source/WebCore/page/WorkerNavigator.cpp.
* Source/WebCore/Modules/badge/EmptyBadgeClient.h: Copied from Source/WebCore/page/WorkerNavigator.cpp.
* Source/WebCore/Modules/badge/Navigator+Badge.idl: Copied from Source/WebCore/workers/shared/context/SharedWorkerThread.h.
* Source/WebCore/Modules/badge/NavigatorBadge.idl: Copied from Source/WebCore/workers/shared/context/SharedWorkerThread.h.
* Source/WebCore/Modules/badge/WorkerBadgeProxy.h: Copied from Source/WebCore/page/WorkerNavigator.cpp.
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/loader/EmptyClients.cpp:
(WebCore::pageConfigurationWithEmptyClients):
* Source/WebCore/page/Navigator.cpp:
(WebCore::Navigator::setAppBadge):
(WebCore::Navigator::clearAppBadge):
(WebCore::Navigator::setClientBadge):
(WebCore::Navigator::clearClientBadge):
* Source/WebCore/page/Navigator.h:
* Source/WebCore/page/Navigator.idl:
* Source/WebCore/page/Page.cpp:
(WebCore::m_badgeClient):
(WebCore::m_contentSecurityPolicyModeForExtension): Deleted.
* Source/WebCore/page/Page.h:
(WebCore::Page::badgeClient):
* Source/WebCore/page/PageConfiguration.cpp:
(WebCore::PageConfiguration::PageConfiguration):
* Source/WebCore/page/PageConfiguration.h:
* Source/WebCore/page/WorkerNavigator.cpp:
(WebCore::WorkerNavigator::setAppBadge):
(WebCore::WorkerNavigator::clearAppBadge):
* Source/WebCore/page/WorkerNavigator.h:
* Source/WebCore/page/WorkerNavigator.idl:
* Source/WebCore/workers/DedicatedWorkerThread.cpp:
(WebCore::DedicatedWorkerThread::DedicatedWorkerThread):
* Source/WebCore/workers/DedicatedWorkerThread.h:
* Source/WebCore/workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
(WebCore::WorkerMessagingProxy::postTaskToWorkerObject):
(WebCore::WorkerMessagingProxy::setAppBadge):
* Source/WebCore/workers/WorkerMessagingProxy.h:
* Source/WebCore/workers/WorkerThread.cpp:
(WebCore::WorkerThread::WorkerThread):
* Source/WebCore/workers/WorkerThread.h:
(WebCore::WorkerThread::workerBadgeProxy const):
* Source/WebCore/workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::ServiceWorkerThread):
* Source/WebCore/workers/service/context/ServiceWorkerThread.h:
* Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp:
(WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
(WebCore::ServiceWorkerThreadProxy::setAppBadge):
* Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h:
* Source/WebCore/workers/shared/context/SharedWorkerThread.cpp:
(WebCore::SharedWorkerThread::SharedWorkerThread):
* Source/WebCore/workers/shared/context/SharedWorkerThread.h:
* Source/WebCore/workers/shared/context/SharedWorkerThreadProxy.cpp:
(WebCore::SharedWorkerThreadProxy::SharedWorkerThreadProxy):
(WebCore::SharedWorkerThreadProxy::setAppBadge):
* Source/WebCore/workers/shared/context/SharedWorkerThreadProxy.h:
* Source/WebKit/Sources.txt:
* Source/WebKit/UIProcess/API/APIUIClient.h:
(API::UIClient::updateAppBadge):
(API::UIClient::updateClientBadge):
* Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _setAppBadgeEnabled:]):
(-[WKPreferences _appBadgeEnabled]):
(-[WKPreferences _setClientBadgeEnabled:]):
(-[WKPreferences _clientBadgeEnabled]):
* Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreDelegate.h:
* Source/WebKit/UIProcess/Cocoa/UIDelegate.h:
* Source/WebKit/UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::setDelegate):
(WebKit::UIDelegate::UIClient::updateAppBadge):
(WebKit::UIDelegate::UIClient::updateClientBadge):
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::setAppBadge):
(WebKit::WebProcessProxy::setClientBadge):
* Source/WebKit/UIProcess/WebProcessProxy.h:
* Source/WebKit/UIProcess/WebProcessProxy.messages.in:
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::workerUpdatedAppBadge):
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h:
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreClient.h:
(WebKit::WebsiteDataStoreClient::workerUpdatedAppBadge):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::installServiceWorker):
* Source/WebKit/WebProcess/Storage/WebSharedWorkerContextManagerConnection.cpp:
(WebKit::WebSharedWorkerContextManagerConnection::launchSharedWorker):
* Source/WebKit/WebProcess/WebCoreSupport/WebBadgeClient.cpp: Copied from Source/WebCore/workers/shared/context/SharedWorkerThread.h.
(WebKit::WebBadgeClient::setAppBadge):
(WebKit::WebBadgeClient::setClientBadge):
* Source/WebKit/WebProcess/WebCoreSupport/WebBadgeClient.h: Copied from Source/WebCore/workers/shared/context/SharedWorkerThread.h.
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::m_appHighlightsVisible):
* Source/WebKit/WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
(WebKit::WebProcess::setAppBadge):
(WebKit::WebProcess::setClientBadge):
* Source/WebKit/WebProcess/WebProcess.h:
(WebKit::WebProcess::badgeClient):
* Source/WebKitLegacy/mac/WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/Badging.mm: Added.
(-[BadgeDelegate updatedAppBadge:]):
(-[BadgeDelegate _webView:updatedAppBadge:]):
(-[BadgeDelegate _webView:updatedClientBadge:]):
(-[BadgeDelegate websiteDataStore:workerOrigin:updatedAppBadge:]):

Canonical link: https://commits.webkit.org/258051@main




More information about the webkit-changes mailing list