Title: [158159] trunk
Revision
158159
Author
[email protected]
Date
2013-10-28 19:38:09 -0700 (Mon, 28 Oct 2013)

Log Message

Web Inspector: CSS Regions: Add protocol API to expose content nodes addition/removal
https://bugs.webkit.org/show_bug.cgi?id=123424

Reviewed by Timothy Hatcher.

Source/WebCore:

Test: inspector-protocol/model/content-flow-content-nodes.html

Adding two new inspector-protocol APIs to handle the cases when new elements are
added or removed from a named flow. These APIs will trigger even though there
is no region associated with the named flow.

* inspector/Inspector.json:
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::didRegisterNamedFlowContentElement):
(WebCore::InspectorCSSAgent::didUnregisterNamedFlowContentElement):
* inspector/InspectorCSSAgent.h:
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didRegisterNamedFlowContentElementImpl):
(WebCore::InspectorInstrumentation::didUnregisterNamedFlowContentElementImpl):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::didRegisterNamedFlowContentElement):
(WebCore::InspectorInstrumentation::didUnregisterNamedFlowContentElement):
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::registerNamedFlowContentElement):
(WebCore::RenderNamedFlowThread::unregisterNamedFlowContentElement):

Source/WebInspectorUI:

Exposed the new CSS Agent events to the ContentFlow class that will now maintain
a list of nodes in the "contentNodes" property.

* UserInterface/CSSObserver.js:
(WebInspector.CSSObserver.prototype.regionOversetChanged):
(WebInspector.CSSObserver.prototype.registeredNamedFlowContentElement):
(WebInspector.CSSObserver.prototype.unregisteredNamedFlowContentElement):
* UserInterface/ContentFlow.js:
(WebInspector.ContentFlow):
(WebInspector.ContentFlow.prototype.set overset):
(WebInspector.ContentFlow.prototype.get contentNodes):
(WebInspector.ContentFlow.prototype.insertContentNodeBefore):
(WebInspector.ContentFlow.prototype.appendContentNode):
(WebInspector.ContentFlow.prototype.removeContentNode):
* UserInterface/DOMTreeManager.js:
(WebInspector.DOMTreeManager.prototype._createContentFlowFromPayload):
(WebInspector.DOMTreeManager.prototype._updateContentFlowFromPayload):
(WebInspector.DOMTreeManager.prototype.regionOversetChanged):
(WebInspector.DOMTreeManager.prototype.registeredNamedFlowContentElement):
(WebInspector.DOMTreeManager.prototype.unregisteredNamedFlowContentElement):
* UserInterface/InspectorBackendCommands.js:

LayoutTests:

Added test to check that the two new events are triggered correctly and can be used to maintain
the flow content nodes list on the inspector side.

* inspector-protocol/model/content-flow-content-nodes-expected.txt: Added.
* inspector-protocol/model/content-flow-content-nodes.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (158158 => 158159)


--- trunk/LayoutTests/ChangeLog	2013-10-29 02:37:53 UTC (rev 158158)
+++ trunk/LayoutTests/ChangeLog	2013-10-29 02:38:09 UTC (rev 158159)
@@ -1,3 +1,16 @@
+2013-10-28  Alexandru Chiculita  <[email protected]>
+
+        Web Inspector: CSS Regions: Add protocol API to expose content nodes addition/removal
+        https://bugs.webkit.org/show_bug.cgi?id=123424
+
+        Reviewed by Timothy Hatcher.
+
+        Added test to check that the two new events are triggered correctly and can be used to maintain
+        the flow content nodes list on the inspector side.
+
+        * inspector-protocol/model/content-flow-content-nodes-expected.txt: Added.
+        * inspector-protocol/model/content-flow-content-nodes.html: Added.
+
 2013-10-28  Simon Fraser  <[email protected]>
 
         Last few Mavericks WK2 failures.

Added: trunk/LayoutTests/inspector-protocol/model/content-flow-content-nodes-expected.txt (0 => 158159)


