| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "core/CoreExport.h" | 29 #include "core/CoreExport.h" |
| 30 #include "core/dom/Range.h" | 30 #include "core/dom/Range.h" |
| 31 #include "core/dom/SynchronousMutationObserver.h" | 31 #include "core/dom/SynchronousMutationObserver.h" |
| 32 #include "core/editing/CompositionUnderline.h" | 32 #include "core/editing/CompositionUnderline.h" |
| 33 #include "core/editing/EphemeralRange.h" | 33 #include "core/editing/EphemeralRange.h" |
| 34 #include "core/editing/FrameSelection.h" | 34 #include "core/editing/FrameSelection.h" |
| 35 #include "core/editing/PlainTextRange.h" | 35 #include "core/editing/PlainTextRange.h" |
| 36 #include "platform/heap/Handle.h" | 36 #include "platform/heap/Handle.h" |
| 37 #include "public/platform/WebTextInputInfo.h" | 37 #include "public/platform/WebTextInputInfo.h" |
| 38 #include "public/platform/WebTextInputType.h" | 38 #include "public/platform/WebTextInputType.h" |
| 39 #include "public/web/WebTextSuggestionInfo.h" |
| 39 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 class Editor; | 44 class Editor; |
| 44 class LocalFrame; | 45 class LocalFrame; |
| 45 class Range; | 46 class Range; |
| 46 | 47 |
| 47 class CORE_EXPORT InputMethodController final | 48 class CORE_EXPORT InputMethodController final |
| 48 : public GarbageCollectedFinalized<InputMethodController>, | 49 : public GarbageCollectedFinalized<InputMethodController>, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 75 // relative to the end of the inserting text. | 76 // relative to the end of the inserting text. |
| 76 bool commitText(const String& text, | 77 bool commitText(const String& text, |
| 77 const Vector<CompositionUnderline>& underlines, | 78 const Vector<CompositionUnderline>& underlines, |
| 78 int relativeCaretPosition); | 79 int relativeCaretPosition); |
| 79 | 80 |
| 80 // Inserts ongoing composing text; changes the selection to the end of | 81 // Inserts ongoing composing text; changes the selection to the end of |
| 81 // the inserting text if DoNotKeepSelection, or holds the selection if | 82 // the inserting text if DoNotKeepSelection, or holds the selection if |
| 82 // KeepSelection. | 83 // KeepSelection. |
| 83 bool finishComposingText(ConfirmCompositionBehavior); | 84 bool finishComposingText(ConfirmCompositionBehavior); |
| 84 | 85 |
| 86 void applySuggestionReplacement(int documentMarkerID, int suggestionIndex); |
| 87 void deleteSuggestionHighlight(); |
| 88 void closeSuggestionMenu(); |
| 89 |
| 85 // Deletes the existing composition text. | 90 // Deletes the existing composition text. |
| 86 void cancelComposition(); | 91 void cancelComposition(); |
| 87 | 92 |
| 88 void cancelCompositionIfSelectionIsInvalid(); | 93 void cancelCompositionIfSelectionIsInvalid(); |
| 89 EphemeralRange compositionEphemeralRange() const; | 94 EphemeralRange compositionEphemeralRange() const; |
| 90 Range* compositionRange() const; | 95 Range* compositionRange() const; |
| 91 | 96 |
| 92 void clear(); | 97 void clear(); |
| 93 void documentAttached(Document*); | 98 void documentAttached(Document*); |
| 94 | 99 |
| 95 PlainTextRange getSelectionOffsets() const; | 100 PlainTextRange getSelectionOffsets() const; |
| 96 // Returns true if setting selection to specified offsets, otherwise false. | 101 // Returns true if setting selection to specified offsets, otherwise false. |
| 97 bool setEditableSelectionOffsets( | 102 bool setEditableSelectionOffsets( |
| 98 const PlainTextRange&, | 103 const PlainTextRange&, |
| 99 FrameSelection::SetSelectionOptions = FrameSelection::CloseTyping); | 104 FrameSelection::SetSelectionOptions = FrameSelection::CloseTyping); |
| 100 void extendSelectionAndDelete(int before, int after); | 105 void extendSelectionAndDelete(int before, int after); |
| 101 PlainTextRange createRangeForSelection(int start, | 106 PlainTextRange createRangeForSelection(int start, |
| 102 int end, | 107 int end, |
| 103 size_t textLength) const; | 108 size_t textLength) const; |
| 104 void deleteSurroundingText(int before, int after); | 109 void deleteSurroundingText(int before, int after); |
| 105 WebTextInputInfo textInputInfo() const; | 110 WebTextInputInfo textInputInfo() const; |
| 106 WebTextInputType textInputType() const; | 111 WebTextInputType textInputType() const; |
| 112 WebVector<blink::WebTextSuggestionInfo> getTextSuggestionInfosUnderCaret() |
| 113 const; |
| 114 void prepareForTextSuggestionMenuToBeShown(); |
| 107 | 115 |
| 108 // Call this when we will change focus. | 116 // Call this when we will change focus. |
| 109 void willChangeFocus(); | 117 void willChangeFocus(); |
| 110 | 118 |
| 111 private: | 119 private: |
| 112 Document& document() const; | 120 Document& document() const; |
| 113 bool isAvailable() const; | 121 bool isAvailable() const; |
| 114 | 122 |
| 115 Member<LocalFrame> m_frame; | 123 Member<LocalFrame> m_frame; |
| 116 Member<Range> m_compositionRange; | 124 Member<Range> m_compositionRange; |
| 117 bool m_hasComposition; | 125 bool m_hasComposition; |
| 118 | 126 |
| 119 explicit InputMethodController(LocalFrame&); | 127 explicit InputMethodController(LocalFrame&); |
| 120 | 128 |
| 121 Editor& editor() const; | 129 Editor& editor() const; |
| 122 LocalFrame& frame() const { | 130 LocalFrame& frame() const { |
| 123 DCHECK(m_frame); | 131 DCHECK(m_frame); |
| 124 return *m_frame; | 132 return *m_frame; |
| 125 } | 133 } |
| 126 | 134 |
| 127 String composingText() const; | 135 String composingText() const; |
| 128 void selectComposition() const; | 136 void selectComposition() const; |
| 129 bool setSelectionOffsets( | 137 bool setSelectionOffsets( |
| 130 const PlainTextRange&, | 138 const PlainTextRange&, |
| 131 FrameSelection::SetSelectionOptions = FrameSelection::CloseTyping); | 139 FrameSelection::SetSelectionOptions = FrameSelection::CloseTyping); |
| 132 | 140 |
| 133 void addCompositionUnderlines(const Vector<CompositionUnderline>& underlines, | 141 void addCompositionUnderlines(const Vector<CompositionUnderline>& underlines, |
| 134 ContainerNode* rootEditableElement, | 142 ContainerNode* rootEditableElement, |
| 135 unsigned offset); | 143 unsigned offset); |
| 144 void clearSuggestionMarkersTouchingSelection(); |
| 136 | 145 |
| 137 bool insertText(const String&); | 146 bool insertText(const String&); |
| 138 bool insertTextAndMoveCaret(const String&, | 147 bool insertTextAndMoveCaret(const String&, |
| 139 int relativeCaretPosition, | 148 int relativeCaretPosition, |
| 140 const Vector<CompositionUnderline>& underlines); | 149 const Vector<CompositionUnderline>& underlines); |
| 141 | 150 |
| 142 // Inserts the given text string in the place of the existing composition. | 151 // Inserts the given text string in the place of the existing composition. |
| 143 // Returns true if did replace. | 152 // Returns true if did replace. |
| 144 bool replaceComposition(const String& text); | 153 bool replaceComposition(const String& text); |
| 145 // Inserts the given text string in the place of the existing composition | 154 // Inserts the given text string in the place of the existing composition |
| (...skipping 12 matching lines...) Expand all Loading... |
| 158 int textInputFlags() const; | 167 int textInputFlags() const; |
| 159 WebTextInputMode inputModeOfFocusedElement() const; | 168 WebTextInputMode inputModeOfFocusedElement() const; |
| 160 | 169 |
| 161 // Implements |SynchronousMutationObserver|. | 170 // Implements |SynchronousMutationObserver|. |
| 162 void contextDestroyed(Document*) final; | 171 void contextDestroyed(Document*) final; |
| 163 }; | 172 }; |
| 164 | 173 |
| 165 } // namespace blink | 174 } // namespace blink |
| 166 | 175 |
| 167 #endif // InputMethodController_h | 176 #endif // InputMethodController_h |
| OLD | NEW |