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

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.
(WebCore::RenderThemeMac::systemColor): Change how system link colors are cached. Don't store useSystemAppearance link colors in the
ColorCache, since that special bool isn't considered in the cache after the first time.

Source/WebKit:

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.

Source/WebKitLegacy/mac:

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.

Tools:

rdar://problem/41796865

Reviewed by Tim Horton.

* TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm:
(TestWebKitAPI.WebKit.LinkColorWithSystemAppearance): Use new color value.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233670 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm
Source/WebCore/rendering/RenderTheme.h
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
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm

index 7a47ea7..256e705 100644 (file)
@@ -1,3 +1,35 @@
+2018-07-09  Timothy Hatcher  <timothy@apple.com>
+
+        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.
+        (WebCore::RenderThemeMac::systemColor): Change how system link colors are cached. Don't store useSystemAppearance link colors in the
+        ColorCache, since that special bool isn't considered in the cache after the first time.
+
 2018-07-09  Simon Fraser  <simon.fraser@apple.com>
 
         Shrink various loading-related enums to shrink CachedResource
index 6d421ae..5295221 100644 (file)
@@ -520,22 +520,29 @@ void Page::initGroup()
     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,18 +2405,32 @@ void Page::setUseSystemAppearance(bool value)
 {
     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();
     }
 }
 
+void Page::setUseDarkAppearance(bool value)
+{
+    if (m_useDarkAppearance == value)
+        return;
+
+    m_useDarkAppearance = value;
+
+    updateStyleAfterChangeInEnvironment();
+}
+
 bool Page::useDarkAppearance() const
 {
     FrameView* view = mainFrame().view();
index 8711f34..c27bd29 100644 (file)
@@ -168,6 +168,8 @@ public:
     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 @@ public:
     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; }
index 62c5182..1d5f7e1 100644 (file)
 
 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(bool useSystemAppeara
 LocalDefaultSystemAppearance::~LocalDefaultSystemAppearance()
 {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
-    if (--recursionCount)
-        return;
-
     [NSAppearance setCurrentAppearance:m_savedSystemAppearance.get()];
 #endif
 }
index 706d704..f5eb05d 100644 (file)
@@ -404,6 +404,8 @@ protected:
     struct ColorCache {
         HashMap<int, Color> systemStyleColors;
 
+        Color systemLinkColor;
+        Color systemActiveLinkColor;
         Color systemVisitedLinkColor;
 
         Color activeSelectionBackgroundColor;
index 9a7e93c..26da429 100644 (file)
@@ -136,14 +136,19 @@ static const double progressAnimationNumFrames = 256;
     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();
 }
 
@@ -542,31 +547,40 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O
 
     auto& cache = colorCache(options);
 
-    // The system color cache below can't handle visited links. The only color value
-    // that cares about visited links is CSSValueWebkitLink, so handle it here.
-    if (forVisitedLink && cssValueID == CSSValueWebkitLink) {
-        // Only use NSColor when the system appearance is desired, otherwise use RenderTheme's default.
-        if (useSystemAppearance) {
-            if (!cache.systemVisitedLinkColor.isValid())
-                cache.systemVisitedLinkColor = semanticColorFromNSColor([NSColor systemPurpleColor]);
-            return cache.systemVisitedLinkColor;
-        }
+    if (useSystemAppearance) {
+        // Only use NSColor for links when the system appearance is desired.
+        auto systemAppearanceColor = [] (Color& color, SEL selector) -> Color {
+            if (!color.isValid()) {
+                auto systemColor = wtfObjcMsgSend<NSColor *>([NSColor class], selector);
+                color = semanticColorFromNSColor(systemColor);
+            }
 
+            return color;
+        };
+
+        switch (cssValueID) {
+        case CSSValueWebkitLink:
+            if (forVisitedLink)
+                return systemAppearanceColor(cache.systemVisitedLinkColor, @selector(systemPurpleColor));
+            return systemAppearanceColor(cache.systemLinkColor, @selector(linkColor));
+        case CSSValueWebkitActivelink:
+            // FIXME: Use a semantic system color for this, instead of systemRedColor. <rdar://problem/39256684>
+            return systemAppearanceColor(cache.systemActiveLinkColor, @selector(systemRedColor));
+        default:
+            // Handle non-link colors below, with the regular cache.
+            break;
+        }
+    } else if (forVisitedLink && cssValueID == CSSValueWebkitLink) {
+        // The system color cache below can't handle visited links. The only color value
+        // that cares about visited links is CSSValueWebkitLink, so handle it here.
         return RenderTheme::systemColor(cssValueID, options);
     }
 
     ASSERT(!forVisitedLink);
 
-    return cache.systemStyleColors.ensure(cssValueID, [this, cssValueID, useSystemAppearance, options] () -> Color {
-        auto selectCocoaColor = [cssValueID, useSystemAppearance] () -> SEL {
+    return cache.systemStyleColors.ensure(cssValueID, [this, cssValueID, options] () -> Color {
+        auto selectCocoaColor = [cssValueID] () -> SEL {
             switch (cssValueID) {
-            case CSSValueWebkitLink:
-                // Only use NSColor when the system appearance is desired, otherwise use RenderTheme's default.
-                return useSystemAppearance ? @selector(linkColor) : nullptr;
-            case CSSValueWebkitActivelink:
-                // Only use NSColor when the system appearance is desired, otherwise use RenderTheme's default.
-                // FIXME: Use a semantic system color for this, instead of systemRedColor. <rdar://problem/39256684>
-                return useSystemAppearance ? @selector(systemRedColor) : nullptr;
             case CSSValueActiveborder:
                 return @selector(keyboardFocusIndicatorColor);
             case CSSValueActivecaption:
index 3bf58ea..9495af5 100644 (file)
@@ -1,3 +1,31 @@
+2018-07-09  Timothy Hatcher  <timothy@apple.com>
+
+        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-09  Simon Fraser  <simon.fraser@apple.com>
 
         Shrink various loading-related enums to shrink CachedResource
index 76e32c2..024d34c 100644 (file)
@@ -470,11 +470,6 @@ static uint32_t convertSystemLayoutDirection(NSUserInterfaceLayoutDirection dire
     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 @@ static void validate(WKWebViewConfiguration *configuration)
 
     _impl->setAutomaticallyAdjustsContentInsets(true);
     _impl->setRequiresUserActionForEditingControlsManager([configuration _requiresUserActionForEditingControlsManager]);
-    _impl->setUseDarkAppearance(self._effectiveAppearanceIsDark);
 #endif
 
 #if ENABLE(ACCESSIBILITY_EVENTS)
@@ -6305,17 +6299,16 @@ static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISe
 - (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>
     if (!_impl)
         return;
 
-    _impl->setUseDarkAppearance(self._effectiveAppearanceIsDark);
+    _impl->effectiveAppearanceDidChange();
 }
 
 - (void)_setHeaderBannerHeight:(int)height
index e4f60a9..874e43e 100644 (file)
@@ -1622,20 +1622,19 @@ static _WKOverlayScrollbarStyle toAPIScrollbarStyle(std::optional<WebCore::Scrol
     _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
index cf49825..98e27a1 100644 (file)
@@ -538,7 +538,10 @@ public:
     
     void setUseSystemAppearance(bool);
     bool useSystemAppearance();
+
     void setUseDarkAppearance(bool);
+
+    void effectiveAppearanceDidChange();
     bool effectiveAppearanceIsDark();
 
 private:
index 77a0928..16c1982 100644 (file)
@@ -1311,6 +1311,8 @@ WebViewImpl::WebViewImpl(NSView <WebViewImplDelegate> *view, WKWebView *outerWeb
 
     m_page->setAddsVisitedLinks(processPool.historyClient().addsVisitedLinks());
 
+    m_page->setUseDarkAppearance(effectiveAppearanceIsDark());
+
     m_page->initializeWebPage();
 
     registerDraggedTypes();
@@ -5013,6 +5015,11 @@ bool WebViewImpl::useSystemAppearance()
     return m_page->useSystemAppearance();
 }
 
+void WebViewImpl::effectiveAppearanceDidChange()
+{
+    setUseDarkAppearance(effectiveAppearanceIsDark());
+}
+
 bool WebViewImpl::effectiveAppearanceIsDark()
 {
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
index a705cb8..b9c0d3b 100644 (file)
@@ -4208,8 +4208,6 @@ void WebPage::setUseSystemAppearance(bool useSystemAppearance)
 void WebPage::setUseDarkAppearance(bool useDarkAppearance)
 {
     corePage()->setUseDarkAppearance(useDarkAppearance);
-    RenderTheme::singleton().platformColorsDidChange();
-    corePage()->setNeedsRecalcStyleInAllFrames();
 }
 #endif
 
index c41a808..1c55a77 100644 (file)
@@ -1,3 +1,20 @@
+2018-07-09  Timothy Hatcher  <timothy@apple.com>
+
+        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-09  Simon Fraser  <simon.fraser@apple.com>
 
         Shrink various loading-related enums to shrink CachedResource
index 4de4edc..b759a60 100644 (file)
@@ -1537,7 +1537,6 @@ static void WebKitInitializeGamepadProviderIfNecessary()
 
 #if !PLATFORM(IOS)
     [self _registerDraggedTypes];
-    [self _updateDefaultAppearance];
 #endif
 
     [self _setIsVisible:[self _isViewVisible]];
@@ -5285,37 +5284,28 @@ static Vector<String> toStringVector(NSArray* patterns)
 #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
 {
     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>
     if (!_private || !_private->page)
         return;
 
-    [self _updateDefaultAppearance];
+    _private->page->setUseDarkAppearance(self._effectiveAppearanceIsDark);
 }
 
 - (void)_setSourceApplicationAuditData:(NSData *)sourceApplicationAuditData
index ea2de1e..996f857 100644 (file)
@@ -1,3 +1,15 @@
+2018-07-09  Timothy Hatcher  <timothy@apple.com>
+
+        Semantic colors don't update when accessibility Increase Contrast mode is enabled.
+        https://bugs.webkit.org/show_bug.cgi?id=187425
+        rdar://problem/39948240
+        rdar://problem/41796865
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm:
+        (TestWebKitAPI.WebKit.LinkColorWithSystemAppearance): Use new color value.
+
 2018-07-09  Simon Fraser  <simon.fraser@apple.com>
 
         Fix dump-class-layout to show bit padding, and fix issues with padding offsets
index ff914d7..a78e8e0 100644 (file)
@@ -53,7 +53,7 @@ TEST(WebKit, LinkColorWithSystemAppearance)
     [webView synchronouslyLoadHTMLString:@"<a href>Test</a>"];
 
     NSString *linkColor = [webView stringByEvaluatingJavaScript:@"getComputedStyle(document.links[0]).color"];
-    EXPECT_WK_STREQ("rgb(0, 105, 217)", linkColor);
+    EXPECT_WK_STREQ("rgb(0, 104, 218)", linkColor);
 }
 #endif