Title: [116848] trunk/Source/WebCore
Revision
116848
Author
[email protected]
Date
2012-05-12 04:09:27 -0700 (Sat, 12 May 2012)

Log Message

Web Inspector: shrink SourceFrame editing API to two methods (was 4).
https://bugs.webkit.org/show_bug.cgi?id=86288

Reviewed by Yury Semikhatsky.

Used specific workflow in two SourceFrame implementations.

* inspector/front-end/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame.prototype.commitEditing):
(WebInspector._javascript_SourceFrame.prototype.afterTextChanged):
(WebInspector._javascript_SourceFrame.prototype._didEditContent):
* inspector/front-end/ResourceView.js:
(WebInspector.EditableResourceSourceFrame.prototype.commitEditing.callbackWrapper):
(WebInspector.EditableResourceSourceFrame.prototype.commitEditing):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype.commitEditing):
(WebInspector.TextViewerDelegateForSourceFrame.prototype.commitEditing):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (116847 => 116848)


--- trunk/Source/WebCore/ChangeLog	2012-05-12 10:17:18 UTC (rev 116847)
+++ trunk/Source/WebCore/ChangeLog	2012-05-12 11:09:27 UTC (rev 116848)
@@ -1,3 +1,23 @@
+2012-05-12  Pavel Feldman  <[email protected]>
+
+        Web Inspector: shrink SourceFrame editing API to two methods (was 4).
+        https://bugs.webkit.org/show_bug.cgi?id=86288
+
+        Reviewed by Yury Semikhatsky.
+
+        Used specific workflow in two SourceFrame implementations.
+
+        * inspector/front-end/_javascript_SourceFrame.js:
+        (WebInspector._javascript_SourceFrame.prototype.commitEditing):
+        (WebInspector._javascript_SourceFrame.prototype.afterTextChanged):
+        (WebInspector._javascript_SourceFrame.prototype._didEditContent):
+        * inspector/front-end/ResourceView.js:
+        (WebInspector.EditableResourceSourceFrame.prototype.commitEditing.callbackWrapper):
+        (WebInspector.EditableResourceSourceFrame.prototype.commitEditing):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame.prototype.commitEditing):
+        (WebInspector.TextViewerDelegateForSourceFrame.prototype.commitEditing):
+
 2012-05-11  Yury Semikhatsky  <[email protected]>
 
         Web Inspector: allow showing arbitrary range of nodes in heap snapshot view

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


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-05-12 10:17:18 UTC (rev 116847)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-05-12 11:09:27 UTC (rev 116848)
@@ -108,10 +108,13 @@
         return WebInspector.DebuggerResourceBinding.canEditScriptSource(this._uiSourceCode);
     },
 
-    editContent: function(newContent, callback)
+    /**
+     * @param {string} text 
+     */
+    commitEditing: function(text)
     {
         this._editingContent = true;
-        WebInspector.DebuggerResourceBinding.setScriptSource(this._uiSourceCode, newContent, callback);
+        WebInspector.DebuggerResourceBinding.setScriptSource(this._uiSourceCode, text, this._didEditContent.bind(this, text));
     },
 
     /**
@@ -173,7 +176,7 @@
         if (isDirty)
             this._setScriptSourceIsDirty(true);
         else
-            this.didEditContent(null, this._originalContent);
+            this._didEditContent(this._originalContent, null);
     },
 
     _setScriptSourceIsDirty: function(isDirty)
@@ -200,13 +203,14 @@
         WebInspector.SourceFrame.prototype.beforeTextChanged.call(this);
     },
 
-    didEditContent: function(error, content)
+    _didEditContent: function(content, error)
     {
         delete this._editingContent;
 
-        WebInspector.SourceFrame.prototype.didEditContent.call(this, error, content);
-        if (error)
+        if (error) {
+            WebInspector.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true);
             return;
+        }
 
         this._originalContent = content;
         this._isDirty = false;

Modified: trunk/Source/WebCore/inspector/front-end/ResourceView.js (116847 => 116848)


--- trunk/Source/WebCore/inspector/front-end/ResourceView.js	2012-05-12 10:17:18 UTC (rev 116847)
+++ trunk/Source/WebCore/inspector/front-end/ResourceView.js	2012-05-12 11:09:27 UTC (rev 116848)
@@ -132,25 +132,31 @@
 }
 
 WebInspector.EditableResourceSourceFrame.prototype = {
+    /**
+     * @return {boolean}
+     */
     canEditSource: function()
     {
         //FIXME: make live edit stop using resource content binding.
         return this._resource.isEditable() && this._resource.type === WebInspector.resourceTypes.Stylesheet;
     },
 
-    editContent: function(newText, callback)
+    /**
+     * @param {string} text
+     */
+    commitEditing: function(text)
     {
         this._clearIncrementalUpdateTimer();
         var majorChange = true;
         this._settingContent = true;
         function callbackWrapper(text)
         {
-            callback(text);
             delete this._settingContent;
+            this.dispatchEventToListeners(WebInspector.EditableResourceSourceFrame.Events.TextEdited, this);
         }
-        this.resource.setContent(newText, majorChange, callbackWrapper.bind(this));
+        this.resource.setContent(text, majorChange, callbackWrapper.bind(this));
     },
-
+    
     afterTextChanged: function(oldRange, newRange)
     {
         function commitIncrementalEdit()
@@ -176,12 +182,6 @@
             WebInspector.ResourceSourceFrame.prototype._contentChanged.call(this, event);
     },
 
-    didEditContent: function(error, content)
-    {
-        WebInspector.SourceFrame.prototype.didEditContent.call(this, error, content);
-        this.dispatchEventToListeners(WebInspector.EditableResourceSourceFrame.Events.TextEdited, this);
-    },
-
     isDirty: function()
     {
         return this._resource.content !== this.textModel.text;

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


--- trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2012-05-12 10:17:18 UTC (rev 116847)
+++ trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2012-05-12 11:09:27 UTC (rev 116848)
@@ -516,30 +516,19 @@
         this._textViewer.inheritScrollPositions(sourceFrame._textViewer);
     },
 
+    /**
+     * @return {boolean}
+     */
     canEditSource: function()
     {
         return false;
     },
 
-    commitEditing: function()
+    /**
+     * @param {string} text 
+     */
+    commitEditing: function(text)
     {
-        function callback(error)
-        {
-            this.didEditContent(error, this._textModel.text);
-        }
-        this.editContent(this._textModel.text, callback.bind(this));
-    },
-
-    didEditContent: function(error, content)
-    {
-        if (error) {
-            WebInspector.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true);
-            return;
-        }
-    },
-
-    editContent: function(newContent, callback)
-    {
     }
 }
 
@@ -568,7 +557,7 @@
 
     commitEditing: function()
     {
-        this._sourceFrame.commitEditing();
+        this._sourceFrame.commitEditing(this._sourceFrame._textModel.text);
     },
 
     populateLineGutterContextMenu: function(contextMenu, lineNumber)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to