LayoutTests/ChangeLog

 12012-08-06 Andrei Poenaru <poenaru@adobe.com>
 2
 3 Web Inspector: Protocol: Add "namedFlowCreated" and "namedFlowRemoved" events
 4 https://bugs.webkit.org/show_bug.cgi?id=92739
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Modified test so that it validates the implemented events.
 9
 10 * inspector/styles/protocol-css-regions-commands-expected.txt:
 11 * inspector/styles/protocol-css-regions-commands.html:
 12
1132012-08-06 Takashi Toyoshima <toyoshim@chromium.org>
214
315 Unreviewed, rebaseline for Mac10.6 against r124752

LayoutTests/inspector/styles/protocol-css-regions-commands-expected.txt

1 Tests the following commands:
 1Tests the following commands and events:
22
33getNamedFlowCollection Bug 91607
44getFlowByName Bug 91855
 5namedFlowCreated Bug 92739
 6namedFlowRemoved Bug 92739
57
68
79Running: testGetNamedFlowCollection

@@Running: testGetFlowByName2
1921=== Name Flow "flow4" from main document ===
2022There is no Named Flow "flow4" in the main document
2123
 24Running: testNamedFlowCreated
 25NamedFlowCreated: "tmpNamedFlow"
 26
 27Running: testNamedFlowRemoved
 28NamedFlowRemoved: "tmpNamedFlow"
 29

LayoutTests/inspector/styles/protocol-css-regions-commands.html

@@function createDynamicElements()
1818 runTest();
1919}
2020
 21function createNamedFlow()
 22{
 23 var article = document.createElement("article");
 24 article.id = "tmpArticle";
 25 article.style.webkitFlowInto = "tmpNamedFlow";
 26
 27 document.body.appendChild(article);
 28}
 29
 30function removeNamedFlow()
 31{
 32 var article = document.getElementById("tmpArticle");
 33
 34 document.body.removeChild(article);
 35}
 36
2137function test()
2238{
2339 WebInspector.showPanel("elements");

@@function test()
99115 next();
100116 }
101117 },
 118
 119 function testNamedFlowCreated(next)
 120 {
 121 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.NamedFlowCreated, callback, this);
 122 InspectorTest.evaluateInPage("createNamedFlow()");
 123
 124 function callback(event)
 125 {
 126 WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.NamedFlowCreated, callback, this);
 127
 128 if (event.data.name !== "tmpNamedFlow") {
 129 Inspector.addResult("[!] Failed");
 130 InspectorTest.completeTest();
 131 return;
 132 }
 133
 134 InspectorTest.addResult("NamedFlowCreated: \"tmpNamedFlow\"");
 135 next();
 136 }
 137 },
 138
 139 function testNamedFlowRemoved(next)
 140 {
 141 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.NamedFlowRemoved, callback, this);
 142 InspectorTest.evaluateInPage("removeNamedFlow()");
 143
 144 function callback(event)
 145 {
 146 WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.NamedFlowRemoved, callback, this);
 147 if (event.data.name !== "tmpNamedFlow") {
 148 Inspector.addResult("[!] Failed");
 149 InspectorTest.completeTest();
 150 return;
 151 }
 152
 153 InspectorTest.addResult("NamedFlowRemoved: \"tmpNamedFlow\"");
 154 next();
 155 }
 156 }
102157 ]);
103158}
104159</script>

@@function test()
106161
107162<body onload="createDynamicElements()">
108163<p>
109 Tests the following commands:
 164Tests the following commands and events:
110165<ul>
111166 <li>getNamedFlowCollection <a href="https://bugs.webkit.org/show_bug.cgi?id=91607">Bug 91607</a></li>
112167 <li>getFlowByName <a href="https://bugs.webkit.org/show_bug.cgi?id=91855">Bug 91855</a></li>
 168 <li>namedFlowCreated <a href="https://bugs.webkit.org/show_bug.cgi?id=92739">Bug 92739</a></li>
 169 <li>namedFlowRemoved <a href="https://bugs.webkit.org/show_bug.cgi?id=92739">Bug 92739</a></li>
113170</ul>
114171</p>
115172

Source/WebCore/ChangeLog

 12012-08-06 Andrei Poenaru <poenaru@adobe.com>
 2
 3 Web Inspector: Protocol: Add "namedFlowCreated" and "namedFlowRemoved" events
 4 https://bugs.webkit.org/show_bug.cgi?id=92739
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Implemented "namedFlowCreated" and "namedFlowRemoved" events.
 9
 10 Modified test: inspector/styles/protocol-css-regions-commands.html.
 11
 12 * dom/WebKitNamedFlowCollection.cpp:
 13 (WebCore::WebKitNamedFlowCollection::ensureFlowWithName):
 14 (WebCore::WebKitNamedFlowCollection::discardNamedFlow):
 15 * inspector/Inspector.json:
 16 * inspector/InspectorCSSAgent.cpp:
 17 (WebCore::InspectorCSSAgent::reset):
 18 (WebCore::InspectorCSSAgent::didCreateNamedFlow):
 19 (WebCore):
 20 (WebCore::InspectorCSSAgent::didRemoveNamedFlow):
 21 (WebCore::InspectorCSSAgent::getNamedFlowCollection):
 22 * inspector/InspectorCSSAgent.h:
 23 (InspectorCSSAgent):
 24 * inspector/InspectorInstrumentation.cpp:
 25 (WebCore):
 26 (WebCore::InspectorInstrumentation::didCreateNamedFlowImpl):
 27 (WebCore::InspectorInstrumentation::didRemoveNamedFlowImpl):
 28 * inspector/InspectorInstrumentation.h:
 29 (InspectorInstrumentation):
 30 (WebCore::InspectorInstrumentation::didCreateNamedFlow):
 31 (WebCore):
 32 (WebCore::InspectorInstrumentation::didRemoveNamedFlow):
 33 * inspector/front-end/CSSStyleModel.js:
 34 (WebInspector.CSSStyleModel.prototype._namedFlowCreated.callback):
 35 (WebInspector.CSSStyleModel.prototype._namedFlowCreated):
 36 (WebInspector.CSSStyleModel.prototype._namedFlowRemoved.callback):
 37 (WebInspector.CSSStyleModel.prototype._namedFlowRemoved):
 38 (WebInspector.CSSDispatcher.prototype.styleSheetChanged):
 39 (WebInspector.CSSDispatcher.prototype.namedFlowCreated):
 40 (WebInspector.CSSDispatcher.prototype.namedFlowRemoved):
 41
1422012-08-06 Sergey Rogulenko <rogulenko@google.com>
243
344 Web Inspector: a tiny refactoring of Highlighter in InspectorDOMAgent

Source/WebCore/dom/WebKitNamedFlowCollection.cpp

3131#include "WebKitNamedFlowCollection.h"
3232
3333#include "Document.h"
 34#include "InspectorInstrumentation.h"
3435#include "WebKitNamedFlow.h"
3536
3637#include <wtf/text/StringHash.h>

@@PassRefPtr<WebKitNamedFlow> WebKitNamedFlowCollection::ensureFlowWithName(const
7980 RefPtr<WebKitNamedFlow> newFlow = WebKitNamedFlow::create(this, flowName);
8081 m_namedFlows.add(newFlow.get());
8182
 83 InspectorInstrumentation::didCreateNamedFlow(m_document, newFlow->name());
 84
8285 return newFlow.release();
8386}
8487

@@void WebKitNamedFlowCollection::discardNamedFlow(WebKitNamedFlow* namedFlow)
9295 ASSERT(m_namedFlows.contains(namedFlow));
9396
9497 m_namedFlows.remove(namedFlow);
 98
 99 InspectorInstrumentation::didRemoveNamedFlow(m_document, namedFlow->name());
95100}
96101
97102void WebKitNamedFlowCollection::documentDestroyed()

Source/WebCore/inspector/Inspector.json

23732373 { "name": "styleSheetId", "$ref": "StyleSheetId" }
23742374 ],
23752375 "description": "Fired whenever a stylesheet is changed as a result of the client operation."
 2376 },
 2377 {
 2378 "name": "namedFlowCreated",
 2379 "parameters": [
 2380 { "name": "nodeId", "$ref": "DOM.NodeId", "description": "The document node id." },
 2381 { "name": "namedFlow", "type": "string", "description": "Identifier of the new Named Flow." }
 2382 ],
 2383 "description": "Fires when a Named Flow is created.",
 2384 "hidden": true
 2385 },
 2386 {
 2387 "name": "namedFlowRemoved",
 2388 "parameters": [
 2389 { "name": "nodeId", "$ref": "DOM.NodeId", "description": "The document node id." },
 2390 { "name": "namedFlow", "type": "string", "description": "Identifier of the removed Named Flow." }
 2391 ],
 2392 "description": "Fires when a Named Flow is removed: has no associated content nodes and regions.",
 2393 "hidden": true
23762394 }
23772395 ]
23782396 },

Source/WebCore/inspector/InspectorCSSAgent.cpp

@@void InspectorCSSAgent::reset()
516516 m_cssStyleSheetToInspectorStyleSheet.clear();
517517 m_nodeToInspectorStyleSheet.clear();
518518 m_documentToInspectorStyleSheet.clear();
 519 m_namedFlowCollectionsRequested.clear();
