DevTools: [Console] Separate height caching from willHide event

This patch introduces ViewportElement.cacheHeight() method which is
called by viewport control in appropriate time to let viewportElement
cache its height. Currently, ViewportElement.willHide() method is
responsible for height caching.

ViewportElement.cacheHeight() must not invalidate DOM. This is not
the case for willHide() method due to the console.table implementation
which removes inner DataGrid views. The bug happens because of the
"scroller securing" (see ViewportElement.refresh method) being done after
the sequence of willHide() calls.

BUG=385685
R=aandrey, pfeldman

Review URL: https://codereview.chromium.org/340483003

git-svn-id: svn://svn.chromium.org/blink/trunk@176431 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 1f0032a3
......@@ -84,9 +84,13 @@ WebInspector.ConsoleViewMessage.prototype = {
}
},
willHide: function()
cacheFastHeight: function()
{
this._cachedHeight = this.contentElement().clientHeight;
},
willHide: function()
{
for (var i = 0; this._dataGrids && i < this._dataGrids.length; ++i) {
var dataGrid = this._dataGrids[i];
this._dataGridParents.put(dataGrid, dataGrid.element.parentElement);
......
......@@ -88,6 +88,8 @@ WebInspector.ViewportControl.Provider.prototype = {
*/
WebInspector.ViewportElement = function() { }
WebInspector.ViewportElement.prototype = {
cacheFastHeight: function() { },
willHide: function() { },
wasShown: function() { },
......@@ -109,6 +111,8 @@ WebInspector.StaticViewportElement = function(element)
}
WebInspector.StaticViewportElement.prototype = {
cacheFastHeight: function() { },
willHide: function() { },
wasShown: function() { },
......@@ -329,6 +333,8 @@ WebInspector.ViewportControl.prototype = {
var itemCount = this._provider.itemCount();
if (!itemCount) {
for (var i = 0; i < this._renderedItems.length; ++i)
this._renderedItems[i].cacheFastHeight();
for (var i = 0; i < this._renderedItems.length; ++i)
this._renderedItems[i].willHide();
this._renderedItems = [];
......@@ -350,7 +356,7 @@ WebInspector.ViewportControl.prototype = {
if (this._cumulativeHeights && itemCount !== this._cumulativeHeights.length)
delete this._cumulativeHeights;
for (var i = 0; i < this._renderedItems.length; ++i) {
this._renderedItems[i].willHide();
this._renderedItems[i].cacheFastHeight();
// Tolerate 1-pixel error due to double-to-integer rounding errors.
if (this._cumulativeHeights && Math.abs(this._cachedItemHeight(this._firstVisibleIndex + i) - this._provider.fastHeight(i + this._firstVisibleIndex)) > 1)
delete this._cumulativeHeights;
......@@ -372,6 +378,8 @@ WebInspector.ViewportControl.prototype = {
this._bottomGapElement._active = !!bottomGapHeight;
this._contentElement.style.setProperty("height", "10000000px");
for (var i = 0; i < this._renderedItems.length; ++i)
this._renderedItems[i].willHide();
this._renderedItems = [];
this._contentElement.removeChildren();
for (var i = this._firstVisibleIndex; i <= this._lastVisibleIndex; ++i) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment