Title: [97056] trunk
Revision
97056
Author
podivi...@chromium.org
Date
2011-10-10 05:40:19 -0700 (Mon, 10 Oct 2011)

Log Message

Web Inspector: saving _javascript_ after live edit resets scroller position.
https://bugs.webkit.org/show_bug.cgi?id=69340

Source/WebCore:

Do not recreate SourceFrame when content is changed. Instead, update text model in existing SourceFrame.

Reviewed by Yury Semikhatsky.

* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel.prototype.setScriptSource.didEditScriptSource):
(WebInspector.DebuggerPresentationModel.prototype.setScriptSource):
* inspector/front-end/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame):
* inspector/front-end/RawSourceCode.js:
(WebInspector.RawSourceCode.prototype.setCompilerSourceMappingProvider):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype._setReadOnly):
(WebInspector.SourceFrame.prototype.contentChanged):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode.prototype.contentChanged):

LayoutTests:

Reviewed by Yury Semikhatsky.

* inspector/debugger/raw-source-code-expected.txt:
* inspector/debugger/raw-source-code.html:
* inspector/debugger/scripts-panel.html:
* inspector/debugger/ui-source-code-expected.txt:
* inspector/debugger/ui-source-code.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (97055 => 97056)


--- trunk/LayoutTests/ChangeLog	2011-10-10 11:43:40 UTC (rev 97055)
+++ trunk/LayoutTests/ChangeLog	2011-10-10 12:40:19 UTC (rev 97056)
@@ -1,3 +1,16 @@
+2011-10-06  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: saving _javascript_ after live edit resets scroller position.
+        https://bugs.webkit.org/show_bug.cgi?id=69340
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/debugger/raw-source-code-expected.txt:
+        * inspector/debugger/raw-source-code.html:
+        * inspector/debugger/scripts-panel.html:
+        * inspector/debugger/ui-source-code-expected.txt:
+        * inspector/debugger/ui-source-code.html:
+
 2011-10-09  Adam Barth  <aba...@webkit.org>
 
         CSP should log unrecognized directives to the console

Modified: trunk/LayoutTests/inspector/debugger/raw-source-code-expected.txt (97055 => 97056)


--- trunk/LayoutTests/inspector/debugger/raw-source-code-expected.txt	2011-10-10 11:43:40 UTC (rev 97055)
+++ trunk/LayoutTests/inspector/debugger/raw-source-code-expected.txt	2011-10-10 12:40:19 UTC (rev 97056)
@@ -7,8 +7,6 @@
 
 Running: testHTMLWithFinishedResource
 
-Running: testContentEdited
-
 Running: testForceUpdateSourceMapping
 
 Running: testFormattingWithFinishedResource

Modified: trunk/LayoutTests/inspector/debugger/raw-source-code.html (97055 => 97056)


--- trunk/LayoutTests/inspector/debugger/raw-source-code.html	2011-10-10 11:43:40 UTC (rev 97055)
+++ trunk/LayoutTests/inspector/debugger/raw-source-code.html	2011-10-10 12:40:19 UTC (rev 97056)
@@ -181,39 +181,6 @@
             }
         },
 
-        function testContentEdited(next)
-        {
-            var script = createScriptMock("foo.js", 0, 0, true, "<script source>");
-            var resource = createFinishedResourceMock("script", "<resource content>");
-            var rawSourceCode = createRawSourceCode(script, resource);
-
-            var sourceMapping = rawSourceCode.sourceMapping;
-            var uiSourceCode = sourceMapping.uiSourceCode;
-            uiSourceCode.requestContent(didRequestContent);
-
-            function didRequestContent(mimeType, content)
-            {
-                InspectorTest.assertEquals("text/_javascript_", mimeType);
-                InspectorTest.assertEquals("<resource content>", content);
-
-                waitForSourceMappingEvent(rawSourceCode, mappingReadyAfterEdit);
-                resource.content = "<edited resource content>";
-                rawSourceCode.contentEdited();
-            }
-
-            function mappingReadyAfterEdit()
-            {
-                rawSourceCode.sourceMapping.uiSourceCode.requestContent(didRequestContentAfterEdit);
-            }
-
-            function didRequestContentAfterEdit(mimeType, content)
-            {
-                InspectorTest.assertEquals(mimeType, "text/_javascript_");
-                InspectorTest.assertEquals("<edited resource content>", content);
-                next();
-            }
-        },
-
         function testForceUpdateSourceMapping(next)
         {
             var script1 = createScriptMock("index.html", 0, 10, false, "<script source 1>");

Modified: trunk/LayoutTests/inspector/debugger/scripts-panel.html (97055 => 97056)


--- trunk/LayoutTests/inspector/debugger/scripts-panel.html	2011-10-10 11:43:40 UTC (rev 97055)
+++ trunk/LayoutTests/inspector/debugger/scripts-panel.html	2011-10-10 12:40:19 UTC (rev 97056)
@@ -28,6 +28,7 @@
             },
             messages: []
         };
+        uiSourceCode.__proto__ = WebInspector.Object.prototype;
         model.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeAdded, uiSourceCode);
         return uiSourceCode;
     }

Modified: trunk/Source/WebCore/ChangeLog (97055 => 97056)


--- trunk/Source/WebCore/ChangeLog	2011-10-10 11:43:40 UTC (rev 97055)
+++ trunk/Source/WebCore/ChangeLog	2011-10-10 12:40:19 UTC (rev 97056)
@@ -1,3 +1,25 @@
+2011-10-06  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: saving _javascript_ after live edit resets scroller position.
+        https://bugs.webkit.org/show_bug.cgi?id=69340
+
+        Do not recreate SourceFrame when content is changed. Instead, update text model in existing SourceFrame.
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel.prototype.setScriptSource.didEditScriptSource):
+        (WebInspector.DebuggerPresentationModel.prototype.setScriptSource):
+        * inspector/front-end/_javascript_SourceFrame.js:
+        (WebInspector._javascript_SourceFrame):
+        * inspector/front-end/RawSourceCode.js:
+        (WebInspector.RawSourceCode.prototype.setCompilerSourceMappingProvider):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame.prototype._setReadOnly):
+        (WebInspector.SourceFrame.prototype.contentChanged):
+        * inspector/front-end/UISourceCode.js:
+        (WebInspector.UISourceCode.prototype.contentChanged):
+
 2011-10-10  Ilya Tikhonovsky  <loi...@chromium.org>
 
         Unreviewed test fix for r97050.

Modified: trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js (97055 => 97056)


--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-10-10 11:43:40 UTC (rev 97055)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-10-10 12:40:19 UTC (rev 97056)
@@ -190,7 +190,7 @@
             if (resource)
                 resource.addRevision(newSource);
 
-            rawSourceCode.contentEdited();
+            uiSourceCode.contentChanged(newSource);
 
             if (WebInspector.debuggerModel.callFrames)
                 this._debuggerPaused();

Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (97055 => 97056)


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2011-10-10 11:43:40 UTC (rev 97055)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2011-10-10 12:40:19 UTC (rev 97056)
@@ -39,6 +39,8 @@
     // FIXME: move all SourceFrame methods related to _javascript_ debugging here and
     // get rid of SourceFrame._delegate.
     WebInspector.SourceFrame.call(this, delegate, uiSourceCode.url);
+
+    uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this.contentChanged, this);
 }
 
 WebInspector._javascript_SourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype;

Modified: trunk/Source/WebCore/inspector/front-end/RawSourceCode.js (97055 => 97056)


--- trunk/Source/WebCore/inspector/front-end/RawSourceCode.js	2011-10-10 11:43:40 UTC (rev 97055)
+++ trunk/Source/WebCore/inspector/front-end/RawSourceCode.js	2011-10-10 12:40:19 UTC (rev 97056)
@@ -86,11 +86,6 @@
         this._updateSourceMapping();
     },
 
-    contentEdited: function()
-    {
-        this._updateSourceMapping();
-    },
-
     _resourceFinished: function()
     {
         if (this._compilerSourceMappingProvider)

Modified: trunk/Source/WebCore/inspector/front-end/SourceFrame.js (97055 => 97056)


--- trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2011-10-10 11:43:40 UTC (rev 97055)
+++ trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2011-10-10 12:40:19 UTC (rev 97056)
@@ -101,6 +101,7 @@
         if (this._popoverHelper)
             this._popoverHelper.hidePopover();
         this._clearLineHighlight();
+        this._textViewer.readOnly = true;
     },
 
     get statusBarItems()
@@ -110,7 +111,7 @@
 
     get loaded()
     {
-        return !!this._content;
+        return this._loaded;
     },
 
     hasContent: function()
@@ -296,7 +297,7 @@
     {
         this._textViewer.mimeType = mimeType;
 
-        this._content = content;
+        this._loaded = true;
         this._textModel.setText(null, content);
 
         var element = this._textViewer.element;
@@ -894,6 +895,13 @@
         WebInspector.markBeingEdited(this._textViewer.element, !readOnly);
         if (readOnly)
             this._delegate.setScriptSourceIsBeingEdited(false);
+    },
+
+    contentChanged: function()
+    {
+        if (!this._contentRequested || !this._textViewer.readOnly)
+            return;
+        this._delegate.requestContent(this._initializeTextViewer.bind(this));
     }
 }
 

Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (97055 => 97056)


--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2011-10-10 11:43:40 UTC (rev 97055)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2011-10-10 12:40:19 UTC (rev 97056)
@@ -41,6 +41,10 @@
     this._requestContentCallbacks = [];
 }
 
+WebInspector.UISourceCode.Events = {
+    ContentChanged: "content-changed"
+}
+
 WebInspector.UISourceCode.prototype = {
     get id()
     {
@@ -74,6 +78,13 @@
             this._contentProvider.requestContent(this._didRequestContent.bind(this));
     },
 
+    contentChanged: function(newContent)
+    {
+        console.assert(this._contentLoaded);
+        this._content = newContent;
+        this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ContentChanged);
+    },
+
     _didRequestContent: function(mimeType, content)
     {
         this._contentLoaded = true;
@@ -85,6 +96,8 @@
     }
 }
 
+WebInspector.UISourceCode.prototype.__proto__ = WebInspector.Object.prototype;
+
 /**
  * @interface
  */
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to