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

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

Issue 2143923002: Introduce 'TextCompositionCancel' for cancelComposition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/commands/TypingCommand.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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // 3. Fire TextEvent and modify DOM 77 // 3. Fire TextEvent and modify DOM
78 // TODO(chongz): 4. Fire 'input' event 78 // TODO(chongz): 4. Fire 'input' event
79 void insertTextDuringCompositionWithEvents( 79 void insertTextDuringCompositionWithEvents(
80 LocalFrame& frame, 80 LocalFrame& frame,
81 const String& text, 81 const String& text,
82 TypingCommand::Options options, 82 TypingCommand::Options options,
83 TypingCommand::TextCompositionType compositionType) { 83 TypingCommand::TextCompositionType compositionType) {
84 DCHECK(compositionType == 84 DCHECK(compositionType ==
85 TypingCommand::TextCompositionType::TextCompositionUpdate || 85 TypingCommand::TextCompositionType::TextCompositionUpdate ||
86 compositionType == 86 compositionType ==
87 TypingCommand::TextCompositionType::TextCompositionConfirm) 87 TypingCommand::TextCompositionType::TextCompositionConfirm ||
88 compositionType ==
89 TypingCommand::TextCompositionType::TextCompositionCancel)
88 << "compositionType should be TextCompositionUpdate or " 90 << "compositionType should be TextCompositionUpdate or "
89 "TextCompositionConfirm, but got " 91 "TextCompositionConfirm or TextCompositionCancel, but got "
90 << static_cast<int>(compositionType); 92 << static_cast<int>(compositionType);
91 if (!frame.document()) 93 if (!frame.document())
92 return; 94 return;
93 95
94 Element* target = frame.document()->focusedElement(); 96 Element* target = frame.document()->focusedElement();
95 if (!target) 97 if (!target)
96 return; 98 return;
97 99
98 // TODO(chongz): Fire 'beforeinput' for the composed text being 100 // TODO(chongz): Fire 'beforeinput' for the composed text being
99 // replaced/deleted. 101 // replaced/deleted.
(...skipping 19 matching lines...) Expand all
119 // 'compositionupdate' event handler may destroy document. 121 // 'compositionupdate' event handler may destroy document.
120 if (!frame.document()) 122 if (!frame.document())
121 return; 123 return;
122 124
123 switch (compositionType) { 125 switch (compositionType) {
124 case TypingCommand::TextCompositionType::TextCompositionUpdate: 126 case TypingCommand::TextCompositionType::TextCompositionUpdate:
125 TypingCommand::insertText(*frame.document(), text, options, 127 TypingCommand::insertText(*frame.document(), text, options,
126 compositionType); 128 compositionType);
127 break; 129 break;
128 case TypingCommand::TextCompositionType::TextCompositionConfirm: 130 case TypingCommand::TextCompositionType::TextCompositionConfirm:
131 case TypingCommand::TextCompositionType::TextCompositionCancel:
129 // TODO(chongz): Use TypingCommand::insertText after TextEvent was 132 // TODO(chongz): Use TypingCommand::insertText after TextEvent was
130 // removed. (Removed from spec since 2012) 133 // removed. (Removed from spec since 2012)
131 // See TextEvent.idl. 134 // See TextEvent.idl.
132 frame.eventHandler().handleTextInputEvent(text, 0, 135 frame.eventHandler().handleTextInputEvent(text, 0,
133 TextEventInputComposition); 136 TextEventInputComposition);
134 break; 137 break;
135 default: 138 default:
136 NOTREACHED(); 139 NOTREACHED();
137 } 140 }
138 // TODO(chongz): Fire 'input' event. 141 // TODO(chongz): Fire 'input' event.
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 clear(); 375 clear();
373 376
374 // TODO(chongz): Figure out which InputType should we use here. 377 // TODO(chongz): Figure out which InputType should we use here.
375 dispatchBeforeInputFromComposition( 378 dispatchBeforeInputFromComposition(
376 document().focusedElement(), 379 document().focusedElement(),
377 InputEvent::InputType::DeleteComposedCharacterBackward, nullAtom, 380 InputEvent::InputType::DeleteComposedCharacterBackward, nullAtom,
378 InputEvent::EventCancelable::NotCancelable); 381 InputEvent::EventCancelable::NotCancelable);
379 dispatchCompositionUpdateEvent(frame(), emptyString()); 382 dispatchCompositionUpdateEvent(frame(), emptyString());
380 insertTextDuringCompositionWithEvents( 383 insertTextDuringCompositionWithEvents(
381 frame(), emptyString(), 0, 384 frame(), emptyString(), 0,
382 TypingCommand::TextCompositionType::TextCompositionConfirm); 385 TypingCommand::TextCompositionType::TextCompositionCancel);
383 // Event handler might destroy document. 386 // Event handler might destroy document.
384 if (!isAvailable()) 387 if (!isAvailable())
385 return; 388 return;
386 389
387 // An open typing command that disagrees about current selection would cause 390 // An open typing command that disagrees about current selection would cause
388 // issues with typing later on. 391 // issues with typing later on.
389 TypingCommand::closeTyping(m_frame); 392 TypingCommand::closeTyping(m_frame);
390 393
391 // No DOM update after 'compositionend'. 394 // No DOM update after 'compositionend'.
392 dispatchCompositionEndEvent(frame(), emptyString()); 395 dispatchCompositionEndEvent(frame(), emptyString());
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 return WebTextInputTypeNone; 1193 return WebTextInputTypeNone;
1191 } 1194 }
1192 1195
1193 DEFINE_TRACE(InputMethodController) { 1196 DEFINE_TRACE(InputMethodController) {
1194 visitor->trace(m_frame); 1197 visitor->trace(m_frame);
1195 visitor->trace(m_compositionRange); 1198 visitor->trace(m_compositionRange);
1196 SynchronousMutationObserver::trace(visitor); 1199 SynchronousMutationObserver::trace(visitor);
1197 } 1200 }
1198 1201
1199 } // namespace blink 1202 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/commands/TypingCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698