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

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

Issue 2747553002: [DevTools] Rework Popover API (Closed)
Patch Set: await Created 3 years, 9 months 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 Network.NetworkWaterfallColumn = class extends UI.VBox { 4 Network.NetworkWaterfallColumn = class extends UI.VBox {
5 /** 5 /**
6 * @param {number} rowHeight 6 * @param {number} rowHeight
7 * @param {!Network.NetworkTimeCalculator} calculator 7 * @param {!Network.NetworkTimeCalculator} calculator
8 */ 8 */
9 constructor(rowHeight, calculator) { 9 constructor(rowHeight, calculator) {
10 // TODO(allada) Make this a shadowDOM when the NetworkWaterfallColumn gets m oved into NetworkLogViewColumns. 10 // TODO(allada) Make this a shadowDOM when the NetworkWaterfallColumn gets m oved into NetworkLogViewColumns.
(...skipping 15 matching lines...) Expand all
26 26
27 this._rowHeight = rowHeight; 27 this._rowHeight = rowHeight;
28 this._headerHeight = 0; 28 this._headerHeight = 0;
29 this._calculator = calculator; 29 this._calculator = calculator;
30 30
31 this._offsetWidth = 0; 31 this._offsetWidth = 0;
32 this._offsetHeight = 0; 32 this._offsetHeight = 0;
33 this._startTime = this._calculator.minimumBoundary(); 33 this._startTime = this._calculator.minimumBoundary();
34 this._endTime = this._calculator.maximumBoundary(); 34 this._endTime = this._calculator.maximumBoundary();
35 35
36 this._popoverHelper = new UI.PopoverHelper(this.element); 36 this._popoverHelper = new UI.PopoverHelper(this.element, false, this._getPop overContent.bind(this));
lushnikov 2017/03/14 01:44:03 nit: could you please add /* disableOnClick */ com
dgozman 2017/03/14 21:34:01 Turned into a method.
37 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this), t his._showPopover.bind(this));
38 this._popoverHelper.setHasPadding(true); 37 this._popoverHelper.setHasPadding(true);
39 this._popoverHelper.setTimeout(300, 300); 38 this._popoverHelper.setTimeout(300, 300);
40 39
41 /** @type {!Array<!Network.NetworkNode>} */ 40 /** @type {!Array<!Network.NetworkNode>} */
42 this._nodes = []; 41 this._nodes = [];
43 42
44 /** @type {?Network.NetworkNode} */ 43 /** @type {?Network.NetworkNode} */
45 this._hoveredNode = null; 44 this._hoveredNode = null;
46 45
47 /** @type {!Map<string, !Array<number>>} */ 46 /** @type {!Map<string, !Array<number>>} */
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 113 }
115 114
116 /** 115 /**
117 * @param {!Event} event 116 * @param {!Event} event
118 */ 117 */
119 _onMouseMove(event) { 118 _onMouseMove(event) {
120 this._setHoveredNode(this.getNodeFromPoint(event.offsetX, event.offsetY), ev ent.shiftKey); 119 this._setHoveredNode(this.getNodeFromPoint(event.offsetX, event.offsetY), ev ent.shiftKey);
121 } 120 }
122 121
123 /** 122 /**
124 * @param {!Element} element
125 * @param {!Event} event 123 * @param {!Event} event
126 * @return {!AnchorBox|undefined} 124 * @return {?UI.PopoverContent}
127 */ 125 */
128 _getPopoverAnchor(element, event) { 126 _getPopoverContent(event) {
129 if (!this._hoveredNode) 127 if (!this._hoveredNode)
130 return; 128 return null;
131 var request = this._hoveredNode.request(); 129 var request = this._hoveredNode.request();
132 if (!request) 130 if (!request)
133 return; 131 return null;
134 var useTimingBars = !Common.moduleSetting('networkColorCodeResourceTypes').g et() && !this._calculator.startAtZero; 132 var useTimingBars = !Common.moduleSetting('networkColorCodeResourceTypes').g et() && !this._calculator.startAtZero;
135 if (useTimingBars) { 133 if (useTimingBars) {
136 var range = Network.RequestTimingView.calculateRequestTimeRanges(request, 0) 134 var range = Network.RequestTimingView.calculateRequestTimeRanges(request, 0)
137 .find(data => data.name === Network.RequestTimeRangeNames. Total); 135 .find(data => data.name === Network.RequestTimeRangeNames. Total);
138 var start = this._timeToPosition(range.start); 136 var start = this._timeToPosition(range.start);
139 var end = this._timeToPosition(range.end); 137 var end = this._timeToPosition(range.end);
140 } else { 138 } else {
141 var range = this._getSimplifiedBarRange(request, 0); 139 var range = this._getSimplifiedBarRange(request, 0);
142 var start = range.start; 140 var start = range.start;
143 var end = range.end; 141 var end = range.end;
144 } 142 }
145 143
146 if (end - start < 50) { 144 if (end - start < 50) {
147 var halfWidth = (end - start) / 2; 145 var halfWidth = (end - start) / 2;
148 start = start + halfWidth - 25; 146 start = start + halfWidth - 25;
149 end = end - halfWidth + 25; 147 end = end - halfWidth + 25;
150 } 148 }
151 149
152 if (event.clientX < this._canvasPosition.left + start || event.clientX > thi s._canvasPosition.left + end) 150 if (event.clientX < this._canvasPosition.left + start || event.clientX > thi s._canvasPosition.left + end)
153 return; 151 return null;
154 152
155 var rowIndex = this._nodes.findIndex(node => node.hovered()); 153 var rowIndex = this._nodes.findIndex(node => node.hovered());
156 var barHeight = this._getBarHeight(range.name); 154 var barHeight = this._getBarHeight(range.name);
157 var y = this._headerHeight + (this._rowHeight * rowIndex - this._scrollTop) + ((this._rowHeight - barHeight) / 2); 155 var y = this._headerHeight + (this._rowHeight * rowIndex - this._scrollTop) + ((this._rowHeight - barHeight) / 2);
158 156
159 if (event.clientY < this._canvasPosition.top + y || event.clientY > this._ca nvasPosition.top + y + barHeight) 157 if (event.clientY < this._canvasPosition.top + y || event.clientY > this._ca nvasPosition.top + y + barHeight)
160 return; 158 return null;
161 159
162 var anchorBox = this.element.boxInWindow(); 160 var anchorBox = this.element.boxInWindow();
163 anchorBox.x += start; 161 anchorBox.x += start;
164 anchorBox.y += y; 162 anchorBox.y += y;
165 anchorBox.width = end - start; 163 anchorBox.width = end - start;
166 anchorBox.height = barHeight; 164 anchorBox.height = barHeight;
167 return anchorBox; 165
166 return {
167 box: anchorBox,
168 show: popover => {
169 var content =
170 Network.RequestTimingView.createTimingTable(/** @type {!SDK.NetworkR equest} */ (request), this._calculator);
171 popover.contentElement.appendChild(content);
172 return Promise.resolve(true);
173 }
174 };
168 } 175 }
169 176
170 /** 177 /**
171 * @param {!Element|!AnchorBox} anchor
172 * @param {!UI.GlassPane} popover
173 * @return {!Promise<boolean>}
174 */
175 _showPopover(anchor, popover) {
176 if (!this._hoveredNode)
177 return Promise.resolve(false);
178 var request = this._hoveredNode.request();
179 if (!request)
180 return Promise.resolve(false);
181 var content = Network.RequestTimingView.createTimingTable(request, this._cal culator);
182 popover.contentElement.appendChild(content);
183 return Promise.resolve(true);
184 }
185
186 /**
187 * @param {?Network.NetworkNode} node 178 * @param {?Network.NetworkNode} node
188 * @param {boolean} highlightInitiatorChain 179 * @param {boolean} highlightInitiatorChain
189 */ 180 */
190 _setHoveredNode(node, highlightInitiatorChain) { 181 _setHoveredNode(node, highlightInitiatorChain) {
191 if (this._hoveredNode) 182 if (this._hoveredNode)
192 this._hoveredNode.setHovered(false, false); 183 this._hoveredNode.setHovered(false, false);
193 this._hoveredNode = node; 184 this._hoveredNode = node;
194 if (this._hoveredNode) 185 if (this._hoveredNode)
195 this._hoveredNode.setHovered(true, highlightInitiatorChain); 186 this._hoveredNode.setHovered(true, highlightInitiatorChain);
196 } 187 }
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 websocket: 'hsl(0, 0%, 95%)', 639 websocket: 'hsl(0, 0%, 95%)',
649 xhr: 'hsl(53, 100%, 80%)', 640 xhr: 'hsl(53, 100%, 80%)',
650 other: 'hsl(0, 0%, 95%)' 641 other: 'hsl(0, 0%, 95%)'
651 }; 642 };
652 643
653 /** @typedef {!{fillStyle: (string|undefined), lineWidth: (number|undefined), bo rderColor: (string|undefined)}} */ 644 /** @typedef {!{fillStyle: (string|undefined), lineWidth: (number|undefined), bo rderColor: (string|undefined)}} */
654 Network.NetworkWaterfallColumn._LayerStyles; 645 Network.NetworkWaterfallColumn._LayerStyles;
655 646
656 /** @typedef {!{x: number, y: number, text: string}} */ 647 /** @typedef {!{x: number, y: number, text: string}} */
657 Network.NetworkWaterfallColumn._TextLayer; 648 Network.NetworkWaterfallColumn._TextLayer;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698