Title: [233828] trunk
Revision
233828
Author
timo...@apple.com
Date
2018-07-13 17:03:49 -0700 (Fri, 13 Jul 2018)

Log Message

Add _drawsBackground to WKWebViewConfiguration.
https://bugs.webkit.org/show_bug.cgi?id=187665
rdar://problem/42182268

Reviewed by Tim Horton.

Source/WebKit:

* UIProcess/API/APIPageConfiguration.cpp:
(API::PageConfiguration::copy const): Copy m_drawsBackground, and some missing values.
* UIProcess/API/APIPageConfiguration.h:
(API::PageConfiguration::drawsBackground const): Added.
(API::PageConfiguration::setDrawsBackground): Added.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]): Transfer _drawsBackground to page config.
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]): Set _drawsBackground to YES.
(-[WKWebViewConfiguration encodeWithCoder:]): Encode _drawsBackground.
(-[WKWebViewConfiguration initWithCoder:]): Decode _drawsBackground.
(-[WKWebViewConfiguration copyWithZone:]): Copy _drawsBackground.
(-[WKWebViewConfiguration _drawsBackground]): Added.
(-[WKWebViewConfiguration _setDrawsBackground:]): Added.
* UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
* UIProcess/WebPageProxy.cpp: Set m_drawsBackground based on configuration.

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/Configuration.mm:
(TestWebKitAPI.WebKit.ConfigurationDrawsBackground): Added.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (233827 => 233828)


--- trunk/Source/WebKit/ChangeLog	2018-07-13 23:20:53 UTC (rev 233827)
+++ trunk/Source/WebKit/ChangeLog	2018-07-14 00:03:49 UTC (rev 233828)
@@ -1,3 +1,28 @@
+2018-07-13  Timothy Hatcher  <timo...@apple.com>
+
+        Add _drawsBackground to WKWebViewConfiguration.
+        https://bugs.webkit.org/show_bug.cgi?id=187665
+        rdar://problem/42182268
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/API/APIPageConfiguration.cpp:
+        (API::PageConfiguration::copy const): Copy m_drawsBackground, and some missing values.
+        * UIProcess/API/APIPageConfiguration.h:
+        (API::PageConfiguration::drawsBackground const): Added.
+        (API::PageConfiguration::setDrawsBackground): Added.
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _initializeWithConfiguration:]): Transfer _drawsBackground to page config.
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration init]): Set _drawsBackground to YES.
+        (-[WKWebViewConfiguration encodeWithCoder:]): Encode _drawsBackground.
+        (-[WKWebViewConfiguration initWithCoder:]): Decode _drawsBackground.
+        (-[WKWebViewConfiguration copyWithZone:]): Copy _drawsBackground.
+        (-[WKWebViewConfiguration _drawsBackground]): Added.
+        (-[WKWebViewConfiguration _setDrawsBackground:]): Added.
+        * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+        * UIProcess/WebPageProxy.cpp: Set m_drawsBackground based on configuration.
+
 2018-07-13  Tim Horton  <timothy_hor...@apple.com>
 
         WebKit sometimes holds WiFi/BT assertions while the Networking process is suspended

Modified: trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp (233827 => 233828)


--- trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp	2018-07-13 23:20:53 UTC (rev 233827)
+++ trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp	2018-07-14 00:03:49 UTC (rev 233828)
@@ -73,8 +73,10 @@
     copy->m_alwaysRunsAtForegroundPriority = this->m_alwaysRunsAtForegroundPriority;
 #endif
     copy->m_initialCapitalizationEnabled = this->m_initialCapitalizationEnabled;
+    copy->m_waitsForPaintAfterViewDidMoveToWindow = this->m_waitsForPaintAfterViewDidMoveToWindow;
+    copy->m_drawsBackground = this->m_drawsBackground;
+    copy->m_controlledByAutomation = this->m_controlledByAutomation;
     copy->m_cpuLimit = this->m_cpuLimit;
-    copy->m_controlledByAutomation = this->m_controlledByAutomation;
     copy->m_overrideContentSecurityPolicy = this->m_overrideContentSecurityPolicy;
 #if ENABLE(APPLICATION_MANIFEST)
     copy->m_applicationManifest = this->m_applicationManifest;

Modified: trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h (233827 => 233828)


--- trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h	2018-07-13 23:20:53 UTC (rev 233827)
+++ trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h	2018-07-14 00:03:49 UTC (rev 233828)
@@ -101,6 +101,9 @@
     bool waitsForPaintAfterViewDidMoveToWindow() const { return m_waitsForPaintAfterViewDidMoveToWindow; }
     void setWaitsForPaintAfterViewDidMoveToWindow(bool shouldSynchronize) { m_waitsForPaintAfterViewDidMoveToWindow = shouldSynchronize; }
 
+    bool drawsBackground() const { return m_drawsBackground; }
+    void setDrawsBackground(bool drawsBackground) { m_drawsBackground = drawsBackground; }
+
     bool isControlledByAutomation() const { return m_controlledByAutomation; }
     void setControlledByAutomation(bool controlledByAutomation) { m_controlledByAutomation = controlledByAutomation; }
 
@@ -133,6 +136,7 @@
 #endif
     bool m_initialCapitalizationEnabled = true;
     bool m_waitsForPaintAfterViewDidMoveToWindow = true;
+    bool m_drawsBackground = true;
     bool m_controlledByAutomation = false;
     std::optional<double> m_cpuLimit;
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (233827 => 233828)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-07-13 23:20:53 UTC (rev 233827)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-07-14 00:03:49 UTC (rev 233828)
@@ -554,6 +554,7 @@
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::allowUniversalAccessFromFileURLsKey(), WebKit::WebPreferencesStore::Value(!![_configuration _allowUniversalAccessFromFileURLs]));
     pageConfiguration->setInitialCapitalizationEnabled([_configuration _initialCapitalizationEnabled]);
     pageConfiguration->setWaitsForPaintAfterViewDidMoveToWindow([_configuration _waitsForPaintAfterViewDidMoveToWindow]);
+    pageConfiguration->setDrawsBackground([_configuration _drawsBackground]);
     pageConfiguration->setControlledByAutomation([_configuration _isControlledByAutomation]);
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::incompleteImageBorderEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _incompleteImageBorderEnabled]));
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (233827 => 233828)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2018-07-13 23:20:53 UTC (rev 233827)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2018-07-14 00:03:49 UTC (rev 233828)
@@ -164,6 +164,7 @@
     BOOL _allowMediaContentTypesRequiringHardwareSupportAsFallback;
     BOOL _colorFilterEnabled;
     BOOL _incompleteImageBorderEnabled;
+    BOOL _drawsBackground;
 
     RetainPtr<NSString> _overrideContentSecurityPolicy;
     RetainPtr<NSString> _mediaContentTypesRequiringHardwareSupport;
@@ -249,6 +250,7 @@
 
     _colorFilterEnabled = NO;
     _incompleteImageBorderEnabled = NO;
+    _drawsBackground = YES;
 
     return self;
 }
@@ -263,8 +265,6 @@
     return YES;
 }
 
-// FIXME: Encode the process pool, user content controller and website data store.
-
 - (void)encodeWithCoder:(NSCoder *)coder
 {
     [coder encodeObject:self.processPool forKey:@"processPool"];
@@ -276,6 +276,8 @@
     [coder encodeObject:self.applicationNameForUserAgent forKey:@"applicationNameForUserAgent"];
     [coder encodeBool:self.allowsAirPlayForMediaPlayback forKey:@"allowsAirPlayForMediaPlayback"];
 
+    [coder encodeBool:self._drawsBackground forKey:@"drawsBackground"];
+
 #if PLATFORM(IOS)
     [coder encodeInteger:self.dataDetectorTypes forKey:@"dataDetectorTypes"];
     [coder encodeBool:self.allowsInlineMediaPlayback forKey:@"allowsInlineMediaPlayback"];
@@ -307,6 +309,9 @@
     self.applicationNameForUserAgent = decodeObjectOfClassForKeyFromCoder([NSString class], @"applicationNameForUserAgent", coder);
     self.allowsAirPlayForMediaPlayback = [coder decodeBoolForKey:@"allowsAirPlayForMediaPlayback"];
 
+    if ([coder containsValueForKey:@"drawsBackground"])
+        self._drawsBackground = [coder decodeBoolForKey:@"drawsBackground"];
+
 #if PLATFORM(IOS)
     self.dataDetectorTypes = [coder decodeIntegerForKey:@"dataDetectorTypes"];
     self.allowsInlineMediaPlayback = [coder decodeBoolForKey:@"allowsInlineMediaPlayback"];
@@ -409,6 +414,7 @@
     configuration->_groupIdentifier = adoptNS([self->_groupIdentifier copyWithZone:zone]);
     configuration->_colorFilterEnabled = self->_colorFilterEnabled;
     configuration->_incompleteImageBorderEnabled = self->_incompleteImageBorderEnabled;
+    configuration->_drawsBackground = self->_drawsBackground;
 
     return configuration;
 }
