| OLD | NEW |
| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 setContext(document); | 209 setContext(document); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void InputMethodController::selectComposition() const { | 212 void InputMethodController::selectComposition() const { |
| 213 const EphemeralRange range = compositionEphemeralRange(); | 213 const EphemeralRange range = compositionEphemeralRange(); |
| 214 if (range.isNull()) | 214 if (range.isNull()) |
| 215 return; | 215 return; |
| 216 | 216 |
| 217 // The composition can start inside a composed character sequence, so we have | 217 // The composition can start inside a composed character sequence, so we have |
| 218 // to override checks. See <http://bugs.webkit.org/show_bug.cgi?id=15781> | 218 // to override checks. See <http://bugs.webkit.org/show_bug.cgi?id=15781> |
| 219 VisibleSelection selection; | 219 frame().selection().setSelection( |
| 220 selection.setWithoutValidation(range.startPosition(), range.endPosition()); | 220 SelectionInDOMTree::Builder().setBaseAndExtent(range).build(), 0); |
| 221 frame().selection().setSelection(selection, 0); | |
| 222 } | 221 } |
| 223 | 222 |
| 224 bool InputMethodController::finishComposingText( | 223 bool InputMethodController::finishComposingText( |
| 225 ConfirmCompositionBehavior confirmBehavior) { | 224 ConfirmCompositionBehavior confirmBehavior) { |
| 226 if (!hasComposition()) | 225 if (!hasComposition()) |
| 227 return false; | 226 return false; |
| 228 | 227 |
| 229 if (confirmBehavior == KeepSelection) { | 228 if (confirmBehavior == KeepSelection) { |
| 230 PlainTextRange oldOffsets = getSelectionOffsets(); | 229 PlainTextRange oldOffsets = getSelectionOffsets(); |
| 231 Editor::RevealSelectionScope revealSelectionScope(&editor()); | 230 Editor::RevealSelectionScope revealSelectionScope(&editor()); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 | 517 |
| 519 if (inserting || deleting) { | 518 if (inserting || deleting) { |
| 520 // Select the text to be deleted. | 519 // Select the text to be deleted. |
| 521 const size_t compositionStart = | 520 const size_t compositionStart = |
| 522 PlainTextRange::create(*editable, compositionEphemeralRange()).start(); | 521 PlainTextRange::create(*editable, compositionEphemeralRange()).start(); |
| 523 const size_t deletionStart = compositionStart + commonPrefixLength; | 522 const size_t deletionStart = compositionStart + commonPrefixLength; |
| 524 const size_t deletionEnd = | 523 const size_t deletionEnd = |
| 525 compositionStart + composing.length() - commonSuffixLength; | 524 compositionStart + composing.length() - commonSuffixLength; |
| 526 const EphemeralRange& deletionRange = | 525 const EphemeralRange& deletionRange = |
| 527 PlainTextRange(deletionStart, deletionEnd).createRange(*editable); | 526 PlainTextRange(deletionStart, deletionEnd).createRange(*editable); |
| 528 VisibleSelection selection; | |
| 529 selection.setWithoutValidation(deletionRange.startPosition(), | |
| 530 deletionRange.endPosition()); | |
| 531 Document& currentDocument = document(); | 527 Document& currentDocument = document(); |
| 532 frame().selection().setSelection(selection, 0); | 528 frame().selection().setSelection( |
| 529 SelectionInDOMTree::Builder().setBaseAndExtent(deletionRange).build(), |
| 530 0); |
| 533 clear(); | 531 clear(); |
| 534 | 532 |
| 535 // FrameSeleciton::setSelection() can change document associate to |frame|. | 533 // FrameSeleciton::setSelection() can change document associate to |frame|. |
| 536 if (!isAvailable() || currentDocument != document()) | 534 if (!isAvailable() || currentDocument != document()) |
| 537 return; | 535 return; |
| 538 if (!currentDocument.focusedElement()) | 536 if (!currentDocument.focusedElement()) |
| 539 return; | 537 return; |
| 540 | 538 |
| 541 // Insert the incremental text. | 539 // Insert the incremental text. |
| 542 const size_t insertionLength = | 540 const size_t insertionLength = |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 return WebTextInputTypeNone; | 1188 return WebTextInputTypeNone; |
| 1191 } | 1189 } |
| 1192 | 1190 |
| 1193 DEFINE_TRACE(InputMethodController) { | 1191 DEFINE_TRACE(InputMethodController) { |
| 1194 visitor->trace(m_frame); | 1192 visitor->trace(m_frame); |
| 1195 visitor->trace(m_compositionRange); | 1193 visitor->trace(m_compositionRange); |
| 1196 SynchronousMutationObserver::trace(visitor); | 1194 SynchronousMutationObserver::trace(visitor); |
| 1197 } | 1195 } |
| 1198 | 1196 |
| 1199 } // namespace blink | 1197 } // namespace blink |
| OLD | NEW |