--- trunk/LayoutTests/inspector-protocol/model/content-flow-content-nodes-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector-protocol/model/content-flow-content-nodes-expected.txt	2013-10-29 02:38:09 UTC (rev 158159)
@@ -0,0 +1,13 @@
+Testing that the ContentFlows events are correctly dispatched when nodes are attached to/detached from a flow.
+
+PASS: ContentFlow was added.
+PASS: ContentFlow.contentNodes has a length of 2.
+PASS: ContentFlow.contentNodes[0].id is "#contentStatic".
+PASS: ContentFlow.contentNodes[1].id is "#contentRemoved".
+PASS: "#contentAddedAtTheTop" was added before "#contentStatic".
+PASS: "#contentAddedAtTheTop" is first in the contentNodes list.
+PASS: "#contentAddedAtTheBottom" was added last.
+PASS: "#contentAddedAtTheBottom" is last in the contentNodes list.
+PASS: "#contentRemoved" was removed.
+PASS: "#contentRemoved" cannot be found in the contentNodes list.
+

Added: trunk/LayoutTests/inspector-protocol/model/content-flow-content-nodes.html (0 => 158159)


--- trunk/LayoutTests/inspector-protocol/model/content-flow-content-nodes.html	                        (rev 0)
+++ trunk/LayoutTests/inspector-protocol/model/content-flow-content-nodes.html	2013-10-29 02:38:09 UTC (rev 158159)
@@ -0,0 +1,93 @@
+<!doctype html>
+<html>
+<head>
+<style>
+.content
+{
+    -webkit-flow-into: flow;
+}
+.hidden
+{
+    -webkit-flow-into: none;
+}
+</style>
+<script type="text/_javascript_" src=""
+<script>
+function changeFlowContent()
+{
+    document.getElementById("contentAddedAtTheTop").classList.remove("hidden");
+    // Force a layout to make sure the events are always fired in the expected order.
+    document.body.offsetTop;
+    document.getElementById("contentAddedAtTheBottom").classList.remove("hidden");
+    document.body.offsetTop;
+    document.getElementById("contentRemoved").classList.add("hidden");
+}
+
+function test()
+{
+    InspectorTest.importInspectorScripts();
+
+    var contentFlow;
+
+    WebInspector.frameResourceManager.addEventListener(WebInspector.FrameResourceManager.Event.MainFrameDidChange, function(event) {
+        var domTree = WebInspector.frameResourceManager.mainFrame.domTree;
+        domTree.addEventListener(WebInspector.DOMTree.Event.RootDOMNodeInvalidated, onRootDOMNodeInvalidated, null);
+        domTree.addEventListener(WebInspector.DOMTree.Event.ContentFlowWasAdded, onContentFlowWasAdded, null);
+        domTree.requestContentFlowList();
+    });
+
+    function onRootDOMNodeInvalidated()
+    {
+        WebInspector.frameResourceManager.mainFrame.domTree.requestContentFlowList();
+    }
+
+    function onContentFlowWasAdded(event)
+    {
+        contentFlow = event.data.flow;
+        InspectorTest.assert(contentFlow.name === "flow", "ContentFlow was added.");
+        InspectorTest.assert(contentFlow.contentNodes.length == 2, "ContentFlow.contentNodes has a length of 2.");
+        InspectorTest.assert(contentFlow.contentNodes[0].getAttribute("id") === "contentStatic", "ContentFlow.contentNodes[0].id is \"#contentStatic\".");
+        InspectorTest.assert(contentFlow.contentNodes[1].getAttribute("id") === "contentRemoved", "ContentFlow.contentNodes[1].id is \"#contentRemoved\".");
+
+        contentFlow.addEventListener(WebInspector.ContentFlow.Event.ContentNodeWasAdded, onContentNodeWasAdded, null);
+        contentFlow.addEventListener(WebInspector.ContentFlow.Event.ContentNodeWasRemoved, onContentNodeWasRemoved, null);
+
+        InspectorTest.sendCommand("Runtime.evaluate", {_expression_: "changeFlowContent()"});
+    }
+
+    function onContentNodeWasAdded(event)
+    {
+        switch (event.data.node.getAttribute("id")) {
+        case "contentAddedAtTheTop":
+            InspectorTest.assert(event.data.before.getAttribute("id") === "contentStatic", "\"#contentAddedAtTheTop\" was added before \"#contentStatic\".");
+            InspectorTest.assert(contentFlow.contentNodes[0] === event.data.node, "\"#contentAddedAtTheTop\" is first in the contentNodes list.");
+            break;
+        case "contentAddedAtTheBottom":
+            InspectorTest.assert(!event.data.before, "\"#contentAddedAtTheBottom\" was added last.");
+            InspectorTest.assert(contentFlow.contentNodes.lastValue === event.data.node, "\"#contentAddedAtTheBottom\" is last in the contentNodes list.");
+            break;
+        default:
+            InspectorTest.log("FAIL: Only two add events are expected.");
+        }
+        
+    }
+
+    function onContentNodeWasRemoved(event)
+    {
+        InspectorTest.assert(event.data.node.getAttribute("id") === "contentRemoved", "\"#contentRemoved\" was removed.");
+        InspectorTest.assert(contentFlow.contentNodes.indexOf(event.data.node) === -1, "\"#contentRemoved\" cannot be found in the contentNodes list.");
+        InspectorTest.completeTest();
+    }
+}
+</script>
+</head>
+<body _onload_="runTest()">
+    <p>Testing that the ContentFlows events are correctly dispatched when nodes are attached to/detached from a flow.</p>
+    
+    <div id="contentAddedAtTheTop" class="content hidden"></div>
+    <div id="contentStatic" class="content"></div>
+    <div id="contentRemoved" class="content"></div>
+    <div id="contentAddedAtTheBottom" class="content hidden"></div>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (158158 => 158159)


