DevTools: do not scroll console to bottom on resize

Currently console gets scrolled to bottom whenever it gets resized.
The patch fixes this erroneous behavior.

R=vsevik, pfeldman

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

git-svn-id: svn://svn.chromium.org/blink/trunk@180175 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2a72b76f
...@@ -89,7 +89,6 @@ WebInspector.ConsoleView = function(hideContextSelector) ...@@ -89,7 +89,6 @@ WebInspector.ConsoleView = function(hideContextSelector)
this._messagesElement.id = "console-messages"; this._messagesElement.id = "console-messages";
this._messagesElement.classList.add("monospace"); this._messagesElement.classList.add("monospace");
this._messagesElement.addEventListener("click", this._messagesClicked.bind(this), true); this._messagesElement.addEventListener("click", this._messagesClicked.bind(this), true);
this._scrolledToBottom = true;
this._viewportThrottler = new WebInspector.Throttler(50); this._viewportThrottler = new WebInspector.Throttler(50);
...@@ -415,16 +414,10 @@ WebInspector.ConsoleView.prototype = { ...@@ -415,16 +414,10 @@ WebInspector.ConsoleView.prototype = {
this._prompt.moveCaretToEndOfPrompt(); this._prompt.moveCaretToEndOfPrompt();
}, },
storeScrollPositions: function()
{
WebInspector.View.prototype.storeScrollPositions.call(this);
this._scrolledToBottom = this._messagesElement.isScrolledToBottom();
},
restoreScrollPositions: function() restoreScrollPositions: function()
{ {
if (this._scrolledToBottom) if (this._viewport.scrolledToBottom())
this._immediatelyScrollIntoView(); this._immediatelyScrollToBottom();
else else
WebInspector.View.prototype.restoreScrollPositions.call(this); WebInspector.View.prototype.restoreScrollPositions.call(this);
}, },
...@@ -433,7 +426,8 @@ WebInspector.ConsoleView.prototype = { ...@@ -433,7 +426,8 @@ WebInspector.ConsoleView.prototype = {
{ {
this._scheduleViewportRefresh(); this._scheduleViewportRefresh();
this._prompt.hideSuggestBox(); this._prompt.hideSuggestBox();
this.restoreScrollPositions(); if (this._viewport.scrolledToBottom())
this._immediatelyScrollToBottom();
}, },
_scheduleViewportRefresh: function() _scheduleViewportRefresh: function()
...@@ -450,7 +444,7 @@ WebInspector.ConsoleView.prototype = { ...@@ -450,7 +444,7 @@ WebInspector.ConsoleView.prototype = {
this._viewportThrottler.schedule(invalidateViewport.bind(this)); this._viewportThrottler.schedule(invalidateViewport.bind(this));
}, },
_immediatelyScrollIntoView: function() _immediatelyScrollToBottom: function()
{ {
// This will scroll viewport and trigger its refresh. // This will scroll viewport and trigger its refresh.
this._promptElement.scrollIntoView(true); this._promptElement.scrollIntoView(true);
...@@ -568,7 +562,6 @@ WebInspector.ConsoleView.prototype = { ...@@ -568,7 +562,6 @@ WebInspector.ConsoleView.prototype = {
{ {
this._clearCurrentSearchResultHighlight(); this._clearCurrentSearchResultHighlight();
this._consoleMessages = []; this._consoleMessages = [];
this._scrolledToBottom = true;
this._updateMessageList(); this._updateMessageList();
if (this._searchRegex) if (this._searchRegex)
......
...@@ -55,6 +55,7 @@ WebInspector.ViewportControl = function(provider) ...@@ -55,6 +55,7 @@ WebInspector.ViewportControl = function(provider)
this._anchorSelection = null; this._anchorSelection = null;
this._headSelection = null; this._headSelection = null;
this._stickToBottom = false; this._stickToBottom = false;
this._scrolledToBottom = true;
} }
/** /**
...@@ -132,6 +133,14 @@ WebInspector.StaticViewportElement.prototype = { ...@@ -132,6 +133,14 @@ WebInspector.StaticViewportElement.prototype = {
} }
WebInspector.ViewportControl.prototype = { WebInspector.ViewportControl.prototype = {
/**
* @return {boolean}
*/
scrolledToBottom: function()
{
return this._scrolledToBottom;
},
/** /**
* @param {boolean} value * @param {boolean} value
*/ */
...@@ -373,7 +382,7 @@ WebInspector.ViewportControl.prototype = { ...@@ -373,7 +382,7 @@ WebInspector.ViewportControl.prototype = {
var visibleFrom = this.element.scrollTop; var visibleFrom = this.element.scrollTop;
var visibleHeight = this._visibleHeight(); var visibleHeight = this._visibleHeight();
var shouldStickToBottom = this._stickToBottom && this.element.isScrolledToBottom(); this._scrolledToBottom = this.element.isScrolledToBottom();
var isInvalidating = !this._cumulativeHeights; var isInvalidating = !this._cumulativeHeights;
if (this._cumulativeHeights && itemCount !== this._cumulativeHeights.length) if (this._cumulativeHeights && itemCount !== this._cumulativeHeights.length)
...@@ -387,6 +396,8 @@ WebInspector.ViewportControl.prototype = { ...@@ -387,6 +396,8 @@ WebInspector.ViewportControl.prototype = {
this._rebuildCumulativeHeightsIfNeeded(); this._rebuildCumulativeHeightsIfNeeded();
var oldFirstVisibleIndex = this._firstVisibleIndex; var oldFirstVisibleIndex = this._firstVisibleIndex;
var oldLastVisibleIndex = this._lastVisibleIndex; var oldLastVisibleIndex = this._lastVisibleIndex;
var shouldStickToBottom = this._stickToBottom && this._scrolledToBottom;
if (shouldStickToBottom) { if (shouldStickToBottom) {
this._lastVisibleIndex = itemCount - 1; this._lastVisibleIndex = itemCount - 1;
this._firstVisibleIndex = Math.max(itemCount - Math.ceil(visibleHeight / this._provider.minimumRowHeight()), 0); this._firstVisibleIndex = Math.max(itemCount - Math.ceil(visibleHeight / this._provider.minimumRowHeight()), 0);
......
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