Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 42a502b73aebe9c7987907a4162c3a267c4d0ddc
https://github.com/WebKit/WebKit/commit/42a502b73aebe9c7987907a4162c3a267c4d0ddc
Author: Abrar Rahman Protyasha <[email protected]>
Date: 2026-01-28 (Wed, 28 Jan 2026)
Changed paths:
M Source/WebCore/html/PluginDocument.cpp
M Source/WebCore/style/values/color/StyleColorOptions.h
M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h
M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm
M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
M Source/WebKit/WebProcess/Plugins/PluginView.cpp
M Source/WebKit/WebProcess/Plugins/PluginView.h
M Source/WebKit/WebProcess/WebPage/WebPage.cpp
M Tools/TestWebKitAPI/Tests/WebKitCocoa/UnifiedPDFTests.mm
M Tools/TestWebKitAPI/cocoa/TestWKWebView.h
M Tools/TestWebKitAPI/cocoa/TestWKWebView.mm
Log Message:
-----------
PDF background should adapt to system appearance changes
https://bugs.webkit.org/show_bug.cgi?id=306305
rdar://168665166
Reviewed by Wenson Hsieh.
In 305691@main, we changed the plugin background color from dark grey to
white, citing a better design fit with Liquid Glass. A missing piece to
this change though is our desire to have the plugin background color
adapt to system appearance changes.
In this patch, we introduce PDF plugin hooks that are notified when the
effective appearance changes. In response to this, we update root layer
colors to `-apple-system-background`. Note that we only do this for full
main frame plugins, and not for <iframe>/<embed>/<object> elements. The
intention with embedded PDFs is that they should adopt the behavior
of their surrounding main frame document.
Tests:
UnifiedPDF.BackgroundAdaptsToColorScheme
UnifiedPDF.BackgroundDoesNotAdaptToColorSchemeOnEmbeddedDocuments
* Source/WebCore/html/PluginDocument.cpp:
Add a <meta color-scheme="light dark"> element to (main frame) plugin
documents, opting us into a mode that can adapt to appearance changes.
* Source/WebCore/style/values/color/StyleColorOptions.h:
WEBCORE_EXPORT the TextStream operator. It is helpful during local
debugging from WebKit.
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
(WebKit::PDFPluginBase::effectiveAppearanceDidChange):
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::PDFPluginBase):
(WebKit::PDFPluginBase::pluginBackgroundColor const):
(WebKit::PDFPluginBase::pluginBackgroundColor): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::effectiveAppearanceDidChange):
* Source/WebKit/WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::effectiveAppearanceDidChange):
* Source/WebKit/WebProcess/Plugins/PluginView.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setUseColorAppearance):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/UnifiedPDFTests.mm:
(TestWebKitAPI::UNIFIED_PDF_TEST):
* Tools/TestWebKitAPI/cocoa/TestWKWebView.h:
* Tools/TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[WKWebView firstLayerWithName:]):
(-[WKWebView firstLayerWithNameContaining:]):
In debug mode, CALayers corresponding to WebCore::GraphicsLayers have
additional debug information prepended to the name set by the
GraphicsLayer API clients (such as UnifiedPDFPlugin). As such, we
introduce a mode where instead of exact layer name searches, we search
that traversed layers contain our target string.
(-[WKWebView _firstLayerWithName:andMatcher:]):
Canonical link: https://commits.webkit.org/306364@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications