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

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

Issue 2491763004: Revert of Utilize FrameSelection::setSelection() taking SelectionInDOMTree/SelectionInFlatTree (Closed)
Patch Set: 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 frame().selection().setSelection( 180 VisibleSelection selection;
181 SelectionInDOMTree::Builder().setBaseAndExtent(range).build(), 0); 181 selection.setWithoutValidation(range.startPosition(), range.endPosition());
182 frame().selection().setSelection(selection, 0);
182 } 183 }
183 184
184 bool InputMethodController::finishComposingText( 185 bool InputMethodController::finishComposingText(
185 ConfirmCompositionBehavior confirmBehavior) { 186 ConfirmCompositionBehavior confirmBehavior) {
186 if (!hasComposition()) 187 if (!hasComposition())
187 return false; 188 return false;
188 189
189 if (confirmBehavior == KeepSelection) { 190 if (confirmBehavior == KeepSelection) {
190 PlainTextRange oldOffsets = getSelectionOffsets(); 191 PlainTextRange oldOffsets = getSelectionOffsets();
191 Editor::RevealSelectionScope revealSelectionScope(&editor()); 192 Editor::RevealSelectionScope revealSelectionScope(&editor());
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 471
471 if (inserting || deleting) { 472 if (inserting || deleting) {
472 // Select the text to be deleted. 473 // Select the text to be deleted.
473 const size_t compositionStart = 474 const size_t compositionStart =
474 PlainTextRange::create(*editable, compositionEphemeralRange()).start(); 475 PlainTextRange::create(*editable, compositionEphemeralRange()).start();
475 const size_t deletionStart = compositionStart + commonPrefixLength; 476 const size_t deletionStart = compositionStart + commonPrefixLength;
476 const size_t deletionEnd = 477 const size_t deletionEnd =
477 compositionStart + composing.length() - commonSuffixLength; 478 compositionStart + composing.length() - commonSuffixLength;
478 const EphemeralRange& deletionRange = 479 const EphemeralRange& deletionRange =
479 PlainTextRange(deletionStart, deletionEnd).createRange(*editable); 480 PlainTextRange(deletionStart, deletionEnd).createRange(*editable);
481 VisibleSelection selection;
482 selection.setWithoutValidation(deletionRange.startPosition(),
483 deletionRange.endPosition());
480 Document* const currentDocument = frame().document(); 484 Document* const currentDocument = frame().document();
481 frame().selection().setSelection( 485 frame().selection().setSelection(selection, 0);
482 SelectionInDOMTree::Builder().setBaseAndExtent(deletionRange).build(),
483 0);
484 clear(); 486 clear();
485 487
486 // FrameSeleciton::setSelection() can change document associate to |frame|. 488 // FrameSeleciton::setSelection() can change document associate to |frame|.
487 if (currentDocument != frame().document()) 489 if (currentDocument != frame().document())
488 return; 490 return;
489 if (!currentDocument->focusedElement()) 491 if (!currentDocument->focusedElement())
490 return; 492 return;
491 493
492 // Insert the incremental text. 494 // Insert the incremental text.
493 const size_t insertionLength = 495 const size_t insertionLength =
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 1156
1155 return WebTextInputTypeNone; 1157 return WebTextInputTypeNone;
1156 } 1158 }
1157 1159
1158 DEFINE_TRACE(InputMethodController) { 1160 DEFINE_TRACE(InputMethodController) {
1159 visitor->trace(m_frame); 1161 visitor->trace(m_frame);
1160 visitor->trace(m_compositionRange); 1162 visitor->trace(m_compositionRange);
1161 } 1163 }
1162 1164
1163 } // namespace blink 1165 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698