Title: [275894] trunk
- Revision
- 275894
- Author
- drou...@apple.com
- Date
- 2021-04-13 10:52:31 -0700 (Tue, 13 Apr 2021)
Log Message
[iOS] Only use the theme color if it's valid when `UseThemeColorForScrollAreaBackgroundColor` is enabled
https://bugs.webkit.org/show_bug.cgi?id=224455
Reviewed by Wenson Hsieh.
Source/WebKit:
Without a check for `isValid()`, the `m_themeColor` would always be used, even if not set.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::scrollAreaBackgroundColor const):
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/HTMLMetaThemeColor.mm:
(createWebView): Added.
(TEST.HTMLMetaThemeColor.ExperimentalUseThemeColorForScrollAreaBackgroundColor): Added.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (275893 => 275894)
--- trunk/Source/WebKit/ChangeLog 2021-04-13 17:42:34 UTC (rev 275893)
+++ trunk/Source/WebKit/ChangeLog 2021-04-13 17:52:31 UTC (rev 275894)
@@ -1,3 +1,15 @@
+2021-04-13 Devin Rousso <drou...@apple.com>
+
+ [iOS] Only use the theme color if it's valid when `UseThemeColorForScrollAreaBackgroundColor` is enabled
+ https://bugs.webkit.org/show_bug.cgi?id=224455
+
+ Reviewed by Wenson Hsieh.
+
+ Without a check for `isValid()`, the `m_themeColor` would always be used, even if not set.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::scrollAreaBackgroundColor const):
+
2021-04-13 Chris Dumez <cdu...@apple.com>
Fix typo in GPUProcessConnection::enableVP9Decoders()
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (275893 => 275894)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-04-13 17:42:34 UTC (rev 275893)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-04-13 17:52:31 UTC (rev 275894)
@@ -1912,7 +1912,7 @@
Color WebPageProxy::scrollAreaBackgroundColor() const
{
- if (m_preferences->useThemeColorForScrollAreaBackgroundColor())
+ if (m_preferences->useThemeColorForScrollAreaBackgroundColor() && m_themeColor.isValid())
return m_themeColor;
return m_pageExtendedBackgroundColor;
Modified: trunk/Tools/ChangeLog (275893 => 275894)
--- trunk/Tools/ChangeLog 2021-04-13 17:42:34 UTC (rev 275893)
+++ trunk/Tools/ChangeLog 2021-04-13 17:52:31 UTC (rev 275894)
@@ -1,3 +1,14 @@
+2021-04-13 Devin Rousso <drou...@apple.com>
+
+ [iOS] Only use the theme color if it's valid when `UseThemeColorForScrollAreaBackgroundColor` is enabled
+ https://bugs.webkit.org/show_bug.cgi?id=224455
+
+ Reviewed by Wenson Hsieh.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/HTMLMetaThemeColor.mm:
+ (createWebView): Added.
+ (TEST.HTMLMetaThemeColor.ExperimentalUseThemeColorForScrollAreaBackgroundColor): Added.
+
2021-04-12 Simon Fraser <simon.fra...@apple.com>
REGRESSION (r275792): [ iOS wk2 ] TestWebKitAPI.IndexedDB.DatabaseProcessKill is a flakey timeout
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/HTMLMetaThemeColor.mm (275893 => 275894)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/HTMLMetaThemeColor.mm 2021-04-13 17:42:34 UTC (rev 275893)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/HTMLMetaThemeColor.mm 2021-04-13 17:52:31 UTC (rev 275894)
@@ -28,7 +28,9 @@
#import "CocoaColor.h"
#import "TestCocoa.h"
#import "TestWKWebView.h"
+#import <WebKit/WKPreferencesPrivate.h>
#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/_WKInternalDebugFeature.h>
#import <wtf/RetainPtr.h>
#define EXPECT_NSSTRING_EQ(expected, actual) \
@@ -167,3 +169,52 @@
EXPECT_NSSTRING_EQ("after-node-removed", [themeColorObserver state]);
EXPECT_TRUE(![webView _themeColor]);
}
+
+#if PLATFORM(IOS_FAMILY)
+
+// There's no API/SPI to get the background color of the scroll area on macOS.
+
+enum class UseThemeColorForScrollAreaBackgroundColor : bool { Yes, No };
+static RetainPtr<TestWKWebView> createWebView(UseThemeColorForScrollAreaBackgroundColor useThemeColorForScrollAreaBackgroundColor)
+{
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ for (_WKInternalDebugFeature *feature in [WKPreferences _internalDebugFeatures]) {
+ if ([feature.key isEqualToString:@"UseThemeColorForScrollAreaBackgroundColor"]) {
+ [[configuration preferences] _setEnabled:(useThemeColorForScrollAreaBackgroundColor == UseThemeColorForScrollAreaBackgroundColor::Yes) forInternalDebugFeature:feature];
+ break;
+ }
+ }
+
+ return adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration.get()]);
+}
+
+TEST(HTMLMetaThemeColor, ExperimentalUseThemeColorForScrollAreaBackgroundColor)
+{
+ auto sRGBColorSpace = adoptCF(CGColorSpaceCreateWithName(kCGColorSpaceSRGB));
+ auto redColor = adoptCF(CGColorCreate(sRGBColorSpace.get(), redColorComponents));
+ auto blueColor = adoptCF(CGColorCreate(sRGBColorSpace.get(), blueColorComponents));
+
+ auto webViewWithoutThemeColorForScrollAreaBackgroundColor = createWebView(UseThemeColorForScrollAreaBackgroundColor::No);
+ EXPECT_TRUE(![webViewWithoutThemeColorForScrollAreaBackgroundColor _themeColor]);
+
+ [webViewWithoutThemeColorForScrollAreaBackgroundColor synchronouslyLoadHTMLStringAndWaitUntilAllImmediateChildFramesPaint:@"<body style='background-color: blue'>"];
+ EXPECT_TRUE(![webViewWithoutThemeColorForScrollAreaBackgroundColor _themeColor]);
+ EXPECT_TRUE(CGColorEqualToColor([webViewWithoutThemeColorForScrollAreaBackgroundColor scrollView].backgroundColor.CGColor, blueColor.get()));
+
+ [webViewWithoutThemeColorForScrollAreaBackgroundColor synchronouslyLoadHTMLStringAndWaitUntilAllImmediateChildFramesPaint:@"<meta name='theme-color' content='red'><body style='background-color: blue'>"];
+ EXPECT_TRUE(CGColorEqualToColor([webViewWithoutThemeColorForScrollAreaBackgroundColor _themeColor].CGColor, redColor.get()));
+ EXPECT_TRUE(CGColorEqualToColor([webViewWithoutThemeColorForScrollAreaBackgroundColor scrollView].backgroundColor.CGColor, blueColor.get()));
+
+ auto webViewWithThemeColorForScrollAreaBackgroundColor = createWebView(UseThemeColorForScrollAreaBackgroundColor::Yes);
+ EXPECT_TRUE(![webViewWithThemeColorForScrollAreaBackgroundColor _themeColor]);
+
+ [webViewWithThemeColorForScrollAreaBackgroundColor synchronouslyLoadHTMLStringAndWaitUntilAllImmediateChildFramesPaint:@"<body style='background-color: blue'>"];
+ EXPECT_TRUE(![webViewWithThemeColorForScrollAreaBackgroundColor _themeColor]);
+ EXPECT_TRUE(CGColorEqualToColor([webViewWithThemeColorForScrollAreaBackgroundColor scrollView].backgroundColor.CGColor, blueColor.get()));
+
+ [webViewWithThemeColorForScrollAreaBackgroundColor synchronouslyLoadHTMLStringAndWaitUntilAllImmediateChildFramesPaint:@"<meta name='theme-color' content='red'><body style='background-color: blue'>"];
+ EXPECT_TRUE(CGColorEqualToColor([webViewWithThemeColorForScrollAreaBackgroundColor _themeColor].CGColor, redColor.get()));
+ EXPECT_TRUE(CGColorEqualToColor([webViewWithThemeColorForScrollAreaBackgroundColor scrollView].backgroundColor.CGColor, redColor.get()));
+}
+
+#endif // PLATFORM(IOS_FAMILY)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes