Changeset 127468 in webkit
- Timestamp:
- Sep 4, 2012 8:32:27 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r127466 r127468 1 2012-09-04 Andrei Poenaru <poenaru@adobe.com> 2 3 Web Inspector: Protocol Extension: Add "regionLayoutUpdate" event 4 https://bugs.webkit.org/show_bug.cgi?id=93443 5 6 Reviewed by Pavel Feldman. 7 8 Validate "regionLayoutUpdate" event. 9 10 * inspector/styles/protocol-css-regions-commands-expected.txt: 11 * inspector/styles/protocol-css-regions-commands.html: 12 1 13 2012-09-04 Mario Sanchez Prada <msanchez@igalia.com> 2 14 -
trunk/LayoutTests/inspector/styles/protocol-css-regions-commands-expected.txt
r125268 r127468 5 5 namedFlowCreated Bug 92739 6 6 namedFlowRemoved Bug 92739 7 regionLayoutUpdated Bug 93443 8 This text is from CSS Named Flow "flow3". 7 9 8 10 9 Running: testGetNamedFlowCollection 111 Running: testGetNamedFlowCollection 10 12 === CSS Named Flows in main document === 11 13 * Named Flow "flow1" … … 19 21 Regions: 1 20 22 21 Running: testGetNamedFlowCollection 223 Running: testGetNamedFlowCollectionWithInvalidDocument 22 24 === CSS Named Flows in #fake-document === 23 25 #fake-document is not a document 24 26 25 Running: testGetFlowByName 127 Running: testGetFlowByName 26 28 === Named Flow "flow2" from main document === 27 29 * Named Flow "flow2" … … 29 31 Regions: 2 30 32 31 Running: testGetFlowByName 233 Running: testGetFlowByNameWithInvalidName 32 34 === Name Flow "flow4" from main document === 33 35 There is no Named Flow "flow4" in the main document … … 36 38 NamedFlowCreated: "tmpNamedFlow" 37 39 40 Running: testRegionLayoutUpdated 41 RegionLayoutUpdated: "flow3" 42 38 43 Running: testNamedFlowRemoved 39 44 NamedFlowRemoved: "tmpNamedFlow" -
trunk/LayoutTests/inspector/styles/protocol-css-regions-commands.html
r125268 r127468 22 22 { 23 23 var article = document.createElement("article"); 24 var div = document.createElement("div"); 25 24 26 article.id = "tmpArticle"; 25 article.style.webkitFlowInto = "tmpNamedFlow"; 27 article.style["-webkit-flow-into"] = "tmpNamedFlow"; 28 article.textContent = "This text is from CSS Named Flow \"tmpNamedFlow\""; 29 30 div.id = "tmpDiv"; 31 div.style["-webkit-flow-from"] = "tmpNamedFlow"; 32 div.style["height"] = "5px"; 33 div.style["width"] = "20px"; 26 34 27 35 document.body.appendChild(article); 36 document.body.appendChild(div); 28 37 } 29 38 30 39 function removeNamedFlow() 31 40 { 32 var article = document.getElementById("tmpArticle"); 33 34 document.body.removeChild(article); 41 document.body.removeChild(document.getElementById("tmpArticle")); 42 document.body.removeChild(document.getElementById("tmpDiv")); 35 43 } 36 44 … … 39 47 WebInspector.showPanel("elements"); 40 48 InspectorTest.runTestSuite([ 41 function testGetNamedFlowCollection 1(next)49 function testGetNamedFlowCollection(next) 42 50 { 43 51 WebInspector.domAgent.requestDocument(documentCallback); … … 48 56 } 49 57 50 function namedFlowCallback(namedFlow s)58 function namedFlowCallback(namedFlowMap) 51 59 { 52 60 InspectorTest.addResult("=== CSS Named Flows in main document ==="); 53 61 54 if (!namedFlow s) {62 if (!namedFlowMap) { 55 63 InspectorTest.addResult("[!] Failed to get Named Flows"); 56 64 InspectorTest.completeTest(); 57 65 return; 58 66 } 67 68 namedFlows = []; 69 for (var flowName in namedFlowMap) 70 namedFlows.push(namedFlowMap[flowName]); 59 71 60 72 namedFlows.sort(function (nf1, nf2) { … … 69 81 }, 70 82 71 function testGetNamedFlowCollection 2(next)83 function testGetNamedFlowCollectionWithInvalidDocument(next) 72 84 { 73 85 WebInspector.domAgent.requestDocument(documentCallback); … … 83 95 } 84 96 85 function namedFlowCallback(namedFlow s)97 function namedFlowCallback(namedFlowMap) 86 98 { 87 99 InspectorTest.addResult("=== CSS Named Flows in #fake-document ==="); 88 100 89 if (namedFlow s) {101 if (namedFlowMap) { 90 102 InspectorTest.addResult("[!] Failed"); 91 103 InspectorTest.completeTest(); … … 98 110 }, 99 111 100 function testGetFlowByName 1(next)112 function testGetFlowByName(next) 101 113 { 102 114 WebInspector.domAgent.requestDocument(documentCallback); … … 123 135 }, 124 136 125 function testGetFlowByName 2(next)137 function testGetFlowByNameWithInvalidName(next) 126 138 { 127 139 WebInspector.domAgent.requestDocument(documentCallback); … … 154 166 function callback(event) 155 167 { 168 if (event.data.name !== "tmpNamedFlow") 169 return; 170 156 171 WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.NamedFlowCreated, callback, this); 157 172 158 if (event.data.name !== "tmpNamedFlow") {159 Inspector.addResult("[!] Failed");160 InspectorTest.completeTest();161 return;162 }163 164 173 InspectorTest.addResult("NamedFlowCreated: \"tmpNamedFlow\""); 174 next(); 175 } 176 }, 177 178 function testRegionLayoutUpdated(next) 179 { 180 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.RegionLayoutUpdated, callback, this); 181 InspectorTest.evaluateInPage("document.getElementById(\"region3\").style[\"width\"] = \"200px\""); 182 183 function callback(event) 184 { 185 if (event.data.name !== "flow3") 186 return; 187 188 WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.RegionLayoutUpdated, callback, this); 189 190 InspectorTest.addResult("RegionLayoutUpdated: \"flow3\""); 165 191 next(); 166 192 } … … 174 200 function callback(event) 175 201 { 202 if (event.data.flowName !== "tmpNamedFlow") 203 return; 204 176 205 WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.NamedFlowRemoved, callback, this); 177 if (event.data.name !== "tmpNamedFlow") {178 Inspector.addResult("[!] Failed");179 InspectorTest.completeTest();180 return;181 }182 206 183 207 InspectorTest.addResult("NamedFlowRemoved: \"tmpNamedFlow\""); … … 205 229 <li>namedFlowCreated <a href="https://bugs.webkit.org/show_bug.cgi?id=92739">Bug 92739</a></li> 206 230 <li>namedFlowRemoved <a href="https://bugs.webkit.org/show_bug.cgi?id=92739">Bug 92739</a></li> 231 <li>regionLayoutUpdated <a href="https://bugs.webkit.org/show_bug.cgi?id=93443">Bug 93443</a></li> 207 232 </ul> 208 233 </p> … … 217 242 <div style="-webkit-flow-from: flow2"></div> 218 243 219 <article style="-webkit-flow-into: flow3"></article> 220 <div style="-webkit-flow-from: flow3"></div> 244 <article style="-webkit-flow-into: flow3"> 245 This text is from CSS Named Flow "flow3". 246 </article> 247 <div id="region3" style="-webkit-flow-from: flow3; height: 20px; width: 5px"></div> 221 248 222 249 <div id="fake-document"></div> -
trunk/Source/WebCore/ChangeLog
r127467 r127468 1 2012-09-04 Andrei Poenaru <poenaru@adobe.com> 2 3 Web Inspector: Protocol Extension: Add "regionLayoutUpdate" event 4 https://bugs.webkit.org/show_bug.cgi?id=93443 5 6 Reviewed by Pavel Feldman. 7 8 Added "regionLayoutUpdate" event to the protocol. 9 10 Removed "getFlowByName" from protocol. 11 12 The front-end keeps in sync the requested Named Flow Collections. 13 14 Modified existing test: inspector/styles/protocol-css-regions-commands.html 15 16 * dom/NamedFlowCollection.cpp: 17 (WebCore::NamedFlowCollection::ensureFlowWithName): 18 (WebCore::NamedFlowCollection::discardNamedFlow): 19 * inspector/Inspector.json: 20 * inspector/InspectorCSSAgent.cpp: 21 (WebCore::InspectorCSSAgent::didCreateNamedFlow): 22 (WebCore::InspectorCSSAgent::willRemoveNamedFlow): 23 (WebCore): 24 (WebCore::InspectorCSSAgent::didUpdateRegionLayout): 25 (WebCore::InspectorCSSAgent::getNamedFlowCollection): 26 (WebCore::InspectorCSSAgent::documentNodeWithRequestedFlowsId): 27 * inspector/InspectorCSSAgent.h: 28 (InspectorCSSAgent): 29 * inspector/InspectorInstrumentation.cpp: 30 (WebCore): 31 (WebCore::InspectorInstrumentation::didCreateNamedFlowImpl): 32 (WebCore::InspectorInstrumentation::willRemoveNamedFlowImpl): 33 (WebCore::InspectorInstrumentation::didUpdateRegionLayoutImpl): 34 * inspector/InspectorInstrumentation.h: 35 (InspectorInstrumentation): 36 (WebCore::InspectorInstrumentation::didCreateNamedFlow): 37 (WebCore::InspectorInstrumentation::willRemoveNamedFlow): 38 (WebCore): 39 (WebCore::InspectorInstrumentation::didUpdateRegionLayout): 40 * inspector/front-end/CSSStyleModel.js: 41 (WebInspector.CSSStyleModel): 42 (WebInspector.CSSStyleModel.prototype.getNamedFlowCollectionAsync.callback): 43 (WebInspector.CSSStyleModel.prototype.getNamedFlowCollectionAsync): 44 (WebInspector.CSSStyleModel.prototype.getFlowByNameAsync.callback): 45 (WebInspector.CSSStyleModel.prototype.getFlowByNameAsync): 46 (WebInspector.CSSStyleModel.prototype._namedFlowCreated): 47 (WebInspector.CSSStyleModel.prototype._namedFlowRemoved): 48 (WebInspector.CSSStyleModel.prototype._regionLayoutUpdated): 49 (WebInspector.CSSStyleModel.prototype._resetNamedFlowCollections): 50 (WebInspector.CSSDispatcher.prototype.namedFlowCreated): 51 (WebInspector.CSSDispatcher.prototype.namedFlowRemoved): 52 (WebInspector.CSSDispatcher.prototype.regionLayoutUpdated): 53 (WebInspector.NamedFlow): 54 (WebInspector.NamedFlowCollection): 55 (WebInspector.NamedFlowCollection.prototype.appendNamedFlow): 56 (WebInspector.NamedFlowCollection.prototype.removeNamedFlow): 57 (WebInspector.NamedFlowCollection.prototype.flowByName): 58 * rendering/RenderNamedFlowThread.cpp: 59 (WebCore::RenderNamedFlowThread::dispatchRegionLayoutUpdateEvent): 60 1 61 2012-09-04 Jonathan Liu <net147@gmail.com> 2 62 -
trunk/Source/WebCore/dom/NamedFlowCollection.cpp
r126627 r127468 82 82 m_namedFlows.add(newFlow.get()); 83 83 84 InspectorInstrumentation::didCreateNamedFlow(m_document, newFlow ->name());84 InspectorInstrumentation::didCreateNamedFlow(m_document, newFlow.get()); 85 85 86 86 return newFlow.release(); … … 96 96 ASSERT(m_namedFlows.contains(namedFlow)); 97 97 98 InspectorInstrumentation::willRemoveNamedFlow(m_document, namedFlow); 99 98 100 m_namedFlows.remove(namedFlow); 99 100 InspectorInstrumentation::didRemoveNamedFlow(m_document, namedFlow->name());101 101 } 102 102 -
trunk/Source/WebCore/inspector/Inspector.json
r127417 r127468 2413 2413 "description": "Returns the Named Flows from the document.", 2414 2414 "hidden": true 2415 },2416 {2417 "name": "getFlowByName",2418 "parameters": [2419 { "name": "documentNodeId", "$ref": "DOM.NodeId", "description": "The document node id." },2420 { "name": "name", "type": "string", "description": "Named Flow identifier." }2421 ],2422 "returns": [2423 { "name": "namedFlow", "$ref": "NamedFlow", "description": "A Named Flow." }2424 ],2425 "description": "Returns the Named Flow identified by the given name",2426 "hidden": true2427 2415 } 2428 2416 ], … … 2442 2430 "name": "namedFlowCreated", 2443 2431 "parameters": [ 2432 { "name": "namedFlow", "$ref": "NamedFlow", "description": "The new Named Flow." } 2433 ], 2434 "description": "Fires when a Named Flow is created.", 2435 "hidden": true 2436 }, 2437 { 2438 "name": "namedFlowRemoved", 2439 "parameters": [ 2444 2440 { "name": "documentNodeId", "$ref": "DOM.NodeId", "description": "The document node id." }, 2445 { "name": "namedFlow", "type": "string", "description": "Identifier of the new Named Flow." } 2446 ], 2447 "description": "Fires when a Named Flow is created.", 2448 "hidden": true 2449 }, 2450 { 2451 "name": "namedFlowRemoved", 2452 "parameters": [ 2453 { "name": "documentNodeId", "$ref": "DOM.NodeId", "description": "The document node id." }, 2454 { "name": "namedFlow", "type": "string", "description": "Identifier of the removed Named Flow." } 2441 { "name": "flowName", "type": "string", "description": "Identifier of the removed Named Flow." } 2455 2442 ], 2456 2443 "description": "Fires when a Named Flow is removed: has no associated content nodes and regions.", 2444 "hidden": true 2445 }, 2446 { 2447 "name": "regionLayoutUpdated", 2448 "parameters": [ 2449 { "name": "namedFlow", "$ref": "NamedFlow", "description": "The Named Flow whose layout may have changed." } 2450 ], 2451 "description": "Fires when a Named Flow's layout may have changed.", 2457 2452 "hidden": true 2458 2453 } -
trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp
r127224 r127468 538 538 } 539 539 540 void InspectorCSSAgent::didCreateNamedFlow(Document* document, const AtomicString& name) 541 { 542 int nodeId = m_domAgent->boundNodeId(document); 543 if (!nodeId || !m_namedFlowCollectionsRequested.contains(nodeId)) 544 return; 545 546 m_frontend->namedFlowCreated(nodeId, name.string()); 547 } 548 549 void InspectorCSSAgent::didRemoveNamedFlow(Document* document, const AtomicString& name) 550 { 551 int nodeId = m_domAgent->boundNodeId(document); 552 if (!nodeId || !m_namedFlowCollectionsRequested.contains(nodeId)) 553 return; 554 555 m_frontend->namedFlowRemoved(nodeId, name.string()); 540 void InspectorCSSAgent::didCreateNamedFlow(Document* document, WebKitNamedFlow* namedFlow) 541 { 542 int documentNodeId = documentNodeWithRequestedFlowsId(document); 543 if (!documentNodeId) 544 return; 545 546 ErrorString errorString; 547 m_frontend->namedFlowCreated(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId)); 548 } 549 550 void InspectorCSSAgent::willRemoveNamedFlow(Document* document, WebKitNamedFlow* namedFlow) 551 { 552 int documentNodeId = documentNodeWithRequestedFlowsId(document); 553 if (!documentNodeId) 554 return; 555 556 m_frontend->namedFlowRemoved(documentNodeId, namedFlow->name().string()); 557 } 558 559 void InspectorCSSAgent::didUpdateRegionLayout(Document* document, WebKitNamedFlow* namedFlow) 560 { 561 int documentNodeId = documentNodeWithRequestedFlowsId(document); 562 if (!documentNodeId) 563 return; 564 565 ErrorString errorString; 566 m_frontend->regionLayoutUpdated(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId)); 556 567 } 557 568 … … 829 840 830 841 m_namedFlowCollectionsRequested.add(documentNodeId); 842 831 843 Vector<RefPtr<WebKitNamedFlow> > namedFlowsVector = document->namedFlows()->namedFlows(); 832 844 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::NamedFlow> > namedFlows = TypeBuilder::Array<TypeBuilder::CSS::NamedFlow>::create(); 833 845 834 835 846 for (Vector<RefPtr<WebKitNamedFlow> >::iterator it = namedFlowsVector.begin(); it != namedFlowsVector.end(); ++it) 836 847 namedFlows->addItem(buildObjectForNamedFlow(errorString, it->get(), documentNodeId)); 837 848 838 849 result = namedFlows.release(); 839 }840 841 void InspectorCSSAgent::getFlowByName(ErrorString* errorString, int documentNodeId, const String& flowName, RefPtr<TypeBuilder::CSS::NamedFlow>& result)842 {843 Document* document = m_domAgent->assertDocument(errorString, documentNodeId);844 if (!document)845 return;846 847 WebKitNamedFlow* webkitNamedFlow = document->namedFlows()->flowByName(flowName);848 if (!webkitNamedFlow) {849 *errorString = "No target CSS Named Flow found";850 return;851 }852 853 RefPtr<WebKitNamedFlow> protector(webkitNamedFlow);854 result = buildObjectForNamedFlow(errorString, webkitNamedFlow, documentNodeId);855 850 } 856 851 … … 932 927 } 933 928 return toElement(node); 929 } 930 931 int InspectorCSSAgent::documentNodeWithRequestedFlowsId(Document* document) 932 { 933 int documentNodeId = m_domAgent->boundNodeId(document); 934 if (!documentNodeId || !m_namedFlowCollectionsRequested.contains(documentNodeId)) 935 return 0; 936 937 return documentNodeId; 934 938 } 935 939 -
trunk/Source/WebCore/inspector/InspectorCSSAgent.h
r127300 r127468 100 100 void reset(); 101 101 void mediaQueryResultChanged(); 102 void didCreateNamedFlow(Document*, const AtomicString& name); 103 void didRemoveNamedFlow(Document*, const AtomicString& name); 102 void didCreateNamedFlow(Document*, WebKitNamedFlow*); 103 void willRemoveNamedFlow(Document*, WebKitNamedFlow*); 104 void didUpdateRegionLayout(Document*, WebKitNamedFlow*); 104 105 105 106 virtual void getComputedStyleForNode(ErrorString*, int nodeId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >&); … … 117 118 virtual void forcePseudoState(ErrorString*, int nodeId, const RefPtr<InspectorArray>& forcedPseudoClasses); 118 119 virtual void getNamedFlowCollection(ErrorString*, int documentNodeId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::NamedFlow> >& result); 119 virtual void getFlowByName(ErrorString*, int documentNodeId, const String& flowName, RefPtr<TypeBuilder::CSS::NamedFlow>& result);120 120 121 121 virtual void startSelectorProfiler(ErrorString*); … … 146 146 InspectorStyleSheetForInlineStyle* asInspectorStyleSheet(Element* element); 147 147 Element* elementForId(ErrorString*, int nodeId); 148 int documentNodeWithRequestedFlowsId(Document*); 148 149 void collectStyleSheets(CSSStyleSheet*, TypeBuilder::Array<WebCore::TypeBuilder::CSS::CSSStyleSheetHeader>*); 149 150 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r127240 r127468 232 232 } 233 233 234 void InspectorInstrumentation::didCreateNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, const AtomicString& name)234 void InspectorInstrumentation::didCreateNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow) 235 235 { 236 236 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent()) 237 cssAgent->didCreateNamedFlow(document, name );238 } 239 240 void InspectorInstrumentation:: didRemoveNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, const AtomicString& name)237 cssAgent->didCreateNamedFlow(document, namedFlow); 238 } 239 240 void InspectorInstrumentation::willRemoveNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow) 241 241 { 242 242 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent()) 243 cssAgent->didRemoveNamedFlow(document, name); 243 cssAgent->willRemoveNamedFlow(document, namedFlow); 244 } 245 246 void InspectorInstrumentation::didUpdateRegionLayoutImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow) 247 { 248 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent()) 249 cssAgent->didUpdateRegionLayout(document, namedFlow); 244 250 } 245 251 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r127300 r127468 114 114 static void didPushShadowRoot(Element* host, ShadowRoot*); 115 115 static void willPopShadowRoot(Element* host, ShadowRoot*); 116 static void didCreateNamedFlow(Document*, const AtomicString& name); 117 static void didRemoveNamedFlow(Document*, const AtomicString& name); 116 static void didCreateNamedFlow(Document*, WebKitNamedFlow*); 117 static void willRemoveNamedFlow(Document*, WebKitNamedFlow*); 118 static void didUpdateRegionLayout(Document*, WebKitNamedFlow*); 118 119 119 120 static void mouseDidMoveOverElement(Page*, const HitTestResult&, unsigned modifierFlags); … … 291 292 static void didPushShadowRootImpl(InstrumentingAgents*, Element* host, ShadowRoot*); 292 293 static void willPopShadowRootImpl(InstrumentingAgents*, Element* host, ShadowRoot*); 293 static void didCreateNamedFlowImpl(InstrumentingAgents*, Document*, const AtomicString& name); 294 static void didRemoveNamedFlowImpl(InstrumentingAgents*, Document*, const AtomicString& name); 294 static void didCreateNamedFlowImpl(InstrumentingAgents*, Document*, WebKitNamedFlow*); 295 static void willRemoveNamedFlowImpl(InstrumentingAgents*, Document*, WebKitNamedFlow*); 296 static void didUpdateRegionLayoutImpl(InstrumentingAgents*, Document*, WebKitNamedFlow*); 295 297 296 298 static void mouseDidMoveOverElementImpl(InstrumentingAgents*, const HitTestResult&, unsigned modifierFlags); … … 562 564 } 563 565 564 inline 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 573 inline 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); 566 inline void InspectorInstrumentation::didCreateNamedFlow(Document* document, WebKitNamedFlow* namedFlow) 567 { 568 #if ENABLE(INSPECTOR) 569 FAST_RETURN_IF_NO_FRONTENDS(void()); 570 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document)) 571 didCreateNamedFlowImpl(instrumentingAgents, document, namedFlow); 572 #endif 573 } 574 575 inline void InspectorInstrumentation::willRemoveNamedFlow(Document* document, WebKitNamedFlow* namedFlow) 576 { 577 #if ENABLE(INSPECTOR) 578 FAST_RETURN_IF_NO_FRONTENDS(void()); 579 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document)) 580 willRemoveNamedFlowImpl(instrumentingAgents, document, namedFlow); 581 #endif 582 } 583 584 inline void InspectorInstrumentation::didUpdateRegionLayout(Document* document, WebKitNamedFlow* namedFlow) 585 { 586 #if ENABLE(INSPECTOR) 587 FAST_RETURN_IF_NO_FRONTENDS(void()); 588 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document)) 589 didUpdateRegionLayoutImpl(instrumentingAgents, document, namedFlow); 579 590 #endif 580 591 } -
trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js
r125399 r127468 40 40 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.UndoRedoCompleted, this._undoRedoCompleted, this); 41 41 this._resourceBinding = new WebInspector.CSSStyleModelResourceBinding(this); 42 this._namedFlowCollections = {}; 43 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.DocumentUpdated, this._resetNamedFlowCollections, this); 42 44 InspectorBackend.registerCSSDispatcher(new WebInspector.CSSDispatcher(this)); 43 45 CSSAgent.enable(); … … 59 61 MediaQueryResultChanged: "MediaQueryResultChanged", 60 62 NamedFlowCreated: "NamedFlowCreated", 61 NamedFlowRemoved: "NamedFlowRemoved" 63 NamedFlowRemoved: "NamedFlowRemoved", 64 RegionLayoutUpdated: "RegionLayoutUpdated" 62 65 } 63 66 … … 173 176 /** 174 177 * @param {DOMAgent.NodeId} nodeId 175 * @param {function(?Array.<WebInspector.NamedFlow>)} userCallback 176 */ 177 getNamedFlowCollectionAsync: function(nodeId, userCallback) 178 { 178 * @param {function(Object)} userCallback 179 */ 180 getNamedFlowCollectionAsync: function(documentNodeId, userCallback) 181 { 182 var namedFlowCollection = this._namedFlowCollections[documentNodeId]; 183 if (namedFlowCollection) { 184 userCallback(namedFlowCollection.namedFlowMap); 185 return; 186 } 187 179 188 /** 180 189 * @param {function(?Array.<WebInspector.NamedFlow>)} userCallback … … 186 195 if (error || !namedFlowPayload) 187 196 userCallback(null); 188 else 189 userCallback(WebInspector.NamedFlow.parsePayloadArray(namedFlowPayload)); 190 } 191 192 CSSAgent.getNamedFlowCollection(nodeId, callback.bind(this, userCallback)); 197 else { 198 var namedFlowCollection = new WebInspector.NamedFlowCollection(namedFlowPayload); 199 this._namedFlowCollections[documentNodeId] = namedFlowCollection; 200 userCallback(namedFlowCollection.namedFlowMap); 201 } 202 } 203 204 CSSAgent.getNamedFlowCollection(documentNodeId, callback.bind(this, userCallback)); 193 205 }, 194 206 … … 198 210 * @param {function(?WebInspector.NamedFlow)} userCallback 199 211 */ 200 getFlowByNameAsync: function(nodeId, flowName, userCallback) 201 { 212 getFlowByNameAsync: function(documentNodeId, flowName, userCallback) 213 { 214 var namedFlowCollection = this._namedFlowCollections[documentNodeId]; 215 if (namedFlowCollection) { 216 userCallback(namedFlowCollection.flowByName(flowName)); 217 return; 218 } 219 202 220 /** 203 221 * @param {function(?WebInspector.NamedFlow)} userCallback 204 * @param {?Protocol.Error} error 205 * @param {?CSSAgent.NamedFlow=} namedFlowPayload 206 */ 207 function callback(userCallback, error, namedFlowPayload) 208 { 209 if (error || !namedFlowPayload) 222 * @param {?CSSAgent.NamedFlow=} namedFlowMap 223 */ 224 function callback(userCallback, namedFlowMap) 225 { 226 if (error || !namedFlowMap) 210 227 userCallback(null); 211 228 else 212 userCallback( WebInspector.NamedFlow.parsePayload(namedFlowPayload));213 } 214 215 CSSAgent.getFlowByName(nodeId, flowName, callback.bind(this, userCallback));229 userCallback(this._namedFlowCollections[documentNodeId].flowByName(flowName)); 230 } 231 232 this.getNamedFlowCollectionAsync(documentNodeId, callback.bind(this, userCallback)); 216 233 }, 217 234 … … 351 368 352 369 /** 370 * @param {CSSAgent.NamedFlow} namedFlowPayload 371 */ 372 _namedFlowCreated: function(namedFlowPayload) 373 { 374 var namedFlow = WebInspector.NamedFlow.parsePayload(namedFlowPayload); 375 var namedFlowCollection = this._namedFlowCollections[namedFlow.documentNodeId]; 376 377 if (!namedFlowCollection) 378 return; 379 380 namedFlowCollection.appendNamedFlow(namedFlow); 381 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.NamedFlowCreated, namedFlow); 382 }, 383 384 /** 353 385 * @param {DOMAgent.NodeId} documentNodeId 354 * @param {string} name 355 */ 356 _namedFlowCreated: function(documentNodeId, name) 357 { 358 if (!this.hasEventListeners(WebInspector.CSSStyleModel.Events.NamedFlowCreated)) 386 * @param {string} flowName 387 */ 388 _namedFlowRemoved: function(documentNodeId, flowName) 389 { 390 var namedFlowCollection = this._namedFlowCollections[documentNodeId]; 391 392 if (!namedFlowCollection) 359 393 return; 360 394 361 /** 362 * @param {WebInspector.DOMDocument} root 363 */ 364 function callback(root) 365 { 366 // FIXME: At the moment we only want support for NamedFlows in the main document 367 if (documentNodeId !== root.id) 368 return; 369 370 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.NamedFlowCreated, { documentNodeId: documentNodeId, name: name }); 371 } 372 373 WebInspector.domAgent.requestDocument(callback.bind(this)); 374 }, 375 376 /** 377 * @param {DOMAgent.NodeId} documentNodeId 378 * @param {string} name 379 */ 380 _namedFlowRemoved: function(documentNodeId, name) 381 { 382 if (!this.hasEventListeners(WebInspector.CSSStyleModel.Events.NamedFlowRemoved)) 395 namedFlowCollection.removeNamedFlow(flowName); 396 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.NamedFlowRemoved, { documentNodeId: documentNodeId, flowName: flowName }); 397 }, 398 399 /** 400 * @param {CSSAgent.NamedFlow} namedFlowPayload 401 */ 402 _regionLayoutUpdated: function(namedFlowPayload) 403 { 404 var namedFlow = WebInspector.NamedFlow.parsePayload(namedFlowPayload); 405 var namedFlowCollection = this._namedFlowCollections[namedFlow.documentNodeId]; 406 407 if (!namedFlowCollection) 383 408 return; 384 409 385 /** 386 * @param {WebInspector.DOMDocument} root 387 */ 388 function callback(root) 389 { 390 // FIXME: At the moment we only want support for NamedFlows in the main document 391 if (documentNodeId !== root.id) 392 return; 393 394 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.NamedFlowRemoved, { documentNodeId: documentNodeId, name: name }); 395 } 396 397 WebInspector.domAgent.requestDocument(callback.bind(this)); 410 namedFlowCollection.appendNamedFlow(namedFlow); 411 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.RegionLayoutUpdated, namedFlow); 398 412 }, 399 413 … … 462 476 { 463 477 this._sourceMappings = {}; 478 }, 479 480 _resetNamedFlowCollections: function() 481 { 482 this._namedFlowCollections = {}; 464 483 }, 465 484 … … 1327 1346 1328 1347 /** 1348 * @param {CSSAgent.NamedFlow} namedFlowPayload 1349 */ 1350 namedFlowCreated: function(namedFlowPayload) 1351 { 1352 this._cssModel._namedFlowCreated(namedFlowPayload); 1353 }, 1354 1355 /** 1329 1356 * @param {DOMAgent.NodeId} documentNodeId 1330 * @param {string} name 1331 */ 1332 namedFlowCreated: function(documentNodeId, name) 1333 { 1334 this._cssModel._namedFlowCreated(documentNodeId, name); 1335 }, 1336 1337 /** 1338 * @param {DOMAgent.NodeId} documentNodeId 1339 * @param {string} name 1340 */ 1341 namedFlowRemoved: function(documentNodeId, name) 1342 { 1343 this._cssModel._namedFlowRemoved(documentNodeId, name); 1357 * @param {string} flowName 1358 */ 1359 namedFlowRemoved: function(documentNodeId, flowName) 1360 { 1361 this._cssModel._namedFlowRemoved(documentNodeId, flowName); 1362 }, 1363 1364 /** 1365 * @param {CSSAgent.NamedFlow} namedFlowPayload 1366 */ 1367 regionLayoutUpdated: function(namedFlowPayload) 1368 { 1369 this._cssModel._regionLayoutUpdated(namedFlowPayload); 1344 1370 } 1345 1371 } … … 1351 1377 WebInspector.NamedFlow = function(payload) 1352 1378 { 1353 this. nodeId = payload.documentNodeId;1379 this.documentNodeId = payload.documentNodeId; 1354 1380 this.name = payload.name; 1355 1381 this.overset = payload.overset; … … 1368 1394 1369 1395 /** 1370 * @param {?Array.<CSSAgent.NamedFlow>=} namedFlowPayload 1371 * @return {?Array.<WebInspector.NamedFlow>} 1372 */ 1373 WebInspector.NamedFlow.parsePayloadArray = function(namedFlowPayload) 1374 { 1375 if (!namedFlowPayload) 1376 return null; 1377 1378 var parsedArray = []; 1379 for (var i = 0; i < namedFlowPayload.length; ++i) 1380 parsedArray[i] = WebInspector.NamedFlow.parsePayload(namedFlowPayload[i]); 1381 return parsedArray; 1382 } 1383 1396 * @constructor 1397 * @param {?Array.<CSSAgent.NamedFlow>=} payload 1398 */ 1399 WebInspector.NamedFlowCollection = function(payload) 1400 { 1401 this.namedFlowMap = {}; 1402 1403 for (var i = 0; i < payload.length; ++i) { 1404 var namedFlow = WebInspector.NamedFlow.parsePayload(payload[i]); 1405 this.namedFlowMap[namedFlow.name] = namedFlow; 1406 } 1407 } 1408 1409 WebInspector.NamedFlowCollection.prototype = { 1410 /** 1411 * @param {WebInspector.NamedFlow} namedFlow 1412 */ 1413 appendNamedFlow: function(namedFlow) 1414 { 1415 this.namedFlowMap[namedFlow.name] = namedFlow; 1416 }, 1417 1418 /** 1419 * @param {string} flowName 1420 */ 1421 removeNamedFlow: function(flowName) 1422 { 1423 delete this.namedFlowMap[flowName]; 1424 }, 1425 1426 /** 1427 * @param {string} flowName 1428 * @return {WebInspector.NamedFlow} 1429 */ 1430 flowByName: function(flowName) 1431 { 1432 var namedFlow = this.namedFlowMap[flowName]; 1433 1434 if (namedFlow === undefined) 1435 return null; 1436 return namedFlow; 1437 } 1438 } 1384 1439 /** 1385 1440 * @type {WebInspector.CSSStyleModel} -
trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp
r127269 r127468 28 28 29 29 #include "FlowThreadController.h" 30 #include "InspectorInstrumentation.h" 30 31 #include "RenderRegion.h" 31 32 #include "RenderView.h" … … 337 338 { 338 339 RenderFlowThread::dispatchRegionLayoutUpdateEvent(); 340 InspectorInstrumentation::didUpdateRegionLayout(document(), m_namedFlow.get()); 339 341 340 342 if (!m_regionLayoutUpdateEventTimer.isActive() && m_namedFlow->hasEventListeners())
Note: See TracChangeset
for help on using the changeset viewer.