Chromium Code Reviews| 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 CompositionMarkerList; | |
| 44 class DocumentMarkerList; | |
| 45 class GrammarMarkerList; | |
| 43 class Node; | 46 class Node; |
| 44 class RenderedDocumentMarker; | 47 class RenderedTextMatchMarker; |
| 45 class Text; | 48 class SpellingMarkerList; |
| 49 class TextMatchMarkerList; | |
| 46 | 50 |
| 47 class MarkerRemoverPredicate final { | 51 class MarkerRemoverPredicate final { |
| 48 public: | 52 public: |
| 49 explicit MarkerRemoverPredicate(const Vector<String>& words); | 53 explicit MarkerRemoverPredicate(const Vector<String>& words); |
| 50 bool operator()(const DocumentMarker&, const Text&) const; | |
|
Xiaocheng
2017/03/18 06:43:14
This change seems irrelevant. There should be a su
rlanday
2017/03/20 18:13:30
Ok
| |
| 51 | |
| 52 private: | |
| 53 Vector<String> m_words; | 54 Vector<String> m_words; |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 class CORE_EXPORT DocumentMarkerController final | 57 class CORE_EXPORT DocumentMarkerController final |
| 57 : public GarbageCollected<DocumentMarkerController>, | 58 : public GarbageCollectedFinalized<DocumentMarkerController>, |
|
Xiaocheng
2017/03/18 06:43:14
Is this relevant?
rlanday
2017/03/20 18:13:30
Hmm I can't remember why I added this, it doesn't
| |
| 58 public SynchronousMutationObserver { | 59 public SynchronousMutationObserver { |
| 59 WTF_MAKE_NONCOPYABLE(DocumentMarkerController); | 60 WTF_MAKE_NONCOPYABLE(DocumentMarkerController); |
| 60 USING_GARBAGE_COLLECTED_MIXIN(DocumentMarkerController); | 61 USING_GARBAGE_COLLECTED_MIXIN(DocumentMarkerController); |
| 61 | 62 |
| 62 public: | 63 public: |
| 63 explicit DocumentMarkerController(Document&); | 64 explicit DocumentMarkerController(Document&); |
| 64 | 65 |
| 65 void clear(); | 66 void clear(); |
| 67 void addMarker(Node*, DocumentMarker*); | |
| 66 void addMarker(const Position& start, | 68 void addMarker(const Position& start, |
| 67 const Position& end, | 69 const Position& end, |
| 68 DocumentMarker::MarkerType, | 70 DocumentMarker::MarkerType, |
| 69 const String& description = emptyString); | 71 const String& description = emptyString); |
| 70 void addTextMatchMarker(const EphemeralRange&, bool activeMatch); | 72 void addTextMatchMarker(const EphemeralRange&, bool activeMatch); |
| 71 void addCompositionMarker(const Position& start, | 73 void addCompositionMarker(const Position& start, |
| 72 const Position& end, | 74 const Position& end, |
| 73 Color underlineColor, | 75 Color underlineColor, |
| 74 bool thick, | 76 bool thick, |
| 75 Color backgroundColor); | 77 Color backgroundColor); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 104 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); | 106 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); |
| 105 void removeMarkers( | 107 void removeMarkers( |
| 106 Node*, | 108 Node*, |
| 107 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); | 109 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); |
| 108 void removeMarkers(const MarkerRemoverPredicate& shouldRemoveMarker); | 110 void removeMarkers(const MarkerRemoverPredicate& shouldRemoveMarker); |
| 109 void repaintMarkers( | 111 void repaintMarkers( |
| 110 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); | 112 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); |
| 111 // Returns true if markers within a range are found. | 113 // Returns true if markers within a range are found. |
| 112 bool setMarkersActive(const EphemeralRange&, bool); | 114 bool setMarkersActive(const EphemeralRange&, bool); |
| 113 // Returns true if markers within a range defined by a node, |startOffset| and | 115 // Returns true if markers within a range defined by a node, |startOffset| and |
| 114 // |endOffset| are found. | 116 // |endOffset| are found |
|
Xiaocheng
2017/03/18 06:43:14
Please elmininate all such irrelevant changes from
rlanday
2017/03/20 18:13:30
Oops, typo
| |
| 115 bool setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool); | 117 bool setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool); |
| 116 bool hasMarkers(Node* node) const { return m_markers.contains(node); } | 118 bool hasMarkers(Node*) const; |
| 117 | 119 |
| 118 DocumentMarkerVector markersFor( | 120 DocumentMarkerVector markersFor( |
| 119 Node*, | 121 Node*, |
| 120 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); | 122 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); |
| 121 DocumentMarkerVector markersInRange(const EphemeralRange&, | 123 DocumentMarkerVector markersInRange(const EphemeralRange&, |
| 122 DocumentMarker::MarkerTypes); | 124 DocumentMarker::MarkerTypes); |
| 123 DocumentMarkerVector markers(); | 125 DocumentMarkerVector markers(); |
| 124 Vector<IntRect> renderedRectsForMarkers(DocumentMarker::MarkerType); | 126 Vector<IntRect> renderedRectsForMarkers(); |
| 125 void updateMarkerRenderedRectIfNeeded(const Node&, RenderedDocumentMarker&); | 127 void updateTextMatchMarkerRenderedRectIfNeeded(const Node&, |
| 128 RenderedTextMatchMarker&); | |
| 126 void invalidateRectsForAllMarkers(); | 129 void invalidateRectsForAllMarkers(); |
| 127 void invalidateRectsForMarkersInNode(const Node&); | 130 void invalidateRectsForMarkersInNode(Node&); |
| 128 | 131 |
| 129 DECLARE_TRACE(); | 132 DECLARE_TRACE(); |
| 130 | 133 |
| 131 #ifndef NDEBUG | 134 #ifndef NDEBUG |
| 132 void showMarkers() const; | 135 void showMarkers() const; |
| 133 #endif | 136 #endif |
| 134 | 137 |
| 135 // SynchronousMutationObserver | 138 // SynchronousMutationObserver |
| 136 void didUpdateCharacterData(CharacterData*, | 139 void didUpdateCharacterData(CharacterData*, |
| 137 unsigned offset, | 140 unsigned offset, |
| 138 unsigned oldLength, | 141 unsigned oldLength, |
| 139 unsigned newLength) final; | 142 unsigned newLength) final; |
| 140 | 143 |
| 141 private: | 144 private: |
| 142 void addMarker(Node*, const DocumentMarker&); | 145 HeapVector<Member<DocumentMarkerList>> getMarkerListsForNode( |
| 143 | 146 Node*, |
| 144 using MarkerList = HeapVector<Member<RenderedDocumentMarker>>; | 147 DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers()); |
| 145 using MarkerLists = | |
| 146 HeapVector<Member<MarkerList>, DocumentMarker::MarkerTypeIndexesCount>; | |
| 147 using MarkerMap = HeapHashMap<WeakMember<const Node>, Member<MarkerLists>>; | |
| 148 void mergeOverlapping(MarkerList*, RenderedDocumentMarker*); | |
| 149 bool possiblyHasMarkers(DocumentMarker::MarkerTypes); | |
| 150 void removeMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes); | |
| 151 void removeMarkers(TextIterator&, | 148 void removeMarkers(TextIterator&, |
| 152 DocumentMarker::MarkerTypes, | 149 DocumentMarker::MarkerTypes, |
| 153 RemovePartiallyOverlappingMarkerOrNot); | 150 RemovePartiallyOverlappingMarkerOrNot); |
| 154 | 151 |
| 155 MarkerMap m_markers; | 152 template <typename MarkerListType> |
| 156 // Provide a quick way to determine whether a particular marker type is absent | 153 using MarkerMap = HeapHashMap<WeakMember<Node>, Member<MarkerListType>>; |
| 157 // without going through the map. | 154 |
| 158 DocumentMarker::MarkerTypes m_possiblyExistingMarkerTypes; | 155 MarkerMap<SpellingMarkerList> m_spelling; |
| 156 MarkerMap<GrammarMarkerList> m_grammar; | |
| 157 MarkerMap<TextMatchMarkerList> m_textMatches; | |
| 158 MarkerMap<CompositionMarkerList> m_compositions; | |
| 159 | |
| 159 const Member<const Document> m_document; | 160 const Member<const Document> m_document; |
| 160 }; | 161 }; |
| 161 | 162 |
| 162 } // namespace blink | 163 } // namespace blink |
| 163 | 164 |
| 164 #ifndef NDEBUG | 165 #ifndef NDEBUG |
| 165 void showDocumentMarkers(const blink::DocumentMarkerController*); | 166 void showDocumentMarkers(const blink::DocumentMarkerController*); |
| 166 #endif | 167 #endif |
| 167 | 168 |
| 168 #endif // DocumentMarkerController_h | 169 #endif // DocumentMarkerController_h |
| OLD | NEW |