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

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

Issue 2664603002: Remove replaceComposition() calls in finishComposingText. (Closed)
Patch Set: Rebase Created 3 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 unified diff | Download patch
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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // to override checks. See <http://bugs.webkit.org/show_bug.cgi?id=15781> 257 // to override checks. See <http://bugs.webkit.org/show_bug.cgi?id=15781>
258 frame().selection().setSelection( 258 frame().selection().setSelection(
259 SelectionInDOMTree::Builder().setBaseAndExtent(range).build(), 0); 259 SelectionInDOMTree::Builder().setBaseAndExtent(range).build(), 0);
260 } 260 }
261 261
262 bool InputMethodController::finishComposingText( 262 bool InputMethodController::finishComposingText(
263 ConfirmCompositionBehavior confirmBehavior) { 263 ConfirmCompositionBehavior confirmBehavior) {
264 if (!hasComposition()) 264 if (!hasComposition())
265 return false; 265 return false;
266 266
267 const String& composing = composingText();
268
267 if (confirmBehavior == KeepSelection) { 269 if (confirmBehavior == KeepSelection) {
268 PlainTextRange oldOffsets = getSelectionOffsets(); 270 PlainTextRange oldOffsets = getSelectionOffsets();
269 Editor::RevealSelectionScope revealSelectionScope(&editor()); 271 Editor::RevealSelectionScope revealSelectionScope(&editor());
270 272
271 bool result = replaceComposition(composingText()); 273 clear();
274 dispatchCompositionEndEvent(frame(), composing);
272 275
273 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 276 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
274 // needs to be audited. see http://crbug.com/590369 for more details. 277 // needs to be audited. see http://crbug.com/590369 for more details.
275 document().updateStyleAndLayoutIgnorePendingStylesheets(); 278 document().updateStyleAndLayoutIgnorePendingStylesheets();
276
277 setSelectionOffsets(oldOffsets); 279 setSelectionOffsets(oldOffsets);
278 return result; 280 return true;
279 } 281 }
280 282
281 return replaceCompositionAndMoveCaret(composingText(), 0, 283 Element* rootEditableElement = frame().selection().rootEditableElement();
282 Vector<CompositionUnderline>()); 284 if (!rootEditableElement)
285 return false;
286 PlainTextRange compositionRange =
287 PlainTextRange::create(*rootEditableElement, *m_compositionRange);
288 if (compositionRange.isNull())
289 return false;
290
291 clear();
292
293 if (!moveCaret(compositionRange.end()))
294 return false;
295
296 dispatchCompositionEndEvent(frame(), composing);
297 return true;
283 } 298 }
284 299
285 bool InputMethodController::commitText( 300 bool InputMethodController::commitText(
286 const String& text, 301 const String& text,
287 const Vector<CompositionUnderline>& underlines, 302 const Vector<CompositionUnderline>& underlines,
288 int relativeCaretPosition) { 303 int relativeCaretPosition) {
289 if (hasComposition()) { 304 if (hasComposition()) {
290 return replaceCompositionAndMoveCaret(text, relativeCaretPosition, 305 return replaceCompositionAndMoveCaret(text, relativeCaretPosition,
291 underlines); 306 underlines);
292 } 307 }
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 frame().chromeClient().resetInputMethod(); 1106 frame().chromeClient().resetInputMethod();
1092 } 1107 }
1093 1108
1094 DEFINE_TRACE(InputMethodController) { 1109 DEFINE_TRACE(InputMethodController) {
1095 visitor->trace(m_frame); 1110 visitor->trace(m_frame);
1096 visitor->trace(m_compositionRange); 1111 visitor->trace(m_compositionRange);
1097 SynchronousMutationObserver::trace(visitor); 1112 SynchronousMutationObserver::trace(visitor);
1098 } 1113 }
1099 1114
1100 } // namespace blink 1115 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698