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

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

Issue 2755013004: Improve how DocumentMarkerController updates markers in response to text edits (Closed)
Patch Set: Rebase (Vector::remove() => Vector::erase()) 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 * 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 12 matching lines...) Expand all
23 * along with this library; see the file COPYING.LIB. If not, write to 23 * along with this library; see the file COPYING.LIB. If not, write to
24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 * Boston, MA 02110-1301, USA. 25 * Boston, MA 02110-1301, USA.
26 * 26 *
27 */ 27 */
28 28
29 #ifndef DocumentMarkerController_h 29 #ifndef DocumentMarkerController_h
30 #define DocumentMarkerController_h 30 #define DocumentMarkerController_h
31 31
32 #include "core/CoreExport.h" 32 #include "core/CoreExport.h"
33 #include "core/dom/SynchronousMutationObserver.h"
33 #include "core/editing/iterators/TextIterator.h" 34 #include "core/editing/iterators/TextIterator.h"
34 #include "core/editing/markers/DocumentMarker.h" 35 #include "core/editing/markers/DocumentMarker.h"
35 #include "platform/geometry/IntRect.h" 36 #include "platform/geometry/IntRect.h"
36 #include "platform/heap/Handle.h" 37 #include "platform/heap/Handle.h"
37 #include "wtf/HashMap.h" 38 #include "wtf/HashMap.h"
38 #include "wtf/Vector.h" 39 #include "wtf/Vector.h"
39 40
40 namespace blink { 41 namespace blink {
41 42
42 class Node; 43 class Node;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 DoNotRemovePartiallyOverlappingMarker); 101 DoNotRemovePartiallyOverlappingMarker);
101 102
102 void removeMarkers( 103 void removeMarkers(
103 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); 104 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
104 void removeMarkers( 105 void removeMarkers(
105 Node*, 106 Node*,
106 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); 107 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
107 void removeMarkers(const MarkerRemoverPredicate& shouldRemoveMarker); 108 void removeMarkers(const MarkerRemoverPredicate& shouldRemoveMarker);
108 void repaintMarkers( 109 void repaintMarkers(
109 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); 110 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
110 void shiftMarkers(Node*, unsigned startOffset, int delta);
111 // Returns true if markers within a range are found. 111 // Returns true if markers within a range are found.
112 bool setMarkersActive(const EphemeralRange&, bool); 112 bool setMarkersActive(const EphemeralRange&, bool);
113 // 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
114 // |endOffset| are found. 114 // |endOffset| are found.
115 bool setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool); 115 bool setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool);
116 bool hasMarkers(Node* node) const { return m_markers.contains(node); } 116 bool hasMarkers(Node* node) const { return m_markers.contains(node); }
117 117
118 DocumentMarkerVector markersFor( 118 DocumentMarkerVector markersFor(
119 Node*, 119 Node*,
120 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); 120 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
(...skipping 19 matching lines...) Expand all
140 140
141 private: 141 private:
142 void addMarker(Node*, const DocumentMarker&); 142 void addMarker(Node*, const DocumentMarker&);
143 143
144 using MarkerList = HeapVector<Member<RenderedDocumentMarker>>; 144 using MarkerList = HeapVector<Member<RenderedDocumentMarker>>;
145 using MarkerLists = 145 using MarkerLists =
146 HeapVector<Member<MarkerList>, DocumentMarker::MarkerTypeIndexesCount>; 146 HeapVector<Member<MarkerList>, DocumentMarker::MarkerTypeIndexesCount>;
147 using MarkerMap = HeapHashMap<WeakMember<const Node>, Member<MarkerLists>>; 147 using MarkerMap = HeapHashMap<WeakMember<const Node>, Member<MarkerLists>>;
148 void mergeOverlapping(MarkerList*, RenderedDocumentMarker*); 148 void mergeOverlapping(MarkerList*, RenderedDocumentMarker*);
149 bool possiblyHasMarkers(DocumentMarker::MarkerTypes); 149 bool possiblyHasMarkers(DocumentMarker::MarkerTypes);
150 bool relocateMarkerIfNeeded(RenderedDocumentMarker*,
151 unsigned offset,
152 unsigned oldLength,
153 unsigned newLength);
150 void removeMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes); 154 void removeMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes);
151 void removeMarkers(TextIterator&, 155 void removeMarkers(TextIterator&,
152 DocumentMarker::MarkerTypes, 156 DocumentMarker::MarkerTypes,
153 RemovePartiallyOverlappingMarkerOrNot); 157 RemovePartiallyOverlappingMarkerOrNot);
154 158
155 MarkerMap m_markers; 159 MarkerMap m_markers;
156 // 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
157 // without going through the map. 161 // without going through the map.
158 DocumentMarker::MarkerTypes m_possiblyExistingMarkerTypes; 162 DocumentMarker::MarkerTypes m_possiblyExistingMarkerTypes;
159 const Member<const Document> m_document; 163 const Member<const Document> m_document;
160 }; 164 };
161 165
162 } // namespace blink 166 } // namespace blink
163 167
164 #ifndef NDEBUG 168 #ifndef NDEBUG
165 void showDocumentMarkers(const blink::DocumentMarkerController*); 169 void showDocumentMarkers(const blink::DocumentMarkerController*);
166 #endif 170 #endif
167 171
168 #endif // DocumentMarkerController_h 172 #endif // DocumentMarkerController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698