Title: [233951] branches/safari-606-branch
Revision
233951
Author
[email protected]
Date
2018-07-18 18:59:38 -0700 (Wed, 18 Jul 2018)

Log Message

Cherry-pick r233869. rdar://problem/42344023

    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

Modified Paths

Added Paths

Diff

Modified: branches/safari-606-branch/LayoutTests/TestExpectations (233950 => 233951)


--- branches/safari-606-branch/LayoutTests/TestExpectations	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/LayoutTests/TestExpectations	2018-07-19 01:59:38 UTC (rev 233951)
@@ -272,6 +272,9 @@
 imported/w3c/web-platform-tests/css/css-ui/caret-color-019.html [ Skip ]
 imported/w3c/web-platform-tests/css/css-ui/caret-color-020.html [ Skip ]
 
+# Only relevant on macOS
+css3/color-filters/punch-out-white-backgrounds.html [ Skip ]
+
 # This test tests a feature that only exists on iOS.
 fast/text/accessibility-bold-system-font-2.html [ Skip ]
 

Added: branches/safari-606-branch/LayoutTests/css3/color-filters/punch-out-white-backgrounds-expected.html (0 => 233951)


--- branches/safari-606-branch/LayoutTests/css3/color-filters/punch-out-white-backgrounds-expected.html	                        (rev 0)
+++ branches/safari-606-branch/LayoutTests/css3/color-filters/punch-out-white-backgrounds-expected.html	2018-07-19 01:59:38 UTC (rev 233951)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Punch out White Backgrounds</title>
+        <link rel="author" title="Apple" href=""
+
+        <style type="text/css">
+            body {
+                background-color: #888;
+            }
+            .test
+            {
+                width: 100px;
+                height: 100px;
+                background-color: rgb(236, 236, 236);
+            }
+            .inline-test
+            {
+                background-color: rgb(236, 236, 236);
+            }
+        </style>
+    </head>
+    <body>
+        <div class="test"></div>
+        <p>Inline element test: <span class="inline-test">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></p>
+    </body>
+</html>

Added: branches/safari-606-branch/LayoutTests/css3/color-filters/punch-out-white-backgrounds.html (0 => 233951)


--- branches/safari-606-branch/LayoutTests/css3/color-filters/punch-out-white-backgrounds.html	                        (rev 0)
+++ branches/safari-606-branch/LayoutTests/css3/color-filters/punch-out-white-backgrounds.html	2018-07-19 01:59:38 UTC (rev 233951)
@@ -0,0 +1,29 @@
+<!DOCTYPE html><!-- webkit-test-runner [ punchOutWhiteBackgrounds=true ] -->
+<html>
+    <head>
+        <title>Punch out White Backgrounds</title>
+        <link rel="author" title="Apple" href=""
+        <link rel="match" href=""
+
+        <style type="text/css">
+            body
+            {
+                background-color: #888;
+            }
+            .test
+            {
+                width: 100px;
+                height: 100px;
+                background-color: white;
+            }
+            .inline-test
+            {
+                background-color: white;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="test"></div>
+        <p>Inline element test: <span class="inline-test">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></p>
+    </body>
+</html>

Modified: branches/safari-606-branch/LayoutTests/displaylists/extent-includes-shadow-expected.txt (233950 => 233951)


--- branches/safari-606-branch/LayoutTests/displaylists/extent-includes-shadow-expected.txt	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/LayoutTests/displaylists/extent-includes-shadow-expected.txt	2018-07-19 01:59:38 UTC (rev 233951)
@@ -9,8 +9,10 @@
   (shadow-blur 12.00)
   (shadow-offset width=10 height=20)
   (shadows-use-legacy-radius 0))
