<!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>[51156] trunk/WebCore</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/51156">51156</a></dd>
<dt>Author</dt> <dd>eric@webkit.org</dd>
<dt>Date</dt> <dd>2009-11-18 16:52:47 -0800 (Wed, 18 Nov 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>2009-11-18  Patrick Mueller  &lt;Patrick_Mueller@us.ibm.com&gt;

        Reviewed by Pavel Feldman.

        Web Inspector - remember last script displayed in Scripts panel
        https://bugs.webkit.org/show_bug.cgi?id=27552

        Manual test added

        * inspector/front-end/ScriptsPanel.js:
        (WebInspector.ScriptsPanel.prototype.showScript):
        (WebInspector.ScriptsPanel.prototype.showResource):
        (WebInspector.ScriptsPanel.prototype._showScriptOrResource):
        (WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu):
        (WebInspector.ScriptsPanel.prototype._callFrameSelected):
        (WebInspector.ScriptsPanel.prototype._goBack):
        (WebInspector.ScriptsPanel.prototype._goForward):
        * manual-tests/inspector/remember-last-script.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreinspectorfrontendScriptsPaneljs">trunk/WebCore/inspector/front-end/ScriptsPanel.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkWebCoremanualtestsinspectorrememberlastscripthtml">trunk/WebCore/manual-tests/inspector/remember-last-script.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (51155 => 51156)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2009-11-19 00:43:58 UTC (rev 51155)
+++ trunk/WebCore/ChangeLog        2009-11-19 00:52:47 UTC (rev 51156)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2009-11-18  Patrick Mueller  &lt;Patrick_Mueller@us.ibm.com&gt;
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector - remember last script displayed in Scripts panel
+        https://bugs.webkit.org/show_bug.cgi?id=27552
+
+        Manual test added
+        
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype.showScript):
+        (WebInspector.ScriptsPanel.prototype.showResource):
+        (WebInspector.ScriptsPanel.prototype._showScriptOrResource):
+        (WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu):
+        (WebInspector.ScriptsPanel.prototype._callFrameSelected):
+        (WebInspector.ScriptsPanel.prototype._goBack):
+        (WebInspector.ScriptsPanel.prototype._goForward):
+        * manual-tests/inspector/remember-last-script.html: Added.
+
</ins><span class="cx"> 2009-11-18  Shinichiro Hamaji  &lt;hamaji@chromium.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Dimitri Glazkov.
</span></span></pre></div>
<a id="trunkWebCoreinspectorfrontendScriptsPaneljs"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/inspector/front-end/ScriptsPanel.js (51155 => 51156)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/inspector/front-end/ScriptsPanel.js        2009-11-19 00:43:58 UTC (rev 51155)
+++ trunk/WebCore/inspector/front-end/ScriptsPanel.js        2009-11-19 00:52:47 UTC (rev 51156)
</span><span class="lines">@@ -501,12 +501,12 @@
</span><span class="cx"> 
</span><span class="cx">     showScript: function(script, line)
</span><span class="cx">     {
</span><del>-        this._showScriptOrResource(script, line, true);
</del><ins>+        this._showScriptOrResource(script, {line: line, shouldHighlightLine: true});
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     showResource: function(resource, line)
</span><span class="cx">     {
</span><del>-        this._showScriptOrResource(resource, line, true);
</del><ins>+        this._showScriptOrResource(resource, {line: line, shouldHighlightLine: true});
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     showView: function(view)
</span><span class="lines">@@ -574,8 +574,12 @@
</span><span class="cx">             return this.sourceFrameForScript(scriptOrResource);
</span><span class="cx">     },
</span><span class="cx"> 
</span><del>-    _showScriptOrResource: function(scriptOrResource, line, shouldHighlightLine, fromBackForwardAction)
</del><ins>+    _showScriptOrResource: function(scriptOrResource, options)
</ins><span class="cx">     {
</span><ins>+        // options = {line:, shouldHighlightLine:, fromBackForwardAction:, initialLoad:}
+        if (!options) 
+            options = {};
+
</ins><span class="cx">         if (!scriptOrResource)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="lines">@@ -601,7 +605,11 @@
</span><span class="cx">         if (!view)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        if (!fromBackForwardAction) {
</del><ins>+        var url = scriptOrResource.url || scriptOrResource.sourceURL;
+        if (url &amp;&amp; !options.initialLoad)
+            InspectorController.setSetting(&quot;LastViewedScriptFile&quot;, url);
+
+        if (!options.fromBackForwardAction) {
</ins><span class="cx">             var oldIndex = this._currentBackForwardIndex;
</span><span class="cx">             if (oldIndex &gt;= 0)
</span><span class="cx">                 this._backForwardList.splice(oldIndex + 1, this._backForwardList.length - oldIndex);
</span><span class="lines">@@ -622,11 +630,11 @@
</span><span class="cx"> 
</span><span class="cx">         this.visibleView = view;
</span><span class="cx"> 
</span><del>-        if (line) {
</del><ins>+        if (options.line) {
</ins><span class="cx">             if (view.revealLine)
</span><del>-                view.revealLine(line);
-            if (view.highlightLine &amp;&amp; shouldHighlightLine)
-                view.highlightLine(line);
</del><ins>+                view.revealLine(options.line);
+            if (view.highlightLine &amp;&amp; options.shouldHighlightLine)
+                view.highlightLine(options.line);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         var option;
</span><span class="lines">@@ -642,7 +650,6 @@
</span><span class="cx"> 
</span><span class="cx">             console.assert(option);
</span><span class="cx">         } else {
</span><del>-            var url = scriptOrResource.url;
</del><span class="cx">             var script = this._scriptsForURLsInFilesSelect[url];
</span><span class="cx">             if (script)
</span><span class="cx">                option = script.filesSelectOption;
</span><span class="lines">@@ -699,7 +706,14 @@
</span><span class="cx">         // Call _showScriptOrResource if the option we just appended ended up being selected.
</span><span class="cx">         // This will happen for the first item added to the menu.
</span><span class="cx">         if (select.options[select.selectedIndex] === option)
</span><del>-            this._showScriptOrResource(option.representedObject);
</del><ins>+            this._showScriptOrResource(option.representedObject, {initialLoad: true});
+        else {
+            // if not first item, check to see if this was the last viewed
+            var url = option.representedObject.url || option.representedObject.sourceURL;
+            var lastURL = InspectorController.setting(&quot;LastViewedScriptFile&quot;);
+            if (url &amp;&amp; url === lastURL)
+                this._showScriptOrResource(option.representedObject, {initialLoad: true});
+        }
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     _clearCurrentExecutionLine: function()
</span><span class="lines">@@ -722,7 +736,7 @@
</span><span class="cx">         this.sidebarPanes.watchExpressions.refreshExpressions();
</span><span class="cx"> 
</span><span class="cx">         var scriptOrResource = this._sourceIDMap[currentFrame.sourceID];
</span><del>-        this._showScriptOrResource(scriptOrResource, currentFrame.line);
</del><ins>+        this._showScriptOrResource(scriptOrResource, {line: currentFrame.line});
</ins><span class="cx"> 
</span><span class="cx">         this._executionSourceFrame = this._sourceFrameForScriptOrResource(scriptOrResource);
</span><span class="cx">         if (this._executionSourceFrame)
</span><span class="lines">@@ -841,7 +855,7 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        this._showScriptOrResource(this._backForwardList[--this._currentBackForwardIndex], null, false, true);
</del><ins>+        this._showScriptOrResource(this._backForwardList[--this._currentBackForwardIndex], {fromBackForwardAction: true});
</ins><span class="cx">         this._updateBackAndForwardButtons();
</span><span class="cx">     },
</span><span class="cx"> 
</span><span class="lines">@@ -852,7 +866,7 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        this._showScriptOrResource(this._backForwardList[++this._currentBackForwardIndex], null, false, true);
</del><ins>+        this._showScriptOrResource(this._backForwardList[++this._currentBackForwardIndex], {fromBackForwardAction: true});
</ins><span class="cx">         this._updateBackAndForwardButtons();
</span><span class="cx">     },
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebCoremanualtestsinspectorrememberlastscripthtml"></a>
<div class="addfile"><h4>Added: trunk/WebCore/manual-tests/inspector/remember-last-script.html (0 => 51156)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/manual-tests/inspector/remember-last-script.html                                (rev 0)
+++ trunk/WebCore/manual-tests/inspector/remember-last-script.html        2009-11-19 00:52:47 UTC (rev 51156)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+&lt;style&gt;code{background-color: #ffc;}&lt;/style&gt;
+&lt;p&gt;&lt;b&gt;Test for &lt;a href=&quot;https://bugs.webkit.org/show_bug.cgi?id=27552&quot;&gt;Bug 27552&lt;/a&gt; - remember last script displayed in Scripts panel&lt;/b&gt;
+
+&lt;ul&gt;
+&lt;li&gt;&lt;p&gt;open this page with Web Inspector, switch to the &lt;b&gt;Scripts&lt;/b&gt; panel, enabling debug if required
+&lt;li&gt;&lt;p&gt;the available scripts in the select element should be:
+    &lt;ul&gt;
+        &lt;li&gt;&lt;b&gt;(program): f1.js&lt;/b&gt;
+        &lt;li&gt;&lt;b&gt;remember-last-script.html&lt;/b&gt;
+    &lt;/ul&gt;
+&lt;li&gt;&lt;p&gt;select &lt;b&gt;(program): f1.js&lt;/b&gt; so the source is available
+&lt;li&gt;&lt;p&gt;switch to the &lt;b&gt;Resources&lt;/b&gt; panel
+&lt;li&gt;&lt;p&gt;close Web Inspector
+&lt;li&gt;&lt;p&gt;Repeat the following several times.  Each time, &lt;b&gt;(program): f1.js&lt;/b&gt;
+should be the selected script:
+    &lt;ul&gt;
+    &lt;li&gt;open Web Inspector, switch to the &lt;b&gt;Scripts&lt;/b&gt; panel, then close Web Inspector
+    &lt;/ul&gt;
+&lt;li&gt;&lt;p&gt;open Web Inspector, switch to the &lt;b&gt;Scripts&lt;/b&gt; panel
+&lt;li&gt;&lt;p&gt;select &lt;b&gt;remember-last-script.html&lt;/b&gt; so the source is available
+&lt;li&gt;&lt;p&gt;Repeat the following several times.  Each time, &lt;b&gt;remember-last-script.html&lt;/b&gt;
+should be the selected script:
+    &lt;ul&gt;
+    &lt;li&gt;open Web Inspector, switch to the &lt;b&gt;Scripts&lt;/b&gt; panel, then close Web Inspector
+    &lt;/ul&gt;
+&lt;/ul&gt;    
+
+&lt;script&gt;
+
+f1 = Function([
+    &quot;&quot;,
+    &quot;   doNothing();&quot;,
+    &quot;//@sourceURL=f1.js&quot;
+].join(&quot;\n&quot;));
+
+function doNothing() { /* allows multi-line functions, easier to debug */ };
+
+doNothing();
+f1();
+
+&lt;/script&gt;
+&lt;!-- End --&gt;
</ins></span></pre>
</div>
</div>

</body>
</html>