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

Unified Diff: Source/core/editing/Editor.cpp

Issue 18041002: compositionstart event's data should contain text to replace. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add a testcase for selection. Created 7 years, 6 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
« no previous file with comments | « LayoutTests/fast/events/ime-composition-events-001-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/Editor.cpp
diff --git a/Source/core/editing/Editor.cpp b/Source/core/editing/Editor.cpp
index 7baf56420357f5d5d84106362208503a1d2470b8..f1678fe550eb71964fff83f03081a60a05ada366 100644
--- a/Source/core/editing/Editor.cpp
+++ b/Source/core/editing/Editor.cpp
@@ -1247,7 +1247,13 @@ void Editor::setComposition(const String& text, const Vector<CompositionUnderlin
// We should send a compositionstart event only when the given text is not empty because this
// function doesn't create a composition node when the text is empty.
if (!text.isEmpty()) {
- target->dispatchEvent(CompositionEvent::create(eventNames().compositionstartEvent, m_frame->document()->domWindow(), text));
+ FrameSelection* selection = m_frame->selection();
+ String selectionText;
+ if (selection->isRange()) {
+ RefPtr<Range> range = selection->toNormalizedRange();
+ selectionText = plainText(range.get());
+ }
+ target->dispatchEvent(CompositionEvent::create(eventNames().compositionstartEvent, m_frame->document()->domWindow(), selectionText));
rniwa-cr 2013/07/15 21:46:52 You could have simply called selectedText() here a
kochi 2013/07/16 09:50:41 Done.
event = CompositionEvent::create(eventNames().compositionupdateEvent, m_frame->document()->domWindow(), text);
}
} else {
« no previous file with comments | « LayoutTests/fast/events/ime-composition-events-001-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698