- Revision
- 233612
- Author
- [email protected]
- Date
- 2018-07-06 20:43:04 -0700 (Fri, 06 Jul 2018)
Log Message
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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (233611 => 233612)
--- trunk/Source/WebCore/ChangeLog 2018-07-07 02:56:20 UTC (rev 233611)
+++ trunk/Source/WebCore/ChangeLog 2018-07-07 03:43:04 UTC (rev 233612)
@@ -1,3 +1,33 @@
+2018-07-06 Timothy Hatcher <[email protected]>
+
+ 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.
+
+ 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.
+
2018-07-06 Ryosuke Niwa <[email protected]>
Make ReasonForSuspension enum class
Modified: trunk/Source/WebCore/page/Page.cpp (233611 => 233612)
--- trunk/Source/WebCore/page/Page.cpp 2018-07-07 02:56:20 UTC (rev 233611)
+++ trunk/Source/WebCore/page/Page.cpp 2018-07-07 03:43:04 UTC (rev 233612)
@@ -520,22 +520,29 @@
m_group = m_singlePageGroup.get();
}
-void Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment()
+void Page::updateStyleAfterChangeInEnvironment()
{
- for (auto* page : allPages()) {
- for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
- // If a change in the global environment has occurred, we need to
- // make sure all the properties a recomputed, therefore we invalidate
- // the properties cache.
- if (!frame->document())
- continue;
- if (StyleResolver* styleResolver = frame->document()->styleScope().resolverIfExists())
- styleResolver->invalidateMatchedPropertiesCache();
- frame->document()->scheduleForcedStyleRecalc();
- }
+ for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
+ // If a change in the global environment has occurred, we need to
+ // make sure all the properties a recomputed, therefore we invalidate
+ // the properties cache.
+ auto* document = frame->document();
+ if (!document)
+ continue;
+
+ if (StyleResolver* styleResolver = document->styleScope().resolverIfExists())
+ styleResolver->invalidateMatchedPropertiesCache();
+ document->scheduleForcedStyleRecalc();
+ document->styleScope().didChangeStyleSheetEnvironment();
}
}
+void Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment()
+{
+ for (auto* page : allPages())
+ page->updateStyleAfterChangeInEnvironment();
+}
+
void Page::setNeedsRecalcStyleInAllFrames()
{
// FIXME: Figure out what this function is actually trying to add in different call sites.
@@ -2398,12 +2405,16 @@
{
if (m_useSystemAppearance == value)
return;
+
m_useSystemAppearance = value;
+ updateStyleAfterChangeInEnvironment();
+
for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
auto* document = frame->document();
if (!document)
continue;
+
// System apperance change may affect stylesheet parsing. We need to reparse.
document->extensionStyleSheets().clearPageUserSheet();
document->extensionStyleSheets().invalidateInjectedStyleSheetCache();
@@ -2410,6 +2421,16 @@
}
}
+void Page::setUseDarkAppearance(bool value)
+{
+ if (m_useDarkAppearance == value)
+ return;
+
+ m_useDarkAppearance = value;
+
+ updateStyleAfterChangeInEnvironment();
+}
+
bool Page::useDarkAppearance() const
{
FrameView* view = mainFrame().view();
Modified: trunk/Source/WebCore/page/Page.h (233611 => 233612)
--- trunk/Source/WebCore/page/Page.h 2018-07-07 02:56:20 UTC (rev 233611)
+++ trunk/Source/WebCore/page/Page.h 2018-07-07 03:43:04 UTC (rev 233612)
@@ -168,6 +168,8 @@
WEBCORE_EXPORT static void updateStyleForAllPagesAfterGlobalChangeInEnvironment();
WEBCORE_EXPORT static void clearPreviousItemFromAllPages(HistoryItem*);
+ void updateStyleAfterChangeInEnvironment();
+
WEBCORE_EXPORT explicit Page(PageConfiguration&&);
WEBCORE_EXPORT ~Page();
@@ -343,7 +345,7 @@
WEBCORE_EXPORT void setUseSystemAppearance(bool);
WEBCORE_EXPORT bool useDarkAppearance() const;
- void setUseDarkAppearance(bool a) { m_useDarkAppearance = a; }
+ WEBCORE_EXPORT void setUseDarkAppearance(bool);
#if ENABLE(TEXT_AUTOSIZING)
float textAutosizingWidth() const { return m_textAutosizingWidth; }
Modified: trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm (233611 => 233612)
--- trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm 2018-07-07 02:56:20 UTC (rev 233611)
+++ trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm 2018-07-07 03:43:04 UTC (rev 233612)
@@ -31,16 +31,9 @@
namespace WebCore {
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
-static size_t recursionCount = 0;
-#endif
-
LocalDefaultSystemAppearance::LocalDefaultSystemAppearance(bool useSystemAppearance, bool useDarkAppearance)
{
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
- if (recursionCount++)
- return;
-
m_savedSystemAppearance = [NSAppearance currentAppearance];
m_usingDarkAppearance = useSystemAppearance && useDarkAppearance;
@@ -54,9 +47,6 @@
LocalDefaultSystemAppearance::~LocalDefaultSystemAppearance()
{
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
- if (--recursionCount)
- return;
-
[NSAppearance setCurrentAppearance:m_savedSystemAppearance.get()];
#endif
}
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (233611 => 233612)
--- trunk/Source/WebCore/rendering/RenderThemeMac.mm 2018-07-07 02:56:20 UTC (rev 233611)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm 2018-07-07 03:43:04 UTC (rev 233612)
@@ -136,14 +136,19 @@
self = [super init];
if (!self)
return nil;
+
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(systemColorsDidChange:) name:NSSystemColorsDidChangeNotification object:nil];
+
+ [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
+ selector:@selector(systemColorsDidChange:) name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification object:nil];
+
return self;
}
-- (void)systemColorsDidChange:(NSNotification *)unusedNotification
+- (void)systemColorsDidChange:(NSNotification *)notification
{
- ASSERT_UNUSED(unusedNotification, [[unusedNotification name] isEqualToString:NSSystemColorsDidChangeNotification]);
+ UNUSED_PARAM(notification);
WebCore::RenderTheme::singleton().platformColorsDidChange();
}
Modified: trunk/Source/WebKit/ChangeLog (233611 => 233612)
--- trunk/Source/WebKit/ChangeLog 2018-07-07 02:56:20 UTC (rev 233611)
+++ trunk/Source/WebKit/ChangeLog 2018-07-07 03:43:04 UTC (rev 233612)
@@ -1,3 +1,31 @@
+2018-07-06 Timothy Hatcher <[email protected]>
+
+ 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.
+
+ * 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.
+
2018-07-06 Chris Dumez <[email protected]>
Add release assertions to try and catch a possible HashMap corruption in NetworkConnectionToWebProcess
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (233611 => 233612)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-07-07 02:56:20 UTC (rev 233611)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-07-07 03:43:04 UTC (rev 233612)
@@ -470,11 +470,6 @@
return static_cast<uint32_t>(WebCore::UserInterfaceLayoutDirection::LTR);
}
-- (bool)_effectiveAppearanceIsDark
-{
- return _impl->effectiveAppearanceIsDark();
-}
-
#endif // PLATFORM(MAC)
static void validate(WKWebViewConfiguration *configuration)
@@ -696,7 +691,6 @@
_impl->setAutomaticallyAdjustsContentInsets(true);
_impl->setRequiresUserActionForEditingControlsManager([configuration _requiresUserActionForEditingControlsManager]);
- _impl->setUseDarkAppearance(self._effectiveAppearanceIsDark);
#endif
#if ENABLE(ACCESSIBILITY_EVENTS)
@@ -6304,10 +6298,9 @@
- (void)_setUseSystemAppearance:(BOOL)useSystemAppearance
{
_impl->setUseSystemAppearance(useSystemAppearance);
- _impl->setUseDarkAppearance(self._effectiveAppearanceIsDark);
}
-- (void)effectiveAppearanceDidChange
+- (void)viewDidChangeEffectiveAppearance
{
// This can be called during [super initWithCoder:] and [super initWithFrame:].
// That is before _impl is ready to be used, so check. <rdar://problem/39611236>
@@ -6314,7 +6307,7 @@
if (!_impl)
return;
- _impl->setUseDarkAppearance(self._effectiveAppearanceIsDark);
+ _impl->effectiveAppearanceDidChange();
}
- (void)_setHeaderBannerHeight:(int)height
Modified: trunk/Source/WebKit/UIProcess/API/mac/WKView.mm (233611 => 233612)
--- trunk/Source/WebKit/UIProcess/API/mac/WKView.mm 2018-07-07 02:56:20 UTC (rev 233611)
+++ trunk/Source/WebKit/UIProcess/API/mac/WKView.mm 2018-07-07 03:43:04 UTC (rev 233612)
@@ -1622,20 +1622,19 @@
_data->_impl->setShouldSuppressFirstResponderChanges(shouldSuppress);
}
-- (bool)_effectiveAppearanceIsDark
+- (void)viewDidChangeEffectiveAppearance
{
- return _data->_impl->effectiveAppearanceIsDark();
-}
+ // This can be called during [super initWithCoder:] and [super initWithFrame:].
+ // That is before _data or _impl is ready to be used, so check. <rdar://problem/39611236>
+ if (!_data || !_data->_impl)
+ return;
-- (void)effectiveAppearanceDidChange
-{
- _data->_impl->setUseDarkAppearance(self._effectiveAppearanceIsDark);
+ _data->_impl->effectiveAppearanceDidChange();
}
- (void)_setUseSystemAppearance:(BOOL)useSystemAppearance
{
_data->_impl->setUseSystemAppearance(useSystemAppearance);
- _data->_impl->setUseDarkAppearance(self._effectiveAppearanceIsDark);
}
- (BOOL)_useSystemAppearance
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (233611 => 233612)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h 2018-07-07 02:56:20 UTC (rev 233611)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h 2018-07-07 03:43:04 UTC (rev 233612)
@@ -538,7 +538,10 @@
void setUseSystemAppearance(bool);
bool useSystemAppearance();
+
void setUseDarkAppearance(bool);
+
+ void effectiveAppearanceDidChange();
bool effectiveAppearanceIsDark();
private:
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (233611 => 233612)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2018-07-07 02:56:20 UTC (rev 233611)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2018-07-07 03:43:04 UTC (rev 233612)
@@ -1311,6 +1311,8 @@
m_page->setAddsVisitedLinks(processPool.historyClient().addsVisitedLinks());
+ m_page->setUseDarkAppearance(effectiveAppearanceIsDark());
+
m_page->initializeWebPage();
registerDraggedTypes();
@@ -5013,6 +5015,11 @@
return m_page->useSystemAppearance();
}
+void WebViewImpl::effectiveAppearanceDidChange()
+{
+ setUseDarkAppearance(effectiveAppearanceIsDark());
+}
+
bool WebViewImpl::effectiveAppearanceIsDark()
{
#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (233611 => 233612)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-07-07 02:56:20 UTC (rev 233611)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-07-07 03:43:04 UTC (rev 233612)
@@ -4208,8 +4208,6 @@
void WebPage::setUseDarkAppearance(bool useDarkAppearance)
{
corePage()->setUseDarkAppearance(useDarkAppearance);
- RenderTheme::singleton().platformColorsDidChange();
- corePage()->setNeedsRecalcStyleInAllFrames();
}
#endif
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (233611 => 233612)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2018-07-07 02:56:20 UTC (rev 233611)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2018-07-07 03:43:04 UTC (rev 233612)
@@ -1,3 +1,20 @@
+2018-07-06 Timothy Hatcher <[email protected]>
+
+ 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.
+
+ * 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.
+
2018-07-05 Timothy Hatcher <[email protected]>
Rename and flip the meaning of defaultAppearance to be useDarkAppearance.
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (233611 => 233612)
--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2018-07-07 02:56:20 UTC (rev 233611)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2018-07-07 03:43:04 UTC (rev 233612)
@@ -1537,7 +1537,6 @@
#if !PLATFORM(IOS)
[self _registerDraggedTypes];
- [self _updateDefaultAppearance];
#endif
[self _setIsVisible:[self _isViewVisible]];
@@ -5285,19 +5284,10 @@
#endif
}
-- (void)_updateDefaultAppearance
-{
- _private->page->setUseDarkAppearance(self._effectiveAppearanceIsDark);
- RenderTheme::singleton().platformColorsDidChange();
- _private->page->setNeedsRecalcStyleInAllFrames();
-}
-
- (void)_setUseSystemAppearance:(BOOL)useSystemAppearance
{
- if (auto page = _private->page) {
- page->setUseSystemAppearance(useSystemAppearance);
- [self _updateDefaultAppearance];
- }
+ if (_private && _private->page)
+ _private->page->setUseSystemAppearance(useSystemAppearance);
}
- (BOOL)_useSystemAppearance
@@ -5304,11 +5294,11 @@
{
if (!_private->page)
return NO;
-
+
return _private->page->useSystemAppearance();
}
-- (void)effectiveAppearanceDidChange
+- (void)viewDidChangeEffectiveAppearance
{
// This can be called during [super initWithCoder:] and [super initWithFrame:].
// That is before _private is ready to be used, so check. <rdar://problem/39611236>
@@ -5315,7 +5305,7 @@
if (!_private || !_private->page)
return;
- [self _updateDefaultAppearance];
+ _private->page->setUseDarkAppearance(self._effectiveAppearanceIsDark);
}
- (void)_setSourceApplicationAuditData:(NSData *)sourceApplicationAuditData