Changeset 84136 in webkit


Ignore:
Timestamp:
Apr 18, 2011 6:36:07 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-04-18 Andrey Adaikin <aandrey@google.com>

Reviewed by Yury Semikhatsky.

Web Inspector: TAB should not move focus from the text editor while live editing
https://bugs.webkit.org/show_bug.cgi?id=58537

  • inspector/front-end/TextViewer.js: (WebInspector.TextViewer.prototype._registerShortcuts): (WebInspector.TextViewer.prototype._cancelEditing): (WebInspector.TextEditorMainPanel.prototype.handleUndoRedo): (WebInspector.TextEditorMainPanel.prototype.handleTabKeyPress): (WebInspector.TextEditorMainPanel.prototype._setCaretLocation): (WebInspector.TextEditorMainPanel.prototype._applyDomUpdates): (WebInspector.TextEditorMainPanel.prototype._setText):
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84135 r84136  
     12011-04-18  Andrey Adaikin  <aandrey@google.com>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: TAB should not move focus from the text editor while live editing
     6        https://bugs.webkit.org/show_bug.cgi?id=58537
     7
     8        * inspector/front-end/TextViewer.js:
     9        (WebInspector.TextViewer.prototype._registerShortcuts):
     10        (WebInspector.TextViewer.prototype._cancelEditing):
     11        (WebInspector.TextEditorMainPanel.prototype.handleUndoRedo):
     12        (WebInspector.TextEditorMainPanel.prototype.handleTabKeyPress):
     13        (WebInspector.TextEditorMainPanel.prototype._setCaretLocation):
     14        (WebInspector.TextEditorMainPanel.prototype._applyDomUpdates):
     15        (WebInspector.TextEditorMainPanel.prototype._setText):
     16
    1172011-04-18  Alexander Pavlov  <apavlov@chromium.org>
    218
  • trunk/Source/WebCore/inspector/front-end/TextViewer.js

    r83951 r84136  
    254254        this._shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Esc.code)] = cancelEditing;
    255255
    256         var handleUndo = this._handleUndoRedo.bind(this, 0);
    257         var handleRedo = this._handleUndoRedo.bind(this, 1);
     256        var handleUndo = this._mainPanel.handleUndoRedo.bind(this._mainPanel, false);
     257        var handleRedo = this._mainPanel.handleUndoRedo.bind(this._mainPanel, true);
    258258        this._shortcuts[WebInspector.KeyboardShortcut.makeKey("z", modifiers.CtrlOrMeta)] = handleUndo;
    259259        this._shortcuts[WebInspector.KeyboardShortcut.makeKey("z", modifiers.Shift | modifiers.CtrlOrMeta)] = handleRedo;
     260
     261        var handleTabKey = this._mainPanel.handleTabKeyPress.bind(this._mainPanel, false);
     262        var handleShiftTabKey = this._mainPanel.handleTabKeyPress.bind(this._mainPanel, true);
     263        this._shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Tab.code)] = handleTabKey;
     264        this._shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Tab.code, modifiers.Shift)] = handleShiftTabKey;
    260265    },
    261266
     
    295300        this._delegate.cancelEditing();
    296301        return true;
    297     },
    298 
    299     _handleUndoRedo: function(redo)
    300     {
    301         return this._mainPanel.handleUndoRedo(redo);
    302302    }
    303303}
     
    938938        var range = redo ? this._textModel.redo(callback) : this._textModel.undo(callback);
    939939        if (range)
    940             this._restoreSelection(new WebInspector.TextRange(range.endLine, range.endColumn, range.endLine, range.endColumn), true);
     940            this._setCaretLocation(range.endLine, range.endColumn, true);
    941941
    942942        this._exitTextChangeMode(null, null);
    943943        this.endUpdates();
    944944
     945        return true;
     946    },
     947
     948    handleTabKeyPress: function(shiftKey)
     949    {
     950        if (this._readOnly || this._dirtyLines)
     951            return false;
     952
     953        var selection = this._getSelection();
     954        if (!selection)
     955            return false;
     956
     957        if (shiftKey)
     958            return true;
     959
     960        this.beginUpdates();
     961        this._enterTextChangeMode();
     962
     963        var range = selection;
     964        if (range.startLine > range.endLine || (range.startLine === range.endLine && range.startColumn > range.endColumn))
     965            range = new WebInspector.TextRange(range.endLine, range.endColumn, range.startLine, range.startColumn);
     966
     967        var newRange = this._setText(range, "\t");
     968
     969        this._exitTextChangeMode(range, newRange);
     970        this.endUpdates();
     971
     972        this._setCaretLocation(newRange.endLine, newRange.endColumn, true);
    945973        return true;
    946974    },
     
    12281256    },
    12291257
     1258    _setCaretLocation: function(line, column, scrollIntoView)
     1259    {
     1260        var range = new WebInspector.TextRange(line, column, line, column);
     1261        this._restoreSelection(range, scrollIntoView);
     1262    },
     1263
    12301264    _selectionToPosition: function(container, offset)
    12311265    {
     
    15071541            var oldRange = new WebInspector.TextRange(startLine, startColumn, endLine - 1, endColumn);
    15081542
    1509         if (this._lastEditedRange && (lines.length !== 1 || this._lastEditedRange.endLine !== oldRange.startLine || this._lastEditedRange.endColumn !== oldRange.startColumn))
    1510             this._textModel.markUndoableState();
    1511 
    1512         var newRange = this._textModel.setText(oldRange, lines.join("\n"));
    1513         this._lastEditedRange = newRange;
    1514 
     1543        var newRange = this._setText(oldRange, lines.join("\n"));
     1544       
    15151545        this._paintScheduledLines(true);
    15161546        this._restoreSelection(selection);
     
    15261556        this._updateHighlightsForRange(newRange);
    15271557        this.endDomUpdates();
     1558    },
     1559
     1560    _setText: function(range, text)
     1561    {
     1562        if (this._lastEditedRange && (!text || text.indexOf("\n") !== -1 || this._lastEditedRange.endLine !== range.startLine || this._lastEditedRange.endColumn !== range.startColumn))
     1563            this._textModel.markUndoableState();
     1564
     1565        var newRange = this._textModel.setText(range, text);
     1566        this._lastEditedRange = newRange;
     1567
     1568        return newRange;
    15281569    },
    15291570
Note: See TracChangeset for help on using the changeset viewer.