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

Side by Side Diff: third_party/WebKit/Source/core/editing/markers/DocumentMarker.h

Issue 2650113004: [WIP] Add support for Android SuggestionSpans when editing text (Closed)
Patch Set: Created 3 years, 11 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 * 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 *
(...skipping 28 matching lines...) Expand all
39 // the match is active, which is ignored for all types other than type 39 // the match is active, which is ignored for all types other than type
40 // TextMatch. 40 // TextMatch.
41 class CORE_EXPORT DocumentMarker : public GarbageCollected<DocumentMarker> { 41 class CORE_EXPORT DocumentMarker : public GarbageCollected<DocumentMarker> {
42 public: 42 public:
43 enum MarkerTypeIndex { 43 enum MarkerTypeIndex {
44 SpellingMarkerIndex = 0, 44 SpellingMarkerIndex = 0,
45 GrammarMarkerIndex, 45 GrammarMarkerIndex,
46 TextMatchMarkerIndex, 46 TextMatchMarkerIndex,
47 InvisibleSpellcheckMarkerIndex, 47 InvisibleSpellcheckMarkerIndex,
48 CompositionMarkerIndex, 48 CompositionMarkerIndex,
49 SuggestionMarkerIndex,
50 SuggestionBackgroundHighlightMarkerIndex,
49 MarkerTypeIndexesCount 51 MarkerTypeIndexesCount
50 }; 52 };
51 53
52 enum MarkerType { 54 enum MarkerType {
53 Spelling = 1 << SpellingMarkerIndex, 55 Spelling = 1 << SpellingMarkerIndex,
54 Grammar = 1 << GrammarMarkerIndex, 56 Grammar = 1 << GrammarMarkerIndex,
55 TextMatch = 1 << TextMatchMarkerIndex, 57 TextMatch = 1 << TextMatchMarkerIndex,
56 InvisibleSpellcheck = 1 << InvisibleSpellcheckMarkerIndex, 58 InvisibleSpellcheck = 1 << InvisibleSpellcheckMarkerIndex,
57 Composition = 1 << CompositionMarkerIndex, 59 Composition = 1 << CompositionMarkerIndex,
60 Suggestion = 1 << SuggestionMarkerIndex,
61 SuggestionBackgroundHighlight = 1
rlanday 2017/01/25 18:48:10 lol @ git cl format...
62 << SuggestionBackgroundHighlightMarkerIndex,
58 }; 63 };
59 64
60 class MarkerTypes { 65 class MarkerTypes {
61 public: 66 public:
62 // The constructor is intentionally implicit to allow conversion from the 67 // The constructor is intentionally implicit to allow conversion from the
63 // bit-wise sum of above types 68 // bit-wise sum of above types
64 MarkerTypes(unsigned mask) : m_mask(mask) {} 69 MarkerTypes(unsigned mask) : m_mask(mask) {}
65 70
66 bool contains(MarkerType type) const { return m_mask & type; } 71 bool contains(MarkerType type) const { return m_mask & type; }
67 bool intersects(const MarkerTypes& types) const { 72 bool intersects(const MarkerTypes& types) const {
68 return (m_mask & types.m_mask); 73 return (m_mask & types.m_mask);
69 } 74 }
70 bool operator==(const MarkerTypes& other) const { 75 bool operator==(const MarkerTypes& other) const {
71 return m_mask == other.m_mask; 76 return m_mask == other.m_mask;
72 } 77 }
73 78
74 void add(const MarkerTypes& types) { m_mask |= types.m_mask; } 79 void add(const MarkerTypes& types) { m_mask |= types.m_mask; }
75 void remove(const MarkerTypes& types) { m_mask &= ~types.m_mask; } 80 void remove(const MarkerTypes& types) { m_mask &= ~types.m_mask; }
76 81
77 private: 82 private:
78 unsigned m_mask; 83 unsigned m_mask;
79 }; 84 };
80 85
81 class AllMarkers : public MarkerTypes { 86 class AllMarkers : public MarkerTypes {
82 public: 87 public:
83 AllMarkers() 88 AllMarkers()
84 : MarkerTypes(Spelling | Grammar | TextMatch | InvisibleSpellcheck | 89 : MarkerTypes(Spelling | Grammar | TextMatch | InvisibleSpellcheck |
85 Composition) {} 90 Composition |
91 Suggestion |
92 SuggestionBackgroundHighlight) {}
86 }; 93 };
87 94
88 class MisspellingMarkers : public MarkerTypes { 95 class MisspellingMarkers : public MarkerTypes {
89 public: 96 public:
90 MisspellingMarkers() : MarkerTypes(Spelling | Grammar) {} 97 MisspellingMarkers() : MarkerTypes(Spelling | Grammar) {}
91 }; 98 };
92 99
93 class SpellCheckClientMarkers : public MarkerTypes { 100 class SpellCheckClientMarkers : public MarkerTypes {
94 public: 101 public:
95 SpellCheckClientMarkers() 102 SpellCheckClientMarkers()
96 : MarkerTypes(Spelling | Grammar | InvisibleSpellcheck) {} 103 : MarkerTypes(Spelling | Grammar | InvisibleSpellcheck) {}
97 }; 104 };
98 105
99 DocumentMarker(MarkerType, 106 DocumentMarker(MarkerType,
100 unsigned startOffset, 107 unsigned startOffset,
101 unsigned endOffset, 108 unsigned endOffset,
102 const String& description, 109 const String& description,
103 uint32_t hash); 110 uint32_t hash);
104 DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch); 111 DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch);
112 DocumentMarker(MarkerType type,
113 unsigned startOffset,
114 unsigned endOffset,
115 Color underlineColor,
116 bool thick,
117 Color backgroundColor);
105 DocumentMarker(unsigned startOffset, 118 DocumentMarker(unsigned startOffset,
106 unsigned endOffset, 119 unsigned endOffset,
107 Color underlineColor, 120 Color underlineColor,
108 bool thick, 121 bool thick,
109 Color backgroundColor); 122 Color backgroundColor,
123 const std::vector<std::string>& suggestions,
124 int32_t suggestionMarkerID);
110 125
111 DocumentMarker(const DocumentMarker&); 126 DocumentMarker(const DocumentMarker&);
112 127
113 MarkerType type() const { return m_type; } 128 MarkerType type() const { return m_type; }
114 unsigned startOffset() const { return m_startOffset; } 129 unsigned startOffset() const { return m_startOffset; }
115 unsigned endOffset() const { return m_endOffset; } 130 unsigned endOffset() const { return m_endOffset; }
116 uint32_t hash() const { return m_hash; } 131 uint32_t hash() const { return m_hash; }
117 132
118 const String& description() const; 133 const String& description() const;
119 bool activeMatch() const; 134 bool activeMatch() const;
120 Color underlineColor() const; 135 Color underlineColor() const;
121 bool thick() const; 136 bool thick() const;
122 Color backgroundColor() const; 137 Color backgroundColor() const;
138 const std::vector<std::string> suggestions() const;
139 int suggestionMarkerID() const;
123 DocumentMarkerDetails* details() const; 140 DocumentMarkerDetails* details() const;
124 141
125 void setActiveMatch(bool); 142 void setActiveMatch(bool);
126 void clearDetails() { m_details.clear(); } 143 void clearDetails() { m_details.clear(); }
144 void replaceSuggestion(int index, const std::string& newSuggestion);
127 145
128 // Offset modifications are done by DocumentMarkerController. 146 // Offset modifications are done by DocumentMarkerController.
129 // Other classes should not call following setters. 147 // Other classes should not call following setters.
130 void setStartOffset(unsigned offset) { m_startOffset = offset; } 148 void setStartOffset(unsigned offset) { m_startOffset = offset; }
131 void setEndOffset(unsigned offset) { m_endOffset = offset; } 149 void setEndOffset(unsigned offset) { m_endOffset = offset; }
132 void shiftOffsets(int delta); 150 void shiftOffsets(int delta);
133 151
134 bool operator==(const DocumentMarker& o) const { 152 bool operator==(const DocumentMarker& o) const {
135 return type() == o.type() && startOffset() == o.startOffset() && 153 return type() == o.type() && startOffset() == o.startOffset() &&
136 endOffset() == o.endOffset(); 154 endOffset() == o.endOffset();
(...skipping 18 matching lines...) Expand all
155 } 173 }
156 174
157 class DocumentMarkerDetails 175 class DocumentMarkerDetails
158 : public GarbageCollectedFinalized<DocumentMarkerDetails> { 176 : public GarbageCollectedFinalized<DocumentMarkerDetails> {
159 public: 177 public:
160 DocumentMarkerDetails() {} 178 DocumentMarkerDetails() {}
161 virtual ~DocumentMarkerDetails(); 179 virtual ~DocumentMarkerDetails();
162 virtual bool isDescription() const { return false; } 180 virtual bool isDescription() const { return false; }
163 virtual bool isTextMatch() const { return false; } 181 virtual bool isTextMatch() const { return false; }
164 virtual bool isComposition() const { return false; } 182 virtual bool isComposition() const { return false; }
183 virtual bool isSuggestion() const { return true; }
165 184
166 DEFINE_INLINE_VIRTUAL_TRACE() {} 185 DEFINE_INLINE_VIRTUAL_TRACE() {}
167 }; 186 };
168 187
169 } // namespace blink 188 } // namespace blink
170 189
171 #endif // DocumentMarker_h 190 #endif // DocumentMarker_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698