Chromium Code Reviews| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 return insertTextAndMoveCaret(text, relativeCaretPosition); | 217 return insertTextAndMoveCaret(text, relativeCaretPosition); |
| 218 } | 218 } |
| 219 | 219 |
| 220 bool InputMethodController::replaceComposition(const String& text) { | 220 bool InputMethodController::replaceComposition(const String& text) { |
| 221 if (!hasComposition()) | 221 if (!hasComposition()) |
| 222 return false; | 222 return false; |
| 223 | 223 |
| 224 // If the composition was set from existing text and didn't change, then | 224 // If the composition was set from existing text and didn't change, then |
| 225 // there's nothing to do here (and we should avoid doing anything as that | 225 // there's nothing to do here (and we should avoid doing anything as that |
| 226 // may clobber multi-node styled text). | 226 // may clobber multi-node styled text). |
| 227 if (!m_isDirty && composingText() == text) { | 227 if (!m_isDirty && composingText() == text) { |
|
yabinh
2016/11/02 07:19:39
If we do nothing here, no event will be fired.
| |
| 228 clear(); | 228 clear(); |
| 229 return true; | 229 return true; |
| 230 } | 230 } |
| 231 | 231 |
| 232 // Select the text that will be deleted or replaced. | 232 // Select the text that will be deleted or replaced. |
| 233 selectComposition(); | 233 selectComposition(); |
| 234 | 234 |
| 235 if (frame().selection().isNone()) | 235 if (frame().selection().isNone()) |
| 236 return false; | 236 return false; |
| 237 | 237 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 selectComposition(); | 515 selectComposition(); |
| 516 | 516 |
| 517 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 517 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 518 // needs to be audited. see http://crbug.com/590369 for more details. | 518 // needs to be audited. see http://crbug.com/590369 for more details. |
| 519 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 519 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 520 | 520 |
| 521 const PlainTextRange& selectedRange = createSelectionRangeForSetComposition( | 521 const PlainTextRange& selectedRange = createSelectionRangeForSetComposition( |
| 522 selectionStart, selectionEnd, text.length()); | 522 selectionStart, selectionEnd, text.length()); |
| 523 // We shouldn't close typing in the middle of setComposition. | 523 // We shouldn't close typing in the middle of setComposition. |
| 524 setEditableSelectionOffsets(selectedRange, NotUserTriggered); | 524 setEditableSelectionOffsets(selectedRange, NotUserTriggered); |
| 525 m_isDirty = true; | |
| 526 } | 525 } |
| 527 | 526 |
| 528 void InputMethodController::setComposition( | 527 void InputMethodController::setComposition( |
| 529 const String& text, | 528 const String& text, |
| 530 const Vector<CompositionUnderline>& underlines, | 529 const Vector<CompositionUnderline>& underlines, |
| 531 int selectionStart, | 530 int selectionStart, |
| 532 int selectionEnd) { | 531 int selectionEnd) { |
| 533 Editor::RevealSelectionScope revealSelectionScope(&editor()); | 532 Editor::RevealSelectionScope revealSelectionScope(&editor()); |
| 534 | 533 |
| 535 // Updates styles before setting selection for composition to prevent | 534 // Updates styles before setting selection for composition to prevent |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1154 | 1153 |
| 1155 return WebTextInputTypeNone; | 1154 return WebTextInputTypeNone; |
| 1156 } | 1155 } |
| 1157 | 1156 |
| 1158 DEFINE_TRACE(InputMethodController) { | 1157 DEFINE_TRACE(InputMethodController) { |
| 1159 visitor->trace(m_frame); | 1158 visitor->trace(m_frame); |
| 1160 visitor->trace(m_compositionRange); | 1159 visitor->trace(m_compositionRange); |
| 1161 } | 1160 } |
| 1162 | 1161 |
| 1163 } // namespace blink | 1162 } // namespace blink |
| OLD | NEW |