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

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

Issue 2812423002: [DMC #1] Refactor DocumentMarkerController on top of new DocumentMarkerListEditor class (Closed)
Patch Set: Respond to comments 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
7 * reserved. 7 * reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 class MarkerRemoverPredicate final { 47 class MarkerRemoverPredicate final {
48 public: 48 public:
49 explicit MarkerRemoverPredicate(const Vector<String>& words); 49 explicit MarkerRemoverPredicate(const Vector<String>& words);
50 bool operator()(const DocumentMarker&, const Text&) const; 50 bool operator()(const DocumentMarker&, const Text&) const;
51 51
52 private: 52 private:
53 Vector<String> words_; 53 Vector<String> words_;
54 }; 54 };
55 55
56 class DocumentMarkerListEditor {
57 public:
58 using MarkerList = HeapVector<Member<RenderedDocumentMarker>>;
59
60 static void AddMarker(MarkerList*, const DocumentMarker*);
61
62 // Returns true if a marker was removed, false otherwise.
63 static bool RemoveMarkers(MarkerList*, unsigned start_offset, int length);
64
65 // Returns true if a marker was shifted or removed, false otherwise.
66 static bool ShiftMarkers(MarkerList*,
67 unsigned offset,
68 unsigned old_length,
69 unsigned new_length);
70
71 private:
72 static void MergeOverlapping(MarkerList*, RenderedDocumentMarker* to_insert);
73 };
74
56 class CORE_EXPORT DocumentMarkerController final 75 class CORE_EXPORT DocumentMarkerController final
57 : public GarbageCollected<DocumentMarkerController>, 76 : public GarbageCollected<DocumentMarkerController>,
58 public SynchronousMutationObserver { 77 public SynchronousMutationObserver {
59 WTF_MAKE_NONCOPYABLE(DocumentMarkerController); 78 WTF_MAKE_NONCOPYABLE(DocumentMarkerController);
60 USING_GARBAGE_COLLECTED_MIXIN(DocumentMarkerController); 79 USING_GARBAGE_COLLECTED_MIXIN(DocumentMarkerController);
61 80
62 public: 81 public:
63 explicit DocumentMarkerController(Document&); 82 explicit DocumentMarkerController(Document&);
64 83
65 void Clear(); 84 void Clear();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 unsigned old_length, 145 unsigned old_length,
127 unsigned new_length) final; 146 unsigned new_length) final;
128 147
129 private: 148 private:
130 void AddMarker(Node*, const DocumentMarker&); 149 void AddMarker(Node*, const DocumentMarker&);
131 150
132 using MarkerList = HeapVector<Member<RenderedDocumentMarker>>; 151 using MarkerList = HeapVector<Member<RenderedDocumentMarker>>;
133 using MarkerLists = 152 using MarkerLists =
134 HeapVector<Member<MarkerList>, DocumentMarker::kMarkerTypeIndexesCount>; 153 HeapVector<Member<MarkerList>, DocumentMarker::kMarkerTypeIndexesCount>;
135 using MarkerMap = HeapHashMap<WeakMember<const Node>, Member<MarkerLists>>; 154 using MarkerMap = HeapHashMap<WeakMember<const Node>, Member<MarkerLists>>;
136 void MergeOverlapping(MarkerList*, RenderedDocumentMarker*);
137 bool PossiblyHasMarkers(DocumentMarker::MarkerTypes); 155 bool PossiblyHasMarkers(DocumentMarker::MarkerTypes);
138 void RemoveMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes); 156 void RemoveMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes);
139 void RemoveMarkers(TextIterator&, DocumentMarker::MarkerTypes); 157 void RemoveMarkers(TextIterator&, DocumentMarker::MarkerTypes);
140 158
141 MarkerMap markers_; 159 MarkerMap markers_;
142 // Provide a quick way to determine whether a particular marker type is absent 160 // Provide a quick way to determine whether a particular marker type is absent
143 // without going through the map. 161 // without going through the map.
144 DocumentMarker::MarkerTypes possibly_existing_marker_types_; 162 DocumentMarker::MarkerTypes possibly_existing_marker_types_;
145 const Member<const Document> document_; 163 const Member<const Document> document_;
146 }; 164 };
147 165
148 } // namespace blink 166 } // namespace blink
149 167
150 #ifndef NDEBUG 168 #ifndef NDEBUG
151 void showDocumentMarkers(const blink::DocumentMarkerController*); 169 void showDocumentMarkers(const blink::DocumentMarkerController*);
152 #endif 170 #endif
153 171
154 #endif // DocumentMarkerController_h 172 #endif // DocumentMarkerController_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698