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 |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
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/CoreExport.h" | 29 #include "core/CoreExport.h" |
30 #include "core/dom/Range.h" | |
31 #include "core/editing/CompositionUnderline.h" | 30 #include "core/editing/CompositionUnderline.h" |
32 #include "core/editing/EphemeralRange.h" | 31 #include "core/editing/EphemeralRange.h" |
33 #include "core/editing/PlainTextRange.h" | 32 #include "core/editing/PlainTextRange.h" |
34 #include "platform/heap/Handle.h" | 33 #include "platform/heap/Handle.h" |
35 #include "wtf/Vector.h" | 34 #include "wtf/Vector.h" |
36 | 35 |
37 namespace blink { | 36 namespace blink { |
38 | 37 |
39 class Editor; | 38 class Editor; |
40 class LocalFrame; | 39 class LocalFrame; |
(...skipping 25 matching lines...) Expand all Loading... |
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 PassRefPtrWillBeRawPtr<Range> compositionRange() const; |
75 | 74 |
| 75 // getting international text input composition state (for use by InlineText
Box) |
| 76 Text* compositionNode() const { return m_compositionNode.get(); } |
| 77 unsigned compositionStart() const { return m_compositionStart; } |
| 78 unsigned compositionEnd() const { return m_compositionEnd; } |
| 79 bool compositionUsesCustomUnderlines() const { return !m_customCompositionUn
derlines.isEmpty(); } |
| 80 const Vector<CompositionUnderline>& customCompositionUnderlines() const { re
turn m_customCompositionUnderlines; } |
| 81 |
76 void clear(); | 82 void clear(); |
77 | 83 |
78 PlainTextRange getSelectionOffsets() const; | 84 PlainTextRange getSelectionOffsets() const; |
79 // Returns true if setting selection to specified offsets, otherwise false. | 85 // Returns true if setting selection to specified offsets, otherwise false. |
80 bool setEditableSelectionOffsets(const PlainTextRange&); | 86 bool setEditableSelectionOffsets(const PlainTextRange&); |
81 void extendSelectionAndDelete(int before, int after); | 87 void extendSelectionAndDelete(int before, int after); |
82 | 88 |
83 private: | 89 private: |
84 class SelectionOffsetsScope { | 90 class SelectionOffsetsScope { |
85 WTF_MAKE_NONCOPYABLE(SelectionOffsetsScope); | 91 WTF_MAKE_NONCOPYABLE(SelectionOffsetsScope); |
86 STACK_ALLOCATED(); | 92 STACK_ALLOCATED(); |
87 public: | 93 public: |
88 explicit SelectionOffsetsScope(InputMethodController*); | 94 explicit SelectionOffsetsScope(InputMethodController*); |
89 ~SelectionOffsetsScope(); | 95 ~SelectionOffsetsScope(); |
90 private: | 96 private: |
91 RawPtrWillBeMember<InputMethodController> m_inputMethodController; | 97 RawPtrWillBeMember<InputMethodController> m_inputMethodController; |
92 const PlainTextRange m_offsets; | 98 const PlainTextRange m_offsets; |
93 }; | 99 }; |
94 friend class SelectionOffsetsScope; | 100 friend class SelectionOffsetsScope; |
95 | 101 |
96 RawPtrWillBeMember<LocalFrame> m_frame; | 102 RawPtrWillBeMember<LocalFrame> m_frame; |
97 RefPtrWillBeMember<Range> m_compositionRange; | 103 RefPtrWillBeMember<Text> m_compositionNode; |
98 bool m_isDirty; | 104 // We don't use PlainTextRange which is immutable, for composition range. |
99 bool m_hasComposition; | 105 unsigned m_compositionStart; |
| 106 unsigned m_compositionEnd; |
| 107 // startOffset and endOffset of CompositionUnderline are based on |
| 108 // m_compositionNode. |
| 109 Vector<CompositionUnderline> m_customCompositionUnderlines; |
100 | 110 |
101 explicit InputMethodController(LocalFrame&); | 111 explicit InputMethodController(LocalFrame&); |
102 | 112 |
103 Editor& editor() const; | 113 Editor& editor() const; |
104 LocalFrame& frame() const | 114 LocalFrame& frame() const |
105 { | 115 { |
106 ASSERT(m_frame); | 116 ASSERT(m_frame); |
107 return *m_frame; | 117 return *m_frame; |
108 } | 118 } |
109 | 119 |
110 bool insertTextForConfirmedComposition(const String& text); | 120 bool insertTextForConfirmedComposition(const String& text); |
111 void selectComposition() const; | 121 void selectComposition() const; |
112 enum FinishCompositionMode { ConfirmComposition, CancelComposition }; | 122 enum FinishCompositionMode { ConfirmComposition, CancelComposition }; |
113 // Returns true if composition exists. | 123 // Returns true if composition exists. |
114 bool finishComposition(const String&, FinishCompositionMode); | 124 bool finishComposition(const String&, FinishCompositionMode); |
115 bool setSelectionOffsets(const PlainTextRange&); | 125 bool setSelectionOffsets(const PlainTextRange&); |
116 }; | 126 }; |
117 | 127 |
118 } // namespace blink | 128 } // namespace blink |
119 | 129 |
120 #endif // InputMethodController_h | 130 #endif // InputMethodController_h |
OLD | NEW |