| 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 23 matching lines...) Expand all Loading... |
| 34 #include "platform/heap/Handle.h" | 34 #include "platform/heap/Handle.h" |
| 35 #include "wtf/Vector.h" | 35 #include "wtf/Vector.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 class Editor; | 39 class Editor; |
| 40 class LocalFrame; | 40 class LocalFrame; |
| 41 class Range; | 41 class Range; |
| 42 class Text; | 42 class Text; |
| 43 | 43 |
| 44 class CORE_EXPORT InputMethodController final : public NoBaseWillBeGarbageCollec
tedFinalized<InputMethodController> { | 44 class CORE_EXPORT InputMethodController final : public GarbageCollectedFinalized
<InputMethodController> { |
| 45 USING_FAST_MALLOC_WILL_BE_REMOVED(InputMethodController); | |
| 46 WTF_MAKE_NONCOPYABLE(InputMethodController); | 45 WTF_MAKE_NONCOPYABLE(InputMethodController); |
| 47 public: | 46 public: |
| 48 enum ConfirmCompositionBehavior { | 47 enum ConfirmCompositionBehavior { |
| 49 DoNotKeepSelection, | 48 DoNotKeepSelection, |
| 50 KeepSelection, | 49 KeepSelection, |
| 51 }; | 50 }; |
| 52 | 51 |
| 53 static PassOwnPtrWillBeRawPtr<InputMethodController> create(LocalFrame&); | 52 static RawPtr<InputMethodController> create(LocalFrame&); |
| 54 ~InputMethodController(); | 53 ~InputMethodController(); |
| 55 DECLARE_TRACE(); | 54 DECLARE_TRACE(); |
| 56 | 55 |
| 57 // international text input composition | 56 // international text input composition |
| 58 bool hasComposition() const; | 57 bool hasComposition() const; |
| 59 void setComposition(const String&, const Vector<CompositionUnderline>&, unsi
gned selectionStart, unsigned selectionEnd); | 58 void setComposition(const String&, const Vector<CompositionUnderline>&, unsi
gned selectionStart, unsigned selectionEnd); |
| 60 void setCompositionFromExistingText(const Vector<CompositionUnderline>&, uns
igned compositionStart, unsigned compositionEnd); | 59 void setCompositionFromExistingText(const Vector<CompositionUnderline>&, uns
igned compositionStart, unsigned compositionEnd); |
| 61 // Inserts the text that is being composed as a regular text and returns tru
e | 60 // Inserts the text that is being composed as a regular text and returns tru
e |
| 62 // if composition exists. | 61 // if composition exists. |
| 63 bool confirmComposition(); | 62 bool confirmComposition(); |
| 64 // Inserts the given text string in the place of the existing composition | 63 // Inserts the given text string in the place of the existing composition |
| 65 // and returns true. | 64 // and returns true. |
| 66 bool confirmComposition(const String& text); | 65 bool confirmComposition(const String& text); |
| 67 // Inserts the text that is being composed or specified non-empty text and | 66 // Inserts the text that is being composed or specified non-empty text and |
| 68 // returns true. | 67 // returns true. |
| 69 bool confirmCompositionOrInsertText(const String& text, ConfirmCompositionBe
havior); | 68 bool confirmCompositionOrInsertText(const String& text, ConfirmCompositionBe
havior); |
| 70 // Deletes the existing composition text. | 69 // Deletes the existing composition text. |
| 71 void cancelComposition(); | 70 void cancelComposition(); |
| 72 void cancelCompositionIfSelectionIsInvalid(); | 71 void cancelCompositionIfSelectionIsInvalid(); |
| 73 EphemeralRange compositionEphemeralRange() const; | 72 EphemeralRange compositionEphemeralRange() const; |
| 74 PassRefPtrWillBeRawPtr<Range> compositionRange() const; | 73 RawPtr<Range> compositionRange() const; |
| 75 | 74 |
| 76 void clear(); | 75 void clear(); |
| 77 void documentDetached(); | 76 void documentDetached(); |
| 78 | 77 |
| 79 PlainTextRange getSelectionOffsets() const; | 78 PlainTextRange getSelectionOffsets() const; |
| 80 // Returns true if setting selection to specified offsets, otherwise false. | 79 // Returns true if setting selection to specified offsets, otherwise false. |
| 81 bool setEditableSelectionOffsets(const PlainTextRange&); | 80 bool setEditableSelectionOffsets(const PlainTextRange&); |
| 82 void extendSelectionAndDelete(int before, int after); | 81 void extendSelectionAndDelete(int before, int after); |
| 83 | 82 |
| 84 private: | 83 private: |
| 85 class SelectionOffsetsScope { | 84 class SelectionOffsetsScope { |
| 86 WTF_MAKE_NONCOPYABLE(SelectionOffsetsScope); | 85 WTF_MAKE_NONCOPYABLE(SelectionOffsetsScope); |
| 87 STACK_ALLOCATED(); | 86 STACK_ALLOCATED(); |
| 88 public: | 87 public: |
| 89 explicit SelectionOffsetsScope(InputMethodController*); | 88 explicit SelectionOffsetsScope(InputMethodController*); |
| 90 ~SelectionOffsetsScope(); | 89 ~SelectionOffsetsScope(); |
| 91 private: | 90 private: |
| 92 RawPtrWillBeMember<InputMethodController> m_inputMethodController; | 91 Member<InputMethodController> m_inputMethodController; |
| 93 const PlainTextRange m_offsets; | 92 const PlainTextRange m_offsets; |
| 94 }; | 93 }; |
| 95 friend class SelectionOffsetsScope; | 94 friend class SelectionOffsetsScope; |
| 96 | 95 |
| 97 RawPtrWillBeMember<LocalFrame> m_frame; | 96 Member<LocalFrame> m_frame; |
| 98 RefPtrWillBeMember<Range> m_compositionRange; | 97 Member<Range> m_compositionRange; |
| 99 bool m_isDirty; | 98 bool m_isDirty; |
| 100 bool m_hasComposition; | 99 bool m_hasComposition; |
| 101 | 100 |
| 102 explicit InputMethodController(LocalFrame&); | 101 explicit InputMethodController(LocalFrame&); |
| 103 | 102 |
| 104 Editor& editor() const; | 103 Editor& editor() const; |
| 105 LocalFrame& frame() const | 104 LocalFrame& frame() const |
| 106 { | 105 { |
| 107 ASSERT(m_frame); | 106 ASSERT(m_frame); |
| 108 return *m_frame; | 107 return *m_frame; |
| 109 } | 108 } |
| 110 | 109 |
| 111 String composingText() const; | 110 String composingText() const; |
| 112 bool insertTextForConfirmedComposition(const String& text); | 111 bool insertTextForConfirmedComposition(const String& text); |
| 113 void selectComposition() const; | 112 void selectComposition() const; |
| 114 bool setSelectionOffsets(const PlainTextRange&); | 113 bool setSelectionOffsets(const PlainTextRange&); |
| 115 }; | 114 }; |
| 116 | 115 |
| 117 } // namespace blink | 116 } // namespace blink |
| 118 | 117 |
| 119 #endif // InputMethodController_h | 118 #endif // InputMethodController_h |
| OLD | NEW |