| 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 17 matching lines...) Expand all Loading... |
| 28 #include "sky/engine/core/editing/InputMethodController.h" | 28 #include "sky/engine/core/editing/InputMethodController.h" |
| 29 | 29 |
| 30 #include "sky/engine/core/dom/Document.h" | 30 #include "sky/engine/core/dom/Document.h" |
| 31 #include "sky/engine/core/dom/Element.h" | 31 #include "sky/engine/core/dom/Element.h" |
| 32 #include "sky/engine/core/dom/Range.h" | 32 #include "sky/engine/core/dom/Range.h" |
| 33 #include "sky/engine/core/dom/Text.h" | 33 #include "sky/engine/core/dom/Text.h" |
| 34 #include "sky/engine/core/editing/Editor.h" | 34 #include "sky/engine/core/editing/Editor.h" |
| 35 #include "sky/engine/core/editing/TypingCommand.h" | 35 #include "sky/engine/core/editing/TypingCommand.h" |
| 36 #include "sky/engine/core/events/CompositionEvent.h" | 36 #include "sky/engine/core/events/CompositionEvent.h" |
| 37 #include "sky/engine/core/frame/LocalFrame.h" | 37 #include "sky/engine/core/frame/LocalFrame.h" |
| 38 #include "sky/engine/core/page/Chrome.h" | |
| 39 #include "sky/engine/core/page/ChromeClient.h" | 38 #include "sky/engine/core/page/ChromeClient.h" |
| 40 #include "sky/engine/core/page/EventHandler.h" | 39 #include "sky/engine/core/page/EventHandler.h" |
| 41 #include "sky/engine/core/rendering/RenderObject.h" | 40 #include "sky/engine/core/rendering/RenderObject.h" |
| 42 | 41 |
| 43 namespace blink { | 42 namespace blink { |
| 44 | 43 |
| 45 InputMethodController::SelectionOffsetsScope::SelectionOffsetsScope(InputMethodC
ontroller* inputMethodController) | 44 InputMethodController::SelectionOffsetsScope::SelectionOffsetsScope(InputMethodC
ontroller* inputMethodController) |
| 46 : m_inputMethodController(inputMethodController) | 45 : m_inputMethodController(inputMethodController) |
| 47 , m_offsets(inputMethodController->getSelectionOffsets()) | 46 , m_offsets(inputMethodController->getSelectionOffsets()) |
| 48 { | 47 { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 132 |
| 134 if (confirmBehavior != KeepSelection) | 133 if (confirmBehavior != KeepSelection) |
| 135 return confirmComposition(); | 134 return confirmComposition(); |
| 136 | 135 |
| 137 SelectionOffsetsScope selectionOffsetsScope(this); | 136 SelectionOffsetsScope selectionOffsetsScope(this); |
| 138 return confirmComposition(); | 137 return confirmComposition(); |
| 139 } | 138 } |
| 140 | 139 |
| 141 void InputMethodController::confirmCompositionAndResetState() | 140 void InputMethodController::confirmCompositionAndResetState() |
| 142 { | 141 { |
| 143 if (!hasComposition()) | 142 // TODO(esprehn): Remove this. |
| 144 return; | |
| 145 | |
| 146 // ChromeClient::willSetInputMethodState() resets input method and the compo
sition string is committed. | |
| 147 m_frame.chromeClient().willSetInputMethodState(); | |
| 148 } | 143 } |
| 149 | 144 |
| 150 void InputMethodController::cancelComposition() | 145 void InputMethodController::cancelComposition() |
| 151 { | 146 { |
| 152 finishComposition(emptyString(), CancelComposition); | 147 finishComposition(emptyString(), CancelComposition); |
| 153 } | 148 } |
| 154 | 149 |
| 155 void InputMethodController::cancelCompositionIfSelectionIsInvalid() | 150 void InputMethodController::cancelCompositionIfSelectionIsInvalid() |
| 156 { | 151 { |
| 157 if (!hasComposition() || editor().preventRevealSelection()) | 152 if (!hasComposition() || editor().preventRevealSelection()) |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 if (!setSelectionOffsets(PlainTextRange(std::max(static_cast<int>(select
ionOffsets.start()) - before, 0), selectionOffsets.end() + after))) | 418 if (!setSelectionOffsets(PlainTextRange(std::max(static_cast<int>(select
ionOffsets.start()) - before, 0), selectionOffsets.end() + after))) |
| 424 return; | 419 return; |
| 425 if (before == 0) | 420 if (before == 0) |
| 426 break; | 421 break; |
| 427 ++before; | 422 ++before; |
| 428 } while (m_frame.selection().start() == m_frame.selection().end() && before
<= static_cast<int>(selectionOffsets.start())); | 423 } while (m_frame.selection().start() == m_frame.selection().end() && before
<= static_cast<int>(selectionOffsets.start())); |
| 429 TypingCommand::deleteSelection(*m_frame.document()); | 424 TypingCommand::deleteSelection(*m_frame.document()); |
| 430 } | 425 } |
| 431 | 426 |
| 432 } // namespace blink | 427 } // namespace blink |
| OLD | NEW |