Flash when tapping compose button after switching to/from dark mode without restartin...
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Jun 2019 00:44:40 +0000 (00:44 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Jun 2019 00:44:40 +0000 (00:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198769
rdar://problem/51370037

Reviewed by Tim Horton.

Source/WebCore:

* WebCore.xcodeproj/project.pbxproj: Make LocalCurrentTraitCollection.h a private header.

Source/WebKit:

Accessing a dynamic color outside a normal UIView choke point without setting
UITraitCollection.currentTraitCollection first can cause undefined results.
Use LocalCurrentTraitCollection inside scrollViewBackgroundColor when accessing
the dynamic system UIColors. Also use systemBackgroundColor instead of white.

* UIProcess/API/Cocoa/WKWebView.mm:
(scrollViewBackgroundColor):

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

index 30759fa..f51216e 100644 (file)
@@ -1,3 +1,13 @@
+2019-06-11  Timothy Hatcher  <timothy@apple.com>
+
+        Flash when tapping compose button after switching to/from dark mode without restarting Mail.
+        https://bugs.webkit.org/show_bug.cgi?id=198769
+        rdar://problem/51370037
+
+        Reviewed by Tim Horton.
+
+        * WebCore.xcodeproj/project.pbxproj: Make LocalCurrentTraitCollection.h a private header.
+
 2019-06-11  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r246320.
index 8f7d3ca..b65799a 100644 (file)
                1C21E57D183ED1FF001C289D /* IOSurfacePool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C21E57B183ED1FF001C289D /* IOSurfacePool.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1C24EEA51C729CE40080F8FC /* FontFaceSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C24EEA31C729CE40080F8FC /* FontFaceSet.h */; };
                1C24EEA91C72A7B40080F8FC /* JSFontFaceSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C24EEA71C72A7B40080F8FC /* JSFontFaceSet.h */; };
-               1C43DE6B22AB4B8A001527D9 /* LocalCurrentTraitCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C43DE6822AB4B8A001527D9 /* LocalCurrentTraitCollection.h */; };
+               1C43DE6B22AB4B8A001527D9 /* LocalCurrentTraitCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C43DE6822AB4B8A001527D9 /* LocalCurrentTraitCollection.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1C6626111C6E7CA600AB527C /* FontFace.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C66260F1C6E7CA600AB527C /* FontFace.h */; };
                1C73A7132185757E004CCEA5 /* TextUnderlineOffset.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB6B4FB217B83940093B9CD /* TextUnderlineOffset.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1C73A71521857587004CCEA5 /* TextDecorationThickness.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB6B4F8217B83930093B9CD /* TextDecorationThickness.h */; settings = {ATTRIBUTES = (Private, ); }; };
index 71fc14c..8e461f9 100644 (file)
@@ -1,3 +1,19 @@
+2019-06-11  Timothy Hatcher  <timothy@apple.com>
+
+        Flash when tapping compose button after switching to/from dark mode without restarting Mail.
+        https://bugs.webkit.org/show_bug.cgi?id=198769
+        rdar://problem/51370037
+
+        Reviewed by Tim Horton.
+
+        Accessing a dynamic color outside a normal UIView choke point without setting
+        UITraitCollection.currentTraitCollection first can cause undefined results.
+        Use LocalCurrentTraitCollection inside scrollViewBackgroundColor when accessing
+        the dynamic system UIColors. Also use systemBackgroundColor instead of white.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (scrollViewBackgroundColor):
+
 2019-06-11  Megan Gardner  <megan_gardner@apple.com>
 
         Integrate scrollbar gestures for iOS
index 3b0fe3b..d11b57a 100644 (file)
 #import <UIKit/UIApplication.h>
 #import <WebCore/FrameLoaderTypes.h>
 #import <WebCore/InspectorOverlay.h>
+#import <WebCore/LocalCurrentTraitCollection.h>
 #import <WebCore/ScrollableArea.h>
 #import <WebCore/WebBackgroundTaskController.h>
 #import <WebCore/WebSQLiteDatabaseTrackerClient.h>
@@ -1702,10 +1703,22 @@ static WebCore::Color scrollViewBackgroundColor(WKWebView *webView)
     if (!webView.opaque)
         return WebCore::Color::transparent;
 
+#if HAVE(OS_DARK_MODE_SUPPORT)
+    WebCore::LocalCurrentTraitCollection localTraitCollection(webView.traitCollection);
+#endif
+
     WebCore::Color color = baseScrollViewBackgroundColor(webView);
 
-    if (!color.isValid())
-        color = webView->_contentView ? [webView->_contentView backgroundColor].CGColor : UIColor.whiteColor.CGColor;
+    if (!color.isValid() && webView->_contentView)
+        color = [webView->_contentView backgroundColor].CGColor;
+
+    if (!color.isValid()) {
+#if HAVE(OS_DARK_MODE_SUPPORT)
+        color = UIColor.systemBackgroundColor.CGColor;
+#else
+        color = WebCore::Color::white;
+#endif
+    }
 
     CGFloat zoomScale = contentZoomScale(webView);
     CGFloat minimumZoomScale = [webView->_scrollView minimumZoomScale];