519520 resetPseudoStates();
520521}
521522

@@void InspectorCSSAgent::mediaQueryResultChanged()
535536 m_frontend->mediaQueryResultChanged();
536537}
537538
 539void InspectorCSSAgent::didCreateNamedFlow(Document* document, const AtomicString& name)
 540{
 541 int nodeId = m_domAgent->boundNodeId(document);
 542 if (!nodeId || !m_namedFlowCollectionsRequested.contains(nodeId))
 543 return;
 544
 545 m_frontend->namedFlowCreated(nodeId, name.string());
 546}
 547
 548void InspectorCSSAgent::didRemoveNamedFlow(Document* document, const AtomicString& name)
 549{
 550 int nodeId = m_domAgent->boundNodeId(document);
 551 if (!nodeId || !m_namedFlowCollectionsRequested.contains(nodeId))
 552 return;
 553
 554 m_frontend->namedFlowRemoved(nodeId, name.string());
 555}
 556
538557bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoType pseudoType)
539558{
540559 if (m_nodeIdToForcedPseudoState.isEmpty())

@@void InspectorCSSAgent::getNamedFlowCollection(ErrorString* errorString, int nod
811830 if (!document)
812831 return;
813832
 833 m_namedFlowCollectionsRequested.add(nodeId);
 834
814835 Vector<String> namedFlowsVector = document->namedFlows()->namedFlowsNames();
815836 RefPtr<TypeBuilder::Array<String> > namedFlows = TypeBuilder::Array<String>::create();
816837

Source/WebCore/inspector/InspectorCSSAgent.h

3636#include "SecurityContext.h"
3737
3838#include <wtf/HashMap.h>
 39#include <wtf/HashSet.h>
3940#include <wtf/PassRefPtr.h>
4041#include <wtf/RefPtr.h>
4142

@@public:
9798 virtual void disable(ErrorString*);
9899 void reset();
99100 void mediaQueryResultChanged();
 101 void didCreateNamedFlow(Document*, const AtomicString& name);
 102 void didRemoveNamedFlow(Document*, const AtomicString& name);
100103
101104 virtual void getComputedStyleForNode(ErrorString*, int nodeId, const RefPtr<InspectorArray>* forcedPseudoClasses, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >&);
102105 virtual void getInlineStylesForNode(ErrorString*, int nodeId, RefPtr<TypeBuilder::CSS::CSSStyle>& inlineStyle, RefPtr<TypeBuilder::CSS::CSSStyle>& attributes);

@@private:
169172 NodeToInspectorStyleSheet m_nodeToInspectorStyleSheet;
170173 DocumentToViaInspectorStyleSheet m_documentToInspectorStyleSheet;
171174 NodeIdToForcedPseudoState m_nodeIdToForcedPseudoState;
 175 HashSet<int> m_namedFlowCollectionsRequested;
172176
173177 int m_lastStyleSheetId;
174178

Source/WebCore/inspector/InspectorInstrumentation.cpp

@@void InspectorInstrumentation::willPopShadowRootImpl(InstrumentingAgents* instru
232232 domAgent->willPopShadowRoot(host, root);
233233}
234234
 235void InspectorInstrumentation::didCreateNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, const AtomicString& name)
 236{
 237 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
 238 cssAgent->didCreateNamedFlow(document, name);
 239}
 240
 241void InspectorInstrumentation::didRemoveNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, const AtomicString& name)
 242{
 243 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
 244 cssAgent->didRemoveNamedFlow(document, name);
 245}
 246
235247void InspectorInstrumentation::mouseDidMoveOverElementImpl(InstrumentingAgents* instrumentingAgents, const HitTestResult& result, unsigned modifierFlags)
236248{
237249 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())

Source/WebCore/inspector/InspectorInstrumentation.h

@@public:
113113 static void mediaQueryResultChanged(Document*);
114114 static void didPushShadowRoot(Element* host, ShadowRoot*);
115115 static void willPopShadowRoot(Element* host, ShadowRoot*);
 116 static void didCreateNamedFlow(Document*, const AtomicString& name);
 117 static void didRemoveNamedFlow(Document*, const AtomicString& name);
116118
117119 static void mouseDidMoveOverElement(Page*, const HitTestResult&, unsigned modifierFlags);
118120 static bool handleMousePress(Page*);

@@private:
290292 static void mediaQueryResultChangedImpl(InstrumentingAgents*);
291293 static void didPushShadowRootImpl(InstrumentingAgents*, Element* host, ShadowRoot*);
292294 static void willPopShadowRootImpl(InstrumentingAgents*, Element* host, ShadowRoot*);
 295 static void didCreateNamedFlowImpl(InstrumentingAgents*, Document*, const AtomicString& name);
 296 static void didRemoveNamedFlowImpl(InstrumentingAgents*, Document*, const AtomicString& name);
