<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[200337] trunk/Source/WebInspectorUI</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/200337">200337</a></dd>
<dt>Author</dt> <dd>nvasilyev@apple.com</dd>
<dt>Date</dt> <dd>2016-05-02 14:01:08 -0700 (Mon, 02 May 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Web Inspector: Adding a new console message shouldn't modify DOM when the console log is hidden
https://bugs.webkit.org/show_bug.cgi?id=155629
<rdar://problem/25235470>
Reviewed by Timothy Hatcher.
Instead of rendering console messages right away, store them (in _pendingMessages)
and render only when the console tab or the split console is visible.
Also, batch rendering operations using requestAnimationFrame.
* UserInterface/Controllers/JavaScriptLogViewController.js:
(WebInspector.JavaScriptLogViewController):
Store console message views in _pendingMessages.
(WebInspector.JavaScriptLogViewController.prototype._appendConsoleMessageView):
(WebInspector.JavaScriptLogViewController.prototype.renderPendingMessages):
Use requestAnimationFrame batching. Run isScrolledToBottom() at most only once
per batch.
(WebInspector.JavaScriptLogViewController.prototype.renderPendingMessagesSoon):
(WebInspector.JavaScriptLogViewController.prototype._didRenderConsoleMessageView):
There is no need to run scrollToBottom again.
* UserInterface/Views/ConsoleCommandView.js:
(WebInspector.ConsoleCommandView):
Move all DOM operations to a new render method.
(WebInspector.ConsoleCommandView.prototype.render):
* UserInterface/Views/ConsoleMessageView.js:
(WebInspector.ConsoleMessageView):
(WebInspector.ConsoleMessageView.prototype.render):
(WebInspector.ConsoleMessageView.prototype.set repeatCount):
(WebInspector.ConsoleMessageView.prototype._renderRepeatCount):
* UserInterface/Views/LogContentView.js:
(WebInspector.LogContentView.prototype.shown):
When the console tab or the split console is opened render all pending messages.
(WebInspector.LogContentView.prototype.didAppendConsoleMessageView):
No need to scrollToBottom once again.
(WebInspector.LogContentView.prototype._messageAdded):
(WebInspector.LogContentView.prototype._previousMessageRepeatCountUpdated):
(WebInspector.LogContentView.prototype._scopeFromMessageLevel): Deleted.
(WebInspector.LogContentView.prototype._markScopeBarItemUnread): Added.
Rename _pulseScopeBarItemBorder. In the very first version the border was pulsing,
but now we use small colored circles instead.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersJavaScriptLogViewControllerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsConsoleCommandViewjs">trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleCommandView.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsConsoleMessageViewjs">trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsLogContentViewjs">trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (200336 => 200337)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2016-05-02 20:32:25 UTC (rev 200336)
+++ trunk/Source/WebInspectorUI/ChangeLog        2016-05-02 21:01:08 UTC (rev 200337)
</span><span class="lines">@@ -1,3 +1,52 @@
</span><ins>+2016-05-02 Nikita Vasilyev <nvasilyev@apple.com>
+
+ Web Inspector: Adding a new console message shouldn't modify DOM when the console log is hidden
+ https://bugs.webkit.org/show_bug.cgi?id=155629
+ <rdar://problem/25235470>
+
+ Reviewed by Timothy Hatcher.
+
+ Instead of rendering console messages right away, store them (in _pendingMessages)
+ and render only when the console tab or the split console is visible.
+ Also, batch rendering operations using requestAnimationFrame.
+
+ * UserInterface/Controllers/JavaScriptLogViewController.js:
+ (WebInspector.JavaScriptLogViewController):
+ Store console message views in _pendingMessages.
+
+ (WebInspector.JavaScriptLogViewController.prototype._appendConsoleMessageView):
+ (WebInspector.JavaScriptLogViewController.prototype.renderPendingMessages):
+ Use requestAnimationFrame batching. Run isScrolledToBottom() at most only once
+ per batch.
+
+ (WebInspector.JavaScriptLogViewController.prototype.renderPendingMessagesSoon):
+ (WebInspector.JavaScriptLogViewController.prototype._didRenderConsoleMessageView):
+ There is no need to run scrollToBottom again.
+
+ * UserInterface/Views/ConsoleCommandView.js:
+ (WebInspector.ConsoleCommandView):
+ Move all DOM operations to a new render method.
+
+ (WebInspector.ConsoleCommandView.prototype.render):
+ * UserInterface/Views/ConsoleMessageView.js:
+ (WebInspector.ConsoleMessageView):
+ (WebInspector.ConsoleMessageView.prototype.render):
+ (WebInspector.ConsoleMessageView.prototype.set repeatCount):
+ (WebInspector.ConsoleMessageView.prototype._renderRepeatCount):
+ * UserInterface/Views/LogContentView.js:
+ (WebInspector.LogContentView.prototype.shown):
+ When the console tab or the split console is opened render all pending messages.
+
+ (WebInspector.LogContentView.prototype.didAppendConsoleMessageView):
+ No need to scrollToBottom once again.
+
+ (WebInspector.LogContentView.prototype._messageAdded):
+ (WebInspector.LogContentView.prototype._previousMessageRepeatCountUpdated):
+ (WebInspector.LogContentView.prototype._scopeFromMessageLevel): Deleted.
+ (WebInspector.LogContentView.prototype._markScopeBarItemUnread): Added.
+ Rename _pulseScopeBarItemBorder. In the very first version the border was pulsing,
+ but now we use small colored circles instead.
+
</ins><span class="cx"> 2016-05-02 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><span class="cx"> Uncaught Exception: TypeError: null is not an object (evaluating 'sourceCodeLocation.formattedLineNumber')
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersJavaScriptLogViewControllerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js (200336 => 200337)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js        2016-05-02 20:32:25 UTC (rev 200336)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js        2016-05-02 21:01:08 UTC (rev 200337)
</span><span class="lines">@@ -60,6 +60,9 @@
</span><span class="cx"> this._promptFindNextKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "G", this._handleFindNextShortcut.bind(this), this._prompt.element);
</span><span class="cx"> this._promptFindPreviousKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Shift, "G", this._handleFindPreviousShortcut.bind(this), this._prompt.element);
</span><span class="cx">
</span><ins>+ this._pendingMessages = [];
+ this._scheduledRenderIdentifier = 0;
+
</ins><span class="cx"> this.startNewSession();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -252,7 +255,7 @@
</span><span class="cx">
</span><span class="cx"> _appendConsoleMessageView(messageView, repeatCountWasInterrupted)
</span><span class="cx"> {
</span><del>- var wasScrolledToBottom = this.isScrolledToBottom();
</del><ins>+ this._pendingMessages.push(messageView);
</ins><span class="cx">
</span><span class="cx"> this._cleared = false;
</span><span class="cx"> this._repeatCountWasInterrupted = repeatCountWasInterrupted || false;
</span><span class="lines">@@ -263,6 +266,45 @@
</span><span class="cx"> if (messageView.message && messageView.message.source !== WebInspector.ConsoleMessage.MessageSource.JS)
</span><span class="cx"> this._lastCommitted = "";
</span><span class="cx">
</span><ins>+ if (WebInspector.consoleContentView.visible)
+ this.renderPendingMessagesSoon();
+ }
+
+ renderPendingMessages()
+ {
+ if (this._scheduledRenderIdentifier) {
+ cancelAnimationFrame(this._scheduledRenderIdentifier);
+ this._scheduledRenderIdentifier = 0;
+ }
+
+ if (this._pendingMessages.length === 0)
+ return;
+
+ let lastMessageView = this._pendingMessages.lastValue;
+ let isCommandView = lastMessageView instanceof WebInspector.ConsoleCommandView;
+ let shouldScrollToBottom = isCommandView || lastMessageView.message.type === WebInspector.ConsoleMessage.MessageType.Result || this.isScrolledToBottom();
+
+ for (let messageView of this._pendingMessages) {
+ messageView.render();
+ this._didRenderConsoleMessageView(messageView);
+ }
+
+ this._pendingMessages = [];
+
+ if (shouldScrollToBottom)
+ this.scrollToBottom();
+ }
+
+ renderPendingMessagesSoon()
+ {
+ if (this._scheduledRenderIdentifier)
+ return;
+
+ this._scheduledRenderIdentifier = requestAnimationFrame(() => this.renderPendingMessages());
+ }
+
+ _didRenderConsoleMessageView(messageView)
+ {
</ins><span class="cx"> var type = messageView instanceof WebInspector.ConsoleCommandView ? null : messageView.message.type;
</span><span class="cx"> if (type === WebInspector.ConsoleMessage.MessageType.EndGroup) {
</span><span class="cx"> var parentGroup = this._currentConsoleGroup.parentGroup;
</span><span class="lines">@@ -278,9 +320,6 @@
</span><span class="cx"> this._currentConsoleGroup.addMessageView(messageView);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (type === WebInspector.ConsoleMessage.MessageType.Result || wasScrolledToBottom)
- this.scrollToBottom();
-
</del><span class="cx"> if (this.delegate && typeof this.delegate.didAppendConsoleMessageView === "function")
</span><span class="cx"> this.delegate.didAppendConsoleMessageView(messageView);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsConsoleCommandViewjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleCommandView.js (200336 => 200337)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleCommandView.js        2016-05-02 20:32:25 UTC (rev 200336)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleCommandView.js        2016-05-02 21:01:08 UTC (rev 200337)
</span><span class="lines">@@ -34,13 +34,19 @@
</span><span class="cx"> super();
</span><span class="cx">
</span><span class="cx"> this._commandText = commandText;
</span><ins>+ this._className = className || "";
+ }
</ins><span class="cx">
</span><ins>+ // Public
+
+ render()
+ {
</ins><span class="cx"> this._element = document.createElement("div");
</span><span class="cx"> this._element.classList.add("console-user-command");
</span><span class="cx"> this._element.setAttribute("data-labelprefix", WebInspector.UIString("Input: "));
</span><span class="cx">
</span><del>- if (className)
- this._element.classList.add(className);
</del><ins>+ if (this._className)
+ this._element.classList.add(this._className);
</ins><span class="cx">
</span><span class="cx"> this._formattedCommandElement = this._element.appendChild(document.createElement("span"));
</span><span class="cx"> this._formattedCommandElement.classList.add("console-message-text");
</span><span class="lines">@@ -50,8 +56,6 @@
</span><span class="cx"> this._element.__commandView = this;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // Public
-
</del><span class="cx"> get element()
</span><span class="cx"> {
</span><span class="cx"> return this._element;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsConsoleMessageViewjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js (200336 => 200337)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js        2016-05-02 20:32:25 UTC (rev 200336)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js        2016-05-02 21:01:08 UTC (rev 200337)
</span><span class="lines">@@ -37,9 +37,18 @@
</span><span class="cx"> console.assert(message instanceof WebInspector.ConsoleMessage);
</span><span class="cx">
</span><span class="cx"> this._message = message;
</span><del>-
</del><span class="cx"> this._expandable = false;
</span><ins>+ this._repeatCount = message._repeatCount || 0;
</ins><span class="cx">
</span><ins>+ // These are the parameters unused by the messages's optional format string.
+ // Any extra parameters will be displayed as children of this message.
+ this._extraParameters = message.parameters;
+ }
+
+ // Public
+
+ render()
+ {
</ins><span class="cx"> this._element = document.createElement("div");
</span><span class="cx"> this._element.classList.add("console-message");
</span><span class="cx">
</span><span class="lines">@@ -76,10 +85,6 @@
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // These are the parameters unused by the messages's optional format string.
- // Any extra parameters will be displayed as children of this message.
- this._extraParameters = this._message.parameters;
-
</del><span class="cx"> // FIXME: The location link should include stack trace information.
</span><span class="cx"> this._appendLocationLink();
</span><span class="cx">
</span><span class="lines">@@ -92,11 +97,9 @@
</span><span class="cx"> this._appendExtraParameters();
</span><span class="cx"> this._appendStackTrace();
</span><span class="cx">
</span><del>- this.repeatCount = this._message.repeatCount;
</del><ins>+ this._renderRepeatCount();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- // Public
-
</del><span class="cx"> get element()
</span><span class="cx"> {
</span><span class="cx"> return this._element;
</span><span class="lines">@@ -121,6 +124,14 @@
</span><span class="cx">
</span><span class="cx"> this._repeatCount = count;
</span><span class="cx">
</span><ins>+ if (this._element)
+ this._renderRepeatCount();
+ }
+
+ _renderRepeatCount()
+ {
+ let count = this._repeatCount;
+
</ins><span class="cx"> if (count <= 1) {
</span><span class="cx"> if (this._repeatCountElement) {
</span><span class="cx"> this._repeatCountElement.remove();
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsLogContentViewjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js (200336 => 200337)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js        2016-05-02 20:32:25 UTC (rev 200336)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js        2016-05-02 21:01:08 UTC (rev 200337)
</span><span class="lines">@@ -122,6 +122,11 @@
</span><span class="cx"> return this.messagesElement.classList.contains(WebInspector.LogContentView.SearchInProgressStyleClassName);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ shown()
+ {
+ this._logViewController.renderPendingMessages();
+ }
+
</ins><span class="cx"> didAppendConsoleMessageView(messageView)
</span><span class="cx"> {
</span><span class="cx"> console.assert(messageView instanceof WebInspector.ConsoleMessageView || messageView instanceof WebInspector.ConsoleCommandView);
</span><span class="lines">@@ -155,6 +160,14 @@
</span><span class="cx"> // We want to remove focusable children after those pending dispatches too.
</span><span class="cx"> InspectorBackend.runAfterPendingDispatches(this._clearFocusableChildren.bind(this));
</span><span class="cx">
</span><ins>+ if (type && type !== WebInspector.ConsoleMessage.MessageType.EndGroup) {
+ console.assert(messageView.message instanceof WebInspector.ConsoleMessage);
+ this._markScopeBarItemUnread(messageView.message.level);
+
+ console.assert(messageView.element instanceof Element);
+ this._filterMessageElements([messageView.element]);
+ }
+
</ins><span class="cx"> // We only auto show the console if the message is a non-synthetic result.
</span><span class="cx"> // This is when the user evaluated something directly in the prompt.
</span><span class="cx"> if (type !== WebInspector.ConsoleMessage.MessageType.Result || messageView.message.synthetic)
</span><span class="lines">@@ -162,8 +175,6 @@
</span><span class="cx">
</span><span class="cx"> if (!WebInspector.isShowingConsoleTab())
</span><span class="cx"> WebInspector.showSplitConsole();
</span><del>-
- this._logViewController.scrollToBottom();
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> get supportsSearch()
</span><span class="lines">@@ -309,7 +320,7 @@
</span><span class="cx"> return messageLevel;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- _pulseScopeBarItemBorder(level)
</del><ins>+ _markScopeBarItemUnread(level)
</ins><span class="cx"> {
</span><span class="cx"> var messageLevel = this._scopeFromMessageLevel(level);
</span><span class="cx">
</span><span class="lines">@@ -327,17 +338,13 @@
</span><span class="cx"> if (this._startedProvisionalLoad)
</span><span class="cx"> this._provisionalMessages.push(event.data.message);
</span><span class="cx">
</span><del>- this._lastMessageView = this._logViewController.appendConsoleMessage(event.data.message);
- if (this._lastMessageView.message.type !== WebInspector.ConsoleMessage.MessageType.EndGroup) {
- this._pulseScopeBarItemBorder(this._lastMessageView.message.level);
- this._filterMessageElements([this._lastMessageView.element]);
- }
</del><ins>+ this._logViewController.appendConsoleMessage(event.data.message);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> _previousMessageRepeatCountUpdated(event)
</span><span class="cx"> {
</span><span class="cx"> if (this._logViewController.updatePreviousMessageRepeatCount(event.data.count) && this._lastMessageView)
</span><del>- this._pulseScopeBarItemBorder(this._lastMessageView.message.level);
</del><ins>+ this._markScopeBarItemUnread(this._lastMessageView.message.level);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> _handleContextMenuEvent(event)
</span></span></pre>
</div>
</div>
</body>
</html>