--- trunk/Source/WebCore/ChangeLog	2013-10-29 02:37:53 UTC (rev 158158)
+++ trunk/Source/WebCore/ChangeLog	2013-10-29 02:38:09 UTC (rev 158159)
@@ -1,3 +1,31 @@
+2013-10-28  Alexandru Chiculita  <[email protected]>
+
+        Web Inspector: CSS Regions: Add protocol API to expose content nodes addition/removal
+        https://bugs.webkit.org/show_bug.cgi?id=123424
+
+        Reviewed by Timothy Hatcher.
+
+        Test: inspector-protocol/model/content-flow-content-nodes.html
+
+        Adding two new inspector-protocol APIs to handle the cases when new elements are
+        added or removed from a named flow. These APIs will trigger even though there
+        is no region associated with the named flow.
+
+        * inspector/Inspector.json:
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::didRegisterNamedFlowContentElement):
+        (WebCore::InspectorCSSAgent::didUnregisterNamedFlowContentElement):
+        * inspector/InspectorCSSAgent.h:
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::didRegisterNamedFlowContentElementImpl):
+        (WebCore::InspectorInstrumentation::didUnregisterNamedFlowContentElementImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::didRegisterNamedFlowContentElement):
+        (WebCore::InspectorInstrumentation::didUnregisterNamedFlowContentElement):
+        * rendering/RenderNamedFlowThread.cpp:
+        (WebCore::RenderNamedFlowThread::registerNamedFlowContentElement):
+        (WebCore::RenderNamedFlowThread::unregisterNamedFlowContentElement):
+
 2013-10-28  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Remove unused inspector/inline-_javascript_-imports.py

Modified: trunk/Source/WebCore/inspector/Inspector.json (158158 => 158159)


--- trunk/Source/WebCore/inspector/Inspector.json	2013-10-29 02:37:53 UTC (rev 158158)
+++ trunk/Source/WebCore/inspector/Inspector.json	2013-10-29 02:38:09 UTC (rev 158159)
@@ -2560,6 +2560,25 @@
                     { "name": "namedFlow", "$ref": "NamedFlow", "description": "The Named Flow containing the regions whose regionOverset values changed." }
                 ],
                 "description": "Fires if any of the regionOverset values changed in a Named Flow's region chain."