293297
294298 static void mouseDidMoveOverElementImpl(InstrumentingAgents*, const HitTestResult&, unsigned modifierFlags);
295299 static bool handleMousePressImpl(InstrumentingAgents*);

@@inline void InspectorInstrumentation::willPopShadowRoot(Element* host, ShadowRoo
557561#endif
558562}
559563
 564inline void InspectorInstrumentation::didCreateNamedFlow(Document* document, const AtomicString& name)
 565{
 566#if ENABLE(INSPECTOR)
 567 FAST_RETURN_IF_NO_FRONTENDS(void());
 568 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
 569 didCreateNamedFlowImpl(instrumentingAgents, document, name);
 570#endif
 571}
 572
 573inline void InspectorInstrumentation::didRemoveNamedFlow(Document* document, const AtomicString& name)
 574{
 575#if ENABLE(INSPECTOR)
 576 FAST_RETURN_IF_NO_FRONTENDS(void());
 577 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
 578 didRemoveNamedFlowImpl(instrumentingAgents, document, name);
 579#endif
 580}
 581
560582inline void InspectorInstrumentation::mouseDidMoveOverElement(Page* page, const HitTestResult& result, unsigned modifierFlags)
561583{
562584#if ENABLE(INSPECTOR)

Source/WebCore/inspector/front-end/CSSStyleModel.js

@@WebInspector.CSSStyleModel.parseRuleArrayPayload = function(ruleArray)
5656
5757WebInspector.CSSStyleModel.Events = {
5858 StyleSheetChanged: "StyleSheetChanged",
59  MediaQueryResultChanged: "MediaQueryResultChanged"
 59 MediaQueryResultChanged: "MediaQueryResultChanged",
 60 NamedFlowCreated: "NamedFlowCreated",
 61 NamedFlowRemoved: "NamedFlowRemoved"
6062}
6163
6264WebInspector.CSSStyleModel.prototype = {

@@WebInspector.CSSStyleModel.prototype = {
340342 },
341343
342344 /**
 345 * @param {DOMAgent.NodeId} documentNodeId
 346 * @param {string} name
 347 */
 348 _namedFlowCreated: function(documentNodeId, name)
 349 {
 350 if (!this.hasEventListeners(WebInspector.CSSStyleModel.Events.NamedFlowCreated))
 351 return;
 352
 353 /**
 354 * @param {WebInspector.DOMDocument} root
 355 */
 356 function callback(root)
 357 {
 358 // FIXME: At the moment we only want support for NamedFlows in the main document
 359 if (documentNodeId !== root.id)
 360 return;
 361
 362 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.NamedFlowCreated, { documentNodeId: documentNodeId, name: name });
 363 }
 364
 365 WebInspector.domAgent.requestDocument(callback.bind(this));
 366 },
 367
 368 /**
 369 * @param {DOMAgent.NodeId} documentNodeId
 370 * @param {string} name
 371 */
 372 _namedFlowRemoved: function(documentNodeId, name)
 373 {
 374 if (!this.hasEventListeners(WebInspector.CSSStyleModel.Events.NamedFlowRemoved))
 375 return;
 376
 377 /**
 378 * @param {WebInspector.DOMDocument} root
 379 */
 380 function callback(root)
 381 {
 382 // FIXME: At the moment we only want support for NamedFlows in the main document
 383 if (documentNodeId !== root.id)
 384 return;
 385
 386 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.NamedFlowRemoved, { documentNodeId: documentNodeId, name: name });
 387 }
 388
 389 WebInspector.domAgent.requestDocument(callback.bind(this));
 390 },
 391
 392 /**
343393 * @param {CSSAgent.StyleSheetId} styleSheetId
344394 * @param {string} newText
345395 * @param {boolean} majorChange

@@WebInspector.CSSDispatcher.prototype = {
12651315 styleSheetChanged: function(styleSheetId)
12661316 {
12671317 this._cssModel._fireStyleSheetChanged(styleSheetId);
 1318 },
 1319
 1320 /**
 1321 * @param {DOMAgent.NodeId} documentNodeId
 1322 * @param {string} name
 1323 */
 1324 namedFlowCreated: function(documentNodeId, name)
 1325 {
 1326 this._cssModel._namedFlowCreated(documentNodeId, name);
 1327 },
 1328
 1329 /**
 1330 * @param {DOMAgent.NodeId} documentNodeId
 1331 * @param {string} name
 1332 */
 1333 namedFlowRemoved: function(documentNodeId, name)
 1334 {
 1335 this._cssModel._namedFlowRemoved(documentNodeId, name);
12681336 }
12691337}
12701338