| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 bool InputMethodController::isAvailable() const { | 175 bool InputMethodController::isAvailable() const { |
| 176 return frame().document(); | 176 return frame().document(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 Document& InputMethodController::document() const { | 179 Document& InputMethodController::document() const { |
| 180 DCHECK(isAvailable()); | 180 DCHECK(isAvailable()); |
| 181 return *frame().document(); | 181 return *frame().document(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 bool InputMethodController::hasComposition() const { | 184 bool InputMethodController::hasComposition() const { |
| 185 return m_hasComposition; | 185 return m_hasComposition && !m_compositionRange->collapsed() && |
| 186 m_compositionRange->isConnected(); |
| 186 } | 187 } |
| 187 | 188 |
| 188 inline Editor& InputMethodController::editor() const { | 189 inline Editor& InputMethodController::editor() const { |
| 189 return frame().editor(); | 190 return frame().editor(); |
| 190 } | 191 } |
| 191 | 192 |
| 192 void InputMethodController::clear() { | 193 void InputMethodController::clear() { |
| 193 m_hasComposition = false; | 194 m_hasComposition = false; |
| 194 if (m_compositionRange) { | 195 if (m_compositionRange) { |
| 195 m_compositionRange->setStart(&document(), 0); | 196 m_compositionRange->setStart(&document(), 0); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 int relativeCaretPosition) { | 308 int relativeCaretPosition) { |
| 308 return textStart + textLength + relativeCaretPosition; | 309 return textStart + textLength + relativeCaretPosition; |
| 309 } | 310 } |
| 310 | 311 |
| 311 bool InputMethodController::replaceCompositionAndMoveCaret( | 312 bool InputMethodController::replaceCompositionAndMoveCaret( |
| 312 const String& text, | 313 const String& text, |
| 313 int relativeCaretPosition) { | 314 int relativeCaretPosition) { |
| 314 Element* rootEditableElement = frame().selection().rootEditableElement(); | 315 Element* rootEditableElement = frame().selection().rootEditableElement(); |
| 315 if (!rootEditableElement) | 316 if (!rootEditableElement) |
| 316 return false; | 317 return false; |
| 318 DCHECK(hasComposition()); |
| 317 PlainTextRange compositionRange = | 319 PlainTextRange compositionRange = |
| 318 PlainTextRange::create(*rootEditableElement, *m_compositionRange); | 320 PlainTextRange::create(*rootEditableElement, *m_compositionRange); |
| 319 if (compositionRange.isNull()) | 321 if (compositionRange.isNull()) |
| 320 return false; | 322 return false; |
| 321 int textStart = compositionRange.start(); | 323 int textStart = compositionRange.start(); |
| 322 | 324 |
| 323 if (!replaceComposition(text)) | 325 if (!replaceComposition(text)) |
| 324 return false; | 326 return false; |
| 325 | 327 |
| 326 int absoluteCaretPosition = computeAbsoluteCaretPosition( | 328 int absoluteCaretPosition = computeAbsoluteCaretPosition( |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 return WebTextInputTypeNone; | 1192 return WebTextInputTypeNone; |
| 1191 } | 1193 } |
| 1192 | 1194 |
| 1193 DEFINE_TRACE(InputMethodController) { | 1195 DEFINE_TRACE(InputMethodController) { |
| 1194 visitor->trace(m_frame); | 1196 visitor->trace(m_frame); |
| 1195 visitor->trace(m_compositionRange); | 1197 visitor->trace(m_compositionRange); |
| 1196 SynchronousMutationObserver::trace(visitor); | 1198 SynchronousMutationObserver::trace(visitor); |
| 1197 } | 1199 } |
| 1198 | 1200 |
| 1199 } // namespace blink | 1201 } // namespace blink |
| OLD | NEW |