+            },
+            {
+                "name": "registeredNamedFlowContentElement",
+                "parameters": [
+                    { "name": "documentNodeId", "$ref": "DOM.NodeId", "description": "The document node id." },
+                    { "name": "flowName", "type": "string", "description": "Named Flow identifier for which the new content element was registered." },
+                    { "name": "contentNodeId", "$ref": "DOM.NodeId", "description": "The node id of the registered content node." },
+                    { "name": "nextContentNodeId", "$ref": "DOM.NodeId", "description": "The node id of the element following the registered content node." }
+                ],
+                "description": "Fires when a Named Flow's has been registered with a new content node."
+            },
+            {
+                "name": "unregisteredNamedFlowContentElement",
+                "parameters": [
+                    { "name": "documentNodeId", "$ref": "DOM.NodeId", "description": "The document node id." },
+                    { "name": "flowName", "type": "string", "description": "Named Flow identifier for which the new content element was unregistered." },
+                    { "name": "contentNodeId", "$ref": "DOM.NodeId", "description": "The node id of the unregistered content node." }
+                ],
+                "description": "Fires when a Named Flow's has been registered with a new content node."
             }
         ]
     },

Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (158158 => 158159)


--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2013-10-29 02:37:53 UTC (rev 158158)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2013-10-29 02:38:09 UTC (rev 158159)
@@ -775,6 +775,29 @@
     m_frontend->regionOversetChanged(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
 }
 
+void InspectorCSSAgent::didRegisterNamedFlowContentElement(Document* document, WebKitNamedFlow* namedFlow, Node* contentElement, Node* nextContentElement)
+{
+    int documentNodeId = documentNodeWithRequestedFlowsId(document);
+    if (!documentNodeId)
+        return;
+
+    ErrorString errorString;
+    int contentElementNodeId = m_domAgent->pushNodeToFrontend(&errorString, documentNodeId, contentElement);
+    int nextContentElementNodeId = nextContentElement ? m_domAgent->pushNodeToFrontend(&errorString, documentNodeId, nextContentElement) : 0;
+    m_frontend->registeredNamedFlowContentElement(documentNodeId, namedFlow->name().string(), contentElementNodeId, nextContentElementNodeId);
+}
+
+void InspectorCSSAgent::didUnregisterNamedFlowContentElement(Document* document, WebKitNamedFlow* namedFlow, Node* contentElement)
+{
+    int documentNodeId = documentNodeWithRequestedFlowsId(document);
+    if (!documentNodeId)
+        return;
+
+    ErrorString errorString;
+    int contentElementNodeId = m_domAgent->pushNodeToFrontend(&errorString, documentNodeId, contentElement);
+    m_frontend->unregisteredNamedFlowContentElement(documentNodeId, namedFlow->name().string(), contentElementNodeId);
+}
+
 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoType pseudoType)
 {
     if (m_nodeIdToForcedPseudoState.isEmpty())

Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.h (158158 => 158159)


--- trunk/Source/WebCore/inspector/InspectorCSSAgent.h	2013-10-29 02:37:53 UTC (rev 158158)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.h	2013-10-29 02:38:09 UTC (rev 158159)
@@ -110,6 +110,8 @@
     void regionLayoutUpdated(WebKitNamedFlow*, int documentNodeId);
     void didChangeRegionOverset(Document*, WebKitNamedFlow*);
     void regionOversetChanged(WebKitNamedFlow*, int documentNodeId);
+    void didRegisterNamedFlowContentElement(Document*, WebKitNamedFlow*, Node* contentElement, Node* nextContentElement = nullptr);
+    void didUnregisterNamedFlowContentElement(Document*, WebKitNamedFlow*, Node* contentElement);
 
     virtual void getComputedStyleForNode(ErrorString*, int nodeId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty>>&);
     virtual void getInlineStylesForNode(ErrorString*, int nodeId, RefPtr<TypeBuilder::CSS::CSSStyle>& inlineStyle, RefPtr<TypeBuilder::CSS::CSSStyle>& attributes);

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (158158 => 158159)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2013-10-29 02:37:53 UTC (rev 158158)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2013-10-29 02:38:09 UTC (rev 158159)
@@ -281,6 +281,18 @@
         cssAgent->didChangeRegionOverset(document, namedFlow);
 }
 
+void InspectorInstrumentation::didRegisterNamedFlowContentElementImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow, Node* contentElement, Node* nextContentElement)
+{
+    if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
+        cssAgent->didRegisterNamedFlowContentElement(document, namedFlow, contentElement, nextContentElement);
+}
+
+void InspectorInstrumentation::didUnregisterNamedFlowContentElementImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow, Node* contentElement)
+{
+    if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
+        cssAgent->didUnregisterNamedFlowContentElement(document, namedFlow, contentElement);
+}
+
 void InspectorInstrumentation::mouseDidMoveOverElementImpl(InstrumentingAgents* instrumentingAgents, const HitTestResult& result, unsigned modifierFlags)
 {
     if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (158158 => 158159)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2013-10-29 02:37:53 UTC (rev 158158)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2013-10-29 02:38:09 UTC (rev 158159)
@@ -132,6 +132,8 @@
     static void willRemoveNamedFlow(Document*, WebKitNamedFlow*);
     static void didUpdateRegionLayout(Document*, WebKitNamedFlow*);
     static void didChangeRegionOverset(Document*, WebKitNamedFlow*);
+    static void didRegisterNamedFlowContentElement(Document*, WebKitNamedFlow*, Node* contentElement, Node* nextContentElement = nullptr);
+    static void didUnregisterNamedFlowContentElement(Document*, WebKitNamedFlow*, Node* contentElement);
 
     static void mouseDidMoveOverElement(Page*, const HitTestResult&, unsigned modifierFlags);
     static bool handleMousePress(Page*);
@@ -337,6 +339,8 @@
     static void willRemoveNamedFlowImpl(InstrumentingAgents*, Document*, WebKitNamedFlow*);
     static void didUpdateRegionLayoutImpl(InstrumentingAgents*, Document*, WebKitNamedFlow*);
     static void didChangeRegionOversetImpl(InstrumentingAgents*, Document*, WebKitNamedFlow*);
+    static void didRegisterNamedFlowContentElementImpl(InstrumentingAgents*, Document*, WebKitNamedFlow*, Node* contentElement, Node* nextContentElement = nullptr);
+    static void didUnregisterNamedFlowContentElementImpl(InstrumentingAgents*, Document*, WebKitNamedFlow*, Node* contentElement);
 
     static void mouseDidMoveOverElementImpl(InstrumentingAgents*, const HitTestResult&, unsigned modifierFlags);
     static bool handleTouchEventImpl(InstrumentingAgents*, Node*);
@@ -718,6 +722,33 @@
 #endif
 }
 
+inline void InspectorInstrumentation::didRegisterNamedFlowContentElement(Document* document, WebKitNamedFlow* namedFlow, Node* contentElement, Node* nextContentElement)
+{
+#if ENABLE(INSPECTOR)
+    FAST_RETURN_IF_NO_FRONTENDS(void());
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
+        didRegisterNamedFlowContentElementImpl(instrumentingAgents, document, namedFlow, contentElement, nextContentElement);
+#else
+    UNUSED_PARAM(document);
+    UNUSED_PARAM(namedFlow);
+    UNUSED_PARAM(contentElement);
+    UNUSED_PARAM(nextContentElement);
+#endif
+}
+
+inline void InspectorInstrumentation::didUnregisterNamedFlowContentElement(Document* document, WebKitNamedFlow* namedFlow, Node* contentElement)
+{
+#if ENABLE(INSPECTOR)
+    FAST_RETURN_IF_NO_FRONTENDS(void());
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
+        didUnregisterNamedFlowContentElementImpl(instrumentingAgents, document, namedFlow, contentElement);
+#else
+    UNUSED_PARAM(document);
+    UNUSED_PARAM(namedFlow);
+    UNUSED_PARAM(contentElement);
+#endif
+}
+
 inline void InspectorInstrumentation::mouseDidMoveOverElement(Page* page, const HitTestResult& result, unsigned modifierFlags)
 {
 #if ENABLE(INSPECTOR)

Modified: trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp (158158 => 158159)


--- trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp	2013-10-29 02:37:53 UTC (rev 158158)
+++ trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp	2013-10-29 02:38:09 UTC (rev 158159)
@@ -447,11 +447,13 @@
         unsigned short position = contentElement.compareDocumentPosition(element);
         if (position & Node::DOCUMENT_POSITION_FOLLOWING) {
             m_contentElements.insertBefore(element, &contentElement);
+            InspectorInstrumentation::didRegisterNamedFlowContentElement(&document(), m_namedFlow.get(), &contentElement, element);
             return;
         }
     }
 
     m_contentElements.add(&contentElement);
+    InspectorInstrumentation::didRegisterNamedFlowContentElement(&document(), m_namedFlow.get(), &contentElement);
 }
 
 void RenderNamedFlowThread::unregisterNamedFlowContentElement(Element& contentElement)
@@ -465,6 +467,8 @@
 
     if (canBeDestroyed())
         setMarkForDestruction();
+
+    InspectorInstrumentation::didUnregisterNamedFlowContentElement(&document(), m_namedFlow.get(), &contentElement);
 }
 
 bool RenderNamedFlowThread::hasContentElement(Element& contentElement) const

Modified: trunk/Source/WebInspectorUI/ChangeLog (158158 => 158159)


--- trunk/Source/WebInspectorUI/ChangeLog	2013-10-29 02:37:53 UTC (rev 158158)
+++ trunk/Source/WebInspectorUI/ChangeLog	2013-10-29 02:38:09 UTC (rev 158159)
@@ -1,3 +1,32 @@
+2013-10-28  Alexandru Chiculita  <[email protected]>
+
+        Web Inspector: CSS Regions: Add protocol API to expose content nodes addition/removal
+        https://bugs.webkit.org/show_bug.cgi?id=123424
+
+        Reviewed by Timothy Hatcher.
+
+        Exposed the new CSS Agent events to the ContentFlow class that will now maintain
+        a list of nodes in the "contentNodes" property.
+
+        * UserInterface/CSSObserver.js:
+        (WebInspector.CSSObserver.prototype.regionOversetChanged):
+        (WebInspector.CSSObserver.prototype.registeredNamedFlowContentElement):
+        (WebInspector.CSSObserver.prototype.unregisteredNamedFlowContentElement):
+        * UserInterface/ContentFlow.js:
+        (WebInspector.ContentFlow):
+        (WebInspector.ContentFlow.prototype.set overset):
+        (WebInspector.ContentFlow.prototype.get contentNodes):
+        (WebInspector.ContentFlow.prototype.insertContentNodeBefore):
+        (WebInspector.ContentFlow.prototype.appendContentNode):
+        (WebInspector.ContentFlow.prototype.removeContentNode):
+        * UserInterface/DOMTreeManager.js:
+        (WebInspector.DOMTreeManager.prototype._createContentFlowFromPayload):
+        (WebInspector.DOMTreeManager.prototype._updateContentFlowFromPayload):
+        (WebInspector.DOMTreeManager.prototype.regionOversetChanged):
+        (WebInspector.DOMTreeManager.prototype.registeredNamedFlowContentElement):
+        (WebInspector.DOMTreeManager.prototype.unregisteredNamedFlowContentElement):
+        * UserInterface/InspectorBackendCommands.js:
+
 2013-10-25  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: PrettyPrinting tool should have save button

