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

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

Issue 2763893002: [WIP] Clean up DocumentMarkerController API (Closed)
Patch Set: 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 unified diff | Download patch
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 29 matching lines...) Expand all
40 40
41 namespace blink { 41 namespace blink {
42 42
43 class CompositionMarkerList; 43 class CompositionMarkerList;
44 class DocumentMarkerList; 44 class DocumentMarkerList;
45 class GrammarMarkerList; 45 class GrammarMarkerList;
46 class Node; 46 class Node;
47 class SpellingMarkerList; 47 class SpellingMarkerList;
48 class TextMatchMarkerList; 48 class TextMatchMarkerList;
49 49
50 class MarkerRemoverPredicate final {
51 public:
52 explicit MarkerRemoverPredicate(const Vector<String>& words);
53 bool operator()(const DocumentMarker&, const Text&) const;
54
55 Vector<String> m_words;
56 };
57
58 class CORE_EXPORT DocumentMarkerController final 50 class CORE_EXPORT DocumentMarkerController final
59 : public GarbageCollected<DocumentMarkerController>, 51 : public GarbageCollected<DocumentMarkerController>,
60 public SynchronousMutationObserver { 52 public SynchronousMutationObserver {
61 WTF_MAKE_NONCOPYABLE(DocumentMarkerController); 53 WTF_MAKE_NONCOPYABLE(DocumentMarkerController);
62 USING_GARBAGE_COLLECTED_MIXIN(DocumentMarkerController); 54 USING_GARBAGE_COLLECTED_MIXIN(DocumentMarkerController);
63 55
64 public: 56 public:
65 explicit DocumentMarkerController(Document&); 57 explicit DocumentMarkerController(Document&);
66 58
67 void clear(); 59 void clear();
68 void addMarker(Node*, DocumentMarker*); 60 void addMarker(Node*, DocumentMarker*);
69 void addMarker(const Position& start, 61
70 const Position& end,
71 DocumentMarker::MarkerType,
72 const String& description = emptyString);
73 void addTextMatchMarker(const EphemeralRange&, bool activeMatch);
74 void addCompositionMarker(const Position& start, 62 void addCompositionMarker(const Position& start,
75 const Position& end, 63 const Position& end,
76 Color underlineColor, 64 Color underlineColor,
77 bool thick, 65 bool thick,
78 Color backgroundColor); 66 Color backgroundColor);
67 void addGrammarMarker(const Position& start,
yosin_UTC9 2017/03/21 05:46:55 Could you introduce them one-by-one to make patch
68 const Position& end,
69 const String& description = emptyString);
70 void addSpellingMarker(const Position& start,
71 const Position& end,
72 const String& description = emptyString);
73 void addTextMatchMarker(const Position& start,
yosin_UTC9 2017/03/21 05:46:55 We prefer to use |EPhemeralRange| instead of passi
74 const Position& end,
75 bool activeMatch);
79 76
80 void copyMarkers(Node* srcNode, 77 void copyMarkers(Node* srcNode,
81 unsigned startOffset, 78 unsigned startOffset,
82 int length, 79 int length,
83 Node* dstNode, 80 Node* dstNode,
84 int delta); 81 int delta);
85 82
86 void prepareForDestruction(); 83 void prepareForDestruction();
87 // When a marker partially overlaps with range, if 84 // When a marker partially overlaps with range, if
88 // removePartiallyOverlappingMarkers is true, we completely remove the marker. 85 // removePartiallyOverlappingMarkers is true, we completely remove the marker.
(...skipping 12 matching lines...) Expand all
101 int length, 98 int length,
102 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers(), 99 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers(),
103 RemovePartiallyOverlappingMarkerOrNot = 100 RemovePartiallyOverlappingMarkerOrNot =
104 DoNotRemovePartiallyOverlappingMarker); 101 DoNotRemovePartiallyOverlappingMarker);
105 102
106 void removeMarkers( 103 void removeMarkers(
107 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); 104 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
108 void removeMarkers( 105 void removeMarkers(
109 Node*, 106 Node*,
110 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); 107 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
111 void removeMarkers(const MarkerRemoverPredicate& shouldRemoveMarker); 108 void removeSpellingMarkersForWords(const Vector<String>& words);
112 void repaintMarkers( 109 void repaintMarkers(
113 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); 110 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
114 // Returns true if markers within a range are found. 111 // Returns true if markers within a range are found.
115 bool setMarkersActive(const EphemeralRange&, bool); 112 bool setTextMatchMarkersActive(const EphemeralRange&, bool);
116 // Returns true if markers within a range defined by a node, |startOffset| and 113 // Returns true if markers within a range defined by a node, |startOffset| and
117 // |endOffset| are found. 114 // |endOffset| are found.
118 bool setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool); 115 bool setTextMatchMarkersActive(Node*,
116 unsigned startOffset,
117 unsigned endOffset,
118 bool);
119 bool hasMarkers(Node*) const; 119 bool hasMarkers(Node*) const;
120 120
121 DocumentMarkerVector markersFor( 121 DocumentMarkerVector markersFor(
122 Node*, 122 Node*,
123 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); 123 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
124 DocumentMarkerVector markersInRange(const EphemeralRange&, 124 DocumentMarkerVector markersInRange(const EphemeralRange&,
125 DocumentMarker::MarkerTypes); 125 DocumentMarker::MarkerTypes);
126 DocumentMarkerVector markers(); 126 DocumentMarkerVector markers();
127 Vector<IntRect> renderedRectsForMarkers(DocumentMarker::MarkerType); 127 Vector<IntRect> renderedRectsForTextMatchMarkers();
128 128 void invalidateRectsForAllTextMatchMarkers();
129 void invalidateRectsForAllMarkers(); 129 void invalidateRectsForTextMatchMarkersInNode(Node&);
130 void invalidateRectsForMarkersInNode(Node&);
131 130
132 DECLARE_TRACE(); 131 DECLARE_TRACE();
133 132
134 #ifndef NDEBUG 133 #ifndef NDEBUG
135 void showMarkers() const; 134 void showMarkers() const;
136 #endif 135 #endif
137 136
138 // SynchronousMutationObserver 137 // SynchronousMutationObserver
139 void didUpdateCharacterData(CharacterData*, 138 void didUpdateCharacterData(CharacterData*,
140 unsigned offset, 139 unsigned offset,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 auto it = markerMap->find(node); 181 auto it = markerMap->find(node);
183 if (it != markerMap->end()) { 182 if (it != markerMap->end()) {
184 it->value->removeMarkers(startOffset, length, 183 it->value->removeMarkers(startOffset, length,
185 shouldRemovePartiallyOverlappingMarker, 184 shouldRemovePartiallyOverlappingMarker,
186 docDirty); 185 docDirty);
187 if (it->value->empty()) 186 if (it->value->empty())
188 markerMap->remove(node); 187 markerMap->remove(node);
189 } 188 }
190 } 189 }
191 190
191 void addGrammarOrSpellingMarker(const Position& start,
192 const Position& end,
193 DocumentMarker::MarkerType,
194 const String& description);
192 HeapVector<Member<DocumentMarkerList>> getMarkerListsForNode( 195 HeapVector<Member<DocumentMarkerList>> getMarkerListsForNode(
193 Node*, 196 Node*,
194 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); 197 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
195 void removeMarkers(TextIterator&, 198 void removeMarkers(TextIterator&,
196 DocumentMarker::MarkerTypes, 199 DocumentMarker::MarkerTypes,
197 RemovePartiallyOverlappingMarkerOrNot); 200 RemovePartiallyOverlappingMarkerOrNot);
198 201
199 MarkerMap<SpellingMarkerList> m_spelling; 202 MarkerMap<SpellingMarkerList> m_spelling;
200 MarkerMap<GrammarMarkerList> m_grammar; 203 MarkerMap<GrammarMarkerList> m_grammar;
201 MarkerMap<TextMatchMarkerList> m_textMatches; 204 MarkerMap<TextMatchMarkerList> m_textMatches;
202 MarkerMap<CompositionMarkerList> m_compositions; 205 MarkerMap<CompositionMarkerList> m_compositions;
203 206
204 const Member<const Document> m_document; 207 const Member<const Document> m_document;
205 }; 208 };
206 209
207 } // namespace blink 210 } // namespace blink
208 211
209 #ifndef NDEBUG 212 #ifndef NDEBUG
210 void showDocumentMarkers(const blink::DocumentMarkerController*); 213 void showDocumentMarkers(const blink::DocumentMarkerController*);
211 #endif 214 #endif
212 215
213 #endif // DocumentMarkerController_h 216 #endif // DocumentMarkerController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698