Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2733)

Unified Diff: WebCore/editing/TypingCommand.cpp

Issue 5812003: Merge 73279 - 2010-12-03 Ryosuke Niwa <rniwa@webkit.org>... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/597/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « WebCore/editing/TypingCommand.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: WebCore/editing/TypingCommand.cpp
===================================================================
--- WebCore/editing/TypingCommand.cpp (revision 73932)
+++ WebCore/editing/TypingCommand.cpp (working copy)
@@ -91,6 +91,7 @@
EditCommand* lastEditCommand = frame->editor()->lastEditCommand();
if (granularity == CharacterGranularity && isOpenForMoreTypingCommand(lastEditCommand)) {
+ updateSelectionIfDifferentFromCurrentSelection(static_cast<TypingCommand*>(lastEditCommand), frame);
static_cast<TypingCommand*>(lastEditCommand)->deleteKeyPressed(granularity, killRing);
return;
}
@@ -110,6 +111,7 @@
EditCommand* lastEditCommand = frame->editor()->lastEditCommand();
if (granularity == CharacterGranularity && isOpenForMoreTypingCommand(lastEditCommand)) {
+ updateSelectionIfDifferentFromCurrentSelection(static_cast<TypingCommand*>(lastEditCommand), frame);
static_cast<TypingCommand*>(lastEditCommand)->forwardDeleteKeyPressed(granularity, killRing);
return;
}
@@ -119,6 +121,18 @@
typingCommand->apply();
}
+void TypingCommand::updateSelectionIfDifferentFromCurrentSelection(TypingCommand* typingCommand, Frame* frame)
+{
+ ASSERT(frame);
+ VisibleSelection currentSelection = frame->selection()->selection();
+ if (currentSelection == typingCommand->endingSelection())
+ return;
+
+ typingCommand->setStartingSelection(currentSelection);
+ typingCommand->setEndingSelection(currentSelection);
+}
+
+
void TypingCommand::insertText(Document* document, const String& text, bool selectInsertedText, bool insertedTextIsComposition)
{
ASSERT(document);
@@ -129,6 +143,7 @@
insertText(document, text, frame->selection()->selection(), selectInsertedText, insertedTextIsComposition);
}
+// FIXME: We shouldn't need to take selectionForInsertion. It should be identical to SelectionController's current selection.
void TypingCommand::insertText(Document* document, const String& text, const VisibleSelection& selectionForInsertion, bool selectInsertedText, bool insertedTextIsComposition)
{
#if REMOVE_MARKERS_UPON_EDITING
@@ -163,15 +178,11 @@
RefPtr<EditCommand> lastEditCommand = frame->editor()->lastEditCommand();
if (isOpenForMoreTypingCommand(lastEditCommand.get())) {
TypingCommand* lastTypingCommand = static_cast<TypingCommand*>(lastEditCommand.get());
- if (changeSelection) {
+ if (lastTypingCommand->endingSelection() != selectionForInsertion) {
lastTypingCommand->setStartingSelection(selectionForInsertion);
lastTypingCommand->setEndingSelection(selectionForInsertion);
}
lastTypingCommand->insertText(newText, selectInsertedText);
- if (changeSelection) {
- lastTypingCommand->setEndingSelection(currentSelection);
- frame->selection()->setSelection(currentSelection);
- }
return;
}
@@ -371,6 +382,10 @@
command = InsertTextCommand::create(document());
applyCommandToComposite(command);
}
+ if (endingSelection() != command->endingSelection()) {
+ command->setStartingSelection(endingSelection());
+ command->setEndingSelection(endingSelection());
+ }
command->input(text, selectInsertedText);
typingAddedToOpenCommand(InsertText);
}
« no previous file with comments | « WebCore/editing/TypingCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698