Clean up how GraphicsLayer's "inWindow" state is set, and fix some issues with Page...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Feb 2017 19:18:16 +0000 (19:18 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Feb 2017 19:18:16 +0000 (19:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167850

Reviewed by Tim Horton.
Source/WebCore:

RenderLayerCompositor::setIsInWindowForLayerIncludingDescendants() walked the RenderLayer
tree to set the GraphicsLayer's "inWindow" state. This had the problem of skipping non-primary
GraphicsLayers. We also never did this work for page overlay layers.

Fix by giving GraphicsLayers a recursive function that sets the inWindow state, and call that
from RenderLayerCompositor::setIsInWindow() and PageOverlayController.

PageOverlayController also needs to implement tiledBackingUsageChanged so that tiled backings
created dynamically get the correct in-window state.

Page overlays also had some serious issues in MiniBrowser, in that they disappeared on reload,
and on hide/show web view. This was because the overlay root layers were re-parented, but
addChild() for each overlay's layer wasn't called. Clean up by replacing willAttachRootLayer() followed
by viewOverlayRootLayer()/documentOverlayRootLayer() with single calls that set up the layers,
update the inWindow state, and return the layer.

Make it possible to dump tile caches in page overlay tests.

Make showGraphicsLayers() always dump page overlay layers (source of much confusion).

Test: pageoverlay/overlay-remove-reinsert-view.html

* page/PageOverlayController.cpp:
(WebCore::PageOverlayController::documentOverlayRootLayer):
(WebCore::PageOverlayController::viewOverlayRootLayer):
(WebCore::PageOverlayController::layerWithDocumentOverlays):
(WebCore::PageOverlayController::layerWithViewOverlays):
(WebCore::PageOverlayController::tiledBackingUsageChanged):
(WebCore::PageOverlayController::willAttachRootLayer): Deleted.
* page/PageOverlayController.h:
* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::setIsInWindowIncludingDescendants):
(WebCore::dumpChildren):
* platform/graphics/GraphicsLayer.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::appendDocumentOverlayLayers):
(WebCore::RenderLayerCompositor::setIsInWindow):
(WebCore::RenderLayerCompositor::attachRootLayer):
(WebCore::RenderLayerCompositor::rootLayerAttachmentChanged):
(WebCore::RenderLayerCompositor::setIsInWindowForLayerIncludingDescendants): Deleted.
* rendering/RenderLayerCompositor.h:
* testing/Internals.cpp:
(WebCore::toLayerTreeFlags):
(WebCore::Internals::layerTreeAsText):
(WebCore::Internals::pageOverlayLayerTreeAsText):
* testing/Internals.h:
* testing/Internals.idl:
* testing/MockPageOverlayClient.cpp:
(WebCore::MockPageOverlayClient::layerTreeAsText):
* testing/MockPageOverlayClient.h:

Tools:

* DumpRenderTree/TestRunner.cpp:
(TestRunner::uiScriptDidComplete): Fix an assertion that fires for non-16-bit strings.

LayoutTests:

* pageoverlay/overlay-large-document-expected.txt:
* pageoverlay/overlay-large-document-scrolled-expected.txt:
* pageoverlay/overlay-remove-reinsert-view-expected.txt: Added.
* pageoverlay/overlay-remove-reinsert-view.html: Added.
* platform/ios-simulator-wk2/pageoverlay/overlay-remove-reinsert-view-expected.txt: Added.
* platform/mac-wk1/pageoverlay/overlay-remove-reinsert-view-expected.txt: Added.
* tiled-drawing/tiled-backing-in-window-expected.txt:

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

23 files changed:
LayoutTests/ChangeLog
LayoutTests/pageoverlay/overlay-large-document-expected.txt
LayoutTests/pageoverlay/overlay-large-document-scrolled-expected.txt
LayoutTests/pageoverlay/overlay-remove-reinsert-view-expected.txt [new file with mode: 0644]
LayoutTests/pageoverlay/overlay-remove-reinsert-view.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator-wk2/pageoverlay/overlay-remove-reinsert-view-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/mac-wk1/pageoverlay/overlay-remove-reinsert-view-expected.txt [new file with mode: 0644]
LayoutTests/tiled-drawing/tiled-backing-in-window-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/page/PageOverlayController.cpp
Source/WebCore/page/PageOverlayController.h
Source/WebCore/platform/graphics/GraphicsLayer.cpp
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebCore/testing/MockPageOverlayClient.cpp
Source/WebCore/testing/MockPageOverlayClient.h
Tools/ChangeLog
Tools/DumpRenderTree/TestRunner.cpp

index 2d05a5ac36ecfcaaac7a100c4aae3309f268bbb8..807fb0ca16e006d8ecea437c45af7ba265218c39 100644 (file)
@@ -1,3 +1,18 @@
+2017-02-04  Simon Fraser  <simon.fraser@apple.com>
+
+        Clean up how GraphicsLayer's "inWindow" state is set, and fix some issues with Page Overlays
+        https://bugs.webkit.org/show_bug.cgi?id=167850
+
+        Reviewed by Tim Horton.
+
+        * pageoverlay/overlay-large-document-expected.txt:
+        * pageoverlay/overlay-large-document-scrolled-expected.txt:
+        * pageoverlay/overlay-remove-reinsert-view-expected.txt: Added.
+        * pageoverlay/overlay-remove-reinsert-view.html: Added.
+        * platform/ios-simulator-wk2/pageoverlay/overlay-remove-reinsert-view-expected.txt: Added.
+        * platform/mac-wk1/pageoverlay/overlay-remove-reinsert-view-expected.txt: Added.
+        * tiled-drawing/tiled-backing-in-window-expected.txt:
+
 2017-02-05  Zalan Bujtas  <zalan@apple.com>
 
         Simple line layout: Use RenderText::canUseSimpleFontCodePath() only as a hint.
index 7b43c96fd616e109c368a0cd5ef01538db4deb63..b1e9717913b07aea2c34157cb5facb63ef9e599f 100644 (file)
@@ -8,7 +8,7 @@ View-relative:
   (children 1
     (GraphicsLayer
       (anchor 0.00 0.00)
-      (bounds 785.00 585.00)
+      (bounds 800.00 600.00)
       (drawsContent 1)
       (backgroundColor #00000000)
     )
index c2c8ee5ba2c60af64d7fe7def70f5de49c1f6e48..4d004ddec7766b2ee8fdcef48e2cb24c7f097fb7 100644 (file)
@@ -8,7 +8,7 @@ View-relative:
   (children 1
     (GraphicsLayer
       (anchor 0.00 0.00)
-      (bounds 785.00 585.00)
+      (bounds 800.00 600.00)
       (drawsContent 1)
       (backgroundColor #00000000)
     )
diff --git a/LayoutTests/pageoverlay/overlay-remove-reinsert-view-expected.txt b/LayoutTests/pageoverlay/overlay-remove-reinsert-view-expected.txt
new file mode 100644 (file)
index 0000000..e46a847
--- /dev/null
@@ -0,0 +1,76 @@
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (0, 0, 785, 585)
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (512, 512, 512, 512)
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (0, 512, 512, 512)
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (512, 0, 512, 512)
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (0, 0, 512, 512)
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (0, 0, 785, 585)
+Initial layers
+
+View-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 800.00 600.00)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+    )
+  )
+)
+
+
+Document-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 5008.00 5016.00)
+      (usingTiledLayer 1)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+    )
+  )
+)
+Layers after removal
+
+View-relative:
+(no view-relative overlay root)
+
+Document-relative:
+(no document-relative overlay root)
+Layers after re-insertion
+
+View-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 785.00 585.00)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+    )
+  )
+)
+
+
+Document-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 5008.00 5016.00)
+      (usingTiledLayer 1)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+    )
+  )
+)
+
diff --git a/LayoutTests/pageoverlay/overlay-remove-reinsert-view.html b/LayoutTests/pageoverlay/overlay-remove-reinsert-view.html
new file mode 100644 (file)
index 0000000..1f65688
--- /dev/null
@@ -0,0 +1,87 @@
+<html>
+<style>
+body {
+    height: 5000px;
+    width: 5000px;
+}
+</style>
+<script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    function getWaitForPresentationUpdateUIScript()
+    {
+        return `
+        (function() {
+            uiController.doAfterPresentationUpdate(function() {
+                uiController.uiScriptComplete('');
+            });
+        })();`
+    }
+
+    function getUnparentUIScript()
+    {
+        return `
+        (function() {
+            uiController.removeViewFromWindow(function() {
+                uiController.uiScriptComplete('');
+            });
+        })();`
+    }
+
+    function getReinsertUIScript()
+    {
+        return `
+        (function() {
+            uiController.addViewToWindow(function() {
+                uiController.uiScriptComplete('');
+            });
+        })();`
+    }
+
+    function dumpLayers(outputId)
+    {
+        if (window.internals) {
+            document.getElementById(outputId).innerText = window.internals.pageOverlayLayerTreeAsText(internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+        }
+    }
+
+    function doTest()
+    {
+        if (!window.testRunner || !testRunner.runUIScript)
+            return;
+
+        internals.installMockPageOverlay("document");
+        internals.installMockPageOverlay("view");
+
+        // Waiting for a presentation update is needed to get the document overlay to become tiled.
+        testRunner.runUIScript(getWaitForPresentationUpdateUIScript(), function(result) {
+            dumpLayers('before-layers');
+
+            testRunner.runUIScript(getUnparentUIScript(), function(result) {
+                dumpLayers('view-removed-layers');
+
+                testRunner.runUIScript(getReinsertUIScript(), function(result) {
+                    dumpLayers('view-reinsertion-layers');
+                    if (window.testRunner)
+                        testRunner.notifyDone();
+                });
+            });
+        });
+    }
+
+    window.addEventListener('load', doTest, false);
+</script>
+<body>
+    <h2>Initial layers</h2>
+    <pre id="before-layers">Layer tree goes here</pre>
+
+    <h2>Layers after removal</h2>
+    <pre id="view-removed-layers">Layer tree goes here</pre>
+
+    <h2>Layers after re-insertion</h2>
+    <pre id="view-reinsertion-layers">Layer tree goes here</pre>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/platform/ios-simulator-wk2/pageoverlay/overlay-remove-reinsert-view-expected.txt b/LayoutTests/platform/ios-simulator-wk2/pageoverlay/overlay-remove-reinsert-view-expected.txt
new file mode 100644 (file)
index 0000000..76f8e55
--- /dev/null
@@ -0,0 +1,100 @@
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (0, 0, 512, 512)
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (512, 0, 512, 512)
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (0, 512, 512, 512)
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (512, 512, 512, 512)
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (0, 0, 800, 600)
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (0, 0, 800, 600)
+Initial layers
+
+View-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 800.00 600.00)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+    )
+  )
+)
+
+
+Document-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 5008.00 5016.00)
+      (usingTiledLayer 1)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+    )
+  )
+)
+Layers after removal
+
+View-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 800.00 600.00)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+    )
+  )
+)
+
+
+Document-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 5008.00 5016.00)
+      (usingTiledLayer 1)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+    )
+  )
+)
+Layers after re-insertion
+
+View-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 800.00 600.00)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+    )
+  )
+)
+
+
+Document-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 5008.00 5016.00)
+      (usingTiledLayer 1)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+    )
+  )
+)
+
index 42cae0b06a67bb03ffd4f95442f178dc5d50be55..a307c4d5324dff825b3769bdff383242dde4f650 100644 (file)
@@ -305,3 +305,5 @@ webkit.org/b/167347 media/modern-media-controls/airplay-button/airplay-button-on
 webkit.org/b/163598 media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-buttons-styles.html [ Pass Timeout ]
 
 webkit.org/b/167127 pointer-lock/locked-element-removed-from-dom.html
+
+webkit.org/b/167857 pageoverlay/overlay-remove-reinsert-view.html [ Skip ]
diff --git a/LayoutTests/platform/mac-wk1/pageoverlay/overlay-remove-reinsert-view-expected.txt b/LayoutTests/platform/mac-wk1/pageoverlay/overlay-remove-reinsert-view-expected.txt
new file mode 100644 (file)
index 0000000..7fab6ae
--- /dev/null
@@ -0,0 +1,74 @@
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (512, 512, 512, 512)
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (0, 512, 512, 512)
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (512, 0, 512, 512)
+CONSOLE MESSAGE: MockPageOverlayClient::drawRect dirtyRect (0, 0, 512, 512)
+Initial layers
+
+View-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 800.00 600.00)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+    )
+  )
+)
+
+
+Document-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 5008.00 5016.00)
+      (usingTiledLayer 1)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+    )
+  )
+)
+Layers after removal
+
+View-relative:
+(no view-relative overlay root)
+
+Document-relative:
+(no document-relative overlay root)
+Layers after re-insertion
+
+View-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 800.00 600.00)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+    )
+  )
+)
+
+
+Document-relative:
+(GraphicsLayer
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 5008.00 5016.00)
+      (usingTiledLayer 1)
+      (drawsContent 1)
+      (backgroundColor #00000000)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+    )
+  )
+)
+
index d5cd7fbe4bf524376ff59535633f71e17616b3cd..da114e18f07de188c57bb1fee4854b0506a29b1f 100644 (file)
@@ -55,7 +55,7 @@ Tiled box
       (tile cache coverage 0, 0 1024 x 1016)
       (tile size 512 x 512)
       (top left tile 0, 0 tiles grid 2 x 2)
-      (in window 0)
+      (in window 1)
       (children 1
         (GraphicsLayer
           (position 8.00 8.00)
index b7f343a966a66cc36b0359010111b34e3c5af74b..8aac96b58de6d1c97759123b5ba8995b120a70a1 100644 (file)
@@ -1,3 +1,61 @@
+2017-02-04  Simon Fraser  <simon.fraser@apple.com>
+
+        Clean up how GraphicsLayer's "inWindow" state is set, and fix some issues with Page Overlays
+        https://bugs.webkit.org/show_bug.cgi?id=167850
+
+        Reviewed by Tim Horton.
+        
+        RenderLayerCompositor::setIsInWindowForLayerIncludingDescendants() walked the RenderLayer
+        tree to set the GraphicsLayer's "inWindow" state. This had the problem of skipping non-primary
+        GraphicsLayers. We also never did this work for page overlay layers.
+
+        Fix by giving GraphicsLayers a recursive function that sets the inWindow state, and call that
+        from RenderLayerCompositor::setIsInWindow() and PageOverlayController.
+
+        PageOverlayController also needs to implement tiledBackingUsageChanged so that tiled backings
+        created dynamically get the correct in-window state.
+
+        Page overlays also had some serious issues in MiniBrowser, in that they disappeared on reload,
+        and on hide/show web view. This was because the overlay root layers were re-parented, but
+        addChild() for each overlay's layer wasn't called. Clean up by replacing willAttachRootLayer() followed
+        by viewOverlayRootLayer()/documentOverlayRootLayer() with single calls that set up the layers,
+        update the inWindow state, and return the layer.
+
+        Make it possible to dump tile caches in page overlay tests.
+
+        Make showGraphicsLayers() always dump page overlay layers (source of much confusion).
+
+        Test: pageoverlay/overlay-remove-reinsert-view.html
+
+        * page/PageOverlayController.cpp:
+        (WebCore::PageOverlayController::documentOverlayRootLayer):
+        (WebCore::PageOverlayController::viewOverlayRootLayer):
+        (WebCore::PageOverlayController::layerWithDocumentOverlays):
+        (WebCore::PageOverlayController::layerWithViewOverlays):
+        (WebCore::PageOverlayController::tiledBackingUsageChanged):
+        (WebCore::PageOverlayController::willAttachRootLayer): Deleted.
+        * page/PageOverlayController.h:
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::setIsInWindowIncludingDescendants):
+        (WebCore::dumpChildren):
+        * platform/graphics/GraphicsLayer.h:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::appendDocumentOverlayLayers):
+        (WebCore::RenderLayerCompositor::setIsInWindow):
+        (WebCore::RenderLayerCompositor::attachRootLayer):
+        (WebCore::RenderLayerCompositor::rootLayerAttachmentChanged):
+        (WebCore::RenderLayerCompositor::setIsInWindowForLayerIncludingDescendants): Deleted.
+        * rendering/RenderLayerCompositor.h:
+        * testing/Internals.cpp:
+        (WebCore::toLayerTreeFlags):
+        (WebCore::Internals::layerTreeAsText):
+        (WebCore::Internals::pageOverlayLayerTreeAsText):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+        * testing/MockPageOverlayClient.cpp:
+        (WebCore::MockPageOverlayClient::layerTreeAsText):
+        * testing/MockPageOverlayClient.h:
+
 2017-02-05  Zalan Bujtas  <zalan@apple.com>
 
         Simple line layout: Use RenderText::canUseSimpleFontCodePath() only as a hint.
index 9f1e54c1886ced64f9bcceb77df9b08699c4fe56..721993de9d54aa3d2ffbe241378ebe05ad70d1e4 100644 (file)
@@ -72,16 +72,14 @@ void PageOverlayController::createRootLayersIfNeeded()
 #endif
 }
 
-GraphicsLayer& PageOverlayController::documentOverlayRootLayer()
+GraphicsLayer* PageOverlayController::documentOverlayRootLayer() const
 {
-    createRootLayersIfNeeded();
-    return *m_documentOverlayRootLayer;
+    return m_documentOverlayRootLayer.get();
 }
 
-GraphicsLayer& PageOverlayController::viewOverlayRootLayer()
+GraphicsLayer* PageOverlayController::viewOverlayRootLayer() const
 {
-    createRootLayersIfNeeded();
-    return *m_viewOverlayRootLayer;
+    return m_viewOverlayRootLayer.get();
 }
 
 static void updateOverlayGeometry(PageOverlay& overlay, GraphicsLayer& graphicsLayer)
@@ -95,6 +93,50 @@ static void updateOverlayGeometry(PageOverlay& overlay, GraphicsLayer& graphicsL
     graphicsLayer.setSize(overlayFrame.size());
 }
 
+GraphicsLayer& PageOverlayController::layerWithDocumentOverlays()
+{
+    createRootLayersIfNeeded();
+
+    bool inWindow = m_mainFrame.page() ? m_mainFrame.page()->isInWindow() : false;
+
+    for (auto& overlayAndLayer : m_overlayGraphicsLayers) {
+        PageOverlay& overlay = *overlayAndLayer.key;
+        if (overlay.overlayType() != PageOverlay::OverlayType::Document)
+            continue;
+
+        GraphicsLayer& layer = *overlayAndLayer.value;
+        layer.setIsInWindowIncludingDescendants(inWindow);
+        updateOverlayGeometry(overlay, layer);
+        
+        if (!layer.parent())
+            m_documentOverlayRootLayer->addChild(&layer);
+    }
+
+    return *m_documentOverlayRootLayer;
+}
+
+GraphicsLayer& PageOverlayController::layerWithViewOverlays()
+{
+    createRootLayersIfNeeded();
+
+    bool inWindow = m_mainFrame.page() ? m_mainFrame.page()->isInWindow() : false;
+
+    for (auto& overlayAndLayer : m_overlayGraphicsLayers) {
+        PageOverlay& overlay = *overlayAndLayer.key;
+        if (overlay.overlayType() != PageOverlay::OverlayType::View)
+            continue;
+
+        GraphicsLayer& layer = *overlayAndLayer.value;
+        layer.setIsInWindowIncludingDescendants(inWindow);
+        updateOverlayGeometry(overlay, layer);
+        
+        if (!layer.parent())
+            m_viewOverlayRootLayer->addChild(&layer);
+    }
+
+    return *m_viewOverlayRootLayer;
+}
+
 void PageOverlayController::installPageOverlay(PageOverlay& overlay, PageOverlay::FadeMode fadeMode)
 {
     createRootLayersIfNeeded();
@@ -201,12 +243,6 @@ GraphicsLayer& PageOverlayController::layerForOverlay(PageOverlay& overlay) cons
     return *m_overlayGraphicsLayers.get(&overlay);
 }
 
-void PageOverlayController::willAttachRootLayer()
-{
-    for (auto& overlayAndLayer : m_overlayGraphicsLayers)
-        updateOverlayGeometry(*overlayAndLayer.key, *overlayAndLayer.value);
-}
-
 void PageOverlayController::willDetachRootLayer()
 {
     m_documentOverlayRootLayer = nullptr;
@@ -367,4 +403,10 @@ bool PageOverlayController::shouldSkipLayerInDump(const GraphicsLayer*, LayerTre
     return !(behavior & LayerTreeAsTextIncludePageOverlayLayers);
 }
 
+void PageOverlayController::tiledBackingUsageChanged(const GraphicsLayer* graphicsLayer, bool usingTiledBacking)
+{
+    if (usingTiledBacking)
+        graphicsLayer->tiledBacking()->setIsInWindow(m_mainFrame.page()->isInWindow());
+}
+
 } // namespace WebKit
index bfb410d2088b20ddcc45e373b70d44e2267060f1..0546929ae6547120db48d099126dfbd8e1c42039 100644 (file)
@@ -44,8 +44,11 @@ public:
     PageOverlayController(MainFrame&);
     virtual ~PageOverlayController();
 
-    WEBCORE_EXPORT GraphicsLayer& documentOverlayRootLayer();
-    WEBCORE_EXPORT GraphicsLayer& viewOverlayRootLayer();
+    GraphicsLayer& layerWithDocumentOverlays();
+    GraphicsLayer& layerWithViewOverlays();
+
+    WEBCORE_EXPORT GraphicsLayer* documentOverlayRootLayer() const;
+    WEBCORE_EXPORT GraphicsLayer* viewOverlayRootLayer() const;
 
     const Vector<RefPtr<PageOverlay>>& pageOverlays() const { return m_pageOverlays; }
 
@@ -57,7 +60,6 @@ public:
     void clearPageOverlay(PageOverlay&);
     GraphicsLayer& layerForOverlay(PageOverlay&) const;
 
-    void willAttachRootLayer();
     void willDetachRootLayer();
 
     void didChangeViewSize();
@@ -89,6 +91,7 @@ private:
     void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& clipRect) override;
     float deviceScaleFactor() const override;
     bool shouldSkipLayerInDump(const GraphicsLayer*, LayerTreeAsTextBehavior) const override;
+    void tiledBackingUsageChanged(const GraphicsLayer*, bool) override;
 
     std::unique_ptr<GraphicsLayer> m_documentOverlayRootLayer;
     std::unique_ptr<GraphicsLayer> m_viewOverlayRootLayer;
index c36851f3ad343c6aecbd67053d9a8ed04fec4beb..2c40fc7af5a1c95259c46176dd396f550eae5b3b 100644 (file)
@@ -364,6 +364,15 @@ void GraphicsLayer::noteDeviceOrPageScaleFactorChangedIncludingDescendants()
         childLayers[i]->noteDeviceOrPageScaleFactorChangedIncludingDescendants();
 }
 
+void GraphicsLayer::setIsInWindowIncludingDescendants(bool inWindow)
+{
+    if (usingTiledBacking())
+        tiledBacking()->setIsInWindow(inWindow);
+
+    for (auto* childLayer : children())
+        childLayer->setIsInWindowIncludingDescendants(inWindow);
+}
+
 void GraphicsLayer::setReplicatedByLayer(GraphicsLayer* layer)
 {
     if (m_replicaLayer == layer)
@@ -680,7 +689,7 @@ static void dumpChildren(TextStream& ts, const Vector<GraphicsLayer*>& children,
 {
     totalChildCount += children.size();
     for (auto* child : children) {
-        if (!child->client().shouldSkipLayerInDump(child, behavior)) {
+        if ((behavior & LayerTreeAsTextDebug) || !child->client().shouldSkipLayerInDump(child, behavior)) {
             child->dumpLayer(ts, indent + 2, behavior);
             continue;
         }
index fe37d2534bfc10712b640121e2f5bd2324baebaa..68b3aee5f7b922a6ba426910e9fbc92a698fc683 100644 (file)
@@ -517,6 +517,8 @@ public:
     virtual void deviceOrPageScaleFactorChanged() { }
     WEBCORE_EXPORT void noteDeviceOrPageScaleFactorChangedIncludingDescendants();
 
+    void setIsInWindowIncludingDescendants(bool);
+
     // Some compositing systems may do internal batching to synchronize compositing updates
     // with updates drawn into the window. These methods flush internal batched state on this layer
     // and descendant layers, and this layer only.
index 1a1422305a3eeb9bc097b7395680cef1ebc48910..50b670941d830cb865b7e990dea054afc9298a21 100644 (file)
@@ -777,9 +777,7 @@ void RenderLayerCompositor::appendDocumentOverlayLayers(Vector<GraphicsLayer*>&
         return;
 
     Frame& frame = m_renderView.frameView().frame();
-    PageOverlayController& pageOverlayController = frame.mainFrame().pageOverlayController();
-    pageOverlayController.willAttachRootLayer();
-    childList.append(&pageOverlayController.documentOverlayRootLayer());
+    childList.append(&frame.mainFrame().pageOverlayController().layerWithDocumentOverlays());
 }
 
 void RenderLayerCompositor::layerBecameNonComposited(const RenderLayer& layer)
@@ -2027,28 +2025,14 @@ GraphicsLayer* RenderLayerCompositor::footerLayer() const
 }
 #endif
 
-void RenderLayerCompositor::setIsInWindowForLayerIncludingDescendants(RenderLayer& layer, bool isInWindow)
-{
-    if (layer.isComposited()) {
-        if (auto* backing = layer.backing()->tiledBacking())
-            backing->setIsInWindow(isInWindow);
-    }
-
-    // No need to recurse if we don't have any other tiled layers.
-    if (!hasNonMainLayersWithTiledBacking())
-        return;
-
-    for (RenderLayer* childLayer = layer.firstChild(); childLayer; childLayer = childLayer->nextSibling())
-        setIsInWindowForLayerIncludingDescendants(*childLayer, isInWindow);
-}
-
 void RenderLayerCompositor::setIsInWindow(bool isInWindow)
 {
-    setIsInWindowForLayerIncludingDescendants(*m_renderView.layer(), isInWindow);
-    
     if (!inCompositingMode())
         return;
 
+    if (GraphicsLayer* rootLayer = rootGraphicsLayer())
+        rootLayer->setIsInWindowIncludingDescendants(isInWindow);
+
     if (isInWindow) {
         if (m_rootLayerAttachment != RootLayerUnattached)
             return;
@@ -3468,11 +3452,8 @@ void RenderLayerCompositor::attachRootLayer(RootLayerAttachment attachment)
         case RootLayerAttachedViaChromeClient: {
             Frame& frame = m_renderView.frameView().frame();
             page().chrome().client().attachRootGraphicsLayer(frame, rootGraphicsLayer());
-            if (frame.isMainFrame()) {
-                PageOverlayController& pageOverlayController = frame.mainFrame().pageOverlayController();
-                pageOverlayController.willAttachRootLayer();
-                page().chrome().client().attachViewOverlayGraphicsLayer(frame, &pageOverlayController.viewOverlayRootLayer());
-            }
+            if (frame.isMainFrame())
+                page().chrome().client().attachViewOverlayGraphicsLayer(frame, &frame.mainFrame().pageOverlayController().layerWithViewOverlays());
             break;
         }
         case RootLayerAttachedViaEnclosingFrame: {
@@ -3551,9 +3532,7 @@ void RenderLayerCompositor::rootLayerAttachmentChanged()
     if (!frame.isMainFrame())
         return;
 
-    PageOverlayController& pageOverlayController = frame.mainFrame().pageOverlayController();
-    pageOverlayController.willAttachRootLayer();
-    m_rootContentLayer->addChild(&pageOverlayController.documentOverlayRootLayer());
+    m_rootContentLayer->addChild(&frame.mainFrame().pageOverlayController().layerWithDocumentOverlays());
 }
 
 void RenderLayerCompositor::notifyIFramesOfCompositingChange()
index 8d5b73b71711b9590e2e3310b8df1ad81b6cf456..873c0449fd15ed6f372ca3d5aa414c4c97d153cf 100644 (file)
@@ -350,7 +350,6 @@ private:
     bool updateBacking(RenderLayer&, CompositingChangeRepaint shouldRepaint, BackingRequired = BackingRequired::Unknown);
 
     void clearBackingForLayerIncludingDescendants(RenderLayer&);
-    void setIsInWindowForLayerIncludingDescendants(RenderLayer&, bool isInWindow);
 
     // Repaint this and its child layers.
     void recursiveRepaintLayer(RenderLayer&);
index e8b6215bc627538d35999b74556eb62ac3324e51..f5139e29ccf71046e21e2c30098d93edf58bb6da 100644 (file)
@@ -2016,6 +2016,23 @@ ExceptionOr<bool> Internals::isPageBoxVisible(int pageNumber)
     return document->isPageBoxVisible(pageNumber);
 }
 
+static LayerTreeFlags toLayerTreeFlags(unsigned short flags)
+{
+    LayerTreeFlags layerTreeFlags = 0;
+    if (flags & Internals::LAYER_TREE_INCLUDES_VISIBLE_RECTS)
+        layerTreeFlags |= LayerTreeFlagsIncludeVisibleRects;
+    if (flags & Internals::LAYER_TREE_INCLUDES_TILE_CACHES)
+        layerTreeFlags |= LayerTreeFlagsIncludeTileCaches;
+    if (flags & Internals::LAYER_TREE_INCLUDES_REPAINT_RECTS)
+        layerTreeFlags |= LayerTreeFlagsIncludeRepaintRects;
+    if (flags & Internals::LAYER_TREE_INCLUDES_PAINTING_PHASES)
+        layerTreeFlags |= LayerTreeFlagsIncludePaintingPhases;
+    if (flags & Internals::LAYER_TREE_INCLUDES_CONTENT_LAYERS)
+        layerTreeFlags |= LayerTreeFlagsIncludeContentLayers;
+
+    return layerTreeFlags;
+}
+
 // FIXME: Remove the document argument. It is almost always the same as
 // contextDocument(), with the exception of a few tests that pass a
 // different document, and could just make the call through another Internals
@@ -2025,19 +2042,7 @@ ExceptionOr<String> Internals::layerTreeAsText(Document& document, unsigned shor
     if (!document.frame())
         return Exception { INVALID_ACCESS_ERR };
 
-    LayerTreeFlags layerTreeFlags = 0;
-    if (flags & LAYER_TREE_INCLUDES_VISIBLE_RECTS)
-        layerTreeFlags |= LayerTreeFlagsIncludeVisibleRects;
-    if (flags & LAYER_TREE_INCLUDES_TILE_CACHES)
-        layerTreeFlags |= LayerTreeFlagsIncludeTileCaches;
-    if (flags & LAYER_TREE_INCLUDES_REPAINT_RECTS)
-        layerTreeFlags |= LayerTreeFlagsIncludeRepaintRects;
-    if (flags & LAYER_TREE_INCLUDES_PAINTING_PHASES)
-        layerTreeFlags |= LayerTreeFlagsIncludePaintingPhases;
-    if (flags & LAYER_TREE_INCLUDES_CONTENT_LAYERS)
-        layerTreeFlags |= LayerTreeFlagsIncludeContentLayers;
-
-    return document.frame()->layerTreeAsText(layerTreeFlags);
+    return document.frame()->layerTreeAsText(toLayerTreeFlags(flags));
 }
 
 ExceptionOr<String> Internals::repaintRectsAsText() const
@@ -3250,7 +3255,7 @@ ExceptionOr<Ref<MockPageOverlay>> Internals::installMockPageOverlay(PageOverlayT
     return MockPageOverlayClient::singleton().installOverlay(document->frame()->mainFrame(), type == PageOverlayType::View ? PageOverlay::OverlayType::View : PageOverlay::OverlayType::Document);
 }
 
-ExceptionOr<String> Internals::pageOverlayLayerTreeAsText() const
+ExceptionOr<String> Internals::pageOverlayLayerTreeAsText(unsigned short flags) const
 {
     Document* document = contextDocument();
     if (!document || !document->frame())
@@ -3258,7 +3263,7 @@ ExceptionOr<String> Internals::pageOverlayLayerTreeAsText() const
 
     document->updateLayout();
 
-    return MockPageOverlayClient::singleton().layerTreeAsText(document->frame()->mainFrame());
+    return MockPageOverlayClient::singleton().layerTreeAsText(document->frame()->mainFrame(), toLayerTreeFlags(flags));
 }
 
 void Internals::setPageMuted(const String& states)
index 5c4e2a7e38d3dcdf8a3afc2100a4f9e0b580a1a4..24659f36d4ab7d43c95ca445b29be5b9d82e0ad3 100644 (file)
@@ -465,7 +465,7 @@ public:
 
     enum class PageOverlayType { View, Document };
     ExceptionOr<Ref<MockPageOverlay>> installMockPageOverlay(PageOverlayType);
-    ExceptionOr<String> pageOverlayLayerTreeAsText() const;
+    ExceptionOr<String> pageOverlayLayerTreeAsText(unsigned short flags) const;
 
     void setPageMuted(const String&);
     String pageMediaState();
index 43a98fa9bab557f7e61df06e0bb3a209b75cae74..21a8153e641f710c5d85114e461f47526f6a6184 100644 (file)
@@ -445,7 +445,7 @@ enum EventThrottlingBehavior {
     [Conditional=VIDEO] boolean elementIsBlockingDisplaySleep(HTMLMediaElement element);
 
     [MayThrowException] MockPageOverlay installMockPageOverlay(PageOverlayType type);
-    [MayThrowException] DOMString pageOverlayLayerTreeAsText();
+    [MayThrowException] DOMString pageOverlayLayerTreeAsText(optional unsigned short flags = 0);
 
     void setPageMuted(DOMString mutedState);
     DOMString pageMediaState();
index 0044041bf7578c3c2a8617b7fe766fd2cbcb2d73..d0b4bab4caa1e509c753c641a720b001703dac20 100644 (file)
@@ -69,9 +69,13 @@ void MockPageOverlayClient::uninstallAllOverlays()
     }
 }
 
-String MockPageOverlayClient::layerTreeAsText(MainFrame& mainFrame)
+String MockPageOverlayClient::layerTreeAsText(MainFrame& mainFrame, LayerTreeFlags flags)
 {
-    return "View-relative:\n" + mainFrame.pageOverlayController().viewOverlayRootLayer().layerTreeAsText(LayerTreeAsTextIncludePageOverlayLayers) + "\n\nDocument-relative:\n" + mainFrame.pageOverlayController().documentOverlayRootLayer().layerTreeAsText(LayerTreeAsTextIncludePageOverlayLayers);
+    GraphicsLayer* viewOverlayRoot = mainFrame.pageOverlayController().viewOverlayRootLayer();
+    GraphicsLayer* documentOverlayRoot = mainFrame.pageOverlayController().documentOverlayRootLayer();
+    
+    return "View-relative:\n" + (viewOverlayRoot ? viewOverlayRoot->layerTreeAsText(flags | LayerTreeAsTextIncludePageOverlayLayers) : "(no view-relative overlay root)")
+        + "\n\nDocument-relative:\n" + (documentOverlayRoot ? documentOverlayRoot->layerTreeAsText(flags | LayerTreeAsTextIncludePageOverlayLayers) : "(no document-relative overlay root)");
 }
 
 void MockPageOverlayClient::willMoveToPage(PageOverlay&, Page*)
index 81e4c185ec863f9e655c23d851d65ed05927a5e0..377d7ab04c3bb0d497717a0d07650f0d3097ff53 100644 (file)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "Frame.h"
 #include "MockPageOverlay.h"
 #include "PageOverlay.h"
 #include <wtf/HashSet.h>
@@ -43,7 +44,7 @@ public:
     Ref<MockPageOverlay> installOverlay(MainFrame&, PageOverlay::OverlayType);
     void uninstallAllOverlays();
 
-    String layerTreeAsText(MainFrame&);
+    String layerTreeAsText(MainFrame&, LayerTreeFlags);
 
     virtual ~MockPageOverlayClient() { }
 
index 62cbcbb0b496e268b729b7fd1876dc7905a37d89..480d317a783caef6df264896b200283f42fc07fa 100644 (file)
@@ -1,3 +1,13 @@
+2017-02-04  Simon Fraser  <simon.fraser@apple.com>
+
+        Clean up how GraphicsLayer's "inWindow" state is set, and fix some issues with Page Overlays
+        https://bugs.webkit.org/show_bug.cgi?id=167850
+
+        Reviewed by Tim Horton.
+
+        * DumpRenderTree/TestRunner.cpp:
+        (TestRunner::uiScriptDidComplete): Fix an assertion that fires for non-16-bit strings.
+
 2017-02-04  Andreas Kling  <akling@apple.com>
 
         Plug some leaks in TestController and UIScriptContext.
index 00e4b47ab1ecc6c24b38e9b9ab539bd2ee8378c1..ca6d1bc9394912b4333e00c904cd05af0e15c56a 100644 (file)
@@ -2431,7 +2431,7 @@ void TestRunner::callUIScriptCallback(unsigned callbackID, JSStringRef result)
 
 void TestRunner::uiScriptDidComplete(const String& result, unsigned callbackID)
 {
-    JSRetainPtr<JSStringRef> stringRef(Adopt, JSStringCreateWithCharacters(result.characters16(), result.length()));
+    JSRetainPtr<JSStringRef> stringRef(Adopt, JSStringCreateWithUTF8CString(result.utf8().data()));
     callUIScriptCallback(callbackID, stringRef.get());
 }