| 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 WebInspector.ViewportControl = class { | 34 UI.ViewportControl = class { |
| 35 /** | 35 /** |
| 36 * @param {!WebInspector.ViewportControl.Provider} provider | 36 * @param {!UI.ViewportControl.Provider} 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 {?WebInspector.ViewportElement} | 131 * @return {?UI.ViewportElement} |
| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 // Proactively render more rows in case some of them will be collapsed wit
hout triggering refresh. @see crbug.com/390169 | 348 // Proactively render more rows in case some of them will be collapsed wit
hout triggering refresh. @see crbug.com/390169 |
| 349 this._lastActiveIndex = this._firstActiveIndex + Math.ceil(activeHeight /
this._provider.minimumRowHeight()) - 1; | 349 this._lastActiveIndex = this._firstActiveIndex + Math.ceil(activeHeight /
this._provider.minimumRowHeight()) - 1; |
| 350 this._lastActiveIndex = Math.min(this._lastActiveIndex, this._itemCount -
1); | 350 this._lastActiveIndex = Math.min(this._lastActiveIndex, this._itemCount -
1); |
| 351 } | 351 } |
| 352 | 352 |
| 353 var topGapHeight = this._cumulativeHeights[this._firstActiveIndex - 1] || 0; | 353 var topGapHeight = this._cumulativeHeights[this._firstActiveIndex - 1] || 0; |
| 354 var bottomGapHeight = | 354 var bottomGapHeight = |
| 355 this._cumulativeHeights[this._cumulativeHeights.length - 1] - this._cumu
lativeHeights[this._lastActiveIndex]; | 355 this._cumulativeHeights[this._cumulativeHeights.length - 1] - this._cumu
lativeHeights[this._lastActiveIndex]; |
| 356 | 356 |
| 357 /** | 357 /** |
| 358 * @this {WebInspector.ViewportControl} | 358 * @this {UI.ViewportControl} |
| 359 */ | 359 */ |
| 360 function prepare() { | 360 function prepare() { |
| 361 this._topGapElement.style.height = topGapHeight + 'px'; | 361 this._topGapElement.style.height = topGapHeight + 'px'; |
| 362 this._bottomGapElement.style.height = bottomGapHeight + 'px'; | 362 this._bottomGapElement.style.height = bottomGapHeight + 'px'; |
| 363 this._topGapElement._active = !!topGapHeight; | 363 this._topGapElement._active = !!topGapHeight; |
| 364 this._bottomGapElement._active = !!bottomGapHeight; | 364 this._bottomGapElement._active = !!bottomGapHeight; |
| 365 this._contentElement.style.setProperty('height', '10000000px'); | 365 this._contentElement.style.setProperty('height', '10000000px'); |
| 366 } | 366 } |
| 367 | 367 |
| 368 if (isInvalidating) | 368 if (isInvalidating) |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 */ | 568 */ |
| 569 _visibleHeight() { | 569 _visibleHeight() { |
| 570 // Use offsetHeight instead of clientHeight to avoid being affected by horiz
ontal scroll. | 570 // Use offsetHeight instead of clientHeight to avoid being affected by horiz
ontal scroll. |
| 571 return this.element.offsetHeight; | 571 return this.element.offsetHeight; |
| 572 } | 572 } |
| 573 }; | 573 }; |
| 574 | 574 |
| 575 /** | 575 /** |
| 576 * @interface | 576 * @interface |
| 577 */ | 577 */ |
| 578 WebInspector.ViewportControl.Provider = function() {}; | 578 UI.ViewportControl.Provider = function() {}; |
| 579 | 579 |
| 580 WebInspector.ViewportControl.Provider.prototype = { | 580 UI.ViewportControl.Provider.prototype = { |
| 581 /** | 581 /** |
| 582 * @param {number} index | 582 * @param {number} index |
| 583 * @return {number} | 583 * @return {number} |
| 584 */ | 584 */ |
| 585 fastHeight: function(index) { | 585 fastHeight: function(index) { |
| 586 return 0; | 586 return 0; |
| 587 }, | 587 }, |
| 588 | 588 |
| 589 /** | 589 /** |
| 590 * @return {number} | 590 * @return {number} |
| 591 */ | 591 */ |
| 592 itemCount: function() { | 592 itemCount: function() { |
| 593 return 0; | 593 return 0; |
| 594 }, | 594 }, |
| 595 | 595 |
| 596 /** | 596 /** |
| 597 * @return {number} | 597 * @return {number} |
| 598 */ | 598 */ |
| 599 minimumRowHeight: function() { | 599 minimumRowHeight: function() { |
| 600 return 0; | 600 return 0; |
| 601 }, | 601 }, |
| 602 | 602 |
| 603 /** | 603 /** |
| 604 * @param {number} index | 604 * @param {number} index |
| 605 * @return {?WebInspector.ViewportElement} | 605 * @return {?UI.ViewportElement} |
| 606 */ | 606 */ |
| 607 itemElement: function(index) { | 607 itemElement: function(index) { |
| 608 return null; | 608 return null; |
| 609 } | 609 } |
| 610 }; | 610 }; |
| 611 | 611 |
| 612 /** | 612 /** |
| 613 * @interface | 613 * @interface |
| 614 */ | 614 */ |
| 615 WebInspector.ViewportElement = function() {}; | 615 UI.ViewportElement = function() {}; |
| 616 WebInspector.ViewportElement.prototype = { | 616 UI.ViewportElement.prototype = { |
| 617 willHide: function() {}, | 617 willHide: function() {}, |
| 618 | 618 |
| 619 wasShown: function() {}, | 619 wasShown: function() {}, |
| 620 | 620 |
| 621 /** | 621 /** |
| 622 * @return {!Element} | 622 * @return {!Element} |
| 623 */ | 623 */ |
| 624 element: function() {}, | 624 element: function() {}, |
| 625 }; | 625 }; |
| 626 | 626 |
| 627 /** | 627 /** |
| 628 * @implements {WebInspector.ViewportElement} | 628 * @implements {UI.ViewportElement} |
| 629 * @unrestricted | 629 * @unrestricted |
| 630 */ | 630 */ |
| 631 WebInspector.StaticViewportElement = class { | 631 UI.StaticViewportElement = class { |
| 632 /** | 632 /** |
| 633 * @param {!Element} element | 633 * @param {!Element} element |
| 634 */ | 634 */ |
| 635 constructor(element) { | 635 constructor(element) { |
| 636 this._element = element; | 636 this._element = element; |
| 637 } | 637 } |
| 638 | 638 |
| 639 /** | 639 /** |
| 640 * @override | 640 * @override |
| 641 */ | 641 */ |
| 642 willHide() { | 642 willHide() { |
| 643 } | 643 } |
| 644 | 644 |
| 645 /** | 645 /** |
| 646 * @override | 646 * @override |
| 647 */ | 647 */ |
| 648 wasShown() { | 648 wasShown() { |
| 649 } | 649 } |
| 650 | 650 |
| 651 /** | 651 /** |
| 652 * @override | 652 * @override |
| 653 * @return {!Element} | 653 * @return {!Element} |
| 654 */ | 654 */ |
| 655 element() { | 655 element() { |
| 656 return this._element; | 656 return this._element; |
| 657 } | 657 } |
| 658 }; | 658 }; |
| OLD | NEW |