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

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

Issue 2827843002: [Devtools] Network waterfall and grid rows feed bg color from same place (Closed)
Patch Set: changes Created 3 years, 8 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 /** @type {?Network.NetworkNode} */ 43 /** @type {?Network.NetworkNode} */
44 this._hoveredNode = null; 44 this._hoveredNode = null;
45 45
46 /** @type {!Map<string, !Array<number>>} */ 46 /** @type {!Map<string, !Array<number>>} */
47 this._eventDividers = new Map(); 47 this._eventDividers = new Map();
48 48
49 /** @type {(number|undefined)} */ 49 /** @type {(number|undefined)} */
50 this._updateRequestID; 50 this._updateRequestID;
51 51
52 var colorUsage = UI.ThemeSupport.ColorUsage;
53 this._rowNavigationRequestColor = UI.themeSupport.patchColorText('#def', col orUsage.Background);
54 this._rowStripeColor = UI.themeSupport.patchColorText('#f5f5f5', colorUsage. Background);
55 this._rowHoverColor = UI.themeSupport.patchColorText(
56 '#ebf2fc', /** @type {!UI.ThemeSupport.ColorUsage} */ (colorUsage.Backgr ound | colorUsage.Selection));
57 this._parentInitiatorColor = UI.themeSupport.patchColorText('hsla(120, 68%, 54%, 0.2)', colorUsage.Background);
58 this._initiatedColor = UI.themeSupport.patchColorText('hsla(0, 68%, 54%, 0.2 )', colorUsage.Background);
59
60 this.element.addEventListener('mousemove', this._onMouseMove.bind(this), tru e); 52 this.element.addEventListener('mousemove', this._onMouseMove.bind(this), tru e);
61 this.element.addEventListener('mouseleave', event => this._setHoveredNode(nu ll, false), true); 53 this.element.addEventListener('mouseleave', event => this._setHoveredNode(nu ll, false), true);
62 54
63 this._styleForTimeRangeName = Network.NetworkWaterfallColumn._buildRequestTi meRangeStyle(); 55 this._styleForTimeRangeName = Network.NetworkWaterfallColumn._buildRequestTi meRangeStyle();
64 56
65 var resourceStyleTuple = Network.NetworkWaterfallColumn._buildResourceTypeSt yle(); 57 var resourceStyleTuple = Network.NetworkWaterfallColumn._buildResourceTypeSt yle();
66 /** @type {!Map<!Common.ResourceType, !Network.NetworkWaterfallColumn._Layer Style>} */ 58 /** @type {!Map<!Common.ResourceType, !Network.NetworkWaterfallColumn._Layer Style>} */
67 this._styleForWaitingResourceType = resourceStyleTuple[0]; 59 this._styleForWaitingResourceType = resourceStyleTuple[0];
68 /** @type {!Map<!Common.ResourceType, !Network.NetworkWaterfallColumn._Layer Style>} */ 60 /** @type {!Map<!Common.ResourceType, !Network.NetworkWaterfallColumn._Layer Style>} */
69 this._styleForDownloadingResourceType = resourceStyleTuple[1]; 61 this._styleForDownloadingResourceType = resourceStyleTuple[1];
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 path.rect(start, middleBarY, end - start, height - lineWidth); 578 path.rect(start, middleBarY, end - start, height - lineWidth);
587 } 579 }
588 } 580 }
589 581
590 /** 582 /**
591 * @param {!CanvasRenderingContext2D} context 583 * @param {!CanvasRenderingContext2D} context
592 * @param {!Network.NetworkNode} node 584 * @param {!Network.NetworkNode} node
593 * @param {number} y 585 * @param {number} y
594 */ 586 */
595 _decorateRow(context, node, y) { 587 _decorateRow(context, node, y) {
596 var isStriped = node.isStriped();
597 if (!isStriped && !node.hovered() && !node.isNavigationRequest() && !node.is OnInitiatorPath() &&
598 !node.isOnInitiatedPath())
599 return;
600
601 var color = getRowColor.call(this);
602 if (color === 'transparent')
603 return;
604 context.save(); 588 context.save();
605 context.beginPath(); 589 context.beginPath();
606 context.fillStyle = color; 590 context.fillStyle = node.backgroundColor();
607 context.rect(0, y, this._offsetWidth, this._rowHeight); 591 context.rect(0, y, this._offsetWidth, this._rowHeight);
608 context.fill(); 592 context.fill();
609 context.restore(); 593 context.restore();
610
611 /**
612 * @return {string}
613 * @this {Network.NetworkWaterfallColumn}
614 */
615 function getRowColor() {
616 if (node.hovered())
617 return this._rowHoverColor;
618 if (node.isOnInitiatorPath())
619 return this._parentInitiatorColor;
620 if (node.isOnInitiatedPath())
621 return this._initiatedColor;
622 if (node.isNavigationRequest())
623 return this._rowNavigationRequestColor;
624 if (!isStriped)
625 return 'transparent';
626 return this._rowStripeColor;
627 }
628 } 594 }
629 }; 595 };
630 596
631 /** @typedef {!{fillStyle: (string|undefined), lineWidth: (number|undefined), bo rderColor: (string|undefined)}} */ 597 /** @typedef {!{fillStyle: (string|undefined), lineWidth: (number|undefined), bo rderColor: (string|undefined)}} */
632 Network.NetworkWaterfallColumn._LayerStyle; 598 Network.NetworkWaterfallColumn._LayerStyle;
633 599
634 /** @typedef {!{x: number, y: number, text: string}} */ 600 /** @typedef {!{x: number, y: number, text: string}} */
635 Network.NetworkWaterfallColumn._TextLayer; 601 Network.NetworkWaterfallColumn._TextLayer;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698