-(fill-rect-with-color
+(fill-composited-rect
   (extent at (43,50) size 134x137)
   (rect at (50,50) size 100x100)
-  (color #0000FF))
+  (color #0000FF)
+  (composite-operation source-over)
+  (blend-mode normal))
 (restore)

Modified: branches/safari-606-branch/LayoutTests/displaylists/extent-includes-transforms-expected.txt (233950 => 233951)


--- branches/safari-606-branch/LayoutTests/displaylists/extent-includes-transforms-expected.txt	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/LayoutTests/displaylists/extent-includes-transforms-expected.txt	2018-07-19 01:59:38 UTC (rev 233951)
@@ -11,8 +11,10 @@
   (shadow-blur 12.00)
   (shadow-offset width=10 height=20)
   (shadows-use-legacy-radius 0))
-(fill-rect-with-color
+(fill-composited-rect
   (extent at (7.14,0.20) size 184.55x185.65)
   (rect at (0,0) size 100x100)
-  (color #0000FF))
+  (color #0000FF)
+  (composite-operation source-over)
+  (blend-mode normal))
 (restore)

Modified: branches/safari-606-branch/LayoutTests/displaylists/layer-dispay-list-expected.txt (233950 => 233951)


--- branches/safari-606-branch/LayoutTests/displaylists/layer-dispay-list-expected.txt	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/LayoutTests/displaylists/layer-dispay-list-expected.txt	2018-07-19 01:59:38 UTC (rev 233951)
@@ -2,10 +2,12 @@
 (translate
   (x 0.00)
   (y 0.00))
-(fill-rect-with-color
+(fill-composited-rect
   (extent at (0,0) size 104x104)
   (rect at (0,0) size 104x104)
-  (color #008000))
+  (color #008000)
+  (composite-operation source-over)
+  (blend-mode normal))
 (set-state
   (change-flags 131456)
   (fill-color #0000FF)

Modified: branches/safari-606-branch/LayoutTests/displaylists/replay-skip-clipped-rect-expected.txt (233950 => 233951)


--- branches/safari-606-branch/LayoutTests/displaylists/replay-skip-clipped-rect-expected.txt	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/LayoutTests/displaylists/replay-skip-clipped-rect-expected.txt	2018-07-19 01:59:38 UTC (rev 233951)
@@ -2,10 +2,12 @@
 (translate
   (x 0.00)
   (y 0.00))
-(fill-rect-with-color
+(fill-composited-rect
   (extent at (412,0) size 100x100)
   (rect at (412,0) size 100x100)
-  (color #0000FF))
+  (color #0000FF)
+  (composite-operation source-over)
+  (blend-mode normal))
 
 replayed: 
 (

Modified: branches/safari-606-branch/Source/WebCore/ChangeLog (233950 => 233951)


--- branches/safari-606-branch/Source/WebCore/ChangeLog	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebCore/ChangeLog	2018-07-19 01:59:38 UTC (rev 233951)
@@ -1,5 +1,142 @@
 2018-07-18  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r233869. rdar://problem/42344023
+
+    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
+
+    2018-07-11  Dean Jackson  <[email protected]>
+
+            Allow removal of white backgrounds
+            https://bugs.webkit.org/show_bug.cgi?id=187574
+            <rdar://problem/41146792>
+
+            Reviewed by Simon Fraser.
+
+            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.
+
+2018-07-18  Babak Shafiei  <[email protected]>
+
         Cherry-pick r233865. rdar://problem/42343023
 
     Fullscreen requires active document.

Modified: branches/safari-606-branch/Source/WebCore/page/Settings.yaml (233950 => 233951)


--- branches/safari-606-branch/Source/WebCore/page/Settings.yaml	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebCore/page/Settings.yaml	2018-07-19 01:59:38 UTC (rev 233951)
@@ -530,7 +530,12 @@
 
 colorFilterEnabled:
   initial: false
+  onChange: setNeedsRecalcStyleInAllFrames
 
+punchOutWhiteBackgroundsInDarkMode:
+  initial: false
+  onChange: setNeedsRecalcStyleInAllFrames
+
 treatIPAddressAsDomain:
   initial: false
 

Modified: branches/safari-606-branch/Source/WebCore/rendering/InlineFlowBox.cpp (233950 => 233951)


--- branches/safari-606-branch/Source/WebCore/rendering/InlineFlowBox.cpp	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebCore/rendering/InlineFlowBox.cpp	2018-07-19 01:59:38 UTC (rev 233951)
@@ -36,8 +36,10 @@
 #include "RenderRubyRun.h"
 #include "RenderRubyText.h"
 #include "RenderTableCell.h"
+#include "RenderTheme.h"
 #include "RenderView.h"
 #include "RootInlineBox.h"
+#include "Settings.h"
 #include "Text.h"
 #include <math.h>
 #include <wtf/IsoMallocInlines.h>
@@ -1358,8 +1360,15 @@
     if (!renderer().boxShadowShouldBeAppliedToBackground(adjustedPaintoffset, BackgroundBleedNone, this))
         paintBoxShadow(paintInfo, lineStyle, Normal, paintRect);
 
-    const Color& color = lineStyle.visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor);
-    paintFillLayers(paintInfo, color, lineStyle.backgroundLayers(), paintRect);
+    Color color = lineStyle.visitedDependentColor(CSSPropertyBackgroundColor);
+
+    CompositeOperator compositeOp = CompositeSourceOver;
+    if (renderer().document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(color) && renderer().theme().usingDarkAppearance(renderer()))
+        compositeOp = CompositeDestinationOut;
+
+    color = lineStyle.colorByApplyingColorFilter(color);
+
+    paintFillLayers(paintInfo, color, lineStyle.backgroundLayers(), paintRect, compositeOp);
     paintBoxShadow(paintInfo, lineStyle, Inset, paintRect);
 
     // :first-line cannot be used to put borders on a line. Always paint borders with our

Modified: branches/safari-606-branch/Source/WebCore/rendering/RenderBox.cpp (233950 => 233951)


--- branches/safari-606-branch/Source/WebCore/rendering/RenderBox.cpp	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebCore/rendering/RenderBox.cpp	2018-07-19 01:59:38 UTC (rev 233951)
@@ -56,6 +56,7 @@
 #include "RenderFlexibleBox.h"
 #include "RenderFragmentContainer.h"
 #include "RenderGeometryMap.h"
+#include "RenderGrid.h"
 #include "RenderInline.h"
 #include "RenderIterator.h"
 #include "RenderLayer.h"
@@ -67,6 +68,7 @@
 #include "RuntimeApplicationChecks.h"
 #include "ScrollAnimator.h"
 #include "ScrollbarTheme.h"
+#include "Settings.h"
 #include "StyleScrollSnapPoints.h"
 #include "TransformState.h"
 #include <algorithm>
@@ -74,12 +76,6 @@
 #include <wtf/IsoMallocInlines.h>
 #include <wtf/StackStats.h>
 
-#include "RenderGrid.h"
-
-#if PLATFORM(IOS)
-#include "Settings.h"
-#endif
-
 namespace WebCore {
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(RenderBox);
@@ -1195,8 +1191,14 @@
         return;
 
     auto& style = rootBackgroundRenderer->style();
-    auto color = style.visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor);
-    paintFillLayers(paintInfo, color, style.backgroundLayers(), view().backgroundRect(), BackgroundBleedNone, CompositeSourceOver, rootBackgroundRenderer);
+
+    auto color = style.visitedDependentColor(CSSPropertyBackgroundColor);
+
+    CompositeOperator compositeOp = CompositeSourceOver;
+    if (document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(color) && theme().usingDarkAppearance(*this))
+        compositeOp = CompositeDestinationOut;
+
+    paintFillLayers(paintInfo, style.colorByApplyingColorFilter(color), style.backgroundLayers(), view().backgroundRect(), BackgroundBleedNone, compositeOp, rootBackgroundRenderer);
 }
 
 BackgroundBleedAvoidance RenderBox::determineBackgroundBleedAvoidance(GraphicsContext& context) const
@@ -1324,7 +1326,13 @@
     if (backgroundIsKnownToBeObscured(paintRect.location()) && !boxShadowShouldBeAppliedToBackground(paintRect.location(), bleedAvoidance))
         return;
 
-    paintFillLayers(paintInfo, style().visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor), style().backgroundLayers(), paintRect, bleedAvoidance);
+    Color backgroundColor = style().visitedDependentColor(CSSPropertyBackgroundColor);
+
+    CompositeOperator compositeOp = CompositeSourceOver;
+    if (document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(backgroundColor) && theme().usingDarkAppearance(*this))
+        compositeOp = CompositeDestinationOut;
+
+    paintFillLayers(paintInfo, style().colorByApplyingColorFilter(backgroundColor), style().backgroundLayers(), paintRect, bleedAvoidance, compositeOp);
 }
 
 bool RenderBox::getBackgroundPaintedExtent(const LayoutPoint& paintOffset, LayoutRect& paintedExtent) const

Modified: branches/safari-606-branch/Source/WebCore/rendering/RenderBoxModelObject.cpp (233950 => 233951)


--- branches/safari-606-branch/Source/WebCore/rendering/RenderBoxModelObject.cpp	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebCore/rendering/RenderBoxModelObject.cpp	2018-07-19 01:59:38 UTC (rev 233951)
@@ -802,16 +802,24 @@
         if (hasRoundedBorder && bleedAvoidance != BackgroundBleedUseTransparencyLayer) {
             FloatRoundedRect pixelSnappedBorder = backgroundRoundedRectAdjustedForBleedAvoidance(context, rect, bleedAvoidance, box, boxSize,
                 includeLeftEdge, includeRightEdge).pixelSnappedRoundedRectForPainting(deviceScaleFactor);
-            if (pixelSnappedBorder.isRenderable())
+            if (pixelSnappedBorder.isRenderable()) {
+                CompositeOperator previousOperator = context.compositeOperation();
+                bool saveRestoreCompositeOp = op != previousOperator;
+                if (saveRestoreCompositeOp)
+                    context.setCompositeOperation(op);
+
                 context.fillRoundedRect(pixelSnappedBorder, bgColor);
-            else {
+
+                if (saveRestoreCompositeOp)
+                    context.setCompositeOperation(previousOperator);
+            } else {
                 context.save();
                 clipRoundedInnerRect(context, pixelSnappedRect, pixelSnappedBorder);
-                context.fillRect(pixelSnappedBorder.rect(), bgColor);
+                context.fillRect(pixelSnappedBorder.rect(), bgColor, op);
                 context.restore();
             }
         } else
-            context.fillRect(pixelSnappedRect, bgColor);
+            context.fillRect(pixelSnappedRect, bgColor, op);
 
         return;
     }
@@ -940,7 +948,13 @@
                     baseColor = baseColor.blend(bgColor);
                 context.fillRect(backgroundRectForPainting, baseColor, CompositeCopy);
             } else if (!baseBgColorOnly && bgColor.isVisible()) {
-                auto operation = shouldClearBackground ? CompositeCopy : context.compositeOperation();
+                auto operation = context.compositeOperation();
+                if (shouldClearBackground) {
+                    if (op == CompositeDestinationOut) // We're punching out the background.
+                        operation = op;
+                    else
+                        operation = CompositeCopy;
+                }
                 context.fillRect(backgroundRectForPainting, bgColor, operation);
             } else if (shouldClearBackground)
                 context.clearRect(backgroundRectForPainting);

Modified: branches/safari-606-branch/Source/WebCore/rendering/RenderTableCell.cpp (233950 => 233951)


--- branches/safari-606-branch/Source/WebCore/rendering/RenderTableCell.cpp	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebCore/rendering/RenderTableCell.cpp	2018-07-19 01:59:38 UTC (rev 233951)
@@ -32,7 +32,9 @@
 #include "HTMLTableCellElement.h"
 #include "PaintInfo.h"
 #include "RenderTableCol.h"
+#include "RenderTheme.h"
 #include "RenderView.h"
+#include "Settings.h"
 #include "StyleProperties.h"
 #include "TransformState.h"
 #include <wtf/IsoMallocInlines.h>
@@ -1282,9 +1284,16 @@
     if (backgroundObject != this)
         adjustedPaintOffset.moveBy(location());
 
-    Color color = backgroundObject->style().visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor);
-    auto& bgLayer = backgroundObject->style().backgroundLayers();
+    const auto& style = backgroundObject->style();
+    auto& bgLayer = style.backgroundLayers();
 
+    CompositeOperator compositeOp = CompositeSourceOver;
+    Color color = style.visitedDependentColor(CSSPropertyBackgroundColor);
+    if (document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(color) && theme().usingDarkAppearance(*this))
+        compositeOp = CompositeDestinationOut;
+
+    color = style.colorByApplyingColorFilter(color);
+
     if (bgLayer.hasImage() || color.isValid()) {
         // We have to clip here because the background would paint
         // on top of the borders otherwise.  This only matters for cells and rows.
@@ -1295,7 +1304,7 @@
                 width() - borderLeft() - borderRight(), height() - borderTop() - borderBottom());
             paintInfo.context().clip(clipRect);
         }
-        paintFillLayers(paintInfo, color, bgLayer, LayoutRect(adjustedPaintOffset, frameRect().size()), BackgroundBleedNone, CompositeSourceOver, backgroundObject);
+        paintFillLayers(paintInfo, color, bgLayer, LayoutRect(adjustedPaintOffset, frameRect().size()), BackgroundBleedNone, compositeOp, backgroundObject);
     }
 }
 

Modified: branches/safari-606-branch/Source/WebCore/rendering/RenderTheme.h (233950 => 233951)


--- branches/safari-606-branch/Source/WebCore/rendering/RenderTheme.h	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebCore/rendering/RenderTheme.h	2018-07-19 01:59:38 UTC (rev 233951)
@@ -38,6 +38,7 @@
 class FillLayer;
 class HTMLInputElement;
 class Icon;
+class Page;
 class RenderAttachment;
 class RenderBox;
 class RenderMeter;
@@ -255,6 +256,8 @@
 
     virtual void drawLineForDocumentMarker(const RenderText&, GraphicsContext&, const FloatPoint& origin, float width, DocumentMarkerLineStyle);
 
+    virtual bool usingDarkAppearance(const RenderObject&) const { return false; }
+
 protected:
     virtual FontCascadeDescription& cachedSystemFontDescription(CSSValueID systemFontID) const;
     virtual void updateCachedSystemFontDescription(CSSValueID systemFontID, FontCascadeDescription&) const = 0;

Modified: branches/safari-606-branch/Source/WebCore/rendering/RenderThemeMac.h (233950 => 233951)


--- branches/safari-606-branch/Source/WebCore/rendering/RenderThemeMac.h	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebCore/rendering/RenderThemeMac.h	2018-07-19 01:59:38 UTC (rev 233951)
@@ -170,6 +170,8 @@
 
     void drawLineForDocumentMarker(const RenderText&, GraphicsContext&, const FloatPoint& origin, float width, DocumentMarkerLineStyle) final;
 
+    bool usingDarkAppearance(const RenderObject&) const final;
+
 private:
     String fileListNameForWidth(const FileList*, const FontCascade&, int width, bool multipleFilesAllowed) const final;
 

Modified: branches/safari-606-branch/Source/WebCore/rendering/RenderThemeMac.mm (233950 => 233951)


--- branches/safari-606-branch/Source/WebCore/rendering/RenderThemeMac.mm	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebCore/rendering/RenderThemeMac.mm	2018-07-19 01:59:38 UTC (rev 233951)
@@ -2778,6 +2778,7 @@
 
 #endif // ENABLE(ATTACHMENT_ELEMENT)
 
+<<<<<<< HEAD
 static CGColorRef colorForStyle(DocumentMarkerLineStyle style, bool useDarkMode)
 {
     switch (style) {
@@ -2822,6 +2823,16 @@
     CGContextFillPath(ctx);
 }
 
+bool RenderThemeMac::usingDarkAppearance(const RenderObject& o) const
+{
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+    return o.page().useSystemAppearance() && o.page().useDarkAppearance();
+#else
+    UNUSED_PARAM(o);
+    return false;
+#endif
+}
+
 } // namespace WebCore
 
 #endif // PLATFORM(MAC)

Modified: branches/safari-606-branch/Source/WebKit/ChangeLog (233950 => 233951)


--- branches/safari-606-branch/Source/WebKit/ChangeLog	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebKit/ChangeLog	2018-07-19 01:59:38 UTC (rev 233951)
@@ -1,5 +1,138 @@
 2018-07-18  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r233869. rdar://problem/42344023
+
+    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
+
+    2018-07-11  Dean Jackson  <[email protected]>
+
+            Allow removal of white backgrounds
+            https://bugs.webkit.org/show_bug.cgi?id=187574
+            <rdar://problem/41146792>
+
+            Reviewed by Simon Fraser.
+
+            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:
+
+2018-07-18  Babak Shafiei  <[email protected]>
+
         Cherry-pick r233865. rdar://problem/42343023
 
     Fullscreen requires active document.

Modified: branches/safari-606-branch/Source/WebKit/Shared/WebPreferences.yaml (233950 => 233951)


--- branches/safari-606-branch/Source/WebKit/Shared/WebPreferences.yaml	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebKit/Shared/WebPreferences.yaml	2018-07-19 01:59:38 UTC (rev 233951)
@@ -1084,6 +1084,10 @@
   type: bool
   defaultValue: false
 
+PunchOutWhiteBackgroundsInDarkMode:
+  type: bool
+  defaultValue: false
+
 IncompleteImageBorderEnabled:
   type: bool
   defaultValue: false

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/API/C/WKPreferences.cpp (233950 => 233951)


--- branches/safari-606-branch/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2018-07-19 01:59:38 UTC (rev 233951)
@@ -2033,3 +2033,13 @@
 {
     return toImpl(preferencesRef)->processSwapOnNavigationEnabled();
 }
+
+void WKPreferencesSetPunchOutWhiteBackgroundsInDarkMode(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setPunchOutWhiteBackgroundsInDarkMode(flag);
+}
+
+bool WKPreferencesGetPunchOutWhiteBackgroundsInDarkMode(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->punchOutWhiteBackgroundsInDarkMode();
+}

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h (233950 => 233951)


--- branches/safari-606-branch/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2018-07-19 01:59:38 UTC (rev 233951)
@@ -569,6 +569,10 @@
 WK_EXPORT void WKPreferencesSetColorFilterEnabled(WKPreferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetColorFilterEnabled(WKPreferencesRef);
 
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetPunchOutWhiteBackgroundsInDarkMode(WKPreferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetPunchOutWhiteBackgroundsInDarkMode(WKPreferencesRef);
+
 #ifdef __cplusplus
 }
 #endif

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm (233950 => 233951)


--- branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm	2018-07-19 01:59:38 UTC (rev 233951)
@@ -761,6 +761,16 @@
     return _preferences->colorFilterEnabled();
 }
 
+- (void)_setPunchOutWhiteBackgroundsInDarkMode:(BOOL)punches
+{
+    _preferences->setPunchOutWhiteBackgroundsInDarkMode(punches);
+}
+
+- (BOOL)_punchOutWhiteBackgroundsInDarkMode
+{
+    return _preferences->punchOutWhiteBackgroundsInDarkMode();
+}
+
 #if PLATFORM(MAC)
 - (void)_setJavaEnabledForLocalFiles:(BOOL)enabled
 {

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h (233950 => 233951)


--- branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2018-07-19 01:59:38 UTC (rev 233951)
@@ -138,6 +138,7 @@
 
 @property (nonatomic, setter=_setStorageAccessPromptsEnabled:) BOOL _storageAccessPromptsEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, setter=_setColorFilterEnabled:) BOOL _colorFilterEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setPunchOutWhiteBackgroundsInDarkMode:) BOOL _punchOutWhiteBackgroundsInDarkMode WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 #if !TARGET_OS_IPHONE
 @property (nonatomic, setter=_setWebGLEnabled:) BOOL _webGLEnabled WK_API_AVAILABLE(macosx(10.13.4));

Modified: branches/safari-606-branch/Source/WebKitLegacy/mac/ChangeLog (233950 => 233951)


--- branches/safari-606-branch/Source/WebKitLegacy/mac/ChangeLog	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebKitLegacy/mac/ChangeLog	2018-07-19 01:59:38 UTC (rev 233951)
@@ -1,3 +1,131 @@
+2018-07-18  Babak Shafiei  <[email protected]>
+
+        Cherry-pick r233869. rdar://problem/42344023
+
+    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
+
+    2018-07-11  Dean Jackson  <[email protected]>
+
+            Allow removal of white backgrounds
+            https://bugs.webkit.org/show_bug.cgi?id=187574
+            <rdar://problem/41146792>
+
+            Reviewed by Simon Fraser.
+
+            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:]):
+
 2018-07-14  Kocsen Chung  <[email protected]>
 
         Ensure WebKit stack is ad-hoc signed

Modified: branches/safari-606-branch/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h (233950 => 233951)


--- branches/safari-606-branch/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h	2018-07-19 01:59:38 UTC (rev 233951)
@@ -195,6 +195,7 @@
 #define WebKitViewportFitEnabledPreferenceKey @"WebKitViewportFitEnabled"
 #define WebKitConstantPropertiesEnabledPreferenceKey @"WebKitConstantPropertiesEnabled"
 #define WebKitColorFilterEnabledPreferenceKey @"WebKitColorFilterEnabled"
+#define WebKitPunchOutWhiteBackgroundsInDarkModePreferenceKey @"WebKitPunchOutWhiteBackgroundsInDarkMode"
 #define WebKitFetchAPIKeepAliveEnabledPreferenceKey @"WebKitFetchAPIKeepAliveEnabled"
 #define WebKitWebAnimationsCSSIntegrationEnabledPreferenceKey @"WebKitWebAnimationsCSSIntegrationEnabled"
 

Modified: branches/safari-606-branch/Source/WebKitLegacy/mac/WebView/WebPreferences.mm (233950 => 233951)


--- branches/safari-606-branch/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2018-07-19 01:59:38 UTC (rev 233951)
@@ -678,6 +678,7 @@
         @YES, WebKitViewportFitEnabledPreferenceKey,
         @YES, WebKitConstantPropertiesEnabledPreferenceKey,
         @NO, WebKitColorFilterEnabledPreferenceKey,
+        @NO, WebKitPunchOutWhiteBackgroundsInDarkModePreferenceKey,
         @YES, WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallbackKey,
         @NO, WebKitInspectorAdditionsEnabledPreferenceKey,
         (NSString *)Settings::defaultMediaContentTypesRequiringHardwareSupport(), WebKitMediaContentTypesRequiringHardwareSupportPreferenceKey,
@@ -3283,6 +3284,16 @@
     [self _setBoolValue:flag forKey:WebKitColorFilterEnabledPreferenceKey];
 }
 
+- (BOOL)punchOutWhiteBackgroundsInDarkMode
+{
+    return [self _boolValueForKey:WebKitPunchOutWhiteBackgroundsInDarkModePreferenceKey];
+}
+
+- (void)setPunchOutWhiteBackgroundsInDarkMode:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitPunchOutWhiteBackgroundsInDarkModePreferenceKey];
+}
+
 - (BOOL)allowMediaContentTypesRequiringHardwareSupportAsFallback
 {
     return [self _boolValueForKey:WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallbackKey];

Modified: branches/safari-606-branch/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h (233950 => 233951)


--- branches/safari-606-branch/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h	2018-07-19 01:59:38 UTC (rev 233951)
@@ -604,6 +604,7 @@
 @property (nonatomic) BOOL viewportFitEnabled;
 @property (nonatomic) BOOL constantPropertiesEnabled;
 @property (nonatomic) BOOL colorFilterEnabled;
+@property (nonatomic) BOOL punchOutWhiteBackgroundsInDarkMode;
 @property (nonatomic) BOOL inspectorAdditionsEnabled;
 @property (nonatomic) BOOL allowMediaContentTypesRequiringHardwareSupportAsFallback;
 @property (nonatomic) BOOL accessibilityObjectModelEnabled;

Modified: branches/safari-606-branch/Source/WebKitLegacy/mac/WebView/WebView.mm (233950 => 233951)


--- branches/safari-606-branch/Source/WebKitLegacy/mac/WebView/WebView.mm	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Source/WebKitLegacy/mac/WebView/WebView.mm	2018-07-19 01:59:38 UTC (rev 233951)
@@ -2958,6 +2958,7 @@
     settings.setPlugInSnapshottingEnabled([preferences plugInSnapshottingEnabled]);
     settings.setHttpEquivEnabled([preferences httpEquivEnabled]);
     settings.setColorFilterEnabled([preferences colorFilterEnabled]);
+    settings.setPunchOutWhiteBackgroundsInDarkMode([preferences punchOutWhiteBackgroundsInDarkMode]);
 
 #if PLATFORM(MAC)
     settings.setAcceleratedCompositingForFixedPositionEnabled(true);

Modified: branches/safari-606-branch/Tools/ChangeLog (233950 => 233951)


--- branches/safari-606-branch/Tools/ChangeLog	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/ChangeLog	2018-07-19 01:59:38 UTC (rev 233951)
@@ -1,5 +1,164 @@
 2018-07-18  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r233869. rdar://problem/42344023
+
+    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
+
+    2018-07-11  Dean Jackson  <[email protected]>
+
+            Allow removal of white backgrounds
+            https://bugs.webkit.org/show_bug.cgi?id=187574
+            <rdar://problem/41146792>
+
+            Reviewed by Simon Fraser.
+
+            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.
+
+2018-07-18  Babak Shafiei  <[email protected]>
+
         Cherry-pick r233853. rdar://problem/42344991
 
     IndexedDB: closeAndDeleteDatabasesForOrigins should remove all databases for those origins

Modified: branches/safari-606-branch/Tools/MiniBrowser/mac/AppDelegate.m (233950 => 233951)


--- branches/safari-606-branch/Tools/MiniBrowser/mac/AppDelegate.m	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/MiniBrowser/mac/AppDelegate.m	2018-07-19 01:59:38 UTC (rev 233951)
@@ -116,7 +116,6 @@
 
     configuration.suppressesIncrementalRendering = [SettingsController shared].incrementalRenderingSuppressed;
     configuration.websiteDataStore._resourceLoadStatisticsEnabled = [SettingsController shared].resourceLoadStatisticsEnabled;
-    configuration._colorFilterEnabled = [SettingsController shared].appleColorFilterEnabled;
     return configuration;
 }
 

Modified: branches/safari-606-branch/Tools/MiniBrowser/mac/SettingsController.h (233950 => 233951)


--- branches/safari-606-branch/Tools/MiniBrowser/mac/SettingsController.h	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/MiniBrowser/mac/SettingsController.h	2018-07-19 01:59:38 UTC (rev 233951)
@@ -57,6 +57,7 @@
 @property (nonatomic, readonly) BOOL largeImageAsyncDecodingEnabled;
 @property (nonatomic, readonly) BOOL animatedImageAsyncDecodingEnabled;
 @property (nonatomic, readonly) BOOL appleColorFilterEnabled;
+@property (nonatomic, readonly) BOOL punchOutWhiteBackgroundsInDarkMode;
 @property (nonatomic, readonly) BOOL useSystemAppearance;
 @property (nonatomic, readonly) BOOL loadsAllSiteIcons;
 @property (nonatomic, readonly) BOOL usesGameControllerFramework;

Modified: branches/safari-606-branch/Tools/MiniBrowser/mac/SettingsController.m (233950 => 233951)


--- branches/safari-606-branch/Tools/MiniBrowser/mac/SettingsController.m	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/MiniBrowser/mac/SettingsController.m	2018-07-19 01:59:38 UTC (rev 233951)
@@ -65,6 +65,7 @@
 static NSString * const LargeImageAsyncDecodingEnabledPreferenceKey = @"LargeImageAsyncDecodingEnabled";
 static NSString * const AnimatedImageAsyncDecodingEnabledPreferenceKey = @"AnimatedImageAsyncDecodingEnabled";
 static NSString * const AppleColorFilterEnabledPreferenceKey = @"AppleColorFilterEnabled";
+static NSString * const PunchOutWhiteBackgroundsInDarkModePreferenceKey = @"PunchOutWhiteBackgroundsInDarkMode";
 static NSString * const UseSystemAppearancePreferenceKey = @"UseSystemAppearance";
 
 // This default name intentionally overlaps with the key that WebKit2 checks when creating a view.
@@ -172,7 +173,8 @@
     [self _addItemWithTitle:@"Enable Resource Load Statistics" action:@selector(toggleResourceLoadStatisticsEnabled:) indented:NO];
     [self _addItemWithTitle:@"Enable Large Image Async Decoding" action:@selector(toggleLargeImageAsyncDecodingEnabled:) indented:NO];
     [self _addItemWithTitle:@"Enable Animated Image Async Decoding" action:@selector(toggleAnimatedImageAsyncDecodingEnabled:) indented:NO];
-    [self _addItemWithTitle:@"Enable -apple-color-filter" action:@selector(toggleAppleColorFilterEnabled:) indented:NO];
+    [self _addItemWithTitle:@"Enable color-filter" action:@selector(toggleAppleColorFilterEnabled:) indented:NO];
+    [self _addItemWithTitle:@"Punch Out White Backgrounds in Dark Mode" action:@selector(togglePunchOutWhiteBackgroundsInDarkMode:) indented:NO];
     [self _addItemWithTitle:@"Use System Appearance" action:@selector(toggleUseSystemAppearance:) indented:NO];
     [self _addHeaderWithTitle:@"WebKit2-only Settings"];
 
@@ -265,6 +267,8 @@
         [menuItem setState:[self animatedImageAsyncDecodingEnabled] ? NSControlStateValueOn : NSControlStateValueOff];
     else if (action == @selector(toggleAppleColorFilterEnabled:))
         [menuItem setState:[self appleColorFilterEnabled] ? NSControlStateValueOn : NSControlStateValueOff];
+    else if (action == @selector(togglePunchOutWhiteBackgroundsInDarkMode:))
+        [menuItem setState:[self punchOutWhiteBackgroundsInDarkMode] ? NSControlStateValueOn : NSControlStateValueOff];
     else if (action == @selector(toggleUseSystemAppearance:))
         [menuItem setState:[self useSystemAppearance] ? NSControlStateValueOn : NSControlStateValueOff];
     else if (action == @selector(toggleVisualViewportEnabled:))
@@ -585,6 +589,16 @@
     return [[NSUserDefaults standardUserDefaults] boolForKey:AppleColorFilterEnabledPreferenceKey];
 }
 
+- (void)togglePunchOutWhiteBackgroundsInDarkMode:(id)sender
+{
+    [self _toggleBooleanDefault:PunchOutWhiteBackgroundsInDarkModePreferenceKey];
+}
+
+- (BOOL)punchOutWhiteBackgroundsInDarkMode
+{
+    return [[NSUserDefaults standardUserDefaults] boolForKey:PunchOutWhiteBackgroundsInDarkModePreferenceKey];
+}
+
 - (void)toggleUseSystemAppearance:(id)sender
 {
     [self _toggleBooleanDefault:UseSystemAppearancePreferenceKey];

Modified: branches/safari-606-branch/Tools/MiniBrowser/mac/WK1BrowserWindowController.m (233950 => 233951)


--- branches/safari-606-branch/Tools/MiniBrowser/mac/WK1BrowserWindowController.m	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/MiniBrowser/mac/WK1BrowserWindowController.m	2018-07-19 01:59:38 UTC (rev 233951)
@@ -312,6 +312,7 @@
     [[WebPreferences standardPreferences] setLargeImageAsyncDecodingEnabled:settings.largeImageAsyncDecodingEnabled];
     [[WebPreferences standardPreferences] setAnimatedImageAsyncDecodingEnabled:settings.animatedImageAsyncDecodingEnabled];
     [[WebPreferences standardPreferences] setColorFilterEnabled:settings.appleColorFilterEnabled];
+    [[WebPreferences standardPreferences] setPunchOutWhiteBackgroundsInDarkMode:settings.punchOutWhiteBackgroundsInDarkMode];
 
     _webView._useSystemAppearance = settings.useSystemAppearance;
 

Modified: branches/safari-606-branch/Tools/MiniBrowser/mac/WK2BrowserWindowController.m (233950 => 233951)


--- branches/safari-606-branch/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2018-07-19 01:59:38 UTC (rev 233951)
@@ -410,6 +410,8 @@
     preferences._visualViewportEnabled = settings.visualViewportEnabled;
     preferences._largeImageAsyncDecodingEnabled = settings.largeImageAsyncDecodingEnabled;
     preferences._animatedImageAsyncDecodingEnabled = settings.animatedImageAsyncDecodingEnabled;
+    preferences._colorFilterEnabled = settings.appleColorFilterEnabled;
+    preferences._punchOutWhiteBackgroundsInDarkMode = settings.punchOutWhiteBackgroundsInDarkMode;
 
     _webView.configuration.websiteDataStore._resourceLoadStatisticsEnabled = settings.resourceLoadStatisticsEnabled;
 

Modified: branches/safari-606-branch/Tools/WebKitTestRunner/PlatformWebView.h (233950 => 233951)


--- branches/safari-606-branch/Tools/WebKitTestRunner/PlatformWebView.h	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/WebKitTestRunner/PlatformWebView.h	2018-07-19 01:59:38 UTC (rev 233951)
@@ -93,7 +93,10 @@
     void makeWebViewFirstResponder();
     void setWindowIsKey(bool);
     bool windowIsKey() const { return m_windowIsKey; }
-    
+
+    bool drawsBackground() const;
+    void setDrawsBackground(bool);
+
     void removeFromWindow();
     void addToWindow();
 

Modified: branches/safari-606-branch/Tools/WebKitTestRunner/TestController.cpp (233950 => 233951)


--- branches/safari-606-branch/Tools/WebKitTestRunner/TestController.cpp	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/WebKitTestRunner/TestController.cpp	2018-07-19 01:59:38 UTC (rev 233951)
@@ -719,6 +719,7 @@
     WKPreferencesSetAllowCrossOriginSubresourcesToAskForCredentials(preferences, options.allowCrossOriginSubresourcesToAskForCredentials);
     WKPreferencesSetWebAnimationsCSSIntegrationEnabled(preferences, options.enableWebAnimationsCSSIntegration);
     WKPreferencesSetColorFilterEnabled(preferences, options.enableColorFilter);
+    WKPreferencesSetPunchOutWhiteBackgroundsInDarkMode(preferences, options.punchOutWhiteBackgroundsInDarkMode);
 
     static WKStringRef defaultTextEncoding = WKStringCreateWithUTF8CString("ISO-8859-1");
     WKPreferencesSetDefaultTextEncodingName(preferences, defaultTextEncoding);
@@ -1134,6 +1135,8 @@
             testOptions.enableProcessSwapOnWindowOpen = parseBooleanTestHeaderValue(value);
         else if (key == "enableColorFilter")
             testOptions.enableColorFilter = parseBooleanTestHeaderValue(value);
+        else if (key == "punchOutWhiteBackgroundsInDarkMode")
+            testOptions.punchOutWhiteBackgroundsInDarkMode = parseBooleanTestHeaderValue(value);
         else if (key == "jscOptions")
             testOptions.jscOptions = value;
         else if (key == "runSingly")

Modified: branches/safari-606-branch/Tools/WebKitTestRunner/TestOptions.h (233950 => 233951)


--- branches/safari-606-branch/Tools/WebKitTestRunner/TestOptions.h	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/WebKitTestRunner/TestOptions.h	2018-07-19 01:59:38 UTC (rev 233951)
@@ -59,6 +59,7 @@
     bool enableProcessSwapOnNavigation { false };
     bool enableProcessSwapOnWindowOpen { false };
     bool enableColorFilter { false };
+    bool punchOutWhiteBackgroundsInDarkMode { false };
     bool runSingly { false };
 
     float deviceScaleFactor { 1 };
@@ -95,6 +96,7 @@
             || enableProcessSwapOnNavigation != options.enableProcessSwapOnNavigation
             || enableProcessSwapOnWindowOpen != options.enableProcessSwapOnWindowOpen
             || enableColorFilter != options.enableColorFilter
+            || punchOutWhiteBackgroundsInDarkMode != options.punchOutWhiteBackgroundsInDarkMode
             || jscOptions != options.jscOptions
             || runSingly != options.runSingly)
             return false;

Modified: branches/safari-606-branch/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (233950 => 233951)


--- branches/safari-606-branch/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2018-07-19 01:59:38 UTC (rev 233951)
@@ -168,6 +168,9 @@
     }
 
     m_mainWebView = std::make_unique<PlatformWebView>(copiedConfiguration.get(), options);
+
+    if (options.punchOutWhiteBackgroundsInDarkMode)
+        m_mainWebView->setDrawsBackground(false);
 #else
     m_mainWebView = std::make_unique<PlatformWebView>(globalWebViewConfiguration, options);
 #endif

Modified: branches/safari-606-branch/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp (233950 => 233951)


--- branches/safari-606-branch/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp	2018-07-19 01:59:38 UTC (rev 233951)
@@ -189,5 +189,14 @@
 {
 }
 
+bool PlatformWebView::drawsBackground() const
+{
+    return false;
+}
+
+void PlatformWebView::setDrawsBackground(bool)
+{
+}
+
 } // namespace WTR
 

Modified: branches/safari-606-branch/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm (233950 => 233951)


--- branches/safari-606-branch/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm	2018-07-19 01:59:38 UTC (rev 233951)
@@ -294,6 +294,15 @@
     // Retina only surface.
 }
 
+bool PlatformWebView::drawsBackground() const
+{
+    return false;
+}
+
+void PlatformWebView::setDrawsBackground(bool)
+{
+}
+
 #if !HAVE(IOSURFACE)
 static void releaseDataProviderData(void* info, const void*, size_t)
 {

Modified: branches/safari-606-branch/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm (233950 => 233951)


--- branches/safari-606-branch/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm	2018-07-19 01:59:38 UTC (rev 233951)
@@ -272,6 +272,24 @@
     [m_window makeFirstResponder:platformView()];
 }
 
+bool PlatformWebView::drawsBackground() const
+{
+#if WK_API_ENABLED
+    return [m_view _drawsBackground];
+#else
+    return false;
+#endif
+}
+
+void PlatformWebView::setDrawsBackground(bool drawsBackground)
+{
+#if WK_API_ENABLED
+    [m_view _setDrawsBackground:drawsBackground];
+#else
+    UNUSED_PARAM(drawsBackground);
+#endif
+}
+
 RetainPtr<CGImageRef> PlatformWebView::windowSnapshotImage()
 {
     [platformView() display];

Modified: branches/safari-606-branch/Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp (233950 => 233951)


--- branches/safari-606-branch/Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp	2018-07-19 01:59:27 UTC (rev 233950)
+++ branches/safari-606-branch/Tools/WebKitTestRunner/wpe/PlatformWebViewWPE.cpp	2018-07-19 01:59:38 UTC (rev 233951)
@@ -132,4 +132,13 @@
 {
 }
 
+bool PlatformWebView::drawsBackground() const
+{
+    return false;
+}
+
+void PlatformWebView::setDrawsBackground(bool)
+{
+}
+
 } // namespace WTR
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to