OLD | NEW |
1 /* | 1 /* |
2 * This file is part of the DOM implementation for WebCore. | 2 * This file is part of the DOM implementation for WebCore. |
3 * | 3 * |
4 * Copyright (C) 2006 Apple Computer, Inc. | 4 * Copyright (C) 2006 Apple Computer, Inc. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 * | 20 * |
21 */ | 21 */ |
22 | 22 |
23 #ifndef DocumentMarker_h | 23 #ifndef DocumentMarker_h |
24 #define DocumentMarker_h | 24 #define DocumentMarker_h |
25 | 25 |
26 #include "core/CoreExport.h" | 26 #include "core/CoreExport.h" |
| 27 #include "platform/graphics/Color.h" |
27 #include "platform/heap/Handle.h" | 28 #include "platform/heap/Handle.h" |
28 #include "wtf/VectorTraits.h" | 29 #include "wtf/VectorTraits.h" |
29 #include "wtf/text/WTFString.h" | 30 #include "wtf/text/WTFString.h" |
30 | 31 |
31 namespace blink { | 32 namespace blink { |
32 | 33 |
33 class DocumentMarkerDetails; | 34 class DocumentMarkerDetails; |
34 | 35 |
35 // A range of a node within a document that is "marked", such as the range of a
misspelled word. | 36 // A range of a node within a document that is "marked", such as the range of a
misspelled word. |
36 // It optionally includes a description that could be displayed in the user inte
rface. | 37 // It optionally includes a description that could be displayed in the user inte
rface. |
37 // It also optionally includes a flag specifying whether the match is active, wh
ich is ignored | 38 // It also optionally includes a flag specifying whether the match is active, wh
ich is ignored |
38 // for all types other than type TextMatch. | 39 // for all types other than type TextMatch. |
39 class CORE_EXPORT DocumentMarker : public NoBaseWillBeGarbageCollected<DocumentM
arker> { | 40 class CORE_EXPORT DocumentMarker : public NoBaseWillBeGarbageCollected<DocumentM
arker> { |
40 public: | 41 public: |
41 enum MarkerTypeIndex { | 42 enum MarkerTypeIndex { |
42 SpellingMarkerIndex = 0, | 43 SpellingMarkerIndex = 0, |
43 GramarMarkerIndex, | 44 GramarMarkerIndex, |
44 TextMatchMarkerIndex, | 45 TextMatchMarkerIndex, |
45 InvisibleSpellcheckMarkerIndex, | 46 InvisibleSpellcheckMarkerIndex, |
| 47 CompositionMarkerIndex, |
46 MarkerTypeIndexesCount | 48 MarkerTypeIndexesCount |
47 }; | 49 }; |
48 | 50 |
49 enum MarkerType { | 51 enum MarkerType { |
50 Spelling = 1 << SpellingMarkerIndex, | 52 Spelling = 1 << SpellingMarkerIndex, |
51 Grammar = 1 << GramarMarkerIndex, | 53 Grammar = 1 << GramarMarkerIndex, |
52 TextMatch = 1 << TextMatchMarkerIndex, | 54 TextMatch = 1 << TextMatchMarkerIndex, |
53 InvisibleSpellcheck = 1 << InvisibleSpellcheckMarkerIndex | 55 InvisibleSpellcheck = 1 << InvisibleSpellcheckMarkerIndex, |
| 56 Composition = 1 << CompositionMarkerIndex, |
54 }; | 57 }; |
55 | 58 |
56 class MarkerTypes { | 59 class MarkerTypes { |
57 public: | 60 public: |
58 // The constructor is intentionally implicit to allow conversion from th
e bit-wise sum of above types | 61 // The constructor is intentionally implicit to allow conversion from th
e bit-wise sum of above types |
59 MarkerTypes(unsigned mask) : m_mask(mask) { } | 62 MarkerTypes(unsigned mask) : m_mask(mask) { } |
60 | 63 |
61 bool contains(MarkerType type) const { return m_mask & type; } | 64 bool contains(MarkerType type) const { return m_mask & type; } |
62 bool intersects(const MarkerTypes& types) const { return (m_mask & types
.m_mask); } | 65 bool intersects(const MarkerTypes& types) const { return (m_mask & types
.m_mask); } |
63 bool operator==(const MarkerTypes& other) const { return m_mask == other
.m_mask; } | 66 bool operator==(const MarkerTypes& other) const { return m_mask == other
.m_mask; } |
64 | 67 |
65 void add(const MarkerTypes& types) { m_mask |= types.m_mask; } | 68 void add(const MarkerTypes& types) { m_mask |= types.m_mask; } |
66 void remove(const MarkerTypes& types) { m_mask &= ~types.m_mask; } | 69 void remove(const MarkerTypes& types) { m_mask &= ~types.m_mask; } |
67 | 70 |
68 private: | 71 private: |
69 unsigned m_mask; | 72 unsigned m_mask; |
70 }; | 73 }; |
71 | 74 |
72 class AllMarkers : public MarkerTypes { | 75 class AllMarkers : public MarkerTypes { |
73 public: | 76 public: |
74 AllMarkers() | 77 AllMarkers() |
75 : MarkerTypes(Spelling | Grammar | TextMatch | InvisibleSpellcheck) | 78 : MarkerTypes(Spelling | Grammar | TextMatch | InvisibleSpellcheck |
Composition) |
76 { | 79 { |
77 } | 80 } |
78 }; | 81 }; |
79 | 82 |
80 class MisspellingMarkers : public MarkerTypes { | 83 class MisspellingMarkers : public MarkerTypes { |
81 public: | 84 public: |
82 MisspellingMarkers() | 85 MisspellingMarkers() |
83 : MarkerTypes(Spelling | Grammar) | 86 : MarkerTypes(Spelling | Grammar) |
84 { | 87 { |
85 } | 88 } |
86 }; | 89 }; |
87 | 90 |
88 class SpellCheckClientMarkers : public MarkerTypes { | 91 class SpellCheckClientMarkers : public MarkerTypes { |
89 public: | 92 public: |
90 SpellCheckClientMarkers() | 93 SpellCheckClientMarkers() |
91 : MarkerTypes(Spelling | Grammar | InvisibleSpellcheck) | 94 : MarkerTypes(Spelling | Grammar | InvisibleSpellcheck) |
92 { | 95 { |
93 } | 96 } |
94 }; | 97 }; |
95 | 98 |
96 DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, const S
tring& description, uint32_t hash); | 99 DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, const S
tring& description, uint32_t hash); |
97 DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch); | 100 DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch); |
| 101 DocumentMarker(unsigned startOffset, unsigned endOffset, Color underlineColo
r, bool thick, Color backgroundColor); |
| 102 |
98 DocumentMarker(const DocumentMarker&); | 103 DocumentMarker(const DocumentMarker&); |
99 | 104 |
100 MarkerType type() const { return m_type; } | 105 MarkerType type() const { return m_type; } |
101 unsigned startOffset() const { return m_startOffset; } | 106 unsigned startOffset() const { return m_startOffset; } |
102 unsigned endOffset() const { return m_endOffset; } | 107 unsigned endOffset() const { return m_endOffset; } |
103 uint32_t hash() const { return m_hash; } | 108 uint32_t hash() const { return m_hash; } |
104 | 109 |
105 const String& description() const; | 110 const String& description() const; |
106 bool activeMatch() const; | 111 bool activeMatch() const; |
| 112 Color underlineColor() const; |
| 113 bool thick() const; |
| 114 Color backgroundColor() const; |
107 DocumentMarkerDetails* details() const; | 115 DocumentMarkerDetails* details() const; |
108 | 116 |
109 void setActiveMatch(bool); | 117 void setActiveMatch(bool); |
110 void clearDetails() { m_details.clear(); } | 118 void clearDetails() { m_details.clear(); } |
111 | 119 |
112 // Offset modifications are done by DocumentMarkerController. | 120 // Offset modifications are done by DocumentMarkerController. |
113 // Other classes should not call following setters. | 121 // Other classes should not call following setters. |
114 void setStartOffset(unsigned offset) { m_startOffset = offset; } | 122 void setStartOffset(unsigned offset) { m_startOffset = offset; } |
115 void setEndOffset(unsigned offset) { m_endOffset = offset; } | 123 void setEndOffset(unsigned offset) { m_endOffset = offset; } |
116 void shiftOffsets(int delta); | 124 void shiftOffsets(int delta); |
(...skipping 24 matching lines...) Expand all Loading... |
141 { | 149 { |
142 return m_details.get(); | 150 return m_details.get(); |
143 } | 151 } |
144 | 152 |
145 class DocumentMarkerDetails : public RefCountedWillBeGarbageCollectedFinalized<D
ocumentMarkerDetails> { | 153 class DocumentMarkerDetails : public RefCountedWillBeGarbageCollectedFinalized<D
ocumentMarkerDetails> { |
146 public: | 154 public: |
147 DocumentMarkerDetails() { } | 155 DocumentMarkerDetails() { } |
148 virtual ~DocumentMarkerDetails(); | 156 virtual ~DocumentMarkerDetails(); |
149 virtual bool isDescription() const { return false; } | 157 virtual bool isDescription() const { return false; } |
150 virtual bool isTextMatch() const { return false; } | 158 virtual bool isTextMatch() const { return false; } |
| 159 virtual bool isComposition() const { return false; } |
151 | 160 |
152 DEFINE_INLINE_VIRTUAL_TRACE() { } | 161 DEFINE_INLINE_VIRTUAL_TRACE() { } |
153 }; | 162 }; |
154 | 163 |
155 } // namespace blink | 164 } // namespace blink |
156 | 165 |
157 #endif // DocumentMarker_h | 166 #endif // DocumentMarker_h |
OLD | NEW |