Changeset 91928 in webkit
- Timestamp:
- Jul 28, 2011 8:13:34 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r91927 r91928 1 2011-07-28 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Add resource initiator column to network panel. 4 https://bugs.webkit.org/show_bug.cgi?id=65105 5 6 Reviewed by Pavel Feldman. 7 8 * http/tests/inspector/network/network-initiator-expected.txt: Added. 9 * http/tests/inspector/network/network-initiator.html: Added. 10 * http/tests/inspector/network/resources/initiator.css: Added. 11 (.image-background): 12 (.image-background-2): 13 1 14 2011-07-28 Tony Gentilcore <tonyg@chromium.org> 2 15 -
trunk/Source/WebCore/ChangeLog
r91924 r91928 1 2011-07-28 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Add resource initiator column to network panel. 4 https://bugs.webkit.org/show_bug.cgi?id=65105 5 6 Reviewed by Pavel Feldman. 7 8 Test: http/tests/inspector/network/network-initiator.html 9 10 * English.lproj/localizedStrings.js: 11 * dom/Document.cpp: 12 (WebCore::Document::scheduleStyleRecalc): 13 * inspector/Inspector.json: 14 * inspector/InspectorInstrumentation.cpp: 15 (WebCore::InspectorInstrumentation::willRecalculateStyleImpl): 16 (WebCore::InspectorInstrumentation::didRecalculateStyleImpl): 17 (WebCore::InspectorInstrumentation::didScheduleStyleRecalculationImpl): 18 * inspector/InspectorInstrumentation.h: 19 (WebCore::InspectorInstrumentation::didScheduleStyleRecalculation): 20 * inspector/InspectorResourceAgent.cpp: 21 (WebCore::InspectorResourceAgent::willSendRequest): 22 (WebCore::InspectorResourceAgent::didLoadResourceFromMemoryCache): 23 (WebCore::InspectorResourceAgent::willRecalculateStyle): 24 (WebCore::InspectorResourceAgent::didRecalculateStyle): 25 (WebCore::InspectorResourceAgent::didScheduleStyleRecalculation): 26 (WebCore::InspectorResourceAgent::buildInitiatorObject): 27 (WebCore::InspectorResourceAgent::InspectorResourceAgent): 28 * inspector/InspectorResourceAgent.h: 29 * inspector/front-end/NetworkManager.js: 30 (WebInspector.NetworkDispatcher.prototype.requestWillBeSent): 31 (WebInspector.NetworkDispatcher.prototype.resourceLoadedFromMemoryCache): 32 (WebInspector.NetworkDispatcher.prototype._appendRedirect): 33 (WebInspector.NetworkDispatcher.prototype._createResource): 34 * inspector/front-end/NetworkPanel.js: 35 (WebInspector.NetworkLogView.prototype._createTable): 36 (WebInspector.NetworkLogView.prototype._createSortingFunctions): 37 (WebInspector.NetworkLogView.prototype.switchToDetailedView): 38 (WebInspector.NetworkLogView.prototype.switchToBriefView): 39 (WebInspector.NetworkLogView.prototype._toggleGridMode): 40 (WebInspector.NetworkLogView.prototype._toggleViewingResourceMode): 41 (WebInspector.NetworkDataGridNode.prototype.createCells): 42 (WebInspector.NetworkDataGridNode.prototype.refreshResource): 43 (WebInspector.NetworkDataGridNode.prototype._refreshInitiatorCell): 44 (WebInspector.NetworkDataGridNode.InitiatorComparator): 45 * inspector/front-end/networkLogView.css: 46 (.initiator-column a): 47 1 48 2011-07-28 Rob Buis <rbuis@rim.com> 2 49 -
trunk/Source/WebCore/dom/Document.cpp
r91860 r91928 1458 1458 1459 1459 m_styleRecalcTimer.startOneShot(0); 1460 1461 InspectorInstrumentation::didScheduleStyleRecalculation(this); 1460 1462 } 1461 1463 -
trunk/Source/WebCore/inspector/Inspector.json
r91839 r91928 330 330 { "name": "networkIdentifier", "type": "integer", "optional": true, "description": "Identifier of the network request associated with the console message." }, 331 331 { "name": "parameters", "type": "array", "items": { "$ref": "Runtime.RemoteObject" }, "description": "Message parameters in case of the formatted message." }, 332 { "name": "stackTrace", " type": "array", "optional": true, "items": { "$ref": "CallFrame" }, "description": "Call frames for assert and error messages." }332 { "name": "stackTrace", "$ref": "StackTrace", "description": "Stack trace for assert and error messages." }, 333 333 ] 334 334 }, … … 343 343 { "name": "columnNumber", "type": "string", "description": "JavaScript source column number." } 344 344 ] 345 }, 346 { 347 "id": "StackTrace", 348 "type": "array", 349 "items": { "$ref": "CallFrame" }, 350 "description": "Call frames for assert and error messages." 345 351 } 346 352 ], … … 460 466 { "name": "bodySize", "type": "number", "description": "Cached response body size." } 461 467 ] 468 }, 469 { 470 "id": "Initiator", 471 "type": "object", 472 "description": "Information about the resource load initiator.", 473 "properties": [ 474 { "name": "type", "type": "string", "enum": ["parser", "script", "other"], "description": "Type of this initiator." }, 475 { "name": "stackTrace", "$ref": "Console.StackTrace", "description": "Initiator JavaScript stack trace, set for Script only." }, 476 { "name": "url", "type": "string", "optional": true, "description": "Initiator URL, set for Parser type only." }, 477 { "name": "lineNumber", "type": "number", "optional": true, "description": "Initiator line number, set for Parser type only." } 478 ] 462 479 } 463 480 ], … … 536 553 { "name": "request", "$ref": "ResourceRequest", "description": "Request data." }, 537 554 { "name": "timestamp", "type": "number", "description": "Timestamp." }, 538 { "name": "stackTrace", "type": "array", "items": { "$ref": "Console.CallFrame"}, "description": "JavaScript stack trace upon issuing this request." }, 555 { "name": "initiator", "$ref": "Initiator", "description": "Request initiator." }, 556 { "name": "stackTrace", "$ref": "Console.StackTrace", "description": "JavaScript stack trace upon issuing this request." }, 539 557 { "name": "redirectResponse", "optional": true, "$ref": "ResourceResponse", "description": "Redirect response data." } 540 558 ] … … 594 612 { "name": "documentURL", "type": "string", "description": "URL of the document this resource is loaded for." }, 595 613 { "name": "timestamp", "type": "number", "description": "Timestamp." }, 614 { "name": "initiator", "$ref": "Initiator", "description": "Request initiator." }, 596 615 { "name": "resource", "$ref": "CachedResource", "description": "Cached resource data." } 597 616 ] -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r91184 r91928 389 389 timelineAgentId = timelineAgent->id(); 390 390 } 391 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent()) 392 resourceAgent->willRecalculateStyle(); 391 393 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId); 392 394 } … … 396 398 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie)) 397 399 timelineAgent->didRecalculateStyle(); 400 InstrumentingAgents* instrumentingAgents = cookie.first; 401 if (!instrumentingAgents) 402 return; 403 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent()) 404 resourceAgent->didRecalculateStyle(); 405 } 406 407 void InspectorInstrumentation::didScheduleStyleRecalculationImpl(InstrumentingAgents* instrumentingAgents, Document* document) 408 { 409 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent()) 410 resourceAgent->didScheduleStyleRecalculation(document); 398 411 } 399 412 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r91184 r91928 114 114 static InspectorInstrumentationCookie willRecalculateStyle(Document*); 115 115 static void didRecalculateStyle(const InspectorInstrumentationCookie&); 116 static void didScheduleStyleRecalculation(Document*); 116 117 117 118 static void applyUserAgentOverride(Frame*, String*); … … 242 243 static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents*); 243 244 static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&); 245 static void didScheduleStyleRecalculationImpl(InstrumentingAgents*, Document*); 244 246 245 247 static void applyUserAgentOverrideImpl(InstrumentingAgents*, String*); … … 666 668 } 667 669 670 inline void InspectorInstrumentation::didScheduleStyleRecalculation(Document* document) 671 { 672 #if ENABLE(INSPECTOR) 673 FAST_RETURN_IF_NO_FRONTENDS(void()); 674 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document)) 675 didScheduleStyleRecalculationImpl(instrumentingAgents, document); 676 #endif 677 } 678 668 679 inline void InspectorInstrumentation::applyUserAgentOverride(Frame* frame, String* userAgent) 669 680 { -
trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp
r91858 r91928 61 61 #include "ScriptCallStack.h" 62 62 #include "ScriptCallStackFactory.h" 63 #include "ScriptableDocumentParser.h" 63 64 #include "WebSocketHandshakeRequest.h" 64 65 #include "WebSocketHandshakeResponse.h" … … 232 233 else 233 234 callStackValue = InspectorArray::create(); 234 m_frontend->requestWillBeSent(resourceId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), loader->url().string(), buildObjectForResourceRequest(request), currentTime(), callStackValue, buildObjectForResourceResponse(redirectResponse)); 235 RefPtr<InspectorObject> initiatorObject = buildInitiatorObject(loader->frame() ? loader->frame()->document() : 0); 236 m_frontend->requestWillBeSent(resourceId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), loader->url().string(), buildObjectForResourceRequest(request), currentTime(), initiatorObject, callStackValue, buildObjectForResourceResponse(redirectResponse)); 235 237 } 236 238 … … 315 317 m_resourcesData->resourceCreated(resourceId, loaderId); 316 318 m_resourcesData->addCachedResource(resourceId, resource); 317 318 m_frontend->resourceLoadedFromMemoryCache(resourceId, frameId, loaderId, loader->url().string(), currentTime(), buildObjectForCachedResource(*resource)); 319 RefPtr<InspectorObject> initiatorObject = buildInitiatorObject(loader->frame() ? loader->frame()->document() : 0); 320 321 m_frontend->resourceLoadedFromMemoryCache(resourceId, frameId, loaderId, loader->url().string(), currentTime(), initiatorObject, buildObjectForCachedResource(*resource)); 319 322 } 320 323 … … 348 351 if (!m_userAgentOverride.isEmpty()) 349 352 *userAgent = m_userAgentOverride; 353 } 354 355 void InspectorResourceAgent::willRecalculateStyle() 356 { 357 m_isRecalculatingStyle = true; 358 } 359 360 void InspectorResourceAgent::didRecalculateStyle() 361 { 362 m_isRecalculatingStyle = false; 363 m_styleRecalculationInitiator = nullptr; 364 } 365 366 void InspectorResourceAgent::didScheduleStyleRecalculation(Document* document) 367 { 368 if (!m_styleRecalculationInitiator) 369 m_styleRecalculationInitiator = buildInitiatorObject(document); 370 } 371 372 PassRefPtr<InspectorObject> InspectorResourceAgent::buildInitiatorObject(Document* document) 373 { 374 RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true); 375 if (stackTrace && stackTrace->size() > 0) { 376 RefPtr<InspectorObject> initiatorObject = InspectorObject::create(); 377 initiatorObject->setString("type", "script"); 378 initiatorObject->setArray("stackTrace", stackTrace->buildInspectorArray()); 379 return initiatorObject; 380 } 381 382 if (document && document->scriptableDocumentParser()) { 383 RefPtr<InspectorObject> initiatorObject = InspectorObject::create(); 384 initiatorObject->setString("type", "parser"); 385 initiatorObject->setString("url", document->url().string()); 386 initiatorObject->setNumber("lineNumber", document->scriptableDocumentParser()->lineNumber() + 1); 387 return initiatorObject; 388 } 389 390 if (m_isRecalculatingStyle && m_styleRecalculationInitiator) 391 return m_styleRecalculationInitiator; 392 393 RefPtr<InspectorObject> initiatorObject = InspectorObject::create(); 394 initiatorObject->setString("type", "other"); 395 return initiatorObject; 350 396 } 351 397 … … 528 574 , m_resourcesData(adoptPtr(new NetworkResourcesData())) 529 575 , m_loadingXHRSynchronously(false) 576 , m_isRecalculatingStyle(false) 530 577 { 531 578 if (isBackgroundEventsCollectionEnabled()) { -
trunk/Source/WebCore/inspector/InspectorResourceAgent.h
r91408 r91928 105 105 void applyUserAgentOverride(String* userAgent); 106 106 107 // FIXME: InspectorResourceAgent should now be aware of style recalculation. 108 void willRecalculateStyle(); 109 void didRecalculateStyle(); 110 void didScheduleStyleRecalculation(Document*); 111 112 PassRefPtr<InspectorObject> buildInitiatorObject(Document*); 113 107 114 #if ENABLE(WEB_SOCKETS) 108 115 void didCreateWebSocket(unsigned long identifier, const KURL& requestURL); … … 148 155 OwnPtr<NetworkResourcesData> m_resourcesData; 149 156 bool m_loadingXHRSynchronously; 157 158 // FIXME: InspectorResourceAgent should now be aware of style recalculation. 159 RefPtr<InspectorObject> m_styleRecalculationInitiator; 160 bool m_isRecalculatingStyle; 150 161 }; 151 162 -
trunk/Source/WebCore/inspector/front-end/NetworkManager.js
r91457 r91928 132 132 }, 133 133 134 requestWillBeSent: function(identifier, frameId, loaderId, documentURL, request, time, stackTrace, redirectResponse)134 requestWillBeSent: function(identifier, frameId, loaderId, documentURL, request, time, initiator, stackTrace, redirectResponse) 135 135 { 136 136 var resource = this._inflightResourcesById[identifier]; … … 142 142 resource = this._appendRedirect(identifier, time, request.url); 143 143 } else 144 resource = this._createResource(identifier, frameId, loaderId, request.url, documentURL, stackTrace);144 resource = this._createResource(identifier, frameId, loaderId, request.url, documentURL, initiator, stackTrace); 145 145 resource.hasNetworkData = true; 146 146 this._updateResourceWithRequest(resource, request); … … 213 213 }, 214 214 215 resourceLoadedFromMemoryCache: function(identifier, frameId, loaderId, documentURL, time, cachedResource)216 { 217 var resource = this._createResource(identifier, frameId, loaderId, cachedResource.url, documentURL );215 resourceLoadedFromMemoryCache: function(identifier, frameId, loaderId, documentURL, time, initiator, cachedResource) 216 { 217 var resource = this._createResource(identifier, frameId, loaderId, cachedResource.url, documentURL, initiator); 218 218 this._updateResourceWithCachedResource(resource, cachedResource); 219 219 resource.cached = true; … … 287 287 this._finishResource(originalResource, time); 288 288 var newResource = this._createResource(identifier, originalResource.frameId, originalResource.loaderId, 289 redirectURL, originalResource.documentURL, originalResource. stackTrace);289 redirectURL, originalResource.documentURL, originalResource.initiator, originalResource.stackTrace); 290 290 newResource.redirects = previousRedirects.concat(originalResource); 291 291 return newResource; … … 318 318 }, 319 319 320 _createResource: function(identifier, frameId, loaderId, url, documentURL, stackTrace)320 _createResource: function(identifier, frameId, loaderId, url, documentURL, initiator, stackTrace) 321 321 { 322 322 var resource = new WebInspector.Resource(identifier, url, loaderId); 323 323 resource.documentURL = documentURL; 324 324 resource.frameId = frameId; 325 resource.initiator = initiator; 325 326 resource.stackTrace = stackTrace; 326 327 return resource; -
trunk/Source/WebCore/inspector/front-end/NetworkPanel.js
r91902 r91928 144 144 _createTable: function() 145 145 { 146 var columns = {name: {}, method: {}, status: {}, type: {}, size: {}, time: {}, timeline: {}};146 var columns = {name: {}, method: {}, status: {}, type: {}, initiator: {}, size: {}, time: {}, timeline: {}}; 147 147 columns.name.titleDOMFragment = this._makeHeaderFragment(WebInspector.UIString("Name"), WebInspector.UIString("Path")); 148 148 columns.name.sortable = true; … … 162 162 columns.type.width = "6%"; 163 163 164 columns.initiator.title = WebInspector.UIString("Initiator"); 165 columns.initiator.sortable = true; 166 columns.initiator.width = "10%"; 167 164 168 columns.size.titleDOMFragment = this._makeHeaderFragment(WebInspector.UIString("Size"), WebInspector.UIString("Content")); 165 169 columns.size.sortable = true; … … 174 178 columns.timeline.title = ""; 175 179 columns.timeline.sortable = false; 176 columns.timeline.width = " 50%";180 columns.timeline.width = "40%"; 177 181 columns.timeline.sort = "ascending"; 178 182 … … 252 256 this._sortingFunctions.status = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "statusCode", false); 253 257 this._sortingFunctions.type = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "mimeType", false); 258 this._sortingFunctions.initiator = WebInspector.NetworkDataGridNode.InitiatorComparator; 254 259 this._sortingFunctions.size = WebInspector.NetworkDataGridNode.SizeComparator; 255 260 this._sortingFunctions.time = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "duration", false); … … 801 806 this._dataGrid.showColumn("status"); 802 807 this._dataGrid.showColumn("type"); 808 this._dataGrid.showColumn("initiator"); 803 809 this._dataGrid.showColumn("size"); 804 810 this._dataGrid.showColumn("time"); … … 810 816 widths.status = 6; 811 817 widths.type = 6; 818 widths.initiator = 10; 812 819 widths.size = 6; 813 820 widths.time = 6; 814 widths.timeline = 50;821 widths.timeline = 40; 815 822 816 823 this._dataGrid.applyColumnWidthsMap(widths); … … 824 831 this._dataGrid.hideColumn("status"); 825 832 this._dataGrid.hideColumn("type"); 833 this._dataGrid.hideColumn("initiator"); 826 834 this._dataGrid.hideColumn("size"); 827 835 this._dataGrid.hideColumn("time"); … … 892 900 this._dataGrid.showColumn("status"); 893 901 this._dataGrid.showColumn("type"); 902 this._dataGrid.showColumn("initiator"); 894 903 this._dataGrid.showColumn("size"); 895 904 this._dataGrid.showColumn("time"); … … 900 909 widths.status = 6; 901 910 widths.type = 6; 911 widths.initiator = 10; 902 912 widths.size = 6; 903 913 widths.time = 6; 904 widths.timeline = 50;914 widths.timeline = 40; 905 915 906 916 this._dataGrid.showColumn("timeline"); … … 919 929 this._dataGrid.hideColumn("status"); 920 930 this._dataGrid.hideColumn("type"); 931 this._dataGrid.hideColumn("initiator"); 921 932 this._dataGrid.hideColumn("size"); 922 933 this._dataGrid.hideColumn("time"); … … 1725 1736 this._statusCell = this._createDivInTD("status"); 1726 1737 this._typeCell = this._createDivInTD("type"); 1738 this._initiatorCell = this._createDivInTD("initiator"); 1727 1739 this._sizeCell = this._createDivInTD("size"); 1728 1740 this._timeCell = this._createDivInTD("time"); … … 1817 1829 this._refreshStatusCell(); 1818 1830 this._refreshTypeCell(); 1831 this._refreshInitiatorCell(); 1819 1832 this._refreshSizeCell(); 1820 1833 this._refreshTimeCell(); … … 1918 1931 }, 1919 1932 1933 _refreshInitiatorCell: function() 1934 { 1935 var initiator = this._resource.initiator; 1936 if (!initiator || initiator.type === "other") { 1937 this._initiatorCell.addStyleClass("network-dim-cell"); 1938 this._initiatorCell.setTextAndTitle(WebInspector.UIString("Other")); 1939 } else { 1940 this._initiatorCell.removeStyleClass("network-dim-cell"); 1941 this._initiatorCell.removeChildren(); 1942 if (initiator.type === "script") { 1943 var topFrame = initiator.stackTrace[0]; 1944 this._initiatorCell.title = topFrame.url + ":" + topFrame.lineNumber; 1945 this._initiatorCell.appendChild(WebInspector.linkifyResourceAsNode(topFrame.url, "scripts", topFrame.lineNumber)); 1946 this._appendSubtitle(this._initiatorCell, WebInspector.UIString("Script")); 1947 } else { // initiator.type === "parser" 1948 this._initiatorCell.title = initiator.url + ":" + initiator.lineNumber; 1949 this._initiatorCell.appendChild(WebInspector.linkifyResourceAsNode(initiator.url, "resources", initiator.lineNumber)); 1950 this._appendSubtitle(this._initiatorCell, WebInspector.UIString("Parser")); 1951 } 1952 } 1953 }, 1954 1920 1955 _refreshSizeCell: function() 1921 1956 { … … 2074 2109 } 2075 2110 2111 WebInspector.NetworkDataGridNode.InitiatorComparator = function(a, b) 2112 { 2113 if (!a._resource.initiator || a._resource.initiator.type === "Other") 2114 return -1; 2115 if (!b._resource.initiator || b._resource.initiator.type === "Other") 2116 return 1; 2117 2118 if (a._resource.initiator.url < b._resource.initiator.url) 2119 return -1; 2120 if (a._resource.initiator.url > b._resource.initiator.url) 2121 return 1; 2122 2123 return a._resource.initiator.lineNumber - b._resource.initiator.lineNumber; 2124 } 2125 2076 2126 WebInspector.NetworkDataGridNode.ResourcePropertyComparator = function(propertyName, revert, a, b) 2077 2127 { -
trunk/Source/WebCore/inspector/front-end/networkLogView.css
r91359 r91928 90 90 .network-log-grid td.status-column, 91 91 .network-log-grid td.type-column, 92 .network-log-grid td.initiator-column, 92 93 .network-log-grid td.size-column, 93 94 .network-log-grid td.time-column { … … 111 112 font-weight: normal; 112 113 color: gray; 114 } 115 116 .initiator-column a { 117 color: inherit; 113 118 } 114 119
Note: See TracChangeset
for help on using the changeset viewer.