WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-109915-20130215141156.patch (text/plain), 15.01 KB, created by
Vsevolod Vlasov
on 2013-02-15 02:15:30 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Vsevolod Vlasov
Created:
2013-02-15 02:15:30 PST
Size:
15.01 KB
patch
obsolete
>Subversion Revision: 142966 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 510f8f7321515e56c7eb85753ba3ce751817a822..7a4efcfa68c9bd465be92f82b86b52a119260b94 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,5 +1,17 @@ > 2013-02-15 Vsevolod Vlasov <vsevik@chromium.org> > >+ Web Inspector: Several consecutive Backspace or Delete strikes should not be marked as undoable state. >+ https://bugs.webkit.org/show_bug.cgi?id=109915 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Extracted _shouldMarkUndoableState() in TextEditorModel to detect if markUndoableState() call is needed. >+ >+ * inspector/front-end/TextEditorModel.js: >+ (WebInspector.TextEditorModel.endsWithBracketRegex.): >+ >+2013-02-15 Vsevolod Vlasov <vsevik@chromium.org> >+ > Web Inspector: Pass original selection to textModel to correctly restore it after undo. > https://bugs.webkit.org/show_bug.cgi?id=109911 > >diff --git a/Source/WebCore/inspector/front-end/TextEditorModel.js b/Source/WebCore/inspector/front-end/TextEditorModel.js >index f8bb73211b038f97ef2e41a899235fd9ac6668f9..79ac5201d252888636bed6fdb02a1e0b59a82975 100644 >--- a/Source/WebCore/inspector/front-end/TextEditorModel.js >+++ b/Source/WebCore/inspector/front-end/TextEditorModel.js >@@ -251,13 +251,68 @@ WebInspector.TextEditorModel.prototype = { > > /** > * @param {WebInspector.TextRange} range >+ * @return {boolean} >+ */ >+ _rangeHasOneCharacter: function(range) >+ { >+ if (range.startLine === range.endLine && range.endColumn - range.startColumn === 1) >+ return true; >+ if (range.endLine - range.startLine === 1 && range.endColumn === 0 && range.startColumn === this.lineLength(range.startLine)) >+ return true; >+ return false; >+ }, >+ >+ /** >+ * @param {WebInspector.TextRange} range >+ * @param {string} text >+ * @return {boolean} >+ */ >+ _shouldMarkUndoableState: function(range, text) >+ { >+ if (!this._lastCommand) >+ return false; >+ // There was non-empty selection before previous command. >+ if (!this._lastCommand.originalSelection.isEmpty()) >+ return true; >+ // There are both erased and added characters. >+ if (!range.isEmpty() && text) >+ return true; >+ // First case: characters were erased. >+ if (!text) { >+ // Previous command added characters or erased more than one character. >+ if (!this._lastCommand.newRange.isEmpty() || this._lastCommand.originalText.length > 1) >+ return true; >+ if (!this._rangeHasOneCharacter(range)) >+ return true; >+ // FIXME: Distinguish backspace and delete in lastCommand. >+ if (this._lastCommand.newRange.endLine === range.startLine && this._lastCommand.newRange.endColumn === range.startColumn) >+ return false; >+ if (this._lastCommand.newRange.endLine === range.endLine && this._lastCommand.newRange.endColumn === range.endColumn) >+ return false; >+ return true; >+ } >+ // Second case: characters were added. >+ // Previous command erased characters or added more than one character. >+ if (this._lastCommand.originalText || !this._rangeHasOneCharacter(this._lastCommand.newRange)) >+ return true; >+ if (text.length > 1 || text === "\n") >+ return true; >+ if (this._lastCommand.newRange.endLine === range.startLine && this._lastCommand.newRange.endColumn === range.startColumn) >+ return false; >+ return true; >+ }, >+ >+ /** >+ * @param {WebInspector.TextRange} range > * @param {string} text > * @param {WebInspector.TextRange=} originalSelection > * @return {WebInspector.TextRange} > */ > editRange: function(range, text, originalSelection) > { >- if (this._lastEditedRange && (!text || text.indexOf("\n") !== -1 || this._lastEditedRange.endLine !== range.startLine || this._lastEditedRange.endColumn !== range.startColumn)) >+ if (range.isEmpty() && !text) >+ return null; >+ if (this._shouldMarkUndoableState(range, text)) > this._markUndoableState(); > return this._innerEditRange(range, text, originalSelection); > }, >@@ -272,8 +327,7 @@ WebInspector.TextEditorModel.prototype = { > { > var originalText = this.copyRange(range); > var newRange = this._innerSetText(range, text); >- this._lastEditedRange = newRange; >- this._pushUndoableCommand(newRange, originalText, originalSelection || range); >+ this._lastCommand = this._pushUndoableCommand(newRange, originalText, originalSelection || range); > this.dispatchEventToListeners(WebInspector.TextEditorModel.Events.TextChanged, { oldRange: range, newRange: newRange, editRange: true }); > return newRange; > }, >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 131b5dbcc2ff40a4608b078ac86e46caa47b6d93..12d3149454c0f6250f6747df26170c4fc98d3ce1 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,5 +1,15 @@ > 2013-02-15 Vsevolod Vlasov <vsevik@chromium.org> > >+ Web Inspector: Several consecutive Backspace or Delete strikes should not be marked as undoable state. >+ https://bugs.webkit.org/show_bug.cgi?id=109915 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * inspector/editor/text-editor-undo-redo-expected.txt: >+ * inspector/editor/text-editor-undo-redo.html: >+ >+2013-02-15 Vsevolod Vlasov <vsevik@chromium.org> >+ > Web Inspector: Pass original selection to textModel to correctly restore it after undo. > https://bugs.webkit.org/show_bug.cgi?id=109911 > >diff --git a/LayoutTests/inspector/editor/text-editor-undo-redo-expected.txt b/LayoutTests/inspector/editor/text-editor-undo-redo-expected.txt >index 253d5034cb704df4df239c0d936027fb8d1e9908..02b087225330bdbb820e1559a453ced9ab06c1a2 100644 >--- a/LayoutTests/inspector/editor/text-editor-undo-redo-expected.txt >+++ b/LayoutTests/inspector/editor/text-editor-undo-redo-expected.txt >@@ -134,6 +134,266 @@ function foo() > } > > >+Running: testDelete >+Text before edit: >+function foo() >+{ >+ >+} >+ >+Text after edit: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();| >+} >+ >+Text after deletes: >+function foo() >+{ >+| >+} >+ >+Text after first undo: >+function foo() >+{ >+| bar(); >+ baz(); >+ foo(); >+} >+ >+Text after second undo: >+function foo() >+{ >+ bar(); >+ baz();| >+} >+ >+Text after first redo: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();| >+} >+ >+Text after second redo: >+function foo() >+{ >+| >+} >+ >+ >+Running: testBackspace >+Text before edit: >+function foo() >+{ >+ >+} >+ >+Text after edit: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();| >+} >+ >+Text after backspaces: >+function foo() >+{ >+| >+} >+ >+Text after first undo: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();| >+} >+ >+Text after second undo: >+function foo() >+{ >+ bar(); >+ baz();| >+} >+ >+Text after first redo: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();| >+} >+ >+Text after second redo: >+function foo() >+{ >+| >+} >+ >+ >+Running: testBackspaceAndDeleteInDifferentLines >+Text before edit: >+function foo() >+{ >+ >+} >+ >+Text after edit: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();| >+} >+ >+Text after backspace: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo()| >+} >+ >+Text after delete: >+function foo() >+{ >+| bar(); >+ baz(); >+ foo() >+} >+ >+Text after first undo: >+function foo() >+{ >+| bar(); >+ baz(); >+ foo() >+} >+ >+Text after second undo: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();| >+} >+ >+Text after third undo: >+function foo() >+{ >+ bar(); >+ baz();| >+} >+ >+Text after first redo: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();| >+} >+ >+Text after second redo: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo()| >+} >+ >+Text after third redo: >+function foo() >+{ >+| bar(); >+ baz(); >+ foo() >+} >+ >+ >+Running: testPasteSeveralTimes >+Text before edit: >+function foo() >+{ >+ >+} >+ >+Text after edit: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();| >+} >+ >+Text after first paste: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();42| >+} >+ >+Text after second paste: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();4242| >+} >+ >+Text after first undo: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();42| >+} >+ >+Text after second undo: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();| >+} >+ >+Text after third undo: >+function foo() >+{ >+ bar(); >+ baz();| >+} >+ >+Text after first redo: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();| >+} >+ >+Text after second redo: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();42| >+} >+ >+Text after third redo: >+function foo() >+{ >+ bar(); >+ baz(); >+ foo();4242| >+} >+ >+ > Running: testSelectionAfterUndoRedo > Text before edit: > function foo() >diff --git a/LayoutTests/inspector/editor/text-editor-undo-redo.html b/LayoutTests/inspector/editor/text-editor-undo-redo.html >index d104714627a2e0c6798fb0288bc87f0c38724fad..d9291a1130981bfc7002e5b273a2eed6e59e0af5 100644 >--- a/LayoutTests/inspector/editor/text-editor-undo-redo.html >+++ b/LayoutTests/inspector/editor/text-editor-undo-redo.html >@@ -19,6 +19,17 @@ function test() > return range; > } > >+ function typeDelete(textModel, startRange, count) >+ { >+ var count = count || 1; >+ var range = startRange; >+ for (var i = 0; i < count; ++i) { >+ var deleteRange = range.isEmpty() ? textModel.growRangeRight(range) : range; >+ range = textModel.editRange(deleteRange, "", range).collapseToEnd(); >+ } >+ return range; >+ } >+ > function typeBackspace(textModel, startRange, count) > { > var count = count || 1; >@@ -88,6 +99,102 @@ function test() > next(); > }, > >+ function testDelete(next) >+ { >+ var textModel = new WebInspector.TextEditorModel(); >+ var functionText = " bar();\n baz();\n foo();"; >+ textModel.setText("function foo()\n{\n\n}\n"); >+ dumpTextModel("Text before edit:\n", textModel); >+ var range = typeText(textModel, new WebInspector.TextRange(2, 0, 2, 0), " bar();\n baz();\n foo();"); >+ dumpTextModel("Text after edit:\n", textModel, range); >+ range = typeDelete(textModel, new WebInspector.TextRange(2, 0, 2, 0), functionText.length); >+ dumpTextModel("Text after deletes:\n", textModel, range); >+ range = textModel.undo(); >+ dumpTextModel("Text after first undo:\n", textModel, range); >+ range = textModel.undo(); >+ dumpTextModel("Text after second undo:\n", textModel, range); >+ range = textModel.redo(); >+ dumpTextModel("Text after first redo:\n", textModel, range); >+ range = textModel.redo(); >+ dumpTextModel("Text after second redo:\n", textModel, range); >+ next(); >+ }, >+ >+ function testBackspace(next) >+ { >+ var textModel = new WebInspector.TextEditorModel(); >+ var functionText = " bar();\n baz();\n foo();"; >+ textModel.setText("function foo()\n{\n\n}\n"); >+ dumpTextModel("Text before edit:\n", textModel); >+ var range = typeText(textModel, new WebInspector.TextRange(2, 0, 2, 0), " bar();\n baz();\n foo();"); >+ dumpTextModel("Text after edit:\n", textModel, range); >+ range = typeBackspace(textModel, range, functionText.length); >+ dumpTextModel("Text after backspaces:\n", textModel, range); >+ range = textModel.undo(); >+ dumpTextModel("Text after first undo:\n", textModel, range); >+ range = textModel.undo(); >+ dumpTextModel("Text after second undo:\n", textModel, range); >+ range = textModel.redo(); >+ dumpTextModel("Text after first redo:\n", textModel, range); >+ range = textModel.redo(); >+ dumpTextModel("Text after second redo:\n", textModel, range); >+ next(); >+ }, >+ >+ function testBackspaceAndDeleteInDifferentLines(next) >+ { >+ var textModel = new WebInspector.TextEditorModel(); >+ var functionText = " bar();\n baz();\n foo();"; >+ textModel.setText("function foo()\n{\n\n}\n"); >+ dumpTextModel("Text before edit:\n", textModel); >+ var range = typeText(textModel, new WebInspector.TextRange(2, 0, 2, 0), " bar();\n baz();\n foo();"); >+ dumpTextModel("Text after edit:\n", textModel, range); >+ range = typeBackspace(textModel, range); >+ dumpTextModel("Text after backspace:\n", textModel, range); >+ range = typeDelete(textModel, new WebInspector.TextRange(2, 0, 2, 0)); >+ dumpTextModel("Text after delete:\n", textModel, range); >+ range = textModel.undo(); >+ dumpTextModel("Text after first undo:\n", textModel, range); >+ range = textModel.undo(); >+ dumpTextModel("Text after second undo:\n", textModel, range); >+ range = textModel.undo(); >+ dumpTextModel("Text after third undo:\n", textModel, range); >+ range = textModel.redo(); >+ dumpTextModel("Text after first redo:\n", textModel, range); >+ range = textModel.redo(); >+ dumpTextModel("Text after second redo:\n", textModel, range); >+ range = textModel.redo(); >+ dumpTextModel("Text after third redo:\n", textModel, range); >+ next(); >+ }, >+ >+ function testPasteSeveralTimes(next) >+ { >+ var textModel = new WebInspector.TextEditorModel(); >+ var functionText = " bar();\n baz();\n foo();"; >+ textModel.setText("function foo()\n{\n\n}\n"); >+ dumpTextModel("Text before edit:\n", textModel); >+ var range = typeText(textModel, new WebInspector.TextRange(2, 0, 2, 0), " bar();\n baz();\n foo();"); >+ dumpTextModel("Text after edit:\n", textModel, range); >+ range = textModel.editRange(range, "42").collapseToEnd(); >+ dumpTextModel("Text after first paste:\n", textModel, range); >+ range = textModel.editRange(range, "42").collapseToEnd(); >+ dumpTextModel("Text after second paste:\n", textModel, range); >+ range = textModel.undo(); >+ dumpTextModel("Text after first undo:\n", textModel, range); >+ range = textModel.undo(); >+ dumpTextModel("Text after second undo:\n", textModel, range); >+ range = textModel.undo(); >+ dumpTextModel("Text after third undo:\n", textModel, range); >+ range = textModel.redo(); >+ dumpTextModel("Text after first redo:\n", textModel, range); >+ range = textModel.redo(); >+ dumpTextModel("Text after second redo:\n", textModel, range); >+ range = textModel.redo(); >+ dumpTextModel("Text after third redo:\n", textModel, range); >+ next(); >+ }, >+ > function testSelectionAfterUndoRedo(next) > { > var textModel = new WebInspector.TextEditorModel();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 109915
:
188517
|
188572