| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 UI.ViewportControl = class { | 34 Console.ConsoleViewport = class { |
| 35 /** | 35 /** |
| 36 * @param {!UI.ViewportControl.Provider} provider | 36 * @param {!Console.ConsoleViewportProvider} provider |
| 37 */ | 37 */ |
| 38 constructor(provider) { | 38 constructor(provider) { |
| 39 this.element = createElement('div'); | 39 this.element = createElement('div'); |
| 40 this.element.style.overflow = 'auto'; | 40 this.element.style.overflow = 'auto'; |
| 41 this._topGapElement = this.element.createChild('div'); | 41 this._topGapElement = this.element.createChild('div'); |
| 42 this._topGapElement.style.height = '0px'; | 42 this._topGapElement.style.height = '0px'; |
| 43 this._topGapElement.style.color = 'transparent'; | 43 this._topGapElement.style.color = 'transparent'; |
| 44 this._contentElement = this.element.createChild('div'); | 44 this._contentElement = this.element.createChild('div'); |
| 45 this._bottomGapElement = this.element.createChild('div'); | 45 this._bottomGapElement = this.element.createChild('div'); |
| 46 this._bottomGapElement.style.height = '0px'; | 46 this._bottomGapElement.style.height = '0px'; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 invalidate() { | 122 invalidate() { |
| 123 delete this._cumulativeHeights; | 123 delete this._cumulativeHeights; |
| 124 delete this._cachedProviderElements; | 124 delete this._cachedProviderElements; |
| 125 this._itemCount = this._provider.itemCount(); | 125 this._itemCount = this._provider.itemCount(); |
| 126 this.refresh(); | 126 this.refresh(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 /** | 129 /** |
| 130 * @param {number} index | 130 * @param {number} index |
| 131 * @return {?UI.ViewportElement} | 131 * @return {?Console.ConsoleViewportElement} |
| 132 */ | 132 */ |
| 133 _providerElement(index) { | 133 _providerElement(index) { |
| 134 if (!this._cachedProviderElements) | 134 if (!this._cachedProviderElements) |
| 135 this._cachedProviderElements = new Array(this._itemCount); | 135 this._cachedProviderElements = new Array(this._itemCount); |
| 136 var element = this._cachedProviderElements[index]; | 136 var element = this._cachedProviderElements[index]; |
| 137 if (!element) { | 137 if (!element) { |
| 138 element = this._provider.itemElement(index); | 138 element = this._provider.itemElement(index); |
| 139 this._cachedProviderElements[index] = element; | 139 this._cachedProviderElements[index] = element; |
| 140 } | 140 } |
| 141 return element; | 141 return element; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 // Proactively render more rows in case some of them will be collapsed wit
hout triggering refresh. @see crbug.com/390169 | 349 // Proactively render more rows in case some of them will be collapsed wit
hout triggering refresh. @see crbug.com/390169 |
| 350 this._lastActiveIndex = this._firstActiveIndex + Math.ceil(activeHeight /
this._provider.minimumRowHeight()) - 1; | 350 this._lastActiveIndex = this._firstActiveIndex + Math.ceil(activeHeight /
this._provider.minimumRowHeight()) - 1; |
| 351 this._lastActiveIndex = Math.min(this._lastActiveIndex, this._itemCount -
1); | 351 this._lastActiveIndex = Math.min(this._lastActiveIndex, this._itemCount -
1); |
| 352 } | 352 } |
| 353 | 353 |
| 354 var topGapHeight = this._cumulativeHeights[this._firstActiveIndex - 1] || 0; | 354 var topGapHeight = this._cumulativeHeights[this._firstActiveIndex - 1] || 0; |
| 355 var bottomGapHeight = | 355 var bottomGapHeight = |
| 356 this._cumulativeHeights[this._cumulativeHeights.length - 1] - this._cumu
lativeHeights[this._lastActiveIndex]; | 356 this._cumulativeHeights[this._cumulativeHeights.length - 1] - this._cumu
lativeHeights[this._lastActiveIndex]; |
| 357 | 357 |
| 358 /** | 358 /** |
| 359 * @this {UI.ViewportControl} | 359 * @this {Console.ConsoleViewport} |
| 360 */ | 360 */ |
| 361 function prepare() { | 361 function prepare() { |
| 362 this._topGapElement.style.height = topGapHeight + 'px'; | 362 this._topGapElement.style.height = topGapHeight + 'px'; |
| 363 this._bottomGapElement.style.height = bottomGapHeight + 'px'; | 363 this._bottomGapElement.style.height = bottomGapHeight + 'px'; |
| 364 this._topGapElement._active = !!topGapHeight; | 364 this._topGapElement._active = !!topGapHeight; |
| 365 this._bottomGapElement._active = !!bottomGapHeight; | 365 this._bottomGapElement._active = !!bottomGapHeight; |
| 366 this._contentElement.style.setProperty('height', '10000000px'); | 366 this._contentElement.style.setProperty('height', '10000000px'); |
| 367 } | 367 } |
| 368 | 368 |
| 369 if (isInvalidating) | 369 if (isInvalidating) |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 */ | 570 */ |
| 571 _visibleHeight() { | 571 _visibleHeight() { |
| 572 // Use offsetHeight instead of clientHeight to avoid being affected by horiz
ontal scroll. | 572 // Use offsetHeight instead of clientHeight to avoid being affected by horiz
ontal scroll. |
| 573 return this.element.offsetHeight; | 573 return this.element.offsetHeight; |
| 574 } | 574 } |
| 575 }; | 575 }; |
| 576 | 576 |
| 577 /** | 577 /** |
| 578 * @interface | 578 * @interface |
| 579 */ | 579 */ |
| 580 UI.ViewportControl.Provider = function() {}; | 580 Console.ConsoleViewportProvider = function() {}; |
| 581 | 581 |
| 582 UI.ViewportControl.Provider.prototype = { | 582 Console.ConsoleViewportProvider.prototype = { |
| 583 /** | 583 /** |
| 584 * @param {number} index | 584 * @param {number} index |
| 585 * @return {number} | 585 * @return {number} |
| 586 */ | 586 */ |
| 587 fastHeight(index) { | 587 fastHeight(index) { |
| 588 return 0; | 588 return 0; |
| 589 }, | 589 }, |
| 590 | 590 |
| 591 /** | 591 /** |
| 592 * @return {number} | 592 * @return {number} |
| 593 */ | 593 */ |
| 594 itemCount() { | 594 itemCount() { |
| 595 return 0; | 595 return 0; |
| 596 }, | 596 }, |
| 597 | 597 |
| 598 /** | 598 /** |
| 599 * @return {number} | 599 * @return {number} |
| 600 */ | 600 */ |
| 601 minimumRowHeight() { | 601 minimumRowHeight() { |
| 602 return 0; | 602 return 0; |
| 603 }, | 603 }, |
| 604 | 604 |
| 605 /** | 605 /** |
| 606 * @param {number} index | 606 * @param {number} index |
| 607 * @return {?UI.ViewportElement} | 607 * @return {?Console.ConsoleViewportElement} |
| 608 */ | 608 */ |
| 609 itemElement(index) { | 609 itemElement(index) { |
| 610 return null; | 610 return null; |
| 611 } | 611 } |
| 612 }; | 612 }; |
| 613 | 613 |
| 614 /** | 614 /** |
| 615 * @interface | 615 * @interface |
| 616 */ | 616 */ |
| 617 UI.ViewportElement = function() {}; | 617 Console.ConsoleViewportElement = function() {}; |
| 618 UI.ViewportElement.prototype = { | 618 Console.ConsoleViewportElement.prototype = { |
| 619 willHide() {}, | 619 willHide() {}, |
| 620 | 620 |
| 621 wasShown() {}, | 621 wasShown() {}, |
| 622 | 622 |
| 623 /** | 623 /** |
| 624 * @return {!Element} | 624 * @return {!Element} |
| 625 */ | 625 */ |
| 626 element() {}, | 626 element() {}, |
| 627 }; | 627 }; |
| 628 | |
| 629 /** | |
| 630 * @implements {UI.ViewportElement} | |
| 631 * @unrestricted | |
| 632 */ | |
| 633 UI.StaticViewportElement = class { | |
| 634 /** | |
| 635 * @param {!Element} element | |
| 636 */ | |
| 637 constructor(element) { | |
| 638 this._element = element; | |
| 639 } | |
| 640 | |
| 641 /** | |
| 642 * @override | |
| 643 */ | |
| 644 willHide() { | |
| 645 } | |
| 646 | |
| 647 /** | |
| 648 * @override | |
| 649 */ | |
| 650 wasShown() { | |
| 651 } | |
| 652 | |
| 653 /** | |
| 654 * @override | |
| 655 * @return {!Element} | |
| 656 */ | |
| 657 element() { | |
| 658 return this._element; | |
| 659 } | |
| 660 }; | |
| OLD | NEW |