| 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 10 matching lines...) Expand all  Loading... | 
| 21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
| 22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
| 23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 24  */ | 24  */ | 
| 25 | 25 | 
| 26 #ifndef InputMethodController_h | 26 #ifndef InputMethodController_h | 
| 27 #define InputMethodController_h | 27 #define InputMethodController_h | 
| 28 | 28 | 
| 29 #include "core/editing/CompositionUnderline.h" | 29 #include "core/editing/CompositionUnderline.h" | 
| 30 #include "core/editing/PlainTextRange.h" | 30 #include "core/editing/PlainTextRange.h" | 
|  | 31 #include "platform/heap/Handle.h" | 
| 31 #include "wtf/Vector.h" | 32 #include "wtf/Vector.h" | 
| 32 | 33 | 
| 33 namespace blink { | 34 namespace blink { | 
| 34 | 35 | 
| 35 class Editor; | 36 class Editor; | 
| 36 class EditorClient; | 37 class EditorClient; | 
| 37 class LocalFrame; | 38 class LocalFrame; | 
| 38 class Range; | 39 class Range; | 
| 39 class Text; | 40 class Text; | 
| 40 | 41 | 
| 41 class InputMethodController { | 42 class InputMethodController FINAL : public NoBaseWillBeGarbageCollectedFinalized
     <InputMethodController> { | 
| 42     WTF_MAKE_NONCOPYABLE(InputMethodController); | 43     WTF_MAKE_NONCOPYABLE(InputMethodController); | 
| 43 public: | 44 public: | 
| 44     enum ConfirmCompositionBehavior { | 45     enum ConfirmCompositionBehavior { | 
| 45         DoNotKeepSelection, | 46         DoNotKeepSelection, | 
| 46         KeepSelection, | 47         KeepSelection, | 
| 47     }; | 48     }; | 
| 48 | 49 | 
| 49     static PassOwnPtr<InputMethodController> create(LocalFrame&); | 50     static PassOwnPtrWillBeRawPtr<InputMethodController> create(LocalFrame&); | 
| 50     ~InputMethodController(); | 51     ~InputMethodController(); | 
|  | 52     void trace(Visitor*); | 
| 51 | 53 | 
| 52     // international text input composition | 54     // international text input composition | 
| 53     bool hasComposition() const; | 55     bool hasComposition() const; | 
| 54     void setComposition(const String&, const Vector<CompositionUnderline>&, unsi
     gned selectionStart, unsigned selectionEnd); | 56     void setComposition(const String&, const Vector<CompositionUnderline>&, unsi
     gned selectionStart, unsigned selectionEnd); | 
| 55     void setCompositionFromExistingText(const Vector<CompositionUnderline>&, uns
     igned compositionStart, unsigned compositionEnd); | 57     void setCompositionFromExistingText(const Vector<CompositionUnderline>&, uns
     igned compositionStart, unsigned compositionEnd); | 
| 56     // Inserts the text that is being composed as a regular text and returns tru
     e | 58     // Inserts the text that is being composed as a regular text and returns tru
     e | 
| 57     // if composition exists. | 59     // if composition exists. | 
| 58     bool confirmComposition(); | 60     bool confirmComposition(); | 
| 59     // Inserts the given text string in the place of the existing composition | 61     // Inserts the given text string in the place of the existing composition | 
| 60     // and returns true. | 62     // and returns true. | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 87         WTF_MAKE_NONCOPYABLE(SelectionOffsetsScope); | 89         WTF_MAKE_NONCOPYABLE(SelectionOffsetsScope); | 
| 88     public: | 90     public: | 
| 89         SelectionOffsetsScope(InputMethodController*); | 91         SelectionOffsetsScope(InputMethodController*); | 
| 90         ~SelectionOffsetsScope(); | 92         ~SelectionOffsetsScope(); | 
| 91     private: | 93     private: | 
| 92         InputMethodController* m_inputMethodController; | 94         InputMethodController* m_inputMethodController; | 
| 93         const PlainTextRange m_offsets; | 95         const PlainTextRange m_offsets; | 
| 94     }; | 96     }; | 
| 95     friend class SelectionOffsetsScope; | 97     friend class SelectionOffsetsScope; | 
| 96 | 98 | 
| 97     LocalFrame& m_frame; | 99     RawPtrWillBeMember<LocalFrame> m_frame; | 
| 98     RefPtrWillBePersistent<Text> m_compositionNode; | 100     RefPtrWillBeMember<Text> m_compositionNode; | 
| 99     // We don't use PlainTextRange which is immutable, for composition range. | 101     // We don't use PlainTextRange which is immutable, for composition range. | 
| 100     unsigned m_compositionStart; | 102     unsigned m_compositionStart; | 
| 101     unsigned m_compositionEnd; | 103     unsigned m_compositionEnd; | 
| 102     // startOffset and endOffset of CompositionUnderline are based on | 104     // startOffset and endOffset of CompositionUnderline are based on | 
| 103     // m_compositionNode. | 105     // m_compositionNode. | 
| 104     Vector<CompositionUnderline> m_customCompositionUnderlines; | 106     Vector<CompositionUnderline> m_customCompositionUnderlines; | 
| 105 | 107 | 
| 106     explicit InputMethodController(LocalFrame&); | 108     explicit InputMethodController(LocalFrame&); | 
| 107     Editor& editor() const; | 109     Editor& editor() const; | 
| 108     bool insertTextForConfirmedComposition(const String& text); | 110     bool insertTextForConfirmedComposition(const String& text); | 
| 109     void selectComposition() const; | 111     void selectComposition() const; | 
| 110     enum FinishCompositionMode { ConfirmComposition, CancelComposition }; | 112     enum FinishCompositionMode { ConfirmComposition, CancelComposition }; | 
| 111     // Returns true if composition exists. | 113     // Returns true if composition exists. | 
| 112     bool finishComposition(const String&, FinishCompositionMode); | 114     bool finishComposition(const String&, FinishCompositionMode); | 
| 113     bool setSelectionOffsets(const PlainTextRange&); | 115     bool setSelectionOffsets(const PlainTextRange&); | 
| 114 }; | 116 }; | 
| 115 | 117 | 
| 116 } // namespace blink | 118 } // namespace blink | 
| 117 | 119 | 
| 118 #endif // InputMethodController_h | 120 #endif // InputMethodController_h | 
| OLD | NEW | 
|---|