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

Unified Diff: third_party/WebKit/WebCore/editing/TypingCommand.cpp

Issue 39293: WebKit merge 41447:41498 [third_party/WebKit] (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove CRLF Created 11 years, 10 months 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
Index: third_party/WebKit/WebCore/editing/TypingCommand.cpp
===================================================================
--- third_party/WebKit/WebCore/editing/TypingCommand.cpp (revision 11154)
+++ third_party/WebKit/WebCore/editing/TypingCommand.cpp (working copy)
@@ -48,7 +48,6 @@
m_commandType(commandType),
m_textToInsert(textToInsert),
m_openForMoreTyping(true),
- m_applyEditing(false),
m_selectInsertedText(selectInsertedText),
m_smartDelete(false),
m_granularity(granularity),
@@ -300,13 +299,7 @@
void TypingCommand::typingAddedToOpenCommand()
{
markMisspellingsAfterTyping();
- // Do not apply editing to the frame on the first time through.
- // The frame will get told in the same way as all other commands.
- // But since this command stays open and is used for additional typing,
- // we need to tell the frame here as other commands are added.
- if (m_applyEditing)
- document()->frame()->editor()->appliedEditing(this);
- m_applyEditing = true;
+ document()->frame()->editor()->appliedEditing(this);
}
void TypingCommand::insertText(const String &text, bool selectInsertedText)
@@ -436,18 +429,23 @@
break;
}
- if (selectionToDelete.isCaretOrRange() && document()->frame()->shouldDeleteSelection(selectionToDelete)) {
- if (killRing)
- document()->frame()->editor()->addToKillRing(selectionToDelete.toNormalizedRange().get(), false);
- // 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);
- CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete);
- setSmartDelete(false);
- typingAddedToOpenCommand();
- }
+ ASSERT(!selectionToDelete.isNone());
+ if (selectionToDelete.isNone())
+ return;
+
+ if (selectionToDelete.isCaret() || !document()->frame()->shouldDeleteSelection(selectionToDelete))
+ return;
+
+ if (killRing)
+ document()->frame()->editor()->addToKillRing(selectionToDelete.toNormalizedRange().get(), false);
+ // 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);
+ CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete);
+ setSmartDelete(false);
+ typingAddedToOpenCommand();
}
void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool killRing)
@@ -514,15 +512,20 @@
break;
}
- if (selectionToDelete.isCaretOrRange() && document()->frame()->shouldDeleteSelection(selectionToDelete)) {
- if (killRing)
- document()->frame()->editor()->addToKillRing(selectionToDelete.toNormalizedRange().get(), false);
- // make undo select what was deleted
- setStartingSelection(selectionAfterUndo);
- CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete);
- setSmartDelete(false);
- typingAddedToOpenCommand();
- }
+ ASSERT(!selectionToDelete.isNone());
+ if (selectionToDelete.isNone())
+ return;
+
+ if (selectionToDelete.isCaret() || !document()->frame()->shouldDeleteSelection(selectionToDelete))
+ return;
+
+ if (killRing)
+ document()->frame()->editor()->addToKillRing(selectionToDelete.toNormalizedRange().get(), false);
+ // make undo select what was deleted
+ setStartingSelection(selectionAfterUndo);
+ CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete);
+ setSmartDelete(false);
+ typingAddedToOpenCommand();
}
void TypingCommand::deleteSelection(bool smartDelete)
« no previous file with comments | « third_party/WebKit/WebCore/editing/TypingCommand.h ('k') | third_party/WebKit/WebCore/html/HTMLMediaElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698