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

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

Issue 2781623010: Add DocumentMarker::clone() (Closed)
Patch Set: Rebase Created 3 years, 8 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 class MisspellingMarkers : public MarkerTypes { 127 class MisspellingMarkers : public MarkerTypes {
128 public: 128 public:
129 MisspellingMarkers() : MarkerTypes(Spelling | Grammar) {} 129 MisspellingMarkers() : MarkerTypes(Spelling | Grammar) {}
130 }; 130 };
131 131
132 class SpellCheckClientMarkers : public MarkerTypes { 132 class SpellCheckClientMarkers : public MarkerTypes {
133 public: 133 public:
134 SpellCheckClientMarkers() : MarkerTypes(Spelling | Grammar) {} 134 SpellCheckClientMarkers() : MarkerTypes(Spelling | Grammar) {}
135 }; 135 };
136 136
137 virtual DocumentMarker* clone() const;
yosin_UTC9 2017/04/04 01:37:51 I don't understand why we need to have |clone()| m
rlanday 2017/04/04 02:07:46 In https://codereview.chromium.org/2780313002 I'm
rlanday 2017/04/04 02:07:46 In https://codereview.chromium.org/2780313002 I'm
yosin_UTC9 2017/04/04 04:07:36 I'm not a fan of clone or copy since we should not
138
137 DocumentMarker(MarkerType, 139 DocumentMarker(MarkerType,
138 unsigned startOffset, 140 unsigned startOffset,
139 unsigned endOffset, 141 unsigned endOffset,
140 const String& description); 142 const String& description);
141 DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch); 143 DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch);
142 DocumentMarker(unsigned startOffset, 144 DocumentMarker(unsigned startOffset,
143 unsigned endOffset, 145 unsigned endOffset,
144 Color underlineColor, 146 Color underlineColor,
145 bool thick, 147 bool thick,
146 Color backgroundColor); 148 Color backgroundColor);
147 149
148 DocumentMarker(const DocumentMarker&);
149
150 MarkerType type() const { return m_type; } 150 MarkerType type() const { return m_type; }
151 unsigned startOffset() const { return m_startOffset; } 151 unsigned startOffset() const { return m_startOffset; }
152 unsigned endOffset() const { return m_endOffset; } 152 unsigned endOffset() const { return m_endOffset; }
153 153
154 const String& description() const; 154 const String& description() const;
155 bool activeMatch() const; 155 bool activeMatch() const;
156 Color underlineColor() const; 156 Color underlineColor() const;
157 bool thick() const; 157 bool thick() const;
158 Color backgroundColor() const; 158 Color backgroundColor() const;
159 DocumentMarkerDetails* details() const; 159 DocumentMarkerDetails* details() const;
160 160
161 void setActiveMatch(bool); 161 void setActiveMatch(bool);
162 void clearDetails() { m_details.clear(); } 162 void clearDetails() { m_details.clear(); }
163 163
164 // Offset modifications are done by DocumentMarkerController. 164 // Offset modifications are done by DocumentMarkerController.
165 // Other classes should not call following setters. 165 // Other classes should not call following setters.
166 void setStartOffset(unsigned offset) { m_startOffset = offset; } 166 void setStartOffset(unsigned offset) { m_startOffset = offset; }
167 void setEndOffset(unsigned offset) { m_endOffset = offset; } 167 void setEndOffset(unsigned offset) { m_endOffset = offset; }
168 void shiftOffsets(int delta); 168 void shiftOffsets(int delta);
169 169
170 bool operator==(const DocumentMarker& o) const { 170 bool operator==(const DocumentMarker& o) const {
171 return type() == o.type() && startOffset() == o.startOffset() && 171 return type() == o.type() && startOffset() == o.startOffset() &&
172 endOffset() == o.endOffset(); 172 endOffset() == o.endOffset();
173 } 173 }
174 174
175 bool operator!=(const DocumentMarker& o) const { return !(*this == o); } 175 bool operator!=(const DocumentMarker& o) const { return !(*this == o); }
176 176
177 DECLARE_TRACE(); 177 DECLARE_TRACE();
178 178
179 protected:
180 DocumentMarker(const DocumentMarker&);
yosin_UTC9 2017/04/04 01:37:51 Could you add TODO to remove copy-ctor from Docume
rlanday 2017/04/04 02:07:46 I need this to implement clone().
181
179 private: 182 private:
180 MarkerType m_type; 183 MarkerType m_type;
181 unsigned m_startOffset; 184 unsigned m_startOffset;
182 unsigned m_endOffset; 185 unsigned m_endOffset;
183 Member<DocumentMarkerDetails> m_details; 186 Member<DocumentMarkerDetails> m_details;
184 }; 187 };
185 188
186 using DocumentMarkerVector = HeapVector<Member<DocumentMarker>>; 189 using DocumentMarkerVector = HeapVector<Member<DocumentMarker>>;
187 190
188 inline DocumentMarkerDetails* DocumentMarker::details() const { 191 inline DocumentMarkerDetails* DocumentMarker::details() const {
189 return m_details.get(); 192 return m_details.get();
190 } 193 }
191 194
192 class DocumentMarkerDetails 195 class DocumentMarkerDetails
193 : public GarbageCollectedFinalized<DocumentMarkerDetails> { 196 : public GarbageCollectedFinalized<DocumentMarkerDetails> {
194 public: 197 public:
195 DocumentMarkerDetails() {} 198 DocumentMarkerDetails() {}
196 virtual ~DocumentMarkerDetails(); 199 virtual ~DocumentMarkerDetails();
197 virtual bool isDescription() const { return false; } 200 virtual bool isDescription() const { return false; }
198 virtual bool isTextMatch() const { return false; } 201 virtual bool isTextMatch() const { return false; }
199 virtual bool isComposition() const { return false; } 202 virtual bool isComposition() const { return false; }
200 203
201 DEFINE_INLINE_VIRTUAL_TRACE() {} 204 DEFINE_INLINE_VIRTUAL_TRACE() {}
202 }; 205 };
203 206
204 } // namespace blink 207 } // namespace blink
205 208
206 #endif // DocumentMarker_h 209 #endif // DocumentMarker_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/BUILD.gn ('k') | third_party/WebKit/Source/core/editing/markers/DocumentMarker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698