Web Inspector: Protocol Extension: add getNamedFlowCollection command
https://bugs.webkit.org/show_bug.cgi?id=91607

Patch by Andrei Poenaru <poenaru@adobe.com> on 2012-07-20
Reviewed by Pavel Feldman.

Source/WebCore:

Extended the protocol with "getNamedFlowCollection" command.
This command returns the CSS Named Flows from the document.

Test: inspector/styles/protocol-getNamedFlowCollection-command.html

* dom/WebKitNamedFlowCollection.cpp:
(WebCore::WebKitNamedFlowCollection::namedFlowsNames):
(WebCore):
* dom/WebKitNamedFlowCollection.h:
(WebKitNamedFlowCollection):
* inspector/Inspector.json:
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::getNamedFlowCollection):
(WebCore):
* inspector/InspectorCSSAgent.h:
(InspectorCSSAgent):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::assertDocument):
(WebCore):
* inspector/InspectorDOMAgent.h:
(InspectorDOMAgent):
* inspector/front-end/CSSStyleModel.js:
(WebInspector.CSSStyleModel.prototype.getNamedFlowCollectionAsync):

LayoutTests:

The test builds a webpage with 3 Named Flows in the main frame and 1 Named Flow in an iframe.
Because the getNamedFlowCollection command is executed with the main document node id as an argument,
it should return only the first 3 Named Flows.

* inspector/styles/protocol-getNamedFlowCollection-command-expected.txt: Added.
* inspector/styles/protocol-getNamedFlowCollection-command.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@123205 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/dom/WebKitNamedFlowCollection.cpp b/Source/WebCore/dom/WebKitNamedFlowCollection.cpp
index b0cff11..c50e057 100644
--- a/Source/WebCore/dom/WebKitNamedFlowCollection.cpp
+++ b/Source/WebCore/dom/WebKitNamedFlowCollection.cpp
@@ -43,6 +43,20 @@
 {
 }
 
+Vector<String> WebKitNamedFlowCollection::namedFlowsNames()
+{
+    Vector<String> namedFlows;
+
+    for (NamedFlowSet::iterator it = m_namedFlows.begin(); it != m_namedFlows.end(); ++it) {
+        if ((*it)->flowState() == WebKitNamedFlow::FlowStateNull)
+            continue;
+
+        namedFlows.append((*it)->name().string());
+    }
+
+    return namedFlows;
+}
+
 WebKitNamedFlow* WebKitNamedFlowCollection::flowByName(const String& flowName)
 {
     NamedFlowSet::iterator it = m_namedFlows.find<String, NamedFlowHashTranslator>(flowName);