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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/perf_ui/TimelineOverviewPane.js

Issue 2747553002: [DevTools] Rework Popover API (Closed)
Patch Set: rebased 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 this._cursorElement = this._overviewGrid.element.createChild('div', 'overvie w-grid-cursor-position'); 46 this._cursorElement = this._overviewGrid.element.createChild('div', 'overvie w-grid-cursor-position');
47 this._cursorArea.addEventListener('mousemove', this._onMouseMove.bind(this), true); 47 this._cursorArea.addEventListener('mousemove', this._onMouseMove.bind(this), true);
48 this._cursorArea.addEventListener('mouseleave', this._hideCursor.bind(this), true); 48 this._cursorArea.addEventListener('mouseleave', this._hideCursor.bind(this), true);
49 49
50 this._overviewGrid.setResizeEnabled(false); 50 this._overviewGrid.setResizeEnabled(false);
51 this._overviewGrid.addEventListener(PerfUI.OverviewGrid.Events.WindowChanged , this._onWindowChanged, this); 51 this._overviewGrid.addEventListener(PerfUI.OverviewGrid.Events.WindowChanged , this._onWindowChanged, this);
52 this._overviewGrid.setClickHandler(this._onClick.bind(this)); 52 this._overviewGrid.setClickHandler(this._onClick.bind(this));
53 this._overviewControls = []; 53 this._overviewControls = [];
54 this._markers = new Map(); 54 this._markers = new Map();
55 55
56 this._popoverHelper = new UI.PopoverHelper(this._cursorArea); 56 this._popoverHelper = new UI.PopoverHelper(this._cursorArea, this._getPopove rRequest.bind(this));
57 this._popoverHelper.initializeCallbacks(
58 this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this._o nHidePopover.bind(this));
59 this._popoverHelper.setHasPadding(true); 57 this._popoverHelper.setHasPadding(true);
60 this._popoverHelper.setTimeout(0); 58 this._popoverHelper.setTimeout(0);
61 59
62 this._updateThrottler = new Common.Throttler(100); 60 this._updateThrottler = new Common.Throttler(100);
63 61
64 this._cursorEnabled = false; 62 this._cursorEnabled = false;
65 this._cursorPosition = 0; 63 this._cursorPosition = 0;
66 this._lastWidth = 0; 64 this._lastWidth = 0;
67 } 65 }
68 66
69 /** 67 /**
70 * @param {!Element} element
71 * @param {!Event} event 68 * @param {!Event} event
72 * @return {!Element|!AnchorBox|undefined} 69 * @return {?UI.PopoverRequest}
73 */ 70 */
74 _getPopoverAnchor(element, event) { 71 _getPopoverRequest(event) {
75 return this._cursorArea; 72 return {
73 box: this._cursorElement.boxInWindow(),
74 show: popover => this._buildPopoverContents().then(fragment => {
75 if (!fragment.firstChild)
76 return false;
77 var content = new PerfUI.TimelineOverviewPane.PopoverContents();
78 this._popoverContents = content.contentElement.createChild('div');
79 this._popoverContents.appendChild(fragment);
80 this._popover = popover;
81 content.show(popover.contentElement);
82 return true;
83 }),
84 hide: () => {
85 this._popover = null;
86 this._popoverContents = null;
87 }
88 };
76 } 89 }
77 90
78 /** 91 /**
79 * @param {!Element|!AnchorBox} anchor
80 * @param {!UI.GlassPane} popover
81 * @return {!Promise<boolean>}
82 */
83 _showPopover(anchor, popover) {
84 return this._buildPopoverContents().then(maybeShowPopover.bind(this));
85
86 /**
87 * @this {PerfUI.TimelineOverviewPane}
88 * @param {!DocumentFragment} fragment
89 * @return {boolean}
90 */
91 function maybeShowPopover(fragment) {
92 if (!fragment.firstChild)
93 return false;
94 var content = new PerfUI.TimelineOverviewPane.PopoverContents();
95 this._popoverContents = content.contentElement.createChild('div');
96 this._popoverContents.appendChild(fragment);
97 this._popover = popover;
98 content.show(popover.contentElement);
99 return true;
100 }
101 }
102
103 _onHidePopover() {
104 this._popover = null;
105 this._popoverContents = null;
106 }
107
108 /**
109 * @param {!Event} event 92 * @param {!Event} event
110 */ 93 */
111 _onMouseMove(event) { 94 _onMouseMove(event) {
112 if (!this._cursorEnabled) 95 if (!this._cursorEnabled)
113 return; 96 return;
114 this._cursorPosition = event.offsetX + event.target.offsetLeft; 97 this._cursorPosition = event.offsetX + event.target.offsetLeft;
115 this._cursorElement.style.left = this._cursorPosition + 'px'; 98 this._cursorElement.style.left = this._cursorPosition + 'px';
116 this._cursorElement.style.visibility = 'visible'; 99 this._cursorElement.style.visibility = 'visible';
117 if (!this._popover) 100 if (!this._popover)
118 return; 101 return;
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 */ 527 */
545 onClick(event) { 528 onClick(event) {
546 return false; 529 return false;
547 } 530 }
548 531
549 resetCanvas() { 532 resetCanvas() {
550 this._canvas.width = this.element.clientWidth * window.devicePixelRatio; 533 this._canvas.width = this.element.clientWidth * window.devicePixelRatio;
551 this._canvas.height = this.element.clientHeight * window.devicePixelRatio; 534 this._canvas.height = this.element.clientHeight * window.devicePixelRatio;
552 } 535 }
553 }; 536 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698