Modified: trunk/Source/WebInspectorUI/UserInterface/CSSObserver.js (158158 => 158159)


--- trunk/Source/WebInspectorUI/UserInterface/CSSObserver.js	2013-10-29 02:37:53 UTC (rev 158158)
+++ trunk/Source/WebInspectorUI/UserInterface/CSSObserver.js	2013-10-29 02:38:09 UTC (rev 158159)
@@ -71,6 +71,16 @@
     regionOversetChanged: function(namedFlow)
     {
         WebInspector.domTreeManager.regionOversetChanged(namedFlow);
+    },
+
+    registeredNamedFlowContentElement: function(documentNodeId, flowName, contentNodeId, nextContentElementNodeId)
+    {
+        WebInspector.domTreeManager.registeredNamedFlowContentElement(documentNodeId, flowName, contentNodeId, nextContentElementNodeId);
+    },
+
+    unregisteredNamedFlowContentElement: function(documentNodeId, flowName, contentNodeId)
+    {
+        WebInspector.domTreeManager.unregisteredNamedFlowContentElement(documentNodeId, flowName, contentNodeId);
     }
 };
 

Modified: trunk/Source/WebInspectorUI/UserInterface/ContentFlow.js (158158 => 158159)


--- trunk/Source/WebInspectorUI/UserInterface/ContentFlow.js	2013-10-29 02:37:53 UTC (rev 158158)
+++ trunk/Source/WebInspectorUI/UserInterface/ContentFlow.js	2013-10-29 02:38:09 UTC (rev 158159)
@@ -27,17 +27,20 @@
  * SUCH DAMAGE.
  */
 
-WebInspector.ContentFlow = function(documentNodeIdentifier, name, overset)
+WebInspector.ContentFlow = function(documentNodeIdentifier, name, overset, contentNodes)
 {
     WebInspector.Object.call(this);
 
     this._documentNodeIdentifier = documentNodeIdentifier;
     this._name = name;
     this._overset = overset;
+    this._contentNodes = contentNodes;
 };
 
 WebInspector.ContentFlow.Event = {
-    OversetWasChanged: "content-flow-overset-was-changed"
+    OversetWasChanged: "content-flow-overset-was-changed",
+    ContentNodeWasAdded: "content-flow-content-node-was-added",
+    ContentNodeWasRemoved: "content-flow-content-node-was-removed"
 };
 
 WebInspector.ContentFlow.prototype = {
@@ -73,8 +76,34 @@
             return;
         this._overset = overset;
         this.dispatchEventToListeners(WebInspector.ContentFlow.Event.FlowOversetWasChanged);
+    },
+
+    get contentNodes()
+    {
+        return this._contentNodes;
+    },
+
+    insertContentNodeBefore: function(contentNode, referenceNode)
+    {
+        var index = this._contentNodes.indexOf(referenceNode);
+        console.assert(index !== -1);
+        this._contentNodes.splice(index, 0, contentNode);
+        this.dispatchEventToListeners(WebInspector.ContentFlow.Event.ContentNodeWasAdded, {node: contentNode, before: referenceNode});
+    },
+
+    appendContentNode: function(contentNode)
+    {
+        this._contentNodes.push(contentNode);
+        this.dispatchEventToListeners(WebInspector.ContentFlow.Event.ContentNodeWasAdded, {node: contentNode});
+    },
+
+    removeContentNode: function(contentNode)
+    {
+        var index = this._contentNodes.indexOf(contentNode);
+        console.assert(index !== -1);
+        this._contentNodes.splice(index, 1);
+        this.dispatchEventToListeners(WebInspector.ContentFlow.Event.ContentNodeWasRemoved, {node: contentNode});
     }
-
 };
 
 

Modified: trunk/Source/WebInspectorUI/UserInterface/DOMTreeManager.js (158158 => 158159)


