Changeset 117781 in webkit


Ignore:
Timestamp:
May 21, 2012 8:09:56 AM (12 years ago)
Author:
vsevik@chromium.org
Message:

Web Inspector: Move working copy support to UISourceCode and use it for both styles and scripts.
https://bugs.webkit.org/show_bug.cgi?id=87021

Reviewed by Pavel Feldman.

UISourceCode now listens for RevisionAdded event.
Virtual methods workingCopyChanged and workingCopyCommitted added to UISourceCode and implemented in descendants.
DebuggerResourceBinding does not call contentChanged on UISourceCode explicitly anymore.

  • inspector/front-end/DebuggerResourceBinding.js:

(WebInspector.DebuggerResourceBinding.setScriptSource.didEditScriptSource):
(WebInspector.DebuggerResourceBinding.setScriptSource):

  • inspector/front-end/JavaScriptSource.js:

(WebInspector.JavaScriptSource.prototype.workingCopyCommitted):

  • inspector/front-end/JavaScriptSourceFrame.js:

(WebInspector.JavaScriptSourceFrame.prototype.commitEditing):

  • inspector/front-end/ScriptSnippetModel.js:

(WebInspector.SnippetJavaScriptSource.prototype.workingCopyCommitted):

  • inspector/front-end/StylesPanel.js:

(WebInspector.StyleSource.prototype.workingCopyCommitted):
(WebInspector.StyleSource.prototype.workingCopyChanged):
(WebInspector.StyleSourceFrame):
(WebInspector.StyleSourceFrame.prototype.commitEditing):
(WebInspector.StyleSourceFrame.prototype.afterTextChanged):
(WebInspector.StyleSourceFrame.prototype._didEditContent):
(WebInspector.StyleSourceFrame.prototype._onContentChanged):

  • inspector/front-end/UISourceCode.js:

