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

Unified Diff: third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp

Issue 2143883002: Fix the bug that matras are input twice for Indian languages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/Source/core/editing/commands/TypingCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp b/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
index 8e56bf043bffd04250b746a2b13d18410291902b..16fc6d7d6fa062bb8532dd0d3a26c24872f29dcb 100644
--- a/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
@@ -40,6 +40,7 @@
#include "core/editing/commands/InsertTextCommand.h"
#include "core/editing/spellcheck/SpellChecker.h"
#include "core/events/BeforeTextInsertedEvent.h"
+#include "core/events/TextEvent.h"
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLBRElement.h"
#include "core/layout/LayoutObject.h"
@@ -140,11 +141,8 @@ void TypingCommand::updateSelectionIfDifferentFromCurrentSelection(TypingCommand
typingCommand->setEndingSelection(currentSelection);
}
-static String dispatchBeforeTextInsertedEvent(const String& text, const VisibleSelection& selectionForInsertion, bool insertionIsForUpdatingComposition)
+static String dispatchBeforeTextInsertedEvent(const String& text, const VisibleSelection& selectionForInsertion)
{
- if (insertionIsForUpdatingComposition)
- return text;
-
String newText = text;
if (Node* startNode = selectionForInsertion.start().computeContainerNode()) {
if (startNode->rootEditableElement()) {
@@ -157,6 +155,19 @@ static String dispatchBeforeTextInsertedEvent(const String& text, const VisibleS
return newText;
}
+static String dispatchTextInputEvent(LocalFrame* frame, const String& text, const VisibleSelection& selectionForInsertion)
+{
+ String newText = text;
+ Element* target = frame->document()->focusedElement();
+ if (target) {
+ // Send TextInputEvent. The event handler will update text if necessary.
+ TextEvent* event = TextEvent::create(frame->domWindow(), text, TextEventInputDrop);
+ target->dispatchEvent(event);
+ newText = event->data();
+ }
+ return newText;
+}
+
void TypingCommand::insertText(Document& document, const String& text, Options options, TextCompositionType composition)
{
LocalFrame* frame = document.frame();
@@ -176,7 +187,12 @@ void TypingCommand::insertText(Document& document, const String& text, const Vis
VisibleSelection currentSelection = frame->selection().selection();
- String newText = dispatchBeforeTextInsertedEvent(text, selectionForInsertion, compositionType == TextCompositionUpdate);
+ String newText = text;
+ if (compositionType != TextCompositionUpdate)
+ newText = dispatchBeforeTextInsertedEvent(text, selectionForInsertion);
+
+ if (compositionType == TextCompositionConfirm)
+ newText = dispatchTextInputEvent(frame, newText, selectionForInsertion);
// Set the starting and ending selection appropriately if we are using a selection
// that is different from the current selection. In the future, we should change EditCommand

Powered by Google App Engine
This is Rietveld 408576698