Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/ResourceWebSocketFrameView.js

Issue 2447933002: [Devtools] Restructured contextMenu for DataGrid. (Closed)
Patch Set: changes Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 19 matching lines...) Expand all
30 30
31 this._splitWidget = new WebInspector.SplitWidget(false, true, "resourceWebSo cketFrameSplitViewState"); 31 this._splitWidget = new WebInspector.SplitWidget(false, true, "resourceWebSo cketFrameSplitViewState");
32 this._splitWidget.show(this.element); 32 this._splitWidget.show(this.element);
33 33
34 var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */ ([ 34 var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */ ([
35 {id: "data", title: WebInspector.UIString("Data"), sortable: false, weig ht: 88}, 35 {id: "data", title: WebInspector.UIString("Data"), sortable: false, weig ht: 88},
36 {id: "length", title: WebInspector.UIString("Length"), sortable: false, align: WebInspector.DataGrid.Align.Right, weight: 5}, 36 {id: "length", title: WebInspector.UIString("Length"), sortable: false, align: WebInspector.DataGrid.Align.Right, weight: 5},
37 {id: "time", title: WebInspector.UIString("Time"), sortable: true, weigh t: 7} 37 {id: "time", title: WebInspector.UIString("Time"), sortable: true, weigh t: 7}
38 ]); 38 ]);
39 39
40 this._dataGrid = new WebInspector.SortableDataGrid(columns, undefined, undef ined, undefined, this._onContextMenu.bind(this)); 40 this._dataGrid = new WebInspector.SortableDataGrid(columns);
41 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.RowContextMenu, onRowContextMenu);
41 this._dataGrid.setStickToBottom(true); 42 this._dataGrid.setStickToBottom(true);
42 this._dataGrid.setCellClass("websocket-frame-view-td"); 43 this._dataGrid.setCellClass("websocket-frame-view-td");
43 this._timeComparator = /** @type {!WebInspector.SortableDataGrid.NodeCompara tor} */ (WebInspector.ResourceWebSocketFrameNodeTimeComparator); 44 this._timeComparator = /** @type {!WebInspector.SortableDataGrid.NodeCompara tor} */ (WebInspector.ResourceWebSocketFrameNodeTimeComparator);
44 this._dataGrid.sortNodes(this._timeComparator, false); 45 this._dataGrid.sortNodes(this._timeComparator, false);
45 this._dataGrid.markColumnAsSortedBy("time", WebInspector.DataGrid.Order.Asce nding); 46 this._dataGrid.markColumnAsSortedBy("time", WebInspector.DataGrid.Order.Asce nding);
46 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sortItems, this); 47 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sortItems, this);
47 48
48 this._dataGrid.setName("ResourceWebSocketFrameView"); 49 this._dataGrid.setName("ResourceWebSocketFrameView");
49 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, t his._onFrameSelected, this); 50 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, t his._onFrameSelected, this);
50 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.DeselectedNode, this._onFrameDeselected, this); 51 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.DeselectedNode, this._onFrameDeselected, this);
51 this._splitWidget.setMainWidget(this._dataGrid.asWidget()); 52 this._splitWidget.setMainWidget(this._dataGrid.asWidget());
52 53
53 var view = new WebInspector.EmptyWidget("Select frame to browse its content. "); 54 var view = new WebInspector.EmptyWidget("Select frame to browse its content. ");
54 this._splitWidget.setSidebarWidget(view); 55 this._splitWidget.setSidebarWidget(view);
55 56
56 /** @type {?WebInspector.ResourceWebSocketFrameNode} */ 57 /** @type {?WebInspector.ResourceWebSocketFrameNode} */
57 this._selectedNode = null; 58 this._selectedNode = null;
59
60 /**
61 * @param {!WebInspector.Event} event
62 */
63 function onRowContextMenu(event)
64 {
65 var contextMenu = /** @type {!WebInspector.ContextMenu} */ (event.data.c ontextMenu);
66 var node = /** @type {!WebInspector.DataGridNode} */ (event.data.node);
67 contextMenu.appendItem(WebInspector.UIString.capitalize("Copy ^message") , InspectorFrontendHost.copyText.bind(InspectorFrontendHost, node.data.data))
68 }
58 }; 69 };
59 70
60 /** @enum {number} */ 71 /** @enum {number} */
61 WebInspector.ResourceWebSocketFrameView.OpCodes = { 72 WebInspector.ResourceWebSocketFrameView.OpCodes = {
62 ContinuationFrame: 0, 73 ContinuationFrame: 0,
63 TextFrame: 1, 74 TextFrame: 1,
64 BinaryFrame: 2, 75 BinaryFrame: 2,
65 ConnectionCloseFrame: 8, 76 ConnectionCloseFrame: 8,
66 PingFrame: 9, 77 PingFrame: 9,
67 PongFrame: 10 78 PongFrame: 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 }, 169 },
159 170
160 refresh: function() 171 refresh: function()
161 { 172 {
162 this._dataGrid.rootNode().removeChildren(); 173 this._dataGrid.rootNode().removeChildren();
163 var frames = this._request.frames(); 174 var frames = this._request.frames();
164 for (var i = 0; i < frames.length; ++i) 175 for (var i = 0; i < frames.length; ++i)
165 this._dataGrid.insertChild(new WebInspector.ResourceWebSocketFrameNo de(this._request.url, frames[i])); 176 this._dataGrid.insertChild(new WebInspector.ResourceWebSocketFrameNo de(this._request.url, frames[i]));
166 }, 177 },
167 178
168 /**
169 * @param {!WebInspector.ContextMenu} contextMenu
170 * @param {!WebInspector.DataGridNode} node
171 */
172 _onContextMenu: function(contextMenu, node)
173 {
174 contextMenu.appendItem(WebInspector.UIString.capitalize("Copy ^message") , this._copyMessage.bind(this, node.data));
175 },
176
177 /**
178 * @param {!Object} row
179 */
180 _copyMessage: function(row)
181 {
182 InspectorFrontendHost.copyText(row.data);
183 },
184
185 _sortItems: function() 179 _sortItems: function()
186 { 180 {
187 this._dataGrid.sortNodes(this._timeComparator, !this._dataGrid.isSortOrd erAscending()); 181 this._dataGrid.sortNodes(this._timeComparator, !this._dataGrid.isSortOrd erAscending());
188 }, 182 },
189 183
190 __proto__: WebInspector.VBox.prototype 184 __proto__: WebInspector.VBox.prototype
191 }; 185 };
192 186
193 /** 187 /**
194 * @constructor 188 * @constructor
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 244
251 /** 245 /**
252 * @param {!WebInspector.ResourceWebSocketFrameNode} a 246 * @param {!WebInspector.ResourceWebSocketFrameNode} a
253 * @param {!WebInspector.ResourceWebSocketFrameNode} b 247 * @param {!WebInspector.ResourceWebSocketFrameNode} b
254 * @return {number} 248 * @return {number}
255 */ 249 */
256 WebInspector.ResourceWebSocketFrameNodeTimeComparator = function(a, b) 250 WebInspector.ResourceWebSocketFrameNodeTimeComparator = function(a, b)
257 { 251 {
258 return a._frame.time - b._frame.time; 252 return a._frame.time - b._frame.time;
259 }; 253 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698