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

Side by Side Diff: Source/core/editing/InputMethodController.cpp

Issue 1162853002: Remove IME API from Blink (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove interface in WebWidgets.h Created 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/InputMethodController.h ('k') | Source/core/events/CompositionEvent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return true; 131 return true;
132 } 132 }
133 133
134 if (confirmBehavior != KeepSelection) 134 if (confirmBehavior != KeepSelection)
135 return confirmComposition(); 135 return confirmComposition();
136 136
137 SelectionOffsetsScope selectionOffsetsScope(this); 137 SelectionOffsetsScope selectionOffsetsScope(this);
138 return confirmComposition(); 138 return confirmComposition();
139 } 139 }
140 140
141 void InputMethodController::confirmCompositionAndResetState()
142 {
143 if (!hasComposition())
144 return;
145
146 // ChromeClient::willSetInputMethodState() resets input method and the compo sition string is committed.
147 frame().chromeClient().willSetInputMethodState();
148 }
149
150 void InputMethodController::cancelComposition() 141 void InputMethodController::cancelComposition()
151 { 142 {
152 finishComposition(emptyString(), CancelComposition); 143 finishComposition(emptyString(), CancelComposition);
153 } 144 }
154 145
155 void InputMethodController::cancelCompositionIfSelectionIsInvalid() 146 void InputMethodController::cancelCompositionIfSelectionIsInvalid()
156 { 147 {
157 if (!hasComposition() || editor().preventRevealSelection()) 148 if (!hasComposition() || editor().preventRevealSelection())
158 return; 149 return;
159 150
(...skipping 24 matching lines...) Expand all
184 else 175 else
185 selectComposition(); 176 selectComposition();
186 177
187 if (frame().selection().isNone()) 178 if (frame().selection().isNone())
188 return false; 179 return false;
189 180
190 // Dispatch a compositionend event to the focused node. 181 // Dispatch a compositionend event to the focused node.
191 // We should send this event before sending a TextEvent as written in Sectio n 6.2.2 and 6.2.3 of 182 // We should send this event before sending a TextEvent as written in Sectio n 6.2.2 and 6.2.3 of
192 // the DOM Event specification. 183 // the DOM Event specification.
193 if (Element* target = frame().document()->focusedElement()) { 184 if (Element* target = frame().document()->focusedElement()) {
194 unsigned baseOffset = frame().selection().base().downstream().deprecated EditingOffset(); 185 RefPtrWillBeRawPtr<CompositionEvent> event = CompositionEvent::create(Ev entTypeNames::compositionend, frame().domWindow(), text);
195 Vector<CompositionUnderline> underlines;
196 for (auto underline : m_customCompositionUnderlines) {
197 underline.startOffset -= baseOffset;
198 underline.endOffset -= baseOffset;
199 underlines.append(underline);
200 }
201 RefPtrWillBeRawPtr<CompositionEvent> event = CompositionEvent::create(Ev entTypeNames::compositionend, frame().domWindow(), text, underlines);
202 target->dispatchEvent(event, IGNORE_EXCEPTION); 186 target->dispatchEvent(event, IGNORE_EXCEPTION);
203 } 187 }
204 188
205 // If text is empty, then delete the old composition here. If text is non-em pty, InsertTextCommand::input 189 // If text is empty, then delete the old composition here. If text is non-em pty, InsertTextCommand::input
206 // will delete the old composition with an optimized replace operation. 190 // will delete the old composition with an optimized replace operation.
207 if (text.isEmpty() && mode != CancelComposition) { 191 if (text.isEmpty() && mode != CancelComposition) {
208 ASSERT(frame().document()); 192 ASSERT(frame().document());
209 TypingCommand::deleteSelection(*frame().document(), 0); 193 TypingCommand::deleteSelection(*frame().document(), 0);
210 } 194 }
211 195
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // Send a compositionupdate event when this function updates the exis ting composition 234 // Send a compositionupdate event when this function updates the exis ting composition
251 // node, i.e. m_compositionNode != 0 && !text.isEmpty(). 235 // node, i.e. m_compositionNode != 0 && !text.isEmpty().
252 // 3. Canceling the ongoing composition. 236 // 3. Canceling the ongoing composition.
253 // Send a compositionend event when function deletes the existing com position node, i.e. 237 // Send a compositionend event when function deletes the existing com position node, i.e.
254 // m_compositionNode != 0 && test.isEmpty(). 238 // m_compositionNode != 0 && test.isEmpty().
255 RefPtrWillBeRawPtr<CompositionEvent> event = nullptr; 239 RefPtrWillBeRawPtr<CompositionEvent> event = nullptr;
256 if (!hasComposition()) { 240 if (!hasComposition()) {
257 // We should send a compositionstart event only when the given text is not empty because this 241 // We should send a compositionstart event only when the given text is not empty because this
258 // function doesn't create a composition node when the text is empty . 242 // function doesn't create a composition node when the text is empty .
259 if (!text.isEmpty()) { 243 if (!text.isEmpty()) {
260 target->dispatchEvent(CompositionEvent::create(EventTypeNames::c ompositionstart, frame().domWindow(), frame().selectedText(), underlines)); 244 target->dispatchEvent(CompositionEvent::create(EventTypeNames::c ompositionstart, frame().domWindow(), frame().selectedText()));
261 event = CompositionEvent::create(EventTypeNames::compositionupda te, frame().domWindow(), text, underlines); 245 event = CompositionEvent::create(EventTypeNames::compositionupda te, frame().domWindow(), text);
262 } 246 }
263 } else { 247 } else {
264 if (!text.isEmpty()) 248 if (!text.isEmpty())
265 event = CompositionEvent::create(EventTypeNames::compositionupda te, frame().domWindow(), text, underlines); 249 event = CompositionEvent::create(EventTypeNames::compositionupda te, frame().domWindow(), text);
266 else 250 else
267 event = CompositionEvent::create(EventTypeNames::compositionend, frame().domWindow(), text, underlines); 251 event = CompositionEvent::create(EventTypeNames::compositionend, frame().domWindow(), text);
268 } 252 }
269 if (event.get()) 253 if (event.get())
270 target->dispatchEvent(event, IGNORE_EXCEPTION); 254 target->dispatchEvent(event, IGNORE_EXCEPTION);
271 } 255 }
272 256
273 // If text is empty, then delete the old composition here. If text is non-em pty, InsertTextCommand::input 257 // If text is empty, then delete the old composition here. If text is non-em pty, InsertTextCommand::input
274 // will delete the old composition with an optimized replace operation. 258 // will delete the old composition with an optimized replace operation.
275 if (text.isEmpty()) { 259 if (text.isEmpty()) {
276 ASSERT(frame().document()); 260 ASSERT(frame().document());
277 TypingCommand::deleteSelection(*frame().document(), TypingCommand::Preve ntSpellChecking); 261 TypingCommand::deleteSelection(*frame().document(), TypingCommand::Preve ntSpellChecking);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 TypingCommand::deleteSelection(*frame().document()); 408 TypingCommand::deleteSelection(*frame().document());
425 } 409 }
426 410
427 DEFINE_TRACE(InputMethodController) 411 DEFINE_TRACE(InputMethodController)
428 { 412 {
429 visitor->trace(m_frame); 413 visitor->trace(m_frame);
430 visitor->trace(m_compositionNode); 414 visitor->trace(m_compositionNode);
431 } 415 }
432 416
433 } // namespace blink 417 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/InputMethodController.h ('k') | Source/core/events/CompositionEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698