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" |
30 #include "core/editing/CompositionUnderline.h" | 31 #include "core/editing/CompositionUnderline.h" |
31 #include "core/editing/EphemeralRange.h" | 32 #include "core/editing/EphemeralRange.h" |
32 #include "core/editing/PlainTextRange.h" | 33 #include "core/editing/PlainTextRange.h" |
33 #include "platform/heap/Handle.h" | 34 #include "platform/heap/Handle.h" |
34 #include "wtf/Vector.h" | 35 #include "wtf/Vector.h" |
35 | 36 |
36 namespace blink { | 37 namespace blink { |
37 | 38 |
38 class Editor; | 39 class Editor; |
39 class LocalFrame; | 40 class LocalFrame; |
(...skipping 25 matching lines...) Expand all Loading... |
65 bool confirmComposition(const String& text); | 66 bool confirmComposition(const String& text); |
66 // Inserts the text that is being composed or specified non-empty text and | 67 // Inserts the text that is being composed or specified non-empty text and |
67 // returns true. | 68 // returns true. |
68 bool confirmCompositionOrInsertText(const String& text, ConfirmCompositionBe
havior); | 69 bool confirmCompositionOrInsertText(const String& text, ConfirmCompositionBe
havior); |
69 // Deletes the existing composition text. | 70 // Deletes the existing composition text. |
70 void cancelComposition(); | 71 void cancelComposition(); |
71 void cancelCompositionIfSelectionIsInvalid(); | 72 void cancelCompositionIfSelectionIsInvalid(); |
72 EphemeralRange compositionEphemeralRange() const; | 73 EphemeralRange compositionEphemeralRange() const; |
73 PassRefPtrWillBeRawPtr<Range> compositionRange() const; | 74 PassRefPtrWillBeRawPtr<Range> compositionRange() const; |
74 | 75 |
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 | |
82 void clear(); | 76 void clear(); |
| 77 void documentDetached(); |
83 | 78 |
84 PlainTextRange getSelectionOffsets() const; | 79 PlainTextRange getSelectionOffsets() const; |
85 // Returns true if setting selection to specified offsets, otherwise false. | 80 // Returns true if setting selection to specified offsets, otherwise false. |
86 bool setEditableSelectionOffsets(const PlainTextRange&); | 81 bool setEditableSelectionOffsets(const PlainTextRange&); |
87 void extendSelectionAndDelete(int before, int after); | 82 void extendSelectionAndDelete(int before, int after); |
88 | 83 |
89 private: | 84 private: |
90 class SelectionOffsetsScope { | 85 class SelectionOffsetsScope { |
91 WTF_MAKE_NONCOPYABLE(SelectionOffsetsScope); | 86 WTF_MAKE_NONCOPYABLE(SelectionOffsetsScope); |
92 STACK_ALLOCATED(); | 87 STACK_ALLOCATED(); |
93 public: | 88 public: |
94 explicit SelectionOffsetsScope(InputMethodController*); | 89 explicit SelectionOffsetsScope(InputMethodController*); |
95 ~SelectionOffsetsScope(); | 90 ~SelectionOffsetsScope(); |
96 private: | 91 private: |
97 RawPtrWillBeMember<InputMethodController> m_inputMethodController; | 92 RawPtrWillBeMember<InputMethodController> m_inputMethodController; |
98 const PlainTextRange m_offsets; | 93 const PlainTextRange m_offsets; |
99 }; | 94 }; |
100 friend class SelectionOffsetsScope; | 95 friend class SelectionOffsetsScope; |
101 | 96 |
102 RawPtrWillBeMember<LocalFrame> m_frame; | 97 RawPtrWillBeMember<LocalFrame> m_frame; |
103 RefPtrWillBeMember<Text> m_compositionNode; | 98 RefPtrWillBeMember<Range> m_compositionRange; |
104 // We don't use PlainTextRange which is immutable, for composition range. | 99 bool m_isDirty; |
105 unsigned m_compositionStart; | 100 bool m_hasComposition; |
106 unsigned m_compositionEnd; | |
107 // startOffset and endOffset of CompositionUnderline are based on | |
108 // m_compositionNode. | |
109 Vector<CompositionUnderline> m_customCompositionUnderlines; | |
110 | 101 |
111 explicit InputMethodController(LocalFrame&); | 102 explicit InputMethodController(LocalFrame&); |
112 | 103 |
113 Editor& editor() const; | 104 Editor& editor() const; |
114 LocalFrame& frame() const | 105 LocalFrame& frame() const |
115 { | 106 { |
116 ASSERT(m_frame); | 107 ASSERT(m_frame); |
117 return *m_frame; | 108 return *m_frame; |
118 } | 109 } |
119 | 110 |
120 bool insertTextForConfirmedComposition(const String& text); | 111 bool insertTextForConfirmedComposition(const String& text); |
121 void selectComposition() const; | 112 void selectComposition() const; |
122 enum FinishCompositionMode { ConfirmComposition, CancelComposition }; | 113 enum FinishCompositionMode { ConfirmComposition, CancelComposition }; |
123 // Returns true if composition exists. | 114 // Returns true if composition exists. |
124 bool finishComposition(const String&, FinishCompositionMode); | 115 bool finishComposition(const String&, FinishCompositionMode); |
125 bool setSelectionOffsets(const PlainTextRange&); | 116 bool setSelectionOffsets(const PlainTextRange&); |
126 }; | 117 }; |
127 | 118 |
128 } // namespace blink | 119 } // namespace blink |
129 | 120 |
130 #endif // InputMethodController_h | 121 #endif // InputMethodController_h |
OLD | NEW |