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

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

Issue 2457613004: Utilize FrameSelection::setSelection() taking SelectionInDOMTree/SelectionInFlatTree (Closed)
Patch Set: 2016-10-28T15:45:56 Created 4 years, 1 month 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 m_compositionRange = nullptr; 170 m_compositionRange = nullptr;
171 } 171 }
172 172
173 void InputMethodController::selectComposition() const { 173 void InputMethodController::selectComposition() const {
174 const EphemeralRange range = compositionEphemeralRange(); 174 const EphemeralRange range = compositionEphemeralRange();
175 if (range.isNull()) 175 if (range.isNull())
176 return; 176 return;
177 177
178 // The composition can start inside a composed character sequence, so we have 178 // The composition can start inside a composed character sequence, so we have
179 // to override checks. See <http://bugs.webkit.org/show_bug.cgi?id=15781> 179 // to override checks. See <http://bugs.webkit.org/show_bug.cgi?id=15781>
180 VisibleSelection selection; 180 frame().selection().setSelection(
181 selection.setWithoutValidation(range.startPosition(), range.endPosition()); 181 SelectionInDOMTree::Builder().setBaseAndExtent(range).build(), 0);
182 frame().selection().setSelection(selection, 0);
183 } 182 }
184 183
185 bool InputMethodController::finishComposingText( 184 bool InputMethodController::finishComposingText(
186 ConfirmCompositionBehavior confirmBehavior) { 185 ConfirmCompositionBehavior confirmBehavior) {
187 if (!hasComposition()) 186 if (!hasComposition())
188 return false; 187 return false;
189 188
190 if (confirmBehavior == KeepSelection) { 189 if (confirmBehavior == KeepSelection) {
191 PlainTextRange oldOffsets = getSelectionOffsets(); 190 PlainTextRange oldOffsets = getSelectionOffsets();
192 Editor::RevealSelectionScope revealSelectionScope(&editor()); 191 Editor::RevealSelectionScope revealSelectionScope(&editor());
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 470
472 if (inserting || deleting) { 471 if (inserting || deleting) {
473 // Select the text to be deleted. 472 // Select the text to be deleted.
474 const size_t compositionStart = 473 const size_t compositionStart =
475 PlainTextRange::create(*editable, compositionEphemeralRange()).start(); 474 PlainTextRange::create(*editable, compositionEphemeralRange()).start();
476 const size_t deletionStart = compositionStart + commonPrefixLength; 475 const size_t deletionStart = compositionStart + commonPrefixLength;
477 const size_t deletionEnd = 476 const size_t deletionEnd =
478 compositionStart + composing.length() - commonSuffixLength; 477 compositionStart + composing.length() - commonSuffixLength;
479 const EphemeralRange& deletionRange = 478 const EphemeralRange& deletionRange =
480 PlainTextRange(deletionStart, deletionEnd).createRange(*editable); 479 PlainTextRange(deletionStart, deletionEnd).createRange(*editable);
481 VisibleSelection selection;
482 selection.setWithoutValidation(deletionRange.startPosition(),
483 deletionRange.endPosition());
484 Document* const currentDocument = frame().document(); 480 Document* const currentDocument = frame().document();
485 frame().selection().setSelection(selection, 0); 481 frame().selection().setSelection(
482 SelectionInDOMTree::Builder().setBaseAndExtent(deletionRange).build(),
483 0);
486 clear(); 484 clear();
487 485
488 // FrameSeleciton::setSelection() can change document associate to |frame|. 486 // FrameSeleciton::setSelection() can change document associate to |frame|.
489 if (currentDocument != frame().document()) 487 if (currentDocument != frame().document())
490 return; 488 return;
491 if (!currentDocument->focusedElement()) 489 if (!currentDocument->focusedElement())
492 return; 490 return;
493 491
494 // Insert the incremental text. 492 // Insert the incremental text.
495 const size_t insertionLength = 493 const size_t insertionLength =
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 1154
1157 return WebTextInputTypeNone; 1155 return WebTextInputTypeNone;
1158 } 1156 }
1159 1157
1160 DEFINE_TRACE(InputMethodController) { 1158 DEFINE_TRACE(InputMethodController) {
1161 visitor->trace(m_frame); 1159 visitor->trace(m_frame);
1162 visitor->trace(m_compositionRange); 1160 visitor->trace(m_compositionRange);
1163 } 1161 }
1164 1162
1165 } // namespace blink 1163 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698