From 5df4339998d2cd30aa189ca6995dac62e2570490 Mon Sep 17 00:00:00 2001 From: "vsevik@chromium.org" Date: Thu, 22 Sep 2011 13:43:23 +0000 Subject: [PATCH] Web Inspector: Console is always scrolled to the top https://bugs.webkit.org/show_bug.cgi?id=67483 Reviewed by Pavel Feldman. * inspector/front-end/ConsoleView.js: (WebInspector.ConsoleView.prototype.wasShown): (WebInspector.ConsoleView.prototype.storeScrollPositions): (WebInspector.ConsoleView.prototype.restoreScrollPositions): (WebInspector.ConsoleView.prototype.onResize): (WebInspector.ConsoleView.prototype._immediatelyScrollIntoView): (WebInspector.ConsoleView.prototype._cancelScheduledScrollIntoView): (WebInspector.ConsoleView.prototype._consoleCleared): * inspector/front-end/Drawer.js: (WebInspector.Drawer.prototype.hide): (WebInspector.Drawer.prototype.resize): (WebInspector.Drawer.prototype._startStatusBarDragging): (WebInspector.Drawer.prototype._statusBarDragging): * inspector/front-end/inspector.js: (WebInspector.animateStyle): (WebInspector.animateStyle.forceComplete): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95716 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 24 +++++++++++++++ Source/WebCore/inspector/front-end/ConsoleView.js | 36 +++++++++++++++++++++++ Source/WebCore/inspector/front-end/Drawer.js | 17 +++++++---- Source/WebCore/inspector/front-end/inspector.js | 12 +++++--- 4 files changed, 79 insertions(+), 10 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 8da03e2..0963f03 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,27 @@ +2011-09-22 Vsevolod Vlasov + + Web Inspector: Console is always scrolled to the top + https://bugs.webkit.org/show_bug.cgi?id=67483 + + Reviewed by Pavel Feldman. + + * inspector/front-end/ConsoleView.js: + (WebInspector.ConsoleView.prototype.wasShown): + (WebInspector.ConsoleView.prototype.storeScrollPositions): + (WebInspector.ConsoleView.prototype.restoreScrollPositions): + (WebInspector.ConsoleView.prototype.onResize): + (WebInspector.ConsoleView.prototype._immediatelyScrollIntoView): + (WebInspector.ConsoleView.prototype._cancelScheduledScrollIntoView): + (WebInspector.ConsoleView.prototype._consoleCleared): + * inspector/front-end/Drawer.js: + (WebInspector.Drawer.prototype.hide): + (WebInspector.Drawer.prototype.resize): + (WebInspector.Drawer.prototype._startStatusBarDragging): + (WebInspector.Drawer.prototype._statusBarDragging): + * inspector/front-end/inspector.js: + (WebInspector.animateStyle): + (WebInspector.animateStyle.forceComplete): + 2011-09-22 Alpha Lam https://bugs.webkit.org/show_bug.cgi?id=68081 diff --git a/Source/WebCore/inspector/front-end/ConsoleView.js b/Source/WebCore/inspector/front-end/ConsoleView.js index 6173ce9..c51682e 100644 --- a/Source/WebCore/inspector/front-end/ConsoleView.js +++ b/Source/WebCore/inspector/front-end/ConsoleView.js @@ -226,6 +226,7 @@ WebInspector.ConsoleView.prototype = { wasShown: function() { + WebInspector.View.prototype.wasShown.call(this); if (!this.prompt.isCaretInsidePrompt()) this.prompt.moveCaretToEndOfPrompt(); }, @@ -235,6 +236,25 @@ WebInspector.ConsoleView.prototype = { WebInspector.currentFocusElement = this.promptElement; }, + storeScrollPositions: function() + { + WebInspector.View.prototype.storeScrollPositions.call(this); + this._scrolledToBottom = this.messagesElement.isScrolledToBottom(); + }, + + restoreScrollPositions: function() + { + if (this._scrolledToBottom) + this._immediatelyScrollIntoView(); + else + WebInspector.View.prototype.restoreScrollPositions.call(this); + }, + + onResize: function() + { + this.restoreScrollPositions(); + }, + _isScrollIntoViewScheduled: function() { return !!this._scrollIntoViewTimer; @@ -253,6 +273,21 @@ WebInspector.ConsoleView.prototype = { this._scrollIntoViewTimer = setTimeout(scrollIntoView.bind(this), 20); }, + _immediatelyScrollIntoView: function() + { + this.promptElement.scrollIntoView(true); + this._cancelScheduledScrollIntoView(); + }, + + _cancelScheduledScrollIntoView: function() + { + if (!this._isScrollIntoViewScheduled()) + return; + + clearTimeout(this._scrollIntoViewTimer); + delete this._scrollIntoViewTimer; + }, + _consoleMessageAdded: function(event) { this._appendConsoleMessage(event.data); @@ -286,6 +321,7 @@ WebInspector.ConsoleView.prototype = { _consoleCleared: function() { + this._scrolledToBottom = true; this.messages = []; this.currentGroup = this.topGroup; diff --git a/Source/WebCore/inspector/front-end/Drawer.js b/Source/WebCore/inspector/front-end/Drawer.js index 8d3baef..78b0169 100644 --- a/Source/WebCore/inspector/front-end/Drawer.js +++ b/Source/WebCore/inspector/front-end/Drawer.js @@ -58,14 +58,14 @@ WebInspector.Drawer.prototype = { show: function(view, immediately) { - var drawerWasVisible = this.visible; - this.immediatelyFinishAnimation(); + + var drawerWasVisible = this.visible; + if (this._view) this.element.removeChild(this._view.element); this._view = view; - this._view.show(this.element); var statusBarItems = this._view.statusBarItems || []; for (var i = 0; i < statusBarItems.length; ++i) @@ -76,6 +76,8 @@ WebInspector.Drawer.prototype = { document.body.addStyleClass("drawer-visible"); + this._view.show(this.element); + var anchoredItems = document.getElementById("anchored-status-bar-items"); var height = this._constrainHeight(this._savedHeight || this.element.offsetHeight); var animations = [ @@ -120,9 +122,6 @@ WebInspector.Drawer.prototype = { this._savedHeight = this.element.offsetHeight; - this.element.removeChild(this._view.element); - delete this._view; - if (this.element === WebInspector.currentFocusElement || this.element.isAncestor(WebInspector.currentFocusElement)) WebInspector.currentFocusElement = WebInspector.previousFocusElement; @@ -161,6 +160,9 @@ WebInspector.Drawer.prototype = { this._counters.insertBefore(this._currentPanelCounters, this._counters.firstChild); } + this._view.hide(); + this.element.removeChild(this._view.element); + delete this._view; document.body.removeStyleClass("drawer-visible"); delete this._currentAnimation; } @@ -175,6 +177,7 @@ WebInspector.Drawer.prototype = { if (!this.visible) return; + this._view.storeScrollPositions(); var height = this._constrainHeight(parseInt(this.element.style.height)); this._mainElement.style.bottom = height + "px"; this.element.style.height = height + "px"; @@ -226,6 +229,7 @@ WebInspector.Drawer.prototype = { if (!this.visible || event.target !== this._mainStatusBar) return; + this._view.storeScrollPositions(); WebInspector.elementDragStart(this._mainStatusBar, this._statusBarDragging.bind(this), this._endStatusBarDragging.bind(this), event, "row-resize"); this._statusBarDragOffset = event.pageY - this.element.totalOffsetTop(); @@ -242,6 +246,7 @@ WebInspector.Drawer.prototype = { this.element.style.height = height + "px"; if (WebInspector.currentPanel()) WebInspector.currentPanel().doResize(); + this._view.doResize(); event.preventDefault(); event.stopPropagation(); diff --git a/Source/WebCore/inspector/front-end/inspector.js b/Source/WebCore/inspector/front-end/inspector.js index c1df97a..aaa3a68 100644 --- a/Source/WebCore/inspector/front-end/inspector.js +++ b/Source/WebCore/inspector/front-end/inspector.js @@ -917,6 +917,9 @@ WebInspector.animateStyle = function(animations, duration, callback) function animateLoop() { + if (hasCompleted) + return; + // Advance forward. complete += intervalDuration; var next = complete + intervalDuration; @@ -953,10 +956,11 @@ WebInspector.animateStyle = function(animations, duration, callback) function forceComplete() { - if (!hasCompleted) { - complete = duration; - animateLoop(); - } + if (hasCompleted) + return; + + complete = duration; + animateLoop(); } function cancel() -- 2.7.4