--- trunk/Source/WebInspectorUI/UserInterface/DOMTreeManager.js	2013-10-29 02:37:53 UTC (rev 158158)
+++ trunk/Source/WebInspectorUI/UserInterface/DOMTreeManager.js	2013-10-29 02:38:09 UTC (rev 158159)
@@ -535,13 +535,17 @@
 
     _createContentFlowFromPayload: function(flowPayload)
     {
-        // FIXME: Collect the content and regions from the payload.
-        return new WebInspector.ContentFlow(flowPayload.documentNodeId, flowPayload.name, flowPayload.overset);
+        // FIXME: Collect the regions from the payload.
+        return new WebInspector.ContentFlow(flowPayload.documentNodeId, flowPayload.name, flowPayload.overset, flowPayload.content.map(this.nodeForId.bind(this)));
     },
 
     _updateContentFlowFromPayload: function(contentFlow, flowPayload)
     {
-        // FIXME: Collect the content and regions from the payload.
+        console.assert(contentFlow.contentNodes.length === flowPayload.content.length);
+        for (var i = 0; i < contentFlow.contentNodes.length; ++i)
+            console.assert(contentFlow.contentNodes[i].id === flowPayload.content[i]);
+
+        // FIXME: Collect the regions from the payload.
         contentFlow.overset = flowPayload.overset;
     },
 
@@ -604,6 +608,27 @@
     regionOversetChanged: function(flowPayload)
     {
         this._sendNamedFlowUpdateEvents(flowPayload);
+    },
+
+    registeredNamedFlowContentElement: function(documentNodeIdentifier, flowName, contentNodeId, nextContentElementNodeId)
+    {
+        var flowKey = WebInspector.DOMTreeManager._flowPayloadHashKey({documentNodeId: documentNodeIdentifier, name: flowName});
+        console.assert(this._flows.hasOwnProperty(flowKey));
+
+        var flow = this._flows[flowKey];
+        var contentNode = this.nodeForId(contentNodeId);
+
+        if (nextContentElementNodeId)
+            flow.insertContentNodeBefore(contentNode, this.nodeForId(nextContentElementNodeId));
+        else
+            flow.appendContentNode(contentNode);
+    },
+
+    unregisteredNamedFlowContentElement: function(documentNodeIdentifier, flowName, contentNodeId)
+    {
+        var flowKey = WebInspector.DOMTreeManager._flowPayloadHashKey({documentNodeId: documentNodeIdentifier, name: flowName});
+        console.assert(this._flows.hasOwnProperty(flowKey));
+        this._flows[flowKey].removeContentNode(this.nodeForId(contentNodeId));
     }
 }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/InspectorBackendCommands.js (158158 => 158159)


--- trunk/Source/WebInspectorUI/UserInterface/InspectorBackendCommands.js	2013-10-29 02:37:53 UTC (rev 158158)
+++ trunk/Source/WebInspectorUI/UserInterface/InspectorBackendCommands.js	2013-10-29 02:38:09 UTC (rev 158159)
@@ -242,6 +242,8 @@
 InspectorBackend.registerEvent("CSS.namedFlowRemoved", ["documentNodeId", "flowName"]);
 InspectorBackend.registerEvent("CSS.regionLayoutUpdated", ["namedFlow"]);
 InspectorBackend.registerEvent("CSS.regionOversetChanged", ["namedFlow"]);
+InspectorBackend.registerEvent("CSS.registeredNamedFlowContentElement", ["documentNodeId", "flowName", "contentNodeId", "nextContentNodeId"]);
+InspectorBackend.registerEvent("CSS.unregisteredNamedFlowContentElement", ["documentNodeId", "flowName", "contentNodeId"]);
 InspectorBackend.registerCommand("CSS.enable", [], []);
 InspectorBackend.registerCommand("CSS.disable", [], []);
 InspectorBackend.registerCommand("CSS.getMatchedStylesForNode", [{"name": "nodeId", "type": "number", "optional": false}, {"name": "includePseudo", "type": "boolean", "optional": true}, {"name": "includeInherited", "type": "boolean", "optional": true}], ["matchedCSSRules", "pseudoElements", "inherited"]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to