[webkit-changes] [WebKit/WebKit] 9d7ff3: `-[WKWebView _setUseSystemAppearance:]` should be ...

Aditya Keerthi noreply at github.com
Tue Dec 24 09:02:57 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9d7ff33e65082e3f29db29ff90fdfc782b6f86ed
      https://github.com/WebKit/WebKit/commit/9d7ff33e65082e3f29db29ff90fdfc782b6f86ed
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2024-12-24 (Tue, 24 Dec 2024)

  Changed paths:
    M LayoutTests/fast/css/mac/focus-ring-color-should-not-expose-accent-color-expected-mismatch.html
    M LayoutTests/fast/css/mac/focus-ring-color-should-not-expose-accent-color.html
    R LayoutTests/fast/media/use-system-appearance-user-stylesheet-parsing-expected.txt
    R LayoutTests/fast/media/use-system-appearance-user-stylesheet-parsing.html
    M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
    M Source/WebCore/css/parser/CSSParserContext.cpp
    M Source/WebCore/css/query/MediaQueryFeatures.cpp
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    M Source/WebCore/page/SettingsBase.cpp
    M Source/WebCore/page/SettingsBase.h
    M Source/WebCore/rendering/TextPaintStyle.cpp
    M Source/WebCore/testing/Internals.cpp
    M Source/WebCore/testing/Internals.h
    M Source/WebCore/testing/Internals.idl
    M Source/WebKit/Shared/WebPageCreationParameters.h
    M Source/WebKit/Shared/WebPageCreationParameters.serialization.in
    M Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKPreferencesInternal.h
    M Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/mac/WebViewImpl.h
    M Source/WebKit/UIProcess/mac/WebViewImpl.mm
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
    M Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h
    M Source/WebKitLegacy/mac/WebView/WebPreferences.mm
    M Source/WebKitLegacy/mac/WebView/WebPreferencesInternal.h
    M Source/WebKitLegacy/mac/WebView/WebView.mm
    M Tools/TestWebKitAPI/SourcesCocoa.txt
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/RenderedImageWithOptions.mm
    A Tools/TestWebKitAPI/Tests/WebKitCocoa/UseSystemAppearance.mm

  Log Message:
  -----------
  `-[WKWebView _setUseSystemAppearance:]` should be backed by a UnifiedWebPreference
https://bugs.webkit.org/show_bug.cgi?id=285108
rdar://141954151

Reviewed by Abrar Rahman Protyasha.

UnifiedWebPreferences have been the way to implement settings for quite a while
now. `Page::useSystemAppearance` is effectively a setting, but it is backed by a
lot of custom code, including state in both the UI process and Web process, as
well as `WebPageCreationParameters`.

Refactor code to use a UnifiedWebPreference to implement
`-[WKWebView _setUseSystemAppearance:]`.

* LayoutTests/fast/css/mac/focus-ring-color-should-not-expose-accent-color-expected-mismatch.html:

Use the test option header to set the new setting. "runSingly" is no longer needed
since the mismatch in options will ensure a new webview is created.

* LayoutTests/fast/css/mac/focus-ring-color-should-not-expose-accent-color.html:
* LayoutTests/fast/media/use-system-appearance-user-stylesheet-parsing-expected.txt: Removed.
* LayoutTests/fast/media/use-system-appearance-user-stylesheet-parsing.html: Removed.

Rewrite this test as an API test. The Internals hook to set `UseSystemAppearance` is
removed in favor of end-to-end testing via an API test.

* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/css/parser/CSSParserContext.cpp:
* Source/WebCore/css/query/MediaQueryFeatures.cpp:
(WebCore::MQ::Features::prefersDarkInterfaceFeatureSchema):
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::useDarkAppearance const):
(WebCore::Document::styleColorOptions const):
(WebCore::Document::useSystemAppearance const): Deleted.
* Source/WebCore/dom/Document.h:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::useSystemAppearanceChanged):

Preserve hook to be called when the setting changes.

(WebCore::Page::setUseSystemAppearance): Deleted.
* Source/WebCore/page/Page.h:
(WebCore::Page::useSystemAppearance const): Deleted.
* Source/WebCore/page/SettingsBase.cpp:
(WebCore::SettingsBase::useSystemAppearanceChanged):

Ensure necessary steps continue to be run whenever the setting is changed.

* Source/WebCore/page/SettingsBase.h:
* Source/WebCore/rendering/TextPaintStyle.cpp:
(WebCore::computeTextPaintStyle):
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::setUseSystemAppearance): Deleted.

Deleted in favor of end-to-end testing via the API.

* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:
* Source/WebKit/Shared/WebPageCreationParameters.h:
* Source/WebKit/Shared/WebPageCreationParameters.serialization.in:
* Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _useSystemAppearance]):
(-[WKPreferences _setUseSystemAppearance:]):
* Source/WebKit/UIProcess/API/Cocoa/WKPreferencesInternal.h:

`-[WKWebView _setUseSystemAppearance:]` should always have been a
configuration/preferences property. However, it is too late to change the API
shape now. Instead, as part of this refactor, implement the API as a real
(internal) preference.

* Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm:
(-[WKWebView _useSystemAppearance]):
(-[WKWebView _setUseSystemAppearance:]):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
(WebKit::WebPageProxy::setUseSystemAppearance): Deleted.
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/mac/WebViewImpl.h:
* Source/WebKit/UIProcess/mac/WebViewImpl.mm:
(WebKit::WebViewImpl::setUseSystemAppearance): Deleted.
(WebKit::WebViewImpl::useSystemAppearance): Deleted.
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::setUseSystemAppearance): Deleted.
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
* Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h:
* Source/WebKitLegacy/mac/WebView/WebPreferences.mm:
(-[WebPreferences _useSystemAppearance]):
(-[WebPreferences _setUseSystemAppearance:]):
* Source/WebKitLegacy/mac/WebView/WebPreferencesInternal.h:
* Source/WebKitLegacy/mac/WebView/WebView.mm:
(-[WebView _setUseSystemAppearance:]):
(-[WebView _useSystemAppearance]):
* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm:

Unified sources build fixes.

(-[_WKTargetedElementInfo takeSnapshot]):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/RenderedImageWithOptions.mm:

Unified sources build fixes.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/UseSystemAppearance.mm: Added.

Rewrite "fast/media/use-system-appearance-user-stylesheet-parsing.html" as an API
test. This provides end-to-end test coverage of the existing API for both WebKit
and WebKitLegacy.

(-[UserStyleSheetParsingWebKitLegacyTest webView:didFinishLoadForFrame:]):
(-[UserStyleSheetParsingWebKitLegacyTest waitForLoadToFinish]):
(TEST(UseSystemAppearance, UserStyleSheetParsing)):
(TEST(UseSystemAppearance, UserStyleSheetParsingWebKitLegacy)):

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list