Semantic colors don't update when accessibility Increase Contrast mode is enabled.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Jul 2018 03:43:04 +0000 (03:43 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Jul 2018 03:43:04 +0000 (03:43 +0000)
commit5f32e9ea3be7b993a4cf0b6c034a6715bb7afb0a
treea21b4d2186cc373132c9076acc042bfd490d9d72
parent381d12dbf1601b08e7cc5427c67426d9c825f8ec
Semantic colors don't update when accessibility Increase Contrast mode is enabled.
https://bugs.webkit.org/show_bug.cgi?id=187425
rdar://problem/39948240

Reviewed by Tim Horton.

Source/WebCore:

Added a listener for the accessibility change notification to invalidate our color caches.

Removed calls to RenderTheme::singleton().platformColorsDidChange() in Page, since that
ended up calling Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment multiple times.
Instead, changed the functions to use the new instance version instead.

* page/Page.cpp:
(WebCore::Page::updateStyleAfterChangeInEnvironment): Added. Gives Page a direct way to do this work
per instance instead of on all pages (since appearance can be difference per view).
(WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment): Call updateStyleAfterChangeInEnvironment.
(WebCore::Page::setUseSystemAppearance): Call updateStyleAfterChangeInEnvironment.
(WebCore::Page::setUseDarkAppearance): Added. Call updateStyleAfterChangeInEnvironment.
* page/Page.h:
(WebCore::Page::setUseDarkAppearance): Moved to the implementation file.
* platform/mac/LocalDefaultSystemAppearance.mm:
(WebCore::LocalDefaultSystemAppearance::LocalDefaultSystemAppearance): Removed recursive check since it was interfering
with the setting of m_usingDarkAppearance and causing the wrong color cache to be used.
(WebCore::LocalDefaultSystemAppearance::~LocalDefaultSystemAppearance): Ditto.
* rendering/RenderThemeMac.mm:
(-[WebCoreRenderThemeNotificationObserver init]): Listen for NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification.
(-[WebCoreRenderThemeNotificationObserver systemColorsDidChange:]): Removed assert since multiple notifications are used now.

Source/WebKit:

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]): Moved call to setUseDarkAppearance to WebViewImpl.
(-[WKWebView _setUseSystemAppearance:]): No need to call setUseDarkAppearance here anymore.
(-[WKWebView viewDidChangeEffectiveAppearance]): Added. This is the proper NSView method to use.
(-[WKWebView _effectiveAppearanceIsDark]): Deleted.
(-[WKWebView effectiveAppearanceDidChange]): Deleted. This method is a deprecated name.
* UIProcess/API/mac/WKView.mm:
(-[WKView viewDidChangeEffectiveAppearance]): Added. This is the proper NSView method to use.
(-[WKView _setUseSystemAppearance:]): No need to call setUseDarkAppearance here anymore.
(-[WKView _effectiveAppearanceIsDark]): Deleted.
(-[WKView effectiveAppearanceDidChange]): Deleted. This method is a deprecated name.
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::WebViewImpl): Call setUseDarkAppearance before page config is sent in initializeWebPage.
(WebKit::WebViewImpl::effectiveAppearanceDidChange): Added.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setUseDarkAppearance): WebCore::Page::setUseDarkAppearance now handles the style changes.
The RenderTheme color caches also don't need cleared with platformColorsDidChange(), since we cache light
and dark colors seperatly in RenderThemeMac.

Source/WebKitLegacy/mac:

* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]): Removed call to
_updateDefaultAppearance, which called setUseDarkAppearance. There is already
a call in this method to setUseDarkAppearance.
(-[WebView _setUseSystemAppearance:]): Just call the page, not setUseDarkAppearance.
(-[WebView viewDidChangeEffectiveAppearance]): Added. This is the proper NSView method to use.
(-[WebView _updateDefaultAppearance]): Deleted.
(-[WebView effectiveAppearanceDidChange]): Deleted. This method is a deprecated name.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233612 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/mac/WKView.mm
Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebView.mm