Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: Source/core/editing/InputMethodController.h

Issue 1325563002: Avoid style clobbering in setCompositionFromExistingText. (2nd land) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Delete CompositionUnderlinesRangeFilter (it's now dead code) Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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();
83 77
84 PlainTextRange getSelectionOffsets() const; 78 PlainTextRange getSelectionOffsets() const;
85 // Returns true if setting selection to specified offsets, otherwise false. 79 // Returns true if setting selection to specified offsets, otherwise false.
86 bool setEditableSelectionOffsets(const PlainTextRange&); 80 bool setEditableSelectionOffsets(const PlainTextRange&);
87 void extendSelectionAndDelete(int before, int after); 81 void extendSelectionAndDelete(int before, int after);
88 82
89 private: 83 private:
90 class SelectionOffsetsScope { 84 class SelectionOffsetsScope {
91 WTF_MAKE_NONCOPYABLE(SelectionOffsetsScope); 85 WTF_MAKE_NONCOPYABLE(SelectionOffsetsScope);
92 STACK_ALLOCATED(); 86 STACK_ALLOCATED();
93 public: 87 public:
94 explicit SelectionOffsetsScope(InputMethodController*); 88 explicit SelectionOffsetsScope(InputMethodController*);
95 ~SelectionOffsetsScope(); 89 ~SelectionOffsetsScope();
96 private: 90 private:
97 RawPtrWillBeMember<InputMethodController> m_inputMethodController; 91 RawPtrWillBeMember<InputMethodController> m_inputMethodController;
98 const PlainTextRange m_offsets; 92 const PlainTextRange m_offsets;
99 }; 93 };
100 friend class SelectionOffsetsScope; 94 friend class SelectionOffsetsScope;
101 95
102 RawPtrWillBeMember<LocalFrame> m_frame; 96 RawPtrWillBeMember<LocalFrame> m_frame;
103 RefPtrWillBeMember<Text> m_compositionNode; 97 RefPtrWillBeMember<Range> m_compositionRange;
104 // We don't use PlainTextRange which is immutable, for composition range. 98 bool m_isDirty;
105 unsigned m_compositionStart; 99 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 100
111 explicit InputMethodController(LocalFrame&); 101 explicit InputMethodController(LocalFrame&);
112 102
113 Editor& editor() const; 103 Editor& editor() const;
114 LocalFrame& frame() const 104 LocalFrame& frame() const
115 { 105 {
116 ASSERT(m_frame); 106 ASSERT(m_frame);
117 return *m_frame; 107 return *m_frame;
118 } 108 }
119 109
120 bool insertTextForConfirmedComposition(const String& text); 110 bool insertTextForConfirmedComposition(const String& text);
121 void selectComposition() const; 111 void selectComposition() const;
122 enum FinishCompositionMode { ConfirmComposition, CancelComposition }; 112 enum FinishCompositionMode { ConfirmComposition, CancelComposition };
123 // Returns true if composition exists. 113 // Returns true if composition exists.
124 bool finishComposition(const String&, FinishCompositionMode); 114 bool finishComposition(const String&, FinishCompositionMode);
125 bool setSelectionOffsets(const PlainTextRange&); 115 bool setSelectionOffsets(const PlainTextRange&);
126 }; 116 };
127 117
128 } // namespace blink 118 } // namespace blink
129 119
130 #endif // InputMethodController_h 120 #endif // InputMethodController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698