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

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

Issue 2780313002: [WIP] Refactor DocumentMarker (Closed)
Patch Set: Rebase Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/markers/DocumentMarker.h
diff --git a/third_party/WebKit/Source/core/editing/markers/DocumentMarker.h b/third_party/WebKit/Source/core/editing/markers/DocumentMarker.h
index 6952d56a9d35a1238035f1fb2e0e377ad0d1f18c..36f75547e81f95c5905b9fb746628dc7e5627641 100644
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarker.h
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarker.h
@@ -31,14 +31,13 @@
namespace blink {
-class DocumentMarkerDetails;
-
// A range of a node within a document that is "marked", such as the range of a
// misspelled word. It optionally includes a description that could be displayed
// in the user interface. It also optionally includes a flag specifying whether
// the match is active, which is ignored for all types other than type
// TextMatch.
-class CORE_EXPORT DocumentMarker : public GarbageCollected<DocumentMarker> {
+class CORE_EXPORT DocumentMarker
+ : public GarbageCollectedFinalized<DocumentMarker> {
public:
enum MarkerTypeIndex {
SpellingMarkerIndex = 0,
@@ -134,31 +133,19 @@ class CORE_EXPORT DocumentMarker : public GarbageCollected<DocumentMarker> {
SpellCheckClientMarkers() : MarkerTypes(Spelling | Grammar) {}
};
- virtual DocumentMarker* clone() const;
+ virtual ~DocumentMarker();
- DocumentMarker(MarkerType,
- unsigned startOffset,
- unsigned endOffset,
- const String& description);
- DocumentMarker(unsigned startOffset,
- unsigned endOffset,
- Color underlineColor,
- bool thick,
- Color backgroundColor);
+ virtual DocumentMarker* clone() const = 0;
- MarkerType type() const { return m_type; }
+ virtual MarkerType type() const = 0;
unsigned startOffset() const { return m_startOffset; }
unsigned endOffset() const { return m_endOffset; }
- const String& description() const;
- bool activeMatch() const;
- Color underlineColor() const;
- bool thick() const;
- Color backgroundColor() const;
- DocumentMarkerDetails* details() const;
-
- void setActiveMatch(bool);
- void clearDetails() { m_details.clear(); }
+ virtual const String& description() const;
Xiaocheng 2017/03/29 23:40:11 These functions only make sense in subclasses. Can
+ virtual bool activeMatch() const;
+ virtual Color underlineColor() const;
+ virtual bool thick() const;
+ virtual Color backgroundColor() const;
struct ShiftMarkerResult {
unsigned newStartOffset;
@@ -176,44 +163,25 @@ class CORE_EXPORT DocumentMarker : public GarbageCollected<DocumentMarker> {
void setEndOffset(unsigned offset) { m_endOffset = offset; }
void shiftOffsets(int delta);
- bool operator==(const DocumentMarker& o) const {
- return type() == o.type() && startOffset() == o.startOffset() &&
- endOffset() == o.endOffset();
- }
+ bool operator==(const DocumentMarker& other) const;
Xiaocheng 2017/03/29 23:40:11 These comparison methods seem not used at all. Co
- bool operator!=(const DocumentMarker& o) const { return !(*this == o); }
+ bool operator!=(const DocumentMarker& other) const {
+ return !(*this == other);
+ }
- DECLARE_TRACE();
+ DEFINE_INLINE_VIRTUAL_TRACE() {}
protected:
DocumentMarker(const DocumentMarker&);
- DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch);
+ DocumentMarker(unsigned startOffset, unsigned endOffset);
private:
- MarkerType m_type;
unsigned m_startOffset;
unsigned m_endOffset;
- Member<DocumentMarkerDetails> m_details;
};
using DocumentMarkerVector = HeapVector<Member<DocumentMarker>>;
-inline DocumentMarkerDetails* DocumentMarker::details() const {
- return m_details.get();
-}
-
-class DocumentMarkerDetails
- : public GarbageCollectedFinalized<DocumentMarkerDetails> {
- public:
- DocumentMarkerDetails() {}
- virtual ~DocumentMarkerDetails();
- virtual bool isDescription() const { return false; }
- virtual bool isTextMatch() const { return false; }
- virtual bool isComposition() const { return false; }
-
- DEFINE_INLINE_VIRTUAL_TRACE() {}
-};
-
} // namespace blink
#endif // DocumentMarker_h

Powered by Google App Engine
This is Rietveld 408576698