| OLD | NEW |
| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return this._cursorArea; | 74 return this._cursorArea; |
| 75 }, | 75 }, |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * @param {!Element} anchor | 78 * @param {!Element} anchor |
| 79 * @param {!WebInspector.Popover} popover | 79 * @param {!WebInspector.Popover} popover |
| 80 */ | 80 */ |
| 81 _showPopover: function(anchor, popover) | 81 _showPopover: function(anchor, popover) |
| 82 { | 82 { |
| 83 this._popover = popover; | 83 this._popover = popover; |
| 84 this._popoverContents = createElement("div"); | 84 this._buildPopoverContents().then(maybeShowPopover.bind(this)); |
| 85 if (!this._populatePopoverContents()) | 85 /** |
| 86 return; | 86 * @this {WebInspector.TimelineOverviewPane} |
| 87 var content = new WebInspector.TimelineOverviewPane.PopoverContents(); | 87 * @param {!DocumentFragment} fragment |
| 88 content.contentElement.appendChild(this._popoverContents); | 88 */ |
| 89 popover.showView(content, this._cursorElement); | 89 function maybeShowPopover(fragment) |
| 90 { |
| 91 if (!fragment.firstChild) |
| 92 return; |
| 93 var content = new WebInspector.TimelineOverviewPane.PopoverContents(
); |
| 94 this._popoverContents = content.contentElement.createChild("div"); |
| 95 this._popoverContents.appendChild(fragment); |
| 96 popover.showView(content, this._cursorElement); |
| 97 } |
| 90 }, | 98 }, |
| 91 | 99 |
| 92 _onHidePopover: function() | 100 _onHidePopover: function() |
| 93 { | 101 { |
| 94 this._popover = null; | 102 this._popover = null; |
| 95 this._popoverContents = null; | 103 this._popoverContents = null; |
| 96 }, | 104 }, |
| 97 | 105 |
| 98 /** | 106 /** |
| 99 * @param {!Event} event | 107 * @param {!Event} event |
| 100 */ | 108 */ |
| 101 _onMouseMove: function(event) | 109 _onMouseMove: function(event) |
| 102 { | 110 { |
| 103 if (!this._cursorEnabled) | 111 if (!this._cursorEnabled) |
| 104 return; | 112 return; |
| 105 var x = event.offsetX + event.target.offsetLeft; | 113 var x = event.offsetX + event.target.offsetLeft; |
| 106 this._cursorElement.style.left = x + "px"; | 114 this._cursorElement.style.left = x + "px"; |
| 107 this._cursorElement.style.visibility = "visible"; | 115 this._cursorElement.style.visibility = "visible"; |
| 108 if (!this._popover) | 116 if (!this._popover) |
| 109 return; | 117 return; |
| 110 this._populatePopoverContents(); | 118 this._buildPopoverContents().then(updatePopover.bind(this)); |
| 111 this._popover.positionElement(this._cursorElement); | 119 this._popover.positionElement(this._cursorElement); |
| 120 /** |
| 121 * @this {WebInspector.TimelineOverviewPane} |
| 122 * @param {!DocumentFragment} fragment |
| 123 */ |
| 124 function updatePopover(fragment) |
| 125 { |
| 126 if (!this._popoverContents) |
| 127 return; |
| 128 this._popoverContents.removeChildren(); |
| 129 this._popoverContents.appendChild(fragment); |
| 130 } |
| 112 }, | 131 }, |
| 113 | 132 |
| 114 _populatePopoverContents: function() | 133 /** |
| 134 * @return {!Promise<!DocumentFragment>} |
| 135 */ |
| 136 _buildPopoverContents: function() |
| 115 { | 137 { |
| 116 var x = this._cursorElement.offsetLeft; | 138 var cursor = this._cursorElement; |
| 117 var elements = []; | 139 var x = cursor.offsetLeft; |
| 118 for (var control of this._overviewControls) { | 140 var promises = []; |
| 119 var element = control.popoverElement(x); | 141 for (var control of this._overviewControls) |
| 120 if (element) | 142 promises.push(control.popoverElementPromise(x)) |
| 121 elements.push(element); | 143 |
| 144 return Promise.all(promises).then(buildFragment); |
| 145 |
| 146 /** |
| 147 * @param {!Array<?Element>} elements |
| 148 */ |
| 149 function buildFragment(elements) |
| 150 { |
| 151 var fragment = cursor.ownerDocument.createDocumentFragment(); |
| 152 for (var element of elements) { |
| 153 if (element) |
| 154 fragment.appendChild(element); |
| 155 } |
| 156 return fragment; |
| 122 } | 157 } |
| 123 this._popoverContents.removeChildren(); | |
| 124 if (!elements.length) | |
| 125 return false; | |
| 126 elements.forEach(this._popoverContents.appendChild.bind(this._popoverCon
tents)); | |
| 127 return true; | |
| 128 }, | 158 }, |
| 129 | 159 |
| 130 _hideCursor: function() | 160 _hideCursor: function() |
| 131 { | 161 { |
| 132 this._cursorElement.style.visibility = "hidden"; | 162 this._cursorElement.style.visibility = "hidden"; |
| 133 }, | 163 }, |
| 134 | 164 |
| 135 /** | 165 /** |
| 136 * @override | 166 * @override |
| 137 */ | 167 */ |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 show: function(parentElement, insertBefore) { }, | 458 show: function(parentElement, insertBefore) { }, |
| 429 | 459 |
| 430 update: function() { }, | 460 update: function() { }, |
| 431 | 461 |
| 432 dispose: function() { }, | 462 dispose: function() { }, |
| 433 | 463 |
| 434 reset: function() { }, | 464 reset: function() { }, |
| 435 | 465 |
| 436 /** | 466 /** |
| 437 * @param {number} x | 467 * @param {number} x |
| 438 * @return {?Element} | 468 * @return {!Promise<?Element>} |
| 439 */ | 469 */ |
| 440 popoverElement: function(x) { }, | 470 popoverElementPromise: function(x) { }, |
| 441 | 471 |
| 442 /** | 472 /** |
| 443 * @param {!Event} event | 473 * @param {!Event} event |
| 444 * @return {boolean} | 474 * @return {boolean} |
| 445 */ | 475 */ |
| 446 onClick: function(event) { }, | 476 onClick: function(event) { }, |
| 447 | 477 |
| 448 /** | 478 /** |
| 449 * @param {number} windowLeft | 479 * @param {number} windowLeft |
| 450 * @param {number} windowRight | 480 * @param {number} windowRight |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 /** | 528 /** |
| 499 * @override | 529 * @override |
| 500 */ | 530 */ |
| 501 reset: function() | 531 reset: function() |
| 502 { | 532 { |
| 503 }, | 533 }, |
| 504 | 534 |
| 505 /** | 535 /** |
| 506 * @override | 536 * @override |
| 507 * @param {number} x | 537 * @param {number} x |
| 508 * @return {?Element} | 538 * @return {!Promise<?Element>} |
| 509 */ | 539 */ |
| 510 popoverElement: function(x) | 540 popoverElementPromise: function(x) |
| 511 { | 541 { |
| 512 return null; | 542 return Promise.resolve(/** @type {?Element} */ (null)); |
| 513 }, | 543 }, |
| 514 | 544 |
| 515 /** | 545 /** |
| 516 * @override | 546 * @override |
| 517 */ | 547 */ |
| 518 timelineStarted: function() | 548 timelineStarted: function() |
| 519 { | 549 { |
| 520 }, | 550 }, |
| 521 | 551 |
| 522 /** | 552 /** |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 }, | 608 }, |
| 579 | 609 |
| 580 resetCanvas: function() | 610 resetCanvas: function() |
| 581 { | 611 { |
| 582 this._canvas.width = this.element.clientWidth * window.devicePixelRatio; | 612 this._canvas.width = this.element.clientWidth * window.devicePixelRatio; |
| 583 this._canvas.height = this.element.clientHeight * window.devicePixelRati
o; | 613 this._canvas.height = this.element.clientHeight * window.devicePixelRati
o; |
| 584 }, | 614 }, |
| 585 | 615 |
| 586 __proto__: WebInspector.VBox.prototype | 616 __proto__: WebInspector.VBox.prototype |
| 587 } | 617 } |
| OLD | NEW |