@@ -778,6 +784,16 @@
     _incompleteImageBorderEnabled = incompleteImageBorderEnabled;
 }
 
+- (BOOL)_drawsBackground
+{
+    return _drawsBackground;
+}
+
+- (void)_setDrawsBackground:(BOOL)drawsBackground
+{
+    _drawsBackground = drawsBackground;
+}
+
 - (BOOL)_requiresUserActionForVideoPlayback
 {
     return self.mediaTypesRequiringUserActionForPlayback & WKAudiovisualMediaTypeVideo;

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (233827 => 233828)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2018-07-13 23:20:53 UTC (rev 233827)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2018-07-14 00:03:49 UTC (rev 233828)
@@ -72,6 +72,7 @@
 @property (nonatomic, setter=_setApplicationManifest:) _WKApplicationManifest *_applicationManifest WK_API_AVAILABLE(macosx(10.13.4), ios(11.3));
 @property (nonatomic, setter=_setColorFilterEnabled:) BOOL _colorFilterEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, setter=_setIncompleteImageBorderEnabled:) BOOL _incompleteImageBorderEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setDrawsBackground:) BOOL _drawsBackground WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 #if TARGET_OS_IPHONE
 @property (nonatomic, setter=_setAlwaysRunsAtForegroundPriority:) BOOL _alwaysRunsAtForegroundPriority WK_API_AVAILABLE(ios(9_0));

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (233827 => 233828)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-07-13 23:20:53 UTC (rev 233827)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-07-14 00:03:49 UTC (rev 233828)
@@ -405,6 +405,7 @@
     , m_cpuLimit(m_configuration->cpuLimit())
     , m_backForwardList(WebBackForwardList::create(*this))
     , m_waitsForPaintAfterViewDidMoveToWindow(m_configuration->waitsForPaintAfterViewDidMoveToWindow())
+    , m_drawsBackground(m_configuration->drawsBackground())
     , m_pageID(pageID)
     , m_controlledByAutomation(m_configuration->isControlledByAutomation())
 #if PLATFORM(COCOA)

Modified: trunk/Tools/ChangeLog (233827 => 233828)


--- trunk/Tools/ChangeLog	2018-07-13 23:20:53 UTC (rev 233827)
+++ trunk/Tools/ChangeLog	2018-07-14 00:03:49 UTC (rev 233828)
@@ -1,3 +1,14 @@
+2018-07-13  Timothy Hatcher  <timo...@apple.com>
+
+        Add _drawsBackground to WKWebViewConfiguration.
+        https://bugs.webkit.org/show_bug.cgi?id=187665
+        rdar://problem/42182268
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/Configuration.mm:
+        (TestWebKitAPI.WebKit.ConfigurationDrawsBackground): Added.
+
 2018-07-13  Chris Dumez  <cdu...@apple.com>
 
         Add a FrameLoaderClient willInjectUserScriptForFrame callback

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Configuration.mm (233827 => 233828)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Configuration.mm	2018-07-13 23:20:53 UTC (rev 233827)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Configuration.mm	2018-07-14 00:03:49 UTC (rev 233828)
@@ -29,6 +29,7 @@
 
 #import "Test.h"
 #import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
 #import <wtf/RetainPtr.h>
 
 TEST(WebKit, ConfigurationCPULimit)
@@ -41,4 +42,21 @@
     EXPECT_EQ([other _cpuLimit], 0.75);
 }
 
+TEST(WebKit, ConfigurationDrawsBackground)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    EXPECT_EQ([configuration _drawsBackground], YES);
+    [configuration _setDrawsBackground:NO];
+    EXPECT_EQ([configuration _drawsBackground], NO);
+
+    auto other = adoptNS([configuration copy]);
+    EXPECT_EQ([other _drawsBackground], NO);
+
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSZeroRect]);
+    EXPECT_EQ([webView _drawsBackground], YES);
+
+    auto configedWebView = adoptNS([[WKWebView alloc] initWithFrame:NSZeroRect configuration:configuration.get()]);
+    EXPECT_EQ([configedWebView _drawsBackground], NO);
+}
+
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to