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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 365 |
366 this._partialViewportUpdate(prepare.bind(this)); | 366 this._partialViewportUpdate(prepare.bind(this)); |
367 this._contentElement.style.removeProperty('height'); | 367 this._contentElement.style.removeProperty('height'); |
368 // Should be the last call in the method as it might force layout. | 368 // Should be the last call in the method as it might force layout. |
369 if (shouldRestoreSelection) | 369 if (shouldRestoreSelection) |
370 this._restoreSelection(selection); | 370 this._restoreSelection(selection); |
371 if (this._stickToBottom) | 371 if (this._stickToBottom) |
372 this.element.scrollTop = 10000000; | 372 this.element.scrollTop = 10000000; |
373 } | 373 } |
374 | 374 |
| 375 fullViewportInvalidate() { |
| 376 for (var i = 0; i < this._renderedItems.length; ++i) |
| 377 this._renderedItems[i].willHide(); |
| 378 this._contentElement.removeChildren(); |
| 379 this.invalidate(); |
| 380 } |
| 381 |
375 /** | 382 /** |
376 * @param {function()} prepare | 383 * @param {function()} prepare |
377 */ | 384 */ |
378 _partialViewportUpdate(prepare) { | 385 _partialViewportUpdate(prepare) { |
379 var itemsToRender = new Set(); | 386 var itemsToRender = new Set(); |
380 for (var i = this._firstActiveIndex; i <= this._lastActiveIndex; ++i) | 387 for (var i = this._firstActiveIndex; i <= this._lastActiveIndex; ++i) |
381 itemsToRender.add(this._providerElement(i)); | 388 itemsToRender.add(this._providerElement(i)); |
382 var willBeHidden = this._renderedItems.filter(item => !itemsToRender.has(ite
m)); | 389 var willBeHidden = this._renderedItems.filter(item => item.element().parentE
lement && !itemsToRender.has(item)); |
383 for (var i = 0; i < willBeHidden.length; ++i) | 390 for (var i = 0; i < willBeHidden.length; ++i) |
384 willBeHidden[i].willHide(); | 391 willBeHidden[i].willHide(); |
385 prepare(); | 392 prepare(); |
386 for (var i = 0; i < willBeHidden.length; ++i) | 393 for (var i = 0; i < willBeHidden.length; ++i) |
387 willBeHidden[i].element().remove(); | 394 willBeHidden[i].element().remove(); |
388 | 395 |
389 var wasShown = []; | 396 var wasShown = []; |
390 var anchor = this._contentElement.firstChild; | 397 var anchor = this._contentElement.firstChild; |
391 for (var viewportElement of itemsToRender) { | 398 for (var viewportElement of itemsToRender) { |
392 var element = viewportElement.element(); | 399 var element = viewportElement.element(); |
| 400 var shouldCallWasShown = !element.parentElement; |
393 if (element !== anchor) { | 401 if (element !== anchor) { |
394 var shouldCallWasShown = !element.parentElement; | |
395 if (shouldCallWasShown) | 402 if (shouldCallWasShown) |
396 wasShown.push(viewportElement); | 403 wasShown.push(viewportElement); |
397 this._contentElement.insertBefore(element, anchor); | 404 this._contentElement.insertBefore(element, anchor); |
398 } else { | 405 } else { |
399 anchor = anchor.nextSibling; | 406 anchor = anchor.nextSibling; |
400 } | 407 } |
401 } | 408 } |
402 for (var i = 0; i < wasShown.length; ++i) | 409 for (var i = 0; i < wasShown.length; ++i) |
403 wasShown[i].wasShown(); | 410 wasShown[i].wasShown(); |
404 this._renderedItems = Array.from(itemsToRender); | 411 this._renderedItems = Array.from(itemsToRender); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 Console.ConsoleViewportElement.prototype = { | 605 Console.ConsoleViewportElement.prototype = { |
599 willHide() {}, | 606 willHide() {}, |
600 | 607 |
601 wasShown() {}, | 608 wasShown() {}, |
602 | 609 |
603 /** | 610 /** |
604 * @return {!Element} | 611 * @return {!Element} |
605 */ | 612 */ |
606 element() {}, | 613 element() {}, |
607 }; | 614 }; |
OLD | NEW |