Title: [147519] trunk/Source/WebCore
- Revision
- 147519
- Author
- [email protected]
- Date
- 2013-04-02 23:00:21 -0700 (Tue, 02 Apr 2013)
Log Message
Web Inspector: [Network] Split business logic and presentation for initiator column.
https://bugs.webkit.org/show_bug.cgi?id=113486
Reviewed by Pavel Feldman.
Currently business logic and presentation are mixed.
This prevents making cell renderer static and applying
viewport rendering, because initiator sorting function
depends on data written when cell is rendered.
* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkDataGridNode.prototype._refreshInitiatorCell):
Removed business logic. Use "initiatorInfo".
(WebInspector.NetworkDataGridNode.InitiatorComparator):
Use "initiatorInfo".
* inspector/front-end/NetworkRequest.js:
(WebInspector.NetworkRequest.prototype.initiatorInfo):
Extracted business logic from "refreshInitiatorCell".
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (147518 => 147519)
--- trunk/Source/WebCore/ChangeLog 2013-04-03 05:39:31 UTC (rev 147518)
+++ trunk/Source/WebCore/ChangeLog 2013-04-03 06:00:21 UTC (rev 147519)
@@ -1,3 +1,24 @@
+2013-04-02 Eugene Klyuchnikov <[email protected]>
+
+ Web Inspector: [Network] Split business logic and presentation for initiator column.
+ https://bugs.webkit.org/show_bug.cgi?id=113486
+
+ Reviewed by Pavel Feldman.
+
+ Currently business logic and presentation are mixed.
+ This prevents making cell renderer static and applying
+ viewport rendering, because initiator sorting function
+ depends on data written when cell is rendered.
+
+ * inspector/front-end/NetworkPanel.js:
+ (WebInspector.NetworkDataGridNode.prototype._refreshInitiatorCell):
+ Removed business logic. Use "initiatorInfo".
+ (WebInspector.NetworkDataGridNode.InitiatorComparator):
+ Use "initiatorInfo".
+ * inspector/front-end/NetworkRequest.js:
+ (WebInspector.NetworkRequest.prototype.initiatorInfo):
+ Extracted business logic from "refreshInitiatorCell".
+
2013-04-02 Ryosuke Niwa <[email protected]>
needsLeopardMailQuirks should be removed
Modified: trunk/Source/WebCore/inspector/front-end/NetworkPanel.js (147518 => 147519)
--- trunk/Source/WebCore/inspector/front-end/NetworkPanel.js 2013-04-03 05:39:31 UTC (rev 147518)
+++ trunk/Source/WebCore/inspector/front-end/NetworkPanel.js 2013-04-03 06:00:21 UTC (rev 147519)
@@ -2236,55 +2236,40 @@
_refreshInitiatorCell: function()
{
+ this._initiatorCell.removeChildren();
this._initiatorCell.removeStyleClass("network-dim-cell");
this._initiatorCell.removeStyleClass("network-script-initiated");
delete this._initiatorCell.request;
- this._initiatorCell.title = "";
- this._displayedInitiatorURL = "";
- this._displayedInitiatorLineNumber = -Infinity;
- this._displayedInitiatorType = "";
- var initiator = this._request.initiator;
- var initiatorTypes = WebInspector.NetworkRequest.InitiatorType;
- if ((initiator && initiator.type !== initiatorTypes.Other) || this._request.redirectSource) {
- this._initiatorCell.removeChildren();
- var redirectSource = this._request.redirectSource;
- if (redirectSource) {
- this._initiatorCell.title = redirectSource.url;
- this._initiatorCell.appendChild(WebInspector.linkifyRequestAsNode(redirectSource));
- this._displayedInitiatorType = WebInspector.UIString("Redirect");
- this._appendSubtitle(this._initiatorCell, this._displayedInitiatorType);
- this._displayedInitiatorURL = redirectSource.url;
- } else if (initiator.type === initiatorTypes.Script) {
- var topFrame = initiator.stackTrace[0];
- // This could happen when request loading was triggered by console.
- if (!topFrame.url) {
- this._initiatorCell.addStyleClass("network-dim-cell");
- this._displayedInitiatorType = WebInspector.UIString("Other");
- this._initiatorCell.setTextAndTitle(this._displayedInitiatorType);
- return;
- }
- var urlElement = this._parentView._linkifier.linkifyLocation(topFrame.url, topFrame.lineNumber - 1, 0);
- urlElement.title = "";
- this._initiatorCell.appendChild(urlElement);
- this._displayedInitiatorType = WebInspector.UIString("Script");
- this._appendSubtitle(this._initiatorCell, this._displayedInitiatorType);
- this._initiatorCell.addStyleClass("network-script-initiated");
- this._initiatorCell.request = this._request;
- this._displayedInitiatorURL = WebInspector.displayNameForURL(topFrame.url);
- this._displayedInitiatorLineNumber = topFrame.lineNumber;
- } else { // initiator.type === initiatorTypes.Parser
- this._initiatorCell.title = initiator.url + ":" + initiator.lineNumber;
- this._initiatorCell.appendChild(WebInspector.linkifyResourceAsNode(initiator.url, initiator.lineNumber - 1));
- this._displayedInitiatorType = WebInspector.UIString("Parser");
- this._appendSubtitle(this._initiatorCell, this._displayedInitiatorType);
- this._displayedInitiatorURL = WebInspector.displayNameForURL(initiator.url);
- this._displayedInitiatorLineNumber = initiator.lineNumber;
- }
- } else {
+ var request = this._request;
+ var initiator = request.initiatorInfo();
+
+ switch (initiator.type) {
+ case WebInspector.NetworkRequest.InitiatorType.Parser:
+ this._initiatorCell.title = initiator.url + ":" + initiator.lineNumber;
+ this._initiatorCell.appendChild(WebInspector.linkifyResourceAsNode(initiator.url, initiator.lineNumber - 1));
+ this._appendSubtitle(this._initiatorCell, WebInspector.UIString("Parser"));
+ break;
+
+ case WebInspector.NetworkRequest.InitiatorType.Redirect:
+ this._initiatorCell.title = initiator.url;
+ this._initiatorCell.appendChild(WebInspector.linkifyRequestAsNode(request.redirectSource));
+ this._appendSubtitle(this._initiatorCell, WebInspector.UIString("Redirect"));
+ break;
+
+ case WebInspector.NetworkRequest.InitiatorType.Script:
+ var urlElement = this._parentView._linkifier.linkifyLocation(initiator.url, initiator.lineNumber - 1, 0);
+ urlElement.title = "";
+ this._initiatorCell.appendChild(urlElement);
+ this._appendSubtitle(this._initiatorCell, WebInspector.UIString("Script"));
+ this._initiatorCell.addStyleClass("network-script-initiated");
+ this._initiatorCell.request = request;
+ break;
+
+ default:
+ this._initiatorCell.title = "";
this._initiatorCell.addStyleClass("network-dim-cell");
- this._displayedInitiatorType = WebInspector.UIString("Other");
- this._initiatorCell.setTextAndTitle(this._displayedInitiatorType);
+ this._initiatorCell.setTextAndTitle(WebInspector.UIString("Other"));
}
},
@@ -2457,19 +2442,22 @@
WebInspector.NetworkDataGridNode.InitiatorComparator = function(a, b)
{
- if (a._displayedInitiatorType < b._displayedInitiatorType)
+ var aInitiator = a._request.initiatorInfo();
+ var bInitiator = b._request.initiatorInfo();
+
+ if (aInitiator.type < bInitiator.type)
return -1;
- if (a._displayedInitiatorType > b._displayedInitiatorType)
+ if (aInitiator.type > bInitiator.type)
return 1;
- if (a._displayedInitiatorURL < b._displayedInitiatorURL)
+ if (aInitiator.source < bInitiator.source)
return -1;
- if (a._displayedInitiatorURL > b._displayedInitiatorURL)
+ if (aInitiator.source > bInitiator.source)
return 1;
- if (a._displayedInitiatorLineNumber < b._displayedInitiatorLineNumber)
+ if (aInitiator.lineNumber < bInitiator.lineNumber)
return -1;
- if (a._displayedInitiatorLineNumber > b._displayedInitiatorLineNumber)
+ if (aInitiator.lineNumber > bInitiator.lineNumber)
return 1;
return 0;
Modified: trunk/Source/WebCore/inspector/front-end/NetworkRequest.js (147518 => 147519)
--- trunk/Source/WebCore/inspector/front-end/NetworkRequest.js 2013-04-03 05:39:31 UTC (rev 147518)
+++ trunk/Source/WebCore/inspector/front-end/NetworkRequest.js 2013-04-03 06:00:21 UTC (rev 147519)
@@ -67,10 +67,12 @@
ResponseHeadersChanged: "ResponseHeadersChanged",
}
+/** @enum {string} */
WebInspector.NetworkRequest.InitiatorType = {
+ Other: "other",
Parser: "parser",
- Script: "script",
- Other: "other",
+ Redirect: "redirect",
+ Script: "script"
}
/** @typedef {{name: string, value: string}} */
@@ -453,6 +455,7 @@
set redirectSource(x)
{
this._redirectSource = x;
+ delete this._initiatorInfo;
},
/**
@@ -875,6 +878,40 @@
},
/**
+ * @return {{type: WebInspector.NetworkRequest.InitiatorType, url: string, source: string, lineNumber: number}}
+ */
+ initiatorInfo: function()
+ {
+ if (this._initiatorInfo)
+ return this._initiatorInfo;
+
+ var type = WebInspector.NetworkRequest.InitiatorType.Other;
+ var url = ""
+ var lineNumber = -Infinity;
+
+ if (this.redirectSource) {
+ type = WebInspector.NetworkRequest.InitiatorType.Redirect;
+ url = ""
+ } else if (this.initiator) {
+ if (this.initiator.type === NetworkAgent.InitiatorType.Parser) {
+ type = WebInspector.NetworkRequest.InitiatorType.Parser;
+ url = ""
+ lineNumber = this.initiator.lineNumber;
+ } else if (this.initiator.type === NetworkAgent.InitiatorType.Script) {
+ var topFrame = this.initiator.stackTrace[0];
+ if (topFrame.url) {
+ type = WebInspector.NetworkRequest.InitiatorType.Script;
+ url = ""
+ lineNumber = topFrame.lineNumber;
+ }
+ }
+ }
+
+ this._initiatorInfo = {type: type, url: url, source: WebInspector.displayNameForURL(url), lineNumber: lineNumber};
+ return this._initiatorInfo;
+ },
+
+ /**
* @return {!Array.<!Object>}
*/
frames: function()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes