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

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

Issue 2681023003: Remove replaceComposition() calls in finishComposingText. (Closed)
Patch Set: 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // to override checks. See <http://bugs.webkit.org/show_bug.cgi?id=15781> 240 // to override checks. See <http://bugs.webkit.org/show_bug.cgi?id=15781>
241 frame().selection().setSelection( 241 frame().selection().setSelection(
242 SelectionInDOMTree::Builder().setBaseAndExtent(range).build(), 0); 242 SelectionInDOMTree::Builder().setBaseAndExtent(range).build(), 0);
243 } 243 }
244 244
245 bool InputMethodController::finishComposingText( 245 bool InputMethodController::finishComposingText(
246 ConfirmCompositionBehavior confirmBehavior) { 246 ConfirmCompositionBehavior confirmBehavior) {
247 if (!hasComposition()) 247 if (!hasComposition())
248 return false; 248 return false;
249 249
250 const String& composing = composingText();
251
250 if (confirmBehavior == KeepSelection) { 252 if (confirmBehavior == KeepSelection) {
251 PlainTextRange oldOffsets = getSelectionOffsets(); 253 PlainTextRange oldOffsets = getSelectionOffsets();
252 Editor::RevealSelectionScope revealSelectionScope(&editor()); 254 Editor::RevealSelectionScope revealSelectionScope(&editor());
253 255
254 bool result = replaceComposition(composingText()); 256 clear();
257 dispatchCompositionEndEvent(frame(), composing);
255 258
256 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 259 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
257 // needs to be audited. see http://crbug.com/590369 for more details. 260 // needs to be audited. see http://crbug.com/590369 for more details.
258 document().updateStyleAndLayoutIgnorePendingStylesheets(); 261 document().updateStyleAndLayoutIgnorePendingStylesheets();
259
260 setSelectionOffsets(oldOffsets); 262 setSelectionOffsets(oldOffsets);
261 return result; 263 return true;
262 } 264 }
263 265
264 return replaceCompositionAndMoveCaret(composingText(), 0, 266 Element* rootEditableElement = frame().selection().rootEditableElement();
265 Vector<CompositionUnderline>()); 267 if (!rootEditableElement)
268 return false;
269 PlainTextRange compositionRange =
270 PlainTextRange::create(*rootEditableElement, *m_compositionRange);
271 if (compositionRange.isNull())
272 return false;
273
274 clear();
275
276 if (!moveCaret(compositionRange.end()))
277 return false;
278
279 dispatchCompositionEndEvent(frame(), composing);
280 return true;
266 } 281 }
267 282
268 bool InputMethodController::commitText( 283 bool InputMethodController::commitText(
269 const String& text, 284 const String& text,
270 const Vector<CompositionUnderline>& underlines, 285 const Vector<CompositionUnderline>& underlines,
271 int relativeCaretPosition) { 286 int relativeCaretPosition) {
272 if (hasComposition()) { 287 if (hasComposition()) {
273 return replaceCompositionAndMoveCaret(text, relativeCaretPosition, 288 return replaceCompositionAndMoveCaret(text, relativeCaretPosition,
274 underlines); 289 underlines);
275 } 290 }
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 frame().chromeClient().resetInputMethod(); 1082 frame().chromeClient().resetInputMethod();
1068 } 1083 }
1069 1084
1070 DEFINE_TRACE(InputMethodController) { 1085 DEFINE_TRACE(InputMethodController) {
1071 visitor->trace(m_frame); 1086 visitor->trace(m_frame);
1072 visitor->trace(m_compositionRange); 1087 visitor->trace(m_compositionRange);
1073 SynchronousMutationObserver::trace(visitor); 1088 SynchronousMutationObserver::trace(visitor);
1074 } 1089 }
1075 1090
1076 } // namespace blink 1091 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698