OLD | NEW |
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 22 matching lines...) Expand all Loading... |
33 #include "core/dom/SynchronousMutationObserver.h" | 33 #include "core/dom/SynchronousMutationObserver.h" |
34 #include "core/editing/iterators/TextIterator.h" | 34 #include "core/editing/iterators/TextIterator.h" |
35 #include "core/editing/markers/DocumentMarker.h" | 35 #include "core/editing/markers/DocumentMarker.h" |
36 #include "platform/geometry/IntRect.h" | 36 #include "platform/geometry/IntRect.h" |
37 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
38 #include "wtf/HashMap.h" | 38 #include "wtf/HashMap.h" |
39 #include "wtf/Vector.h" | 39 #include "wtf/Vector.h" |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
| 43 class DocumentMarkerList; |
43 class Node; | 44 class Node; |
44 class RenderedDocumentMarker; | |
45 class Text; | |
46 | 45 |
47 class MarkerRemoverPredicate final { | 46 class MarkerRemoverPredicate final { |
48 public: | 47 public: |
49 explicit MarkerRemoverPredicate(const Vector<String>& words); | 48 explicit MarkerRemoverPredicate(const Vector<String>& words); |
50 bool operator()(const DocumentMarker&, const Text&) const; | 49 bool operator()(const DocumentMarker&, const Text&) const; |
51 | 50 |
52 private: | |
53 Vector<String> m_words; | 51 Vector<String> m_words; |
54 }; | 52 }; |
55 | 53 |
56 class CORE_EXPORT DocumentMarkerController final | 54 class CORE_EXPORT DocumentMarkerController final |
57 : public GarbageCollected<DocumentMarkerController>, | 55 : public GarbageCollected<DocumentMarkerController>, |
58 public SynchronousMutationObserver { | 56 public SynchronousMutationObserver { |
59 WTF_MAKE_NONCOPYABLE(DocumentMarkerController); | 57 WTF_MAKE_NONCOPYABLE(DocumentMarkerController); |
60 USING_GARBAGE_COLLECTED_MIXIN(DocumentMarkerController); | 58 USING_GARBAGE_COLLECTED_MIXIN(DocumentMarkerController); |
61 | 59 |
62 public: | 60 public: |
63 explicit DocumentMarkerController(Document&); | 61 explicit DocumentMarkerController(Document&); |
64 | 62 |
65 void clear(); | 63 void clear(); |
| 64 void addMarker(Node*, DocumentMarker*); |
66 void addMarker(const Position& start, | 65 void addMarker(const Position& start, |
67 const Position& end, | 66 const Position& end, |
68 DocumentMarker::MarkerType, | 67 DocumentMarker::MarkerType, |
69 const String& description = emptyString); | 68 const String& description = emptyString); |
70 void addTextMatchMarker(const EphemeralRange&, bool activeMatch); | 69 void addTextMatchMarker(const EphemeralRange&, bool activeMatch); |
71 void addCompositionMarker(const Position& start, | 70 void addCompositionMarker(const Position& start, |
72 const Position& end, | 71 const Position& end, |
73 Color underlineColor, | 72 Color underlineColor, |
74 bool thick, | 73 bool thick, |
75 Color backgroundColor); | 74 Color backgroundColor); |
(...skipping 30 matching lines...) Expand all Loading... |
106 Node*, | 105 Node*, |
107 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); | 106 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); |
108 void removeMarkers(const MarkerRemoverPredicate& shouldRemoveMarker); | 107 void removeMarkers(const MarkerRemoverPredicate& shouldRemoveMarker); |
109 void repaintMarkers( | 108 void repaintMarkers( |
110 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); | 109 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); |
111 // Returns true if markers within a range are found. | 110 // Returns true if markers within a range are found. |
112 bool setMarkersActive(const EphemeralRange&, bool); | 111 bool setMarkersActive(const EphemeralRange&, bool); |
113 // Returns true if markers within a range defined by a node, |startOffset| and | 112 // Returns true if markers within a range defined by a node, |startOffset| and |
114 // |endOffset| are found. | 113 // |endOffset| are found. |
115 bool setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool); | 114 bool setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool); |
116 bool hasMarkers(Node* node) const { return m_markers.contains(node); } | 115 bool hasMarkers(Node*) const; |
117 | 116 |
118 DocumentMarkerVector markersFor( | 117 DocumentMarkerVector markersFor( |
119 Node*, | 118 Node*, |
120 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); | 119 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); |
121 DocumentMarkerVector markersInRange(const EphemeralRange&, | 120 DocumentMarkerVector markersInRange(const EphemeralRange&, |
122 DocumentMarker::MarkerTypes); | 121 DocumentMarker::MarkerTypes); |
123 DocumentMarkerVector markers(); | 122 DocumentMarkerVector markers(); |
124 Vector<IntRect> renderedRectsForMarkers(DocumentMarker::MarkerType); | 123 Vector<IntRect> renderedRectsForMarkers(DocumentMarker::MarkerType); |
125 void updateMarkerRenderedRectIfNeeded(const Node&, RenderedDocumentMarker&); | 124 |
126 void invalidateRectsForAllMarkers(); | 125 void invalidateRectsForAllMarkers(); |
127 void invalidateRectsForMarkersInNode(const Node&); | 126 void invalidateRectsForMarkersInNode(Node&); |
128 | 127 |
129 DECLARE_TRACE(); | 128 DECLARE_TRACE(); |
130 | 129 |
131 #ifndef NDEBUG | 130 #ifndef NDEBUG |
132 void showMarkers() const; | 131 void showMarkers() const; |
133 #endif | 132 #endif |
134 | 133 |
135 // SynchronousMutationObserver | 134 // SynchronousMutationObserver |
136 void didUpdateCharacterData(CharacterData*, | 135 void didUpdateCharacterData(CharacterData*, |
137 unsigned offset, | 136 unsigned offset, |
138 unsigned oldLength, | 137 unsigned oldLength, |
139 unsigned newLength) final; | 138 unsigned newLength) final; |
140 | 139 |
141 private: | 140 private: |
142 void addMarker(Node*, const DocumentMarker&); | 141 using MarkerMap = HeapHashMap<WeakMember<Node>, Member<DocumentMarkerList>>; |
143 | 142 |
144 using MarkerList = HeapVector<Member<RenderedDocumentMarker>>; | 143 DocumentMarkerList* createMarkerListOfType(DocumentMarker::MarkerType); |
145 using MarkerLists = | 144 HeapVector<Member<DocumentMarkerList>> getMarkerListsForNode( |
146 HeapVector<Member<MarkerList>, DocumentMarker::MarkerTypeIndexesCount>; | 145 Node*, |
147 using MarkerMap = HeapHashMap<WeakMember<const Node>, Member<MarkerLists>>; | 146 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); |
148 void mergeOverlapping(MarkerList*, RenderedDocumentMarker*); | 147 MarkerMap& markerMapForType(DocumentMarker::MarkerType); |
149 bool possiblyHasMarkers(DocumentMarker::MarkerTypes); | 148 const MarkerMap& markerMapForType(DocumentMarker::MarkerType) const; |
150 void removeMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes); | |
151 void removeMarkers(TextIterator&, | 149 void removeMarkers(TextIterator&, |
152 DocumentMarker::MarkerTypes, | 150 DocumentMarker::MarkerTypes, |
153 RemovePartiallyOverlappingMarkerOrNot); | 151 RemovePartiallyOverlappingMarkerOrNot); |
154 | 152 |
155 MarkerMap m_markers; | 153 MarkerMap m_spelling; |
156 // Provide a quick way to determine whether a particular marker type is absent | 154 MarkerMap m_grammar; |
157 // without going through the map. | 155 MarkerMap m_textMatches; |
158 DocumentMarker::MarkerTypes m_possiblyExistingMarkerTypes; | 156 MarkerMap m_compositions; |
| 157 |
159 const Member<const Document> m_document; | 158 const Member<const Document> m_document; |
160 }; | 159 }; |
161 | 160 |
162 } // namespace blink | 161 } // namespace blink |
163 | 162 |
164 #ifndef NDEBUG | 163 #ifndef NDEBUG |
165 void showDocumentMarkers(const blink::DocumentMarkerController*); | 164 void showDocumentMarkers(const blink::DocumentMarkerController*); |
166 #endif | 165 #endif |
167 | 166 |
168 #endif // DocumentMarkerController_h | 167 #endif // DocumentMarkerController_h |
OLD | NEW |