Web Inspector: CSS Regions: Add protocol API to expose content nodes addition/removal
authorachicu@adobe.com <achicu@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Oct 2013 02:38:09 +0000 (02:38 +0000)
committerachicu@adobe.com <achicu@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Oct 2013 02:38:09 +0000 (02:38 +0000)
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.

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

15 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector-protocol/model/content-flow-content-nodes-expected.txt [new file with mode: 0644]
LayoutTests/inspector-protocol/model/content-flow-content-nodes.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/InspectorCSSAgent.cpp
Source/WebCore/inspector/InspectorCSSAgent.h
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/rendering/RenderNamedFlowThread.cpp
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/CSSObserver.js
Source/WebInspectorUI/UserInterface/ContentFlow.js
Source/WebInspectorUI/UserInterface/DOMTreeManager.js
Source/WebInspectorUI/UserInterface/InspectorBackendCommands.js

index 980c0fa..259e86c 100644 (file)
@@ -1,3 +1,16 @@
+2013-10-28  Alexandru Chiculita  <achicu@adobe.com>
+
+        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  <simon.fraser@apple.com>
 
         Last few Mavericks WK2 failures.
diff --git a/LayoutTests/inspector-protocol/model/content-flow-content-nodes-expected.txt b/LayoutTests/inspector-protocol/model/content-flow-content-nodes-expected.txt
new file mode 100644 (file)
index 0000000..c5d1c81
--- /dev/null
@@ -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.
+
diff --git a/LayoutTests/inspector-protocol/model/content-flow-content-nodes.html b/LayoutTests/inspector-protocol/model/content-flow-content-nodes.html
new file mode 100644 (file)
index 0000000..4f251c5
--- /dev/null
@@ -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="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
+<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>
index 221a81b..e31b71c 100644 (file)
@@ -1,3 +1,31 @@
+2013-10-28  Alexandru Chiculita  <achicu@adobe.com>
+
+        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  <pecoraro@apple.com>
 
         Web Inspector: Remove unused inspector/inline-javascript-imports.py
index 1c62971..f21b07a 100644 (file)
                     { "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."
             }
         ]
     },
index 26b4274..988c3c4 100644 (file)
@@ -775,6 +775,29 @@ void InspectorCSSAgent::regionOversetChanged(WebKitNamedFlow* namedFlow, int doc
     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())
index 3c82a2f..3295644 100644 (file)
@@ -110,6 +110,8 @@ public:
     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);
index a7d1e6a..12077c3 100644 (file)
@@ -281,6 +281,18 @@ void InspectorInstrumentation::didChangeRegionOversetImpl(InstrumentingAgents* i
         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())
index f091221..d3513c3 100644 (file)
@@ -132,6 +132,8 @@ public:
     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 @@ private:
     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 @@ inline void InspectorInstrumentation::didChangeRegionOverset(Document* document,
 #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)
index fe5c872..8c8c578 100644 (file)
@@ -447,11 +447,13 @@ void RenderNamedFlowThread::registerNamedFlowContentElement(Element& contentElem
         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 @@ void RenderNamedFlowThread::unregisterNamedFlowContentElement(Element& contentEl
 
     if (canBeDestroyed())
         setMarkForDestruction();
+
+    InspectorInstrumentation::didUnregisterNamedFlowContentElement(&document(), m_namedFlow.get(), &contentElement);
 }
 
 bool RenderNamedFlowThread::hasContentElement(Element& contentElement) const
index 0715817..06ecafa 100644 (file)
@@ -1,3 +1,32 @@
+2013-10-28  Alexandru Chiculita  <achicu@adobe.com>
+
+        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  <pecoraro@apple.com>
 
         Web Inspector: PrettyPrinting tool should have save button
index 55f3442..44fed24 100644 (file)
@@ -71,6 +71,16 @@ WebInspector.CSSObserver.prototype = {
     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);
     }
 };
 
index 7f3a710..d2e2c44 100644 (file)
  * 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 @@ WebInspector.ContentFlow.prototype = {
             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});
+    }
 };
 
 
index ae7fac9..37df97c 100644 (file)
@@ -535,13 +535,17 @@ WebInspector.DOMTreeManager.prototype = {
 
     _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 @@ WebInspector.DOMTreeManager.prototype = {
     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));
     }
 }
 
index 8c7f43a..1976f9e 100644 (file)
@@ -242,6 +242,8 @@ InspectorBackend.registerEvent("CSS.namedFlowCreated", ["namedFlow"]);
 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"]);