(WebInspector.UISourceCode):
(WebInspector.UISourceCode.prototype._revisionAdded):
(WebInspector.UISourceCode.prototype.contentChanged):
(WebInspector.UISourceCode.prototype.workingCopy):
(WebInspector.UISourceCode.prototype.setWorkingCopy):
(WebInspector.UISourceCode.prototype.workingCopyChanged):
(WebInspector.UISourceCode.prototype.commitWorkingCopy):
(WebInspector.UISourceCode.prototype.workingCopyCommitted):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r117778 r117781  
     12012-05-21  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Web Inspector: Move working copy support to UISourceCode and use it for both styles and scripts.
     4        https://bugs.webkit.org/show_bug.cgi?id=87021
     5
     6        Reviewed by Pavel Feldman.
     7
     8        UISourceCode now listens for RevisionAdded event.
     9        Virtual methods workingCopyChanged and workingCopyCommitted added to UISourceCode and implemented in descendants.
     10        DebuggerResourceBinding does not call contentChanged on UISourceCode explicitly anymore.
     11
     12        * inspector/front-end/DebuggerResourceBinding.js:
     13        (WebInspector.DebuggerResourceBinding.setScriptSource.didEditScriptSource):
     14        (WebInspector.DebuggerResourceBinding.setScriptSource):
     15        * inspector/front-end/JavaScriptSource.js:
     16        (WebInspector.JavaScriptSource.prototype.workingCopyCommitted):
     17        * inspector/front-end/JavaScriptSourceFrame.js:
     18        (WebInspector.JavaScriptSourceFrame.prototype.commitEditing):
     19        * inspector/front-end/ScriptSnippetModel.js:
     20        (WebInspector.SnippetJavaScriptSource.prototype.workingCopyCommitted):
     21        * inspector/front-end/StylesPanel.js:
     22        (WebInspector.StyleSource.prototype.workingCopyCommitted):
     23        (WebInspector.StyleSource.prototype.workingCopyChanged):
     24        (WebInspector.StyleSourceFrame):
     25        (WebInspector.StyleSourceFrame.prototype.commitEditing):
     26        (WebInspector.StyleSourceFrame.prototype.afterTextChanged):
     27        (WebInspector.StyleSourceFrame.prototype._didEditContent):
     28        (WebInspector.StyleSourceFrame.prototype._onContentChanged):
     29        * inspector/front-end/UISourceCode.js:
     30        (WebInspector.UISourceCode):
     31        (WebInspector.UISourceCode.prototype._revisionAdded):
     32        (WebInspector.UISourceCode.prototype.contentChanged):
     33        (WebInspector.UISourceCode.prototype.workingCopy):
     34        (WebInspector.UISourceCode.prototype.setWorkingCopy):
     35        (WebInspector.UISourceCode.prototype.workingCopyChanged):
     36        (WebInspector.UISourceCode.prototype.commitWorkingCopy):
     37        (WebInspector.UISourceCode.prototype.workingCopyCommitted):
     38
    1392012-05-21  Andrey Kosyakov  <caseq@chromium.org>
    240
  • trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js

    r117746 r117781  
    6565            resource.addRevision(newSource);
    6666
    67         uiSourceCode.contentChanged(newSource);
    6867        callback(null);
    6968    }
  • trunk/Source/WebCore/inspector/front-end/JavaScriptSource.js

    r117600 r117781  
    178178    },
    179179
    180     commitWorkingCopy: function(callback)
     180    /**
     181     * @param {function(?string)} callback
     182     */
     183    workingCopyCommitted: function(callback)
    181184    { 
    182185        WebInspector.DebuggerResourceBinding.setScriptSource(this, this.workingCopy(), callback);
  • trunk/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js

    r117751 r117781  
    9494    {
    9595        this._editingContent = true;
    96         if (!this._uiSourceCode.isDirty())
    97             return;
    9896        this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this));
    9997    },
  • trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js

    r117600 r117781  
    317317    },
    318318
    319     commitWorkingCopy: function(callback)
    320     {
     319    /**
     320     * @param {function(?string)} callback
     321     */
     322    workingCopyCommitted: function(callback)
     323    { 
    321324        this._scriptSnippetModel.setScriptSnippetContent(this, this.workingCopy());
    322         callback();
     325        callback(null);
    323326    },
    324327
  • trunk/Source/WebCore/inspector/front-end/StylesPanel.js

    r117750 r117781  
    9999
    100100WebInspector.StyleSource.prototype = {
     101    /**
     102     * @param {function(?string)} callback
     103     */
     104    workingCopyCommitted: function(callback)
     105    { 
     106        this._resource.setContent(this.workingCopy(), true, callback);
     107    },
     108
     109    workingCopyChanged: function()
     110    { 
     111        function commitIncrementalEdit()
     112        {
     113            this._resource.setContent(this.workingCopy(), false, function() {});
     114        }
     115        const updateTimeout = 200;
     116        this._incrementalUpdateTimer = setTimeout(commitIncrementalEdit.bind(this), updateTimeout);
     117    }
    101118}
    102119
     
    112129    this._styleSource = styleSource;
    113130    WebInspector.SourceFrame.call(this, this._styleSource);
    114     this._styleSource.resource().addEventListener(WebInspector.Resource.Events.RevisionAdded, this._contentChanged, this);
     131    this._styleSource.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._onContentChanged, this);
    115132}
    116133
     
    129146    commitEditing: function(text)
    130147    {
    131         this._styleSource.resource().setContent(text, true, function() {});
     148        this._styleSource.commitWorkingCopy(this._didEditContent.bind(this));
    132149    },
    133150
    134151    afterTextChanged: function(oldRange, newRange)
    135152    {
    136         function commitIncrementalEdit()
    137         {
    138             var text = this._textModel.text;
    139             this._styleSource.setWorkingCopy(text);
    140             this._styleSource.resource().setContent(text, false, function() {});
    141         }
    142         const updateTimeout = 200;
    143         this._incrementalUpdateTimer = setTimeout(commitIncrementalEdit.bind(this), updateTimeout);
     153        this._styleSource.setWorkingCopy(this.textModel.text);
     154    },
     155
     156    _didEditContent: function(error)
     157    {
     158        if (error) {
     159            WebInspector.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true);
     160            return;
     161        }
    144162    },
    145163
     
    151169    },
    152170
    153     _contentChanged: function(event)
    154     {
    155         this._styleSource.contentChanged(this._styleSource.resource().content || "");
     171    /**
     172     * @param {WebInspector.Event} event
     173     */
     174    _onContentChanged: function(event)
     175    {
    156176        this.setContent(this._styleSource.resource().content, false, "text/stylesheet");
    157177    },
  • trunk/Source/WebCore/inspector/front-end/UISourceCode.js

    r117774 r117781  
    5656     */
    5757    this._consoleMessages = [];
     58   
     59    if (this.resource())
     60        this.resource().addEventListener(WebInspector.Resource.Events.RevisionAdded, this._revisionAdded, this);
    5861}
    5962
     
    132135    },
    133136
     137    _revisionAdded: function(event)
     138    {
     139        this.contentChanged(this.resource().content || "");
     140    },
     141
    134142    /**
    135143     * @param {string} newContent
     
    137145    contentChanged: function(newContent)
    138146    {
    139         console.assert(this._contentLoaded);
    140         var oldContent = this._content;
     147        if (this._committingWorkingCopy)
     148            return;
     149
     150        var oldContent = this._contentLoaded ? this._content : undefined;
    141151        this._content = newContent;
    142152        delete this._workingCopy;
     
    158168    {
    159169        console.assert(this._contentLoaded);
    160         return this._workingCopy;
     170        if (this.isDirty())
     171            return this._workingCopy;
     172        return this._content;
    161173    },
    162174
     
    172184        else
    173185            this._workingCopy = newWorkingCopy;
     186        this.workingCopyChanged();
    174187        this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyChanged, {oldWorkingCopy: oldWorkingCopy, workingCopy: newWorkingCopy});
     188    },
     189
     190    workingCopyChanged: function()
     191    { 
     192        // Overridden.
     193    },
     194
     195    /**
     196     * @param {function(?string)} callback
     197     */
     198    commitWorkingCopy: function(callback)
     199    {
     200        /**
     201         * @param {?string} error
     202         */
     203        function innerCallback(error)
     204        {
     205            delete this._committingWorkingCopy;
     206            if (!error)
     207                this.contentChanged(newContent);
     208            callback(error);
     209        }
     210
     211        if (!this.isDirty()) {
     212            callback(null);
     213            return;
     214        }
     215
     216        var newContent = this._workingCopy;
     217        this._committingWorkingCopy = true;
     218        this.workingCopyCommitted(innerCallback.bind(this));
     219    },
     220
     221    /**
     222     * @param {function(?string)} callback
     223     */
     224    workingCopyCommitted: function(callback)
     225    { 
     226        // Overridden.
    175227    },
    176228
Note: See TracChangeset for help on using the changeset viewer.