Semantic colors don't update when accessibility Increase Contrast mode is enabled.
[WebKit-https.git] / Source / WebKit / UIProcess / API / mac / WKView.mm
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