Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. | 2 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Lesser General Public | 5 * modify it under the terms of the GNU Lesser General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 WebInspector.ResourceWebSocketFrameView = function(request) | 24 WebInspector.ResourceWebSocketFrameView = function(request) |
| 25 { | 25 { |
| 26 WebInspector.VBox.call(this); | 26 WebInspector.VBox.call(this); |
| 27 this.registerRequiredCSS("webSocketFrameView.css"); | 27 this.registerRequiredCSS("webSocketFrameView.css"); |
| 28 this.element.classList.add("websocket-frame-view"); | 28 this.element.classList.add("websocket-frame-view"); |
| 29 this._request = request; | 29 this._request = request; |
| 30 | 30 |
| 31 var columns = [ | 31 var columns = [ |
| 32 {id: "data", title: WebInspector.UIString("Data"), sortable: false, weig ht: 88, longText: true}, | 32 {id: "data", title: WebInspector.UIString("Data"), sortable: false, weig ht: 88, longText: true}, |
| 33 {id: "length", title: WebInspector.UIString("Length"), sortable: false, align: WebInspector.DataGrid.Align.Right, weight: 5}, | 33 {id: "length", title: WebInspector.UIString("Length"), sortable: false, align: WebInspector.DataGrid.Align.Right, weight: 5}, |
| 34 {id: "time", title: WebInspector.UIString("Time"), weight: 7} | 34 {id: "time", title: WebInspector.UIString("Time"), sortable: true, weigh t: 7} |
| 35 ] | 35 ] |
| 36 | 36 |
| 37 this._dataGrid = new WebInspector.SortableDataGrid(columns, undefined, undef ined, undefined, this._onContextMenu.bind(this)); | 37 this._dataGrid = new WebInspector.SortableDataGrid(columns, undefined, undef ined, undefined, this._onContextMenu.bind(this)); |
| 38 this._dataGrid.setStickToBottom(true); | |
| 38 this._dataGrid.setCellClass("websocket-frame-view-td"); | 39 this._dataGrid.setCellClass("websocket-frame-view-td"); |
| 39 var comparator = /** @type {!WebInspector.SortableDataGrid.NodeComparator} * / (WebInspector.ResourceWebSocketFrameNodeTimeComparator); | 40 this._timeComparator = /** @type {!WebInspector.SortableDataGrid.NodeCompara tor} */ (WebInspector.ResourceWebSocketFrameNodeTimeComparator); |
| 40 this._dataGrid.sortNodes(comparator, true); | 41 this._dataGrid.sortNodes(this._timeComparator, false); |
| 42 this._dataGrid.markColumnAsSortedBy("time", WebInspector.DataGrid.Order.Asce nding); | |
| 43 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sortItems, this); | |
| 41 | 44 |
| 42 this.refresh(); | |
| 43 this._dataGrid.setName("ResourceWebSocketFrameView"); | 45 this._dataGrid.setName("ResourceWebSocketFrameView"); |
| 44 this._dataGrid.show(this.element); | 46 this._dataGrid.show(this.element); |
| 45 } | 47 } |
| 46 | 48 |
| 47 /** @enum {number} */ | 49 /** @enum {number} */ |
| 48 WebInspector.ResourceWebSocketFrameView.OpCodes = { | 50 WebInspector.ResourceWebSocketFrameView.OpCodes = { |
| 49 ContinuationFrame: 0, | 51 ContinuationFrame: 0, |
| 50 TextFrame: 1, | 52 TextFrame: 1, |
| 51 BinaryFrame: 2, | 53 BinaryFrame: 2, |
| 52 ConnectionCloseFrame: 8, | 54 ConnectionCloseFrame: 8, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 74 * @return {string} | 76 * @return {string} |
| 75 */ | 77 */ |
| 76 WebInspector.ResourceWebSocketFrameView.opCodeDescription = function(opCode, mas k) | 78 WebInspector.ResourceWebSocketFrameView.opCodeDescription = function(opCode, mas k) |
| 77 { | 79 { |
| 78 var rawDescription = WebInspector.ResourceWebSocketFrameView.opCodeDescripti ons[opCode] || ""; | 80 var rawDescription = WebInspector.ResourceWebSocketFrameView.opCodeDescripti ons[opCode] || ""; |
| 79 var localizedDescription = WebInspector.UIString(rawDescription); | 81 var localizedDescription = WebInspector.UIString(rawDescription); |
| 80 return WebInspector.UIString("%s (Opcode %d%s)", localizedDescription, opCod e, (mask ? ", mask" : "")); | 82 return WebInspector.UIString("%s (Opcode %d%s)", localizedDescription, opCod e, (mask ? ", mask" : "")); |
| 81 } | 83 } |
| 82 | 84 |
| 83 WebInspector.ResourceWebSocketFrameView.prototype = { | 85 WebInspector.ResourceWebSocketFrameView.prototype = { |
| 86 wasShown: function() | |
| 87 { | |
| 88 this.refresh(); | |
| 89 this._request.addEventListener(WebInspector.NetworkRequest.Events.Websoc ketFrameAdded, this._frameAdded, this); | |
| 90 }, | |
| 91 | |
| 92 willHide: function() | |
| 93 { | |
| 94 this._request.removeEventListener(WebInspector.NetworkRequest.Events.Web socketFrameAdded, this._frameAdded, this); | |
| 95 }, | |
| 96 | |
| 97 /** | |
| 98 * @param {!WebInspector.Event} event | |
| 99 */ | |
| 100 _frameAdded: function(event) | |
| 101 { | |
| 102 var frame = /** @type {!WebInspector.NetworkRequest.WebSocketFrame} */ ( event.data); | |
| 103 this._dataGrid.insertChild(new WebInspector.ResourceWebSocketFrameNode(f rame)); | |
| 104 }, | |
| 105 | |
| 84 refresh: function() | 106 refresh: function() |
| 85 { | 107 { |
| 86 this._dataGrid.rootNode().removeChildren(); | 108 this._dataGrid.rootNode().removeChildren(); |
| 87 var frames = this._request.frames(); | 109 var frames = this._request.frames(); |
| 88 for (var i = frames.length - 1; i >= 0; --i) | 110 for (var i = 0; i < frames.length; ++i) |
| 89 this._dataGrid.insertChild(new WebInspector.ResourceWebSocketFrameNo de(frames[i])); | 111 this._dataGrid.insertChild(new WebInspector.ResourceWebSocketFrameNo de(frames[i])); |
| 90 }, | 112 }, |
| 91 | 113 |
| 92 show: function(parentElement, insertBefore) | |
| 93 { | |
| 94 this.refresh(); | |
| 95 WebInspector.View.prototype.show.call(this, parentElement, insertBefore) ; | |
| 96 }, | |
| 97 | |
| 98 /** | 114 /** |
| 99 * @param {!WebInspector.ContextMenu} contextMenu | 115 * @param {!WebInspector.ContextMenu} contextMenu |
| 100 * @param {!WebInspector.DataGridNode} node | 116 * @param {!WebInspector.DataGridNode} node |
| 101 */ | 117 */ |
| 102 _onContextMenu: function(contextMenu, node) | 118 _onContextMenu: function(contextMenu, node) |
| 103 { | 119 { |
| 104 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Copy message" : "Copy Message"), this._copyMessage.bind(this, node .data)); | 120 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Copy message" : "Copy Message"), this._copyMessage.bind(this, node .data)); |
| 105 }, | 121 }, |
| 106 | 122 |
| 107 /** | 123 /** |
| 108 * @param {!Object} row | 124 * @param {!Object} row |
| 109 */ | 125 */ |
| 110 _copyMessage: function(row) | 126 _copyMessage: function(row) |
| 111 { | 127 { |
| 112 InspectorFrontendHost.copyText(row.data); | 128 InspectorFrontendHost.copyText(row.data); |
| 113 }, | 129 }, |
| 114 | 130 |
| 131 _sortItems: function() | |
| 132 { | |
| 133 this._dataGrid.sortNodes(this._timeComparator, !this._dataGrid.isSortOrd erAscending()); | |
| 134 }, | |
| 135 | |
| 115 __proto__: WebInspector.VBox.prototype | 136 __proto__: WebInspector.VBox.prototype |
| 116 } | 137 } |
| 117 | 138 |
| 118 /** | 139 /** |
| 119 * @constructor | 140 * @constructor |
| 120 * @extends {WebInspector.SortableDataGridNode} | 141 * @extends {WebInspector.SortableDataGridNode} |
| 121 * @param {!WebInspector.NetworkRequest.WebSocketFrame} frame | 142 * @param {!WebInspector.NetworkRequest.WebSocketFrame} frame |
| 122 */ | 143 */ |
| 123 WebInspector.ResourceWebSocketFrameNode = function(frame) | 144 WebInspector.ResourceWebSocketFrameNode = function(frame) |
| 124 { | 145 { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 138 /** override */ | 159 /** override */ |
| 139 createCells: function() | 160 createCells: function() |
| 140 { | 161 { |
| 141 var element = this._element; | 162 var element = this._element; |
| 142 element.classList.toggle("websocket-frame-view-row-error", this._frame.t ype === WebInspector.NetworkRequest.WebSocketFrameType.Error); | 163 element.classList.toggle("websocket-frame-view-row-error", this._frame.t ype === WebInspector.NetworkRequest.WebSocketFrameType.Error); |
| 143 element.classList.toggle("websocket-frame-view-row-outcoming", this._fra me.type === WebInspector.NetworkRequest.WebSocketFrameType.Send); | 164 element.classList.toggle("websocket-frame-view-row-outcoming", this._fra me.type === WebInspector.NetworkRequest.WebSocketFrameType.Send); |
| 144 element.classList.toggle("websocket-frame-view-row-opcode", !this._isTex tFrame); | 165 element.classList.toggle("websocket-frame-view-row-opcode", !this._isTex tFrame); |
| 145 WebInspector.SortableDataGridNode.prototype.createCells.call(this); | 166 WebInspector.SortableDataGridNode.prototype.createCells.call(this); |
| 146 }, | 167 }, |
| 147 | 168 |
| 169 /** | |
| 170 * @override | |
| 171 * @return {number} | |
| 172 */ | |
| 173 nodeSelfHeight: function() { | |
|
vsevik
2014/10/16 08:03:32
{ on the next line
eustas
2014/10/16 08:32:05
Done.
| |
| 174 return 17; | |
| 175 }, | |
| 176 | |
| 148 __proto__: WebInspector.SortableDataGridNode.prototype | 177 __proto__: WebInspector.SortableDataGridNode.prototype |
| 149 } | 178 } |
| 150 | 179 |
| 151 /** | 180 /** |
| 152 * @param {!WebInspector.ResourceWebSocketFrameNode} a | 181 * @param {!WebInspector.ResourceWebSocketFrameNode} a |
| 153 * @param {!WebInspector.ResourceWebSocketFrameNode} b | 182 * @param {!WebInspector.ResourceWebSocketFrameNode} b |
| 154 * @return {number} | 183 * @return {number} |
| 155 */ | 184 */ |
| 156 WebInspector.ResourceWebSocketFrameNodeTimeComparator = function(a, b) | 185 WebInspector.ResourceWebSocketFrameNodeTimeComparator = function(a, b) |
| 157 { | 186 { |
| 158 return a._frame.time - b._frame.time; | 187 return a._frame.time - b._frame.time; |
| 159 } | 188 } |
| OLD | NEW |