Reviewed by Harrison.
<rdar://problem/
5378473> Undoing a deletion that is part of an open typing command fails to reinsert the caret
* editing/undo/
5378473.html: Added.
* platform/mac/editing: Added.
* platform/mac/editing/undo: Added.
* platform/mac/editing/undo/
5378473-expected.checksum: Added.
* platform/mac/editing/undo/
5378473-expected.png: Added.
* platform/mac/editing/undo/
5378473-expected.txt: Added.
WebCore:
Reviewed by Harrison.
<rdar://problem/
5378473>
REGRESSION: Undoing a deletion that is part of an open typing command fails to reinsert the caret
We recently made Undo of a series of deletes select all of the
characters that were deleted, not just the most recently deleted
character. But the code that did this set a new starting selection
after every delete, even those that were part of an open typing
command that started with character insertions or forward deletes,
operations that when undone, remove the starting selection being
set from the document.
After this change we only set a new starting selection if the open typing
command was opened by a backward delete. The new behavior matches TextEdit.
We don't do something similar or forward deletes because TextEdit opens
and closes a new typing command on forward delete (added a FIXME about this).
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::TypingCommand): Initialize
m_openedByBackwardDelete.
(WebCore::TypingCommand::forwardDeleteKeyPressed): Added a FIXME about
how in TextEdit, forward deletes open and close a new typing command.
(WebCore::TypingCommand::doApply): Set m_openedByBackwardDelete
appropriately.
(WebCore::TypingCommand::deleteKeyPressed): Only set the starting
selection if this delete is the first one in an open typing command
or one in a series of deletes that opened the typing command.
* editing/TypingCommand.h: Added m_openedByBackwardDelete.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25115
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-08-16 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by Harrison.
+
+ <rdar://problem/5378473> Undoing a deletion that is part of an open typing command fails to reinsert the caret
+
+ * editing/undo/5378473.html: Added.
+ * platform/mac/editing: Added.
+ * platform/mac/editing/undo: Added.
+ * platform/mac/editing/undo/5378473-expected.checksum: Added.
+ * platform/mac/editing/undo/5378473-expected.png: Added.
+ * platform/mac/editing/undo/5378473-expected.txt: Added.
+
2007-08-16 Alice Liu <alice.liu@apple.com>
Removed a fixed test from the skip list. r25112 fixed this test.
--- /dev/null
+<div id="div" contenteditable="true"></div>
+
+<script>
+div = document.getElementById("div");
+div.focus();
+document.execCommand("InsertText", false, "foo");
+document.execCommand("Delete");
+document.execCommand("Undo");
+</script>
--- /dev/null
+2a251ca75a4ee28206fbc9f203a921e3
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {DIV} at (0,0) size 784x18
+caret: position 0 of child 0 {DIV} of child 0 {BODY} of child 0 {HTML} of document
+2007-08-16 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by Harrison.
+
+ <rdar://problem/5378473>
+ REGRESSION: Undoing a deletion that is part of an open typing command fails to reinsert the caret
+
+ We recently made Undo of a series of deletes select all of the
+ characters that were deleted, not just the most recently deleted
+ character. But the code that did this set a new starting selection
+ after every delete, even those that were part of an open typing
+ command that started with character insertions or forward deletes,
+ operations that when undone, remove the starting selection being
+ set from the document.
+
+ After this change we only set a new starting selection if the open typing
+ command was opened by a backward delete. The new behavior matches TextEdit.
+ We don't do something similar or forward deletes because TextEdit opens
+ and closes a new typing command on forward delete (added a FIXME about this).
+
+ * editing/TypingCommand.cpp:
+ (WebCore::TypingCommand::TypingCommand): Initialize
+ m_openedByBackwardDelete.
+ (WebCore::TypingCommand::forwardDeleteKeyPressed): Added a FIXME about
+ how in TextEdit, forward deletes open and close a new typing command.
+ (WebCore::TypingCommand::doApply): Set m_openedByBackwardDelete
+ appropriately.
+ (WebCore::TypingCommand::deleteKeyPressed): Only set the starting
+ selection if this delete is the first one in an open typing command
+ or one in a series of deletes that opened the typing command.
+ * editing/TypingCommand.h: Added m_openedByBackwardDelete.
+
2007-08-13 Geoffrey Garen <ggaren@apple.com>
Reviewed by Dave Hyatt.
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
- compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
knownRegions = (
English,
m_applyEditing(false),
m_selectInsertedText(selectInsertedText),
m_smartDelete(false),
- m_granularity(granularity)
+ m_granularity(granularity),
+ m_openedByBackwardDelete(false)
{
}
void TypingCommand::forwardDeleteKeyPressed(Document *document, bool smartDelete, TextGranularity granularity)
{
+ // FIXME: Forward delete in TextEdit appears to open and close a new typing command.
ASSERT(document);
Frame *frame = document->frame();
{
if (endingSelection().isNone())
return;
+
+ if (m_commandType == DeleteKey)
+ if (m_commands.isEmpty())
+ m_openedByBackwardDelete = true;
switch (m_commandType) {
case DeleteKey:
}
if (selectionToDelete.isCaretOrRange() && document()->frame()->shouldDeleteSelection(selectionToDelete)) {
- // make undo select what was deleted
- setStartingSelection(selectionAfterUndo);
+ // Make undo select everything that has been deleted, unless an undo will undo more than just this deletion.
+ // FIXME: This behaves like TextEdit except for the case where you open with text insertion and then delete
+ // more text than you insert. In that case all of the text that was around originally should be selected.
+ if (m_openedByBackwardDelete)
+ setStartingSelection(selectionAfterUndo);
deleteSelection(selectionToDelete, m_smartDelete);
setSmartDelete(false);
typingAddedToOpenCommand();
bool m_selectInsertedText;
bool m_smartDelete;
TextGranularity m_granularity;
+
+ // Undoing a series of backward deletes will restore a selection around all of the
+ // characters that were deleted, but only if the typing command being undone
+ // was opened with a backward delete.
+ bool m_openedByBackwardDelete;
};
} // namespace WebCore