Changeset 86552 in webkit


Ignore:
Timestamp:
May 16, 2011 2:53:57 AM (13 years ago)
Author:
podivilov@chromium.org
Message:

2011-05-05 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: move double click handling from TextEditor to SourceFrame.
https://bugs.webkit.org/show_bug.cgi?id=60271

It is SourceFrame's responsibility to check if content is editable and
to configure TextEditor component (e.g. set editable range) when user
tries to initiate editing.

  • inspector/front-end/ResourceView.js: (WebInspector.ResourceSourceFrame.prototype.doubleClick): (WebInspector.RevisionSourceFrame.prototype.doubleClick):
  • inspector/front-end/SourceFrame.js: (WebInspector.SourceFrame.prototype.beforeTextChanged): (WebInspector.SourceFrame.prototype.afterTextChanged): (WebInspector.SourceFrame.prototype.doubleClick): (WebInspector.SourceFrame.prototype.commitEditing.didEditContent): (WebInspector.SourceFrame.prototype.commitEditing): (WebInspector.SourceFrame.prototype.cancelEditing): (WebInspector.SourceFrame.prototype._setReadOnly):
  • inspector/front-end/TextViewer.js: (WebInspector.TextViewer.prototype.set readOnly): (WebInspector.TextViewer.prototype._enterInternalTextChangeMode): (WebInspector.TextViewer.prototype._exitInternalTextChangeMode): (WebInspector.TextViewer.prototype._doubleClick): (WebInspector.TextViewer.prototype._commitEditing): (WebInspector.TextViewer.prototype._cancelEditing): (WebInspector.TextViewerDelegate.prototype.doubleClick): (WebInspector.TextViewerDelegate.prototype.beforeTextChanged): (WebInspector.TextViewerDelegate.prototype.afterTextChanged):
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86551 r86552  
     12011-05-05  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: move double click handling from TextEditor to SourceFrame.
     6        https://bugs.webkit.org/show_bug.cgi?id=60271
     7
     8        It is SourceFrame's responsibility to check if content is editable and
     9        to configure TextEditor component (e.g. set editable range) when user
     10        tries to initiate editing.
     11
     12        * inspector/front-end/ResourceView.js:
     13        (WebInspector.ResourceSourceFrame.prototype.doubleClick):
     14        (WebInspector.RevisionSourceFrame.prototype.doubleClick):
     15        * inspector/front-end/SourceFrame.js:
     16        (WebInspector.SourceFrame.prototype.beforeTextChanged):
     17        (WebInspector.SourceFrame.prototype.afterTextChanged):
     18        (WebInspector.SourceFrame.prototype.doubleClick):
     19        (WebInspector.SourceFrame.prototype.commitEditing.didEditContent):
     20        (WebInspector.SourceFrame.prototype.commitEditing):
     21        (WebInspector.SourceFrame.prototype.cancelEditing):
     22        (WebInspector.SourceFrame.prototype._setReadOnly):
     23        * inspector/front-end/TextViewer.js:
     24        (WebInspector.TextViewer.prototype.set readOnly):
     25        (WebInspector.TextViewer.prototype._enterInternalTextChangeMode):
     26        (WebInspector.TextViewer.prototype._exitInternalTextChangeMode):
     27        (WebInspector.TextViewer.prototype._doubleClick):
     28        (WebInspector.TextViewer.prototype._commitEditing):
     29        (WebInspector.TextViewer.prototype._cancelEditing):
     30        (WebInspector.TextViewerDelegate.prototype.doubleClick):
     31        (WebInspector.TextViewerDelegate.prototype.beforeTextChanged):
     32        (WebInspector.TextViewerDelegate.prototype.afterTextChanged):
     33
    1342011-05-15  Robert Hogan  <robert@webkit.org>
    235
  • trunk/Source/WebCore/inspector/front-end/ResourceView.js

    r85943 r86552  
    137137    },
    138138
    139     isContentEditable: function()
    140     {
    141         return this._resource.isEditable();
     139    doubleClick: function(lineNumber)
     140    {
     141        if (!this._resource.isEditable())
     142            return;
     143
     144        if (this._commitEditingInProgress)
     145            return;
     146
     147        this._textViewer.readOnly = false;
     148        WebInspector.markBeingEdited(this._textViewer.element, true);
    142149    },
    143150
     
    157164    },
    158165
    159     endEditing: function(oldRange, newRange)
     166    afterTextChanged: function(oldRange, newRange)
    160167    {
    161168        function commitIncrementalEdit()
     
    205212    },
    206213
    207     isContentEditable: function()
    208     {
    209         return false;
     214    doubleClick: function(lineNumber)
     215    {
    210216    },
    211217
  • trunk/Source/WebCore/inspector/front-end/SourceFrame.js

    r85319 r86552  
    234234    },
    235235
    236     isContentEditable: function()
    237     {
    238         return this._delegate.canEditScriptSource();
    239     },
    240 
    241     readOnlyStateChanged: function(readOnly)
    242     {
    243         WebInspector.markBeingEdited(this._textViewer.element, !readOnly);
    244     },
    245 
    246     startEditing: function()
     236    beforeTextChanged: function()
    247237    {
    248238        if (!this._viewerState) {
     
    255245    },
    256246
    257     endEditing: function(oldRange, newRange)
     247    afterTextChanged: function(oldRange, newRange)
    258248    {
    259249        if (!oldRange || !newRange)
     
    884874    },
    885875
     876    doubleClick: function(lineNumber)
     877    {
     878        if (!this._delegate.canEditScriptSource())
     879            return;
     880
     881        if (this._commitEditingInProgress)
     882            return;
     883
     884        this._setReadOnly(false);
     885    },
     886
    886887    commitEditing: function(callback)
    887888    {
    888889        if (!this._viewerState) {
    889890            // No editing was actually done.
    890             this._delegate.setScriptSourceIsBeingEdited(false);
     891            this._setReadOnly(true);
    891892            callback();
    892893            return;
     
    895896        function didEditContent(error)
    896897        {
     898            this._commitEditingInProgress = false;
    897899            if (error) {
    898900                if (error.data && error.data[0]) {
     
    900902                    WebInspector.showConsole();
    901903                }
    902                 callback(error);
     904                this._textViewer.readOnly = false;
    903905                return;
    904906            }
     
    919921
    920922            delete this._viewerState;
     923            this._setReadOnly(true);
     924        }
     925        this._commitEditingInProgress = true;
     926        this._textViewer.readOnly = true;
     927        this.editContent(this._textModel.text, didEditContent.bind(this));
     928    },
     929
     930    editContent: function(newContent, callback)
     931    {
     932        this._delegate.editScriptSource(newContent, callback);
     933    },
     934
     935    cancelEditing: function()
     936    {
     937        this._restoreViewerState();
     938        this._setReadOnly(true);
     939    },
     940
     941    _setReadOnly: function(readOnly)
     942    {
     943        this._textViewer.readOnly = readOnly;
     944        WebInspector.markBeingEdited(this._textViewer.element, !readOnly);
     945        if (readOnly)
    921946            this._delegate.setScriptSourceIsBeingEdited(false);
    922 
    923             callback();
    924         }
    925         this.editContent(this._textModel.text, didEditContent.bind(this));
    926     },
    927 
    928     editContent: function(newContent, callback)
    929     {
    930         this._delegate.editScriptSource(newContent, callback);
    931     },
    932 
    933     cancelEditing: function()
    934     {
    935         this._restoreViewerState();
    936         this._delegate.setScriptSourceIsBeingEdited(false);
    937947    }
    938948}
  • trunk/Source/WebCore/inspector/front-end/TextViewer.js

    r86446 r86552  
    7373            return;
    7474        this._mainPanel.readOnly = readOnly;
    75         this._delegate.readOnlyStateChanged(readOnly);
    7675    },
    7776
     
    178177    {
    179178        this._internalTextChangeMode = true;
    180         this._delegate.startEditing();
     179        this._delegate.beforeTextChanged();
    181180    },
    182181
     
    184183    {
    185184        this._internalTextChangeMode = false;
    186         this._delegate.endEditing(oldRange, newRange);
     185        this._delegate.afterTextChanged(oldRange, newRange);
    187186    },
    188187
     
    230229    _doubleClick: function(event)
    231230    {
    232         if (!this.readOnly || this._commitEditingInProgress)
     231        if (!this.readOnly)
    233232            return;
    234233
     
    237236            return;  // Do not trigger editing from line numbers.
    238237
    239         if (!this._delegate.isContentEditable())
    240             return;
    241 
    242         this.readOnly = false;
     238        this._delegate.doubleClick(lineRow.lineNumber);
    243239        window.getSelection().collapseToStart();
    244240    },
     
    302298            return false;
    303299
    304         this.readOnly = true;
    305         function didCommitEditing(error)
    306         {
    307             this._commitEditingInProgress = false;
    308             if (error)
    309                 this.readOnly = false;
    310         }
    311         this._commitEditingInProgress = true;
    312         this._delegate.commitEditing(didCommitEditing.bind(this));
     300        this._delegate.commitEditing();
    313301        return true;
    314302    },
     
    319307            return false;
    320308
    321         this.readOnly = true;
    322309        this._delegate.cancelEditing();
    323310        return true;
     
    332319
    333320WebInspector.TextViewerDelegate.prototype = {
    334     isContentEditable: function()
     321    doubleClick: function(lineNumber)
    335322    {
    336323        // Should be implemented by subclasses.
    337324    },
    338325
    339     readOnlyStateChanged: function(readOnly)
     326    beforeTextChanged: function()
    340327    {
    341328        // Should be implemented by subclasses.
    342329    },
    343330
    344     startEditing: function()
    345     {
    346         // Should be implemented by subclasses.
    347     },
    348 
    349     endEditing: function(oldRange, newRange)
     331    afterTextChanged: function(oldRange, newRange)
    350332    {
    351333        // Should be implemented by subclasses.
Note: See TracChangeset for help on using the changeset viewer.