Allow removal of white backgrounds
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2018 23:34:42 +0000 (23:34 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2018 23:34:42 +0000 (23:34 +0000)
commit88978b357a143b1ecaf5aeb99234fd319fdcd900
tree6ba4a80099799bff73686d728232c44612f13ca9
parentacc922052bb84628743dae459c9fdc54cd094ee4
Allow removal of white backgrounds
https://bugs.webkit.org/show_bug.cgi?id=187574
<rdar://problem/41146792>

Reviewed by Simon Fraser.

Source/WebCore:

Add a drawing mode that turns white backgrounds into transparent
regions, such that a hosting app can see through to its window.

Test: css3/color-filters/punch-out-white-backgrounds.html

* page/Settings.yaml: New Setting.

* rendering/InlineFlowBox.cpp: Draw with a destination out blend mode
if the background is white and we are punching out backgrounds, which means
that it will erase the destination.
(WebCore::InlineFlowBox::paintBoxDecorations):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::paintBackground): Ditto.
* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::paintBackgroundsBehindCell): Ditto.

* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended): Save and restore
the composition mode if necessary.

Source/WebKit:

Add a new WebPreference for punching out white backgrounds.

* Shared/WebPreferences.yaml:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetPunchOutWhiteBackgroundsInDarkMode):
(WKPreferencesGetPunchOutWhiteBackgroundsInDarkMode):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]):
(-[WKWebViewConfiguration copyWithZone:]):
(-[WKWebViewConfiguration _punchOutWhiteBackgroundsInDarkMode]):
(-[WKWebViewConfiguration _setPunchOutWhiteBackgroundsInDarkMode:]):
* UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:

Source/WebKitLegacy/mac:

Add a new WebPreference for punching out white backgrounds.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences punchOutWhiteBackgroundsInDarkMode]):
(-[WebPreferences setPunchOutWhiteBackgroundsInDarkMode:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Tools:

Add a new menu item for punching out white backgrounds in MiniBrowser.
In WebKitTestRunner, expose the new setting and hook that up to
drawing a background in the WebView.

* MiniBrowser/mac/AppDelegate.m:
(defaultConfiguration): Add _punchOutWhiteBackgroundsInDarkMode.

* MiniBrowser/mac/SettingsController.h: Ditto.
* MiniBrowser/mac/SettingsController.m:
(-[SettingsController _populateMenu]):
(-[SettingsController validateMenuItem:]):
(-[SettingsController togglePunchOutWhiteBackgroundsInDarkMode:]):
(-[SettingsController punchOutWhiteBackgroundsInDarkMode]):

* MiniBrowser/mac/WK1BrowserWindowController.m:
(-[WK1BrowserWindowController didChangeSettings]): Set the new preference.

* WebKitTestRunner/PlatformWebView.h: Expose a drawsBackground property.
* WebKitTestRunner/gtk/PlatformWebViewGtk.cpp: Null implementation.
(WTR::PlatformWebView::drawsBackground const):
(WTR::PlatformWebView::setDrawsBackground):
* WebKitTestRunner/wpe/PlatformWebViewWPE.cpp: Ditto.
(WTR::PlatformWebView::drawsBackground const):
(WTR::PlatformWebView::setDrawsBackground):
* WebKitTestRunner/ios/PlatformWebViewIOS.mm: Call into the WKWebView and
set its SPI.
(WTR::PlatformWebView::drawsBackground const):
(WTR::PlatformWebView::setDrawsBackground):
* WebKitTestRunner/mac/PlatformWebViewMac.mm: Ditto.
(WTR::PlatformWebView::drawsBackground const):
(WTR::PlatformWebView::setDrawsBackground):

* WebKitTestRunner/TestController.cpp: Reset and copy the new preference.
(WTR::TestController::resetPreferencesToConsistentValues):
(WTR::updateTestOptionsFromTestHeader):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):

* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::platformCreateWebView): If the option for punching
out the background was set, tell the WebView to not draw its background.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233869 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
LayoutTests/TestExpectations
LayoutTests/css3/color-filters/punch-out-white-backgrounds-expected.html [new file with mode: 0644]
LayoutTests/css3/color-filters/punch-out-white-backgrounds.html [new file with mode: 0644]
LayoutTests/displaylists/extent-includes-shadow-expected.txt
LayoutTests/displaylists/extent-includes-transforms-expected.txt
LayoutTests/displaylists/layer-dispay-list-expected.txt
LayoutTests/displaylists/replay-skip-clipped-rect-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/page/Settings.yaml
Source/WebCore/rendering/InlineFlowBox.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderTableCell.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/C/WKPreferences.cpp
Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKitLegacy/mac/WebView/WebPreferences.mm
Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h
Source/WebKitLegacy/mac/WebView/WebView.mm
Tools/ChangeLog
Tools/MiniBrowser/mac/AppDelegate.m
Tools/MiniBrowser/mac/SettingsController.h
Tools/MiniBrowser/mac/SettingsController.m
Tools/MiniBrowser/mac/WK1BrowserWindowController.m
Tools/MiniBrowser/mac/WK2BrowserWindowController.m
Tools/WebKitTestRunner/PlatformWebView.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestOptions.h
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp
Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm
Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm
Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp