Title: [208666] trunk
Revision
208666
Author
[email protected]
Date
2016-11-12 23:19:07 -0800 (Sat, 12 Nov 2016)

Log Message

Add a way to get the UI-side scrolling tree as text via UIScriptController
https://bugs.webkit.org/show_bug.cgi?id=164697

Reviewed by Zalan Bujtas.

Source/WebCore:

Add dumping to ScrollingTreeNode and subclasses (previously, we could only dump
the scrolling state tree). This re-uses the flags used for state tree dumping.

NodeIDs are not dumped by default because they can depend on earlier tests.

Test: scrollingcoordinator/ios/ui-scrolling-tree.html

* page/scrolling/ScrollingStateNode.h:
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::scrollingTreeAsText):
* page/scrolling/ScrollingTree.h:
* page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
(WebCore::ScrollingTreeFrameScrollingNode::dumpProperties):
* page/scrolling/ScrollingTreeFrameScrollingNode.h:
* page/scrolling/ScrollingTreeNode.cpp:
(WebCore::ScrollingTreeNode::dumpProperties):
(WebCore::ScrollingTreeNode::dump):
* page/scrolling/ScrollingTreeNode.h:
* page/scrolling/ScrollingTreeScrollingNode.cpp:
(WebCore::ScrollingTreeScrollingNode::dumpProperties):
* page/scrolling/ScrollingTreeScrollingNode.h:
* page/scrolling/mac/ScrollingTreeFixedNode.h:
* page/scrolling/mac/ScrollingTreeFixedNode.mm:
(WebCore::ScrollingTreeFixedNode::dumpProperties):
* page/scrolling/mac/ScrollingTreeStickyNode.h:
* page/scrolling/mac/ScrollingTreeStickyNode.mm:
(WebCore::ScrollingTreeStickyNode::dumpProperties):

Source/WebKit2:

Add a property to WKWebView to retrieve the scrolling tree as text, for testing.
Expose it via the RemoteScrollingCoordinatorProxy.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _scrollingTreeAsText]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeAsText):
* UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:

Tools:

Add UIScriptController::scrollingTreeAsText(), which gets the state of the scrolling
tree in the UI process, including the current positions of CALayers. This will be used
to test UI-side scrolling and visual viewports.

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::scrollingTreeAsText):
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::scrollingTreeAsText):
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::scrollingTreeAsText):

LayoutTests:

Add a test that dumps the scrolling state tree with a fixed element.

* scrollingcoordinator/ios/ui-scrolling-tree-expected.txt: Added.
* scrollingcoordinator/ios/ui-scrolling-tree.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208665 => 208666)


--- trunk/LayoutTests/ChangeLog	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/LayoutTests/ChangeLog	2016-11-13 07:19:07 UTC (rev 208666)
@@ -1,5 +1,17 @@
 2016-11-12  Simon Fraser  <[email protected]>
 
+        Add a way to get the UI-side scrolling tree as text via UIScriptController
+        https://bugs.webkit.org/show_bug.cgi?id=164697
+
+        Reviewed by Zalan Bujtas.
+
+        Add a test that dumps the scrolling state tree with a fixed element.
+
+        * scrollingcoordinator/ios/ui-scrolling-tree-expected.txt: Added.
+        * scrollingcoordinator/ios/ui-scrolling-tree.html: Added.
+
+2016-11-12  Simon Fraser  <[email protected]>
+
         [iOS WK2] Share some code with Mac for post-async-scroll state reconciliation
         https://bugs.webkit.org/show_bug.cgi?id=164694
 

Added: trunk/LayoutTests/scrollingcoordinator/ios/ui-scrolling-tree-expected.txt (0 => 208666)


--- trunk/LayoutTests/scrollingcoordinator/ios/ui-scrolling-tree-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/ios/ui-scrolling-tree-expected.txt	2016-11-13 07:19:07 UTC (rev 208666)
@@ -0,0 +1,12 @@
+
+(scrolling tree
+  (frame scrolling node
+    (layout viewport (0,0) width=320 height=568)
+    (min layoutViewport origin (0,0))
+    (max layoutViewport origin (988,1453))
+    (behavior for fixed 0)
+    (fixed node
+      (fixed constraints 
+        (viewport-rect-at-last-layout (0,0) width=683 height=1212)
+        (layer-position-at-last-layout (12,10)))
+      (layer top left (12,10))))

Added: trunk/LayoutTests/scrollingcoordinator/ios/ui-scrolling-tree.html (0 => 208666)


--- trunk/LayoutTests/scrollingcoordinator/ios/ui-scrolling-tree.html	                        (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/ios/ui-scrolling-tree.html	2016-11-13 07:19:07 UTC (rev 208666)
@@ -0,0 +1,52 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=1.0">
+    <style>
+        body {
+            width: 1300px;
+            height: 2000px;
+        }
+        
+        .fixed {
+            position: fixed;
+            top: 10px;
+            left: 12px;
+            height: 100px;
+            width: 100px;
+            background-color: blue;
+        }
+    </style>
+    <script>
+        if (window.testRunner) {
+            testRunner.waitUntilDone();
+            testRunner.dumpAsText();
+        }
+
+        function getScrollingTreeUIScript(x, y)
+        {
+            return `(function() {
+                return uiController.scrollingTreeAsText;
+            })();`;
+        }
+
+        function doTest()
+        {
+            if (!testRunner.runUIScript)
+                return
+
+            testRunner.runUIScript(getScrollingTreeUIScript(), function(scrollingTree) {
+                document.getElementById('layers').textContent = scrollingTree;
+                testRunner.notifyDone();
+            });
+        }
+        
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+<div class="fixed"></div>
+<pre id="layers"></pre>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (208665 => 208666)


--- trunk/Source/WebCore/ChangeLog	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/ChangeLog	2016-11-13 07:19:07 UTC (rev 208666)
@@ -1,3 +1,38 @@
+2016-11-12  Simon Fraser  <[email protected]>
+
+        Add a way to get the UI-side scrolling tree as text via UIScriptController
+        https://bugs.webkit.org/show_bug.cgi?id=164697
+
+        Reviewed by Zalan Bujtas.
+
+        Add dumping to ScrollingTreeNode and subclasses (previously, we could only dump
+        the scrolling state tree). This re-uses the flags used for state tree dumping.
+
+        NodeIDs are not dumped by default because they can depend on earlier tests.
+
+        Test: scrollingcoordinator/ios/ui-scrolling-tree.html
+
+        * page/scrolling/ScrollingStateNode.h:
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::scrollingTreeAsText):
+        * page/scrolling/ScrollingTree.h:
+        * page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
+        (WebCore::ScrollingTreeFrameScrollingNode::dumpProperties):
+        * page/scrolling/ScrollingTreeFrameScrollingNode.h:
+        * page/scrolling/ScrollingTreeNode.cpp:
+        (WebCore::ScrollingTreeNode::dumpProperties):
+        (WebCore::ScrollingTreeNode::dump):
+        * page/scrolling/ScrollingTreeNode.h:
+        * page/scrolling/ScrollingTreeScrollingNode.cpp:
+        (WebCore::ScrollingTreeScrollingNode::dumpProperties):
+        * page/scrolling/ScrollingTreeScrollingNode.h:
+        * page/scrolling/mac/ScrollingTreeFixedNode.h:
+        * page/scrolling/mac/ScrollingTreeFixedNode.mm:
+        (WebCore::ScrollingTreeFixedNode::dumpProperties):
+        * page/scrolling/mac/ScrollingTreeStickyNode.h:
+        * page/scrolling/mac/ScrollingTreeStickyNode.mm:
+        (WebCore::ScrollingTreeStickyNode::dumpProperties):
+
 2016-11-12  Darin Adler  <[email protected]>
 
         Remove some use of ExceptionCode in MediaStream

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h (208665 => 208666)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h	2016-11-13 07:19:07 UTC (rev 208666)
@@ -40,9 +40,11 @@
 class TextStream;
 
 enum ScrollingStateTreeAsTextBehaviorFlags {
-    ScrollingStateTreeAsTextBehaviorNormal               = 0,
-    ScrollingStateTreeAsTextBehaviorIncludeLayerIDs      = 1 << 0,
-    ScrollingStateTreeAsTextBehaviorDebug                = ScrollingStateTreeAsTextBehaviorIncludeLayerIDs
+    ScrollingStateTreeAsTextBehaviorNormal                  = 0,
+    ScrollingStateTreeAsTextBehaviorIncludeLayerIDs         = 1 << 0,
+    ScrollingStateTreeAsTextBehaviorIncludeNodeIDs          = 1 << 1,
+    ScrollingStateTreeAsTextBehaviorIncludeLayerPositions   = 1 << 2,
+    ScrollingStateTreeAsTextBehaviorDebug                   = ScrollingStateTreeAsTextBehaviorIncludeLayerIDs | ScrollingStateTreeAsTextBehaviorIncludeNodeIDs | ScrollingStateTreeAsTextBehaviorIncludeLayerPositions
 };
 typedef unsigned ScrollingStateTreeAsTextBehavior;
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (208665 => 208666)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2016-11-13 07:19:07 UTC (rev 208666)
@@ -381,6 +381,30 @@
     m_latchedNode = 0;
 }
 
+String ScrollingTree::scrollingTreeAsText()
+{
+    TextStream ts(TextStream::LineMode::MultipleLine);
+
+    TextStream::GroupScope scope(ts);
+    ts << "scrolling tree";
+    
+    if (m_latchedNode)
+        ts.dumpProperty("latched node", m_latchedNode);
+
+    if (m_mainFrameScrollPosition != IntPoint())
+        ts.dumpProperty("main frame scroll position", m_mainFrameScrollPosition);
+    
+    {
+        LockHolder lock(m_mutex);
+        if (m_rootNode) {
+            TextStream::GroupScope scope(ts);
+            m_rootNode->dump(ts, ScrollingStateTreeAsTextBehaviorIncludeLayerPositions);
+        }
+    }
+
+    return ts.release();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(ASYNC_SCROLLING)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (208665 => 208666)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2016-11-13 07:19:07 UTC (rev 208666)
@@ -145,6 +145,8 @@
         --m_fixedOrStickyNodeCount;
     }
     
+    WEBCORE_EXPORT String scrollingTreeAsText();
+    
 protected:
     void setMainFrameScrollPosition(FloatPoint);
     void setVisualViewportEnabled(bool b) { m_visualViewportEnabled = b; }

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp (208665 => 208666)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp	2016-11-13 07:19:07 UTC (rev 208666)
@@ -133,6 +133,32 @@
     return toFloatSize(scrollPosition) - FloatSize(0, headerHeight() + topContentInset());
 }
 
+void ScrollingTreeFrameScrollingNode::dumpProperties(TextStream& ts, ScrollingStateTreeAsTextBehavior) const
+{
+    ts << "frame scrolling node";
+
+    ts.dumpProperty("layout viewport", m_layoutViewport);
+    ts.dumpProperty("min layoutViewport origin", m_minLayoutViewportOrigin);
+    ts.dumpProperty("max layoutViewport origin", m_maxLayoutViewportOrigin);
+
+    if (m_frameScaleFactor != 1)
+        ts.dumpProperty("frame scale factor", m_frameScaleFactor);
+    if (m_topContentInset)
+        ts.dumpProperty("top content inset", m_topContentInset);
+
+    if (m_headerHeight)
+        ts.dumpProperty("header height", m_headerHeight);
+    if (m_footerHeight)
+        ts.dumpProperty("footer height", m_footerHeight);
+    if (m_synchronousScrollingReasons)
+        ts.dumpProperty("synchronous scrolling reasons", ScrollingCoordinator::synchronousScrollingReasonsAsText(m_synchronousScrollingReasons));
+
+    ts.dumpProperty("behavior for fixed", m_behaviorForFixed);
+    if (m_fixedElementsLayoutRelativeToFrame)
+        ts.dumpProperty("fixed elements lay out relative to frame", m_fixedElementsLayoutRelativeToFrame);
+}
+
+
 } // namespace WebCore
 
 #endif // ENABLE(ASYNC_SCROLLING)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h (208665 => 208666)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h	2016-11-13 07:19:07 UTC (rev 208666)
@@ -76,6 +76,8 @@
     ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const { return m_behaviorForFixed; }
     
 private:
+    void dumpProperties(TextStream&, ScrollingStateTreeAsTextBehavior) const override;
+
     FloatRect m_layoutViewport;
     FloatPoint m_minLayoutViewportOrigin;
     FloatPoint m_maxLayoutViewportOrigin;

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp (208665 => 208666)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp	2016-11-13 07:19:07 UTC (rev 208666)
@@ -29,6 +29,7 @@
 #if ENABLE(ASYNC_SCROLLING)
 
 #include "ScrollingStateTree.h"
+#include "TextStream.h"
 
 namespace WebCore {
 
@@ -72,6 +73,24 @@
         child->removeChild(node);
 }
 
+void ScrollingTreeNode::dumpProperties(TextStream& ts, ScrollingStateTreeAsTextBehavior behavior) const
+{
+    if (behavior & ScrollingStateTreeAsTextBehaviorIncludeNodeIDs)
+        ts.dumpProperty("nodeID", scrollingNodeID());
+}
+
+void ScrollingTreeNode::dump(TextStream& ts, ScrollingStateTreeAsTextBehavior behavior) const
+{
+    dumpProperties(ts, behavior);
+
+    if (m_children) {
+        for (auto& child : *m_children) {
+            TextStream::GroupScope scope(ts);
+            child->dump(ts, behavior);
+        }
+    }
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(ASYNC_SCROLLING)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h (208665 => 208666)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h	2016-11-13 07:19:07 UTC (rev 208666)
@@ -30,6 +30,7 @@
 #include "IntRect.h"
 #include "ScrollTypes.h"
 #include "ScrollingCoordinator.h"
+#include "ScrollingStateNode.h"
 #include <wtf/RefCounted.h>
 #include <wtf/TypeCasts.h>
 
@@ -36,7 +37,6 @@
 namespace WebCore {
 
 class ScrollingStateFixedNode;
-class ScrollingStateNode;
 class ScrollingStateScrollingNode;
 
 class ScrollingTreeNode : public RefCounted<ScrollingTreeNode> {
@@ -66,6 +66,8 @@
     void appendChild(PassRefPtr<ScrollingTreeNode>);
     void removeChild(ScrollingTreeNode*);
 
+    WEBCORE_EXPORT void dump(TextStream&, ScrollingStateTreeAsTextBehavior) const;
+
 protected:
     ScrollingTreeNode(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
     ScrollingTree& scrollingTree() const { return m_scrollingTree; }
@@ -72,6 +74,8 @@
 
     std::unique_ptr<ScrollingTreeChildrenVector> m_children;
 
+    WEBCORE_EXPORT virtual void dumpProperties(TextStream&, ScrollingStateTreeAsTextBehavior) const;
+
 private:
     ScrollingTree& m_scrollingTree;
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (208665 => 208666)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2016-11-13 07:19:07 UTC (rev 208666)
@@ -30,6 +30,7 @@
 
 #include "ScrollingStateTree.h"
 #include "ScrollingTree.h"
+#include "TextStream.h"
 
 namespace WebCore {
 
@@ -124,7 +125,35 @@
     return FloatPoint(contentSizePoint - scrollableAreaSize()).expandedTo(FloatPoint());
 }
 
+void ScrollingTreeScrollingNode::dumpProperties(TextStream& ts, ScrollingStateTreeAsTextBehavior behavior) const
+{
+    ScrollingTreeNode::dumpProperties(ts, behavior);
+    ts.dumpProperty("scrollable area size", m_scrollableAreaSize);
+    ts.dumpProperty("total content size", m_totalContentsSize);
+    if (m_totalContentsSizeForRubberBand != m_totalContentsSize)
+        ts.dumpProperty("total content size for rubber band", m_totalContentsSizeForRubberBand);
+    if (m_reachableContentsSize != m_totalContentsSize)
+        ts.dumpProperty("reachable content size", m_reachableContentsSize);
+    ts.dumpProperty("scrollable area size", m_lastCommittedScrollPosition);
+    if (m_scrollOrigin != IntPoint())
+        ts.dumpProperty("scrollable area size", m_scrollOrigin);
 
+#if ENABLE(CSS_SCROLL_SNAP)
+    if (m_horizontalSnapOffsets.size())
+        ts.dumpProperty("horizontal snap offsets", m_horizontalSnapOffsets);
+
+    if (m_verticalSnapOffsets.size())
+        ts.dumpProperty("horizontal snap offsets", m_verticalSnapOffsets);
+
+    if (m_currentHorizontalSnapPointIndex)
+        ts.dumpProperty("current horizontal snap point index", m_verticalSnapOffsets);
+
+    if (m_currentVerticalSnapPointIndex)
+        ts.dumpProperty("current vertical snap point index", m_currentVerticalSnapPointIndex);
+    
+#endif
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(ASYNC_SCROLLING)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (208665 => 208666)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h	2016-11-13 07:19:07 UTC (rev 208666)
@@ -92,6 +92,8 @@
 
     bool canHaveScrollbars() const { return m_scrollableAreaParameters.horizontalScrollbarMode != ScrollbarAlwaysOff || m_scrollableAreaParameters.verticalScrollbarMode != ScrollbarAlwaysOff; }
 
+    WEBCORE_EXPORT void dumpProperties(TextStream&, ScrollingStateTreeAsTextBehavior) const override;
+
 private:
     FloatSize m_scrollableAreaSize;
     FloatSize m_totalContentsSize;

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFixedNode.h (208665 => 208666)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFixedNode.h	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFixedNode.h	2016-11-13 07:19:07 UTC (rev 208666)
@@ -49,6 +49,8 @@
     void commitStateBeforeChildren(const ScrollingStateNode&) override;
     void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta) override;
 
+    void dumpProperties(TextStream&, ScrollingStateTreeAsTextBehavior) const override;
+
     FixedPositionViewportConstraints m_constraints;
     RetainPtr<CALayer> m_layer;
 };

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFixedNode.mm (208665 => 208666)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFixedNode.mm	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFixedNode.mm	2016-11-13 07:19:07 UTC (rev 208666)
@@ -30,6 +30,7 @@
 
 #include "ScrollingStateFixedNode.h"
 #include "ScrollingTree.h"
+#include "TextStream.h"
 #include <QuartzCore/CALayer.h>
 
 namespace WebCore {
@@ -86,6 +87,21 @@
         child->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, newDelta);
 }
 
+void ScrollingTreeFixedNode::dumpProperties(TextStream& ts, ScrollingStateTreeAsTextBehavior behavior) const
+{
+    ts << "fixed node";
+    ScrollingTreeNode::dumpProperties(ts, behavior);
+    ts.dumpProperty("fixed constraints", m_constraints);
+    
+    if (behavior & ScrollingStateTreeAsTextBehaviorIncludeLayerPositions) {
+        FloatRect layerBounds = [m_layer bounds];
+        FloatPoint anchorPoint = [m_layer anchorPoint];
+        FloatPoint position = [m_layer position];
+        FloatPoint layerTopLeft = position - toFloatSize(anchorPoint) * layerBounds.size() + m_constraints.alignmentOffset();
+        ts.dumpProperty("layer top left", layerTopLeft);
+    }
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(ASYNC_SCROLLING)

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeStickyNode.h (208665 => 208666)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeStickyNode.h	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeStickyNode.h	2016-11-13 07:19:07 UTC (rev 208666)
@@ -49,6 +49,8 @@
     void commitStateBeforeChildren(const ScrollingStateNode&) override;
     void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta) override;
 
+    void dumpProperties(TextStream&, ScrollingStateTreeAsTextBehavior) const override;
+
     StickyPositionViewportConstraints m_constraints;
     RetainPtr<CALayer> m_layer;
 };

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeStickyNode.mm (208665 => 208666)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeStickyNode.mm	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeStickyNode.mm	2016-11-13 07:19:07 UTC (rev 208666)
@@ -32,6 +32,7 @@
 #include "ScrollingTree.h"
 #include "ScrollingTreeFrameScrollingNode.h"
 #include "ScrollingTreeOverflowScrollingNode.h"
+#include "TextStream.h"
 #include <QuartzCore/CALayer.h>
 
 namespace WebCore {
@@ -101,6 +102,22 @@
         child->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, deltaForDescendants);
 }
 
+void ScrollingTreeStickyNode::dumpProperties(TextStream& ts, ScrollingStateTreeAsTextBehavior behavior) const
+{
+    ts << "sticky node";
+
+    ScrollingTreeNode::dumpProperties(ts, behavior);
+    ts.dumpProperty("sticky constraints", m_constraints);
+
+    if (behavior & ScrollingStateTreeAsTextBehaviorIncludeLayerPositions) {
+        FloatRect layerBounds = [m_layer bounds];
+        FloatPoint anchorPoint = [m_layer anchorPoint];
+        FloatPoint position = [m_layer position];
+        FloatPoint layerTopLeft = position - toFloatSize(anchorPoint) * layerBounds.size() + m_constraints.alignmentOffset();
+        ts.dumpProperty("layer top left", layerTopLeft);
+    }
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(ASYNC_SCROLLING)

Modified: trunk/Source/WebKit2/ChangeLog (208665 => 208666)


--- trunk/Source/WebKit2/ChangeLog	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebKit2/ChangeLog	2016-11-13 07:19:07 UTC (rev 208666)
@@ -1,3 +1,20 @@
+2016-11-12  Simon Fraser  <[email protected]>
+
+        Add a way to get the UI-side scrolling tree as text via UIScriptController
+        https://bugs.webkit.org/show_bug.cgi?id=164697
+
+        Reviewed by Zalan Bujtas.
+
+        Add a property to WKWebView to retrieve the scrolling tree as text, for testing.
+        Expose it via the RemoteScrollingCoordinatorProxy.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _scrollingTreeAsText]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:
+        (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeAsText):
+        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
+
 2016-11-12  Daniel Bates  <[email protected]>
 
         Incorrect release log message emitted when waiting/not waiting for the WebProcess continue a load

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (208665 => 208666)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-11-13 07:19:07 UTC (rev 208666)
@@ -4687,6 +4687,15 @@
     return [_contentView valueForKeyPath:@"interactionAssistant.selectionView.rangeView.m_rectViews"];
 }
 
+- (NSString *)_scrollingTreeAsText
+{
+    WebKit::RemoteScrollingCoordinatorProxy* coordinator = _page->scrollingCoordinatorProxy();
+    if (!coordinator)
+        return @"";
+
+    return coordinator->scrollingTreeAsText();
+}
+
 #endif // PLATFORM(IOS)
 
 #if PLATFORM(MAC)

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (208665 => 208666)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2016-11-13 07:19:07 UTC (rev 208666)
@@ -285,6 +285,8 @@
 
 @property (nonatomic, readonly) NSArray<UIView *> *_uiTextSelectionRectViews WK_API_AVAILABLE(ios(WK_IOS_TBA));
 
+@property (nonatomic, readonly) NSString *_scrollingTreeAsText WK_API_AVAILABLE(ios(WK_IOS_TBA));
+
 #endif
 
 #if !TARGET_OS_IPHONE

Modified: trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp (208665 => 208666)


--- trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp	2016-11-13 07:19:07 UTC (rev 208666)
@@ -185,6 +185,14 @@
     }
 }
 
+String RemoteScrollingCoordinatorProxy::scrollingTreeAsText() const
+{
+    if (m_scrollingTree)
+        return m_scrollingTree->scrollingTreeAsText();
+    
+    return emptyString();
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(ASYNC_SCROLLING)

Modified: trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h (208665 => 208666)


--- trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h	2016-11-13 07:19:07 UTC (rev 208666)
@@ -94,6 +94,8 @@
 #endif
 #endif
 
+    String scrollingTreeAsText() const;
+
 private:
     void connectStateNodeLayers(WebCore::ScrollingStateTree&, const RemoteLayerTreeHost&);
 #if ENABLE(CSS_SCROLL_SNAP)

Modified: trunk/Tools/ChangeLog (208665 => 208666)


--- trunk/Tools/ChangeLog	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Tools/ChangeLog	2016-11-13 07:19:07 UTC (rev 208666)
@@ -1,3 +1,23 @@
+2016-11-12  Simon Fraser  <[email protected]>
+
+        Add a way to get the UI-side scrolling tree as text via UIScriptController
+        https://bugs.webkit.org/show_bug.cgi?id=164697
+
+        Reviewed by Zalan Bujtas.
+
+        Add UIScriptController::scrollingTreeAsText(), which gets the state of the scrolling
+        tree in the UI process, including the current positions of CALayers. This will be used
+        to test UI-side scrolling and visual viewports.
+
+        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::scrollingTreeAsText):
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
+        (WTR::UIScriptController::scrollingTreeAsText):
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::scrollingTreeAsText):
+
 2016-11-12  Wenson Hsieh  <[email protected]>
 
         The main content heuristic should be robust when handling large media elements

Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm (208665 => 208666)


--- trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm	2016-11-13 07:19:07 UTC (rev 208666)
@@ -219,6 +219,11 @@
 {
 }
 
+JSRetainPtr<JSStringRef> UIScriptController::scrollingTreeAsText() const
+{
+    return nullptr;
 }
 
+}
+
 #endif // PLATFORM(IOS)

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (208665 => 208666)


--- trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2016-11-13 07:19:07 UTC (rev 208666)
@@ -159,5 +159,7 @@
     void insertText(DOMString text, long location, long length);
     void removeAllDynamicDictionaries();
 
+    readonly attribute DOMString scrollingTreeAsText;
+
     void uiScriptComplete(DOMString result);
 };

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp (208665 => 208666)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp	2016-11-13 07:19:07 UTC (rev 208666)
@@ -282,6 +282,11 @@
 {
 }
 
+JSRetainPtr<JSStringRef> UIScriptController::scrollingTreeAsText() const
+{
+    return nullptr;
+}
+
 void UIScriptController::platformSetDidStartFormControlInteractionCallback()
 {
 }

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (208665 => 208666)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2016-11-13 07:19:07 UTC (rev 208666)
@@ -27,6 +27,7 @@
 #define UIScriptController_h
 
 #include "JSWrappable.h"
+#include <_javascript_Core/JSRetainPtr.h>
 #include <wtf/Ref.h>
 
 namespace WebCore {
@@ -119,6 +120,8 @@
 
     void insertText(JSStringRef, int location, int length);
     void removeAllDynamicDictionaries();
+    
+    JSRetainPtr<JSStringRef> scrollingTreeAsText() const;
 
     void uiScriptComplete(JSStringRef result);
 

Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (208665 => 208666)


--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2016-11-13 05:50:32 UTC (rev 208665)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2016-11-13 07:19:07 UTC (rev 208666)
@@ -399,6 +399,12 @@
     [UIKeyboard removeAllDynamicDictionaries];
 }
 
+JSRetainPtr<JSStringRef> UIScriptController::scrollingTreeAsText() const
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    return JSStringCreateWithCFString((CFStringRef)[webView _scrollingTreeAsText]);
+}
+
 void UIScriptController::platformSetDidStartFormControlInteractionCallback()
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to