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 20 matching lines...) Expand all Loading... | |
| 31 | 31 |
| 32 #include "core/CoreExport.h" | 32 #include "core/CoreExport.h" |
| 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 // TODO: remove | |
| 42 #include "core/editing/markers/RenderedDocumentMarker.h" | |
|
rlanday
2017/04/13 02:31:45
oops, I can remove this, I was implementing Docume
| |
| 43 | |
| 41 namespace blink { | 44 namespace blink { |
| 42 | 45 |
| 43 class Node; | 46 class Node; |
| 44 class RenderedDocumentMarker; | 47 class RenderedDocumentMarker; |
| 45 class Text; | 48 class Text; |
| 46 | 49 |
| 47 class MarkerRemoverPredicate final { | 50 class MarkerRemoverPredicate final { |
| 48 public: | 51 public: |
| 49 explicit MarkerRemoverPredicate(const Vector<String>& words); | 52 explicit MarkerRemoverPredicate(const Vector<String>& words); |
| 50 bool operator()(const DocumentMarker&, const Text&) const; | 53 bool operator()(const DocumentMarker&, const Text&) const; |
| 51 | 54 |
| 52 private: | 55 private: |
| 53 Vector<String> words_; | 56 Vector<String> words_; |
| 54 }; | 57 }; |
| 55 | 58 |
| 59 class DocumentMarkerList | |
|
Xiaocheng
2017/04/13 02:39:51
Let's use another name, say, GenericDocumentMarker
| |
| 60 : public GarbageCollectedFinalized<DocumentMarkerList> { | |
| 61 public: | |
| 62 bool IsEmpty() const; | |
| 63 | |
| 64 void Add(DocumentMarker*); | |
| 65 void Clear(); | |
| 66 | |
| 67 void AppendMarkersToInputList(DocumentMarkerVector* input_list) const; | |
| 68 | |
| 69 bool MoveMarkers(int length, DocumentMarkerList* dst_list); | |
| 70 bool RemoveMarkers(unsigned start_offset, int length); | |
| 71 bool ShiftMarkers(unsigned offset, unsigned old_length, unsigned new_length); | |
| 72 | |
| 73 DECLARE_TRACE(); | |
| 74 | |
| 75 private: | |
| 76 void MergeOverlapping(DocumentMarker*); | |
| 77 | |
| 78 HeapVector<Member<DocumentMarker>> markers_; | |
|
Xiaocheng
2017/04/13 02:39:51
RenderedDocumentMarker is another (big) source of
yosin_UTC9
2017/04/13 05:53:57
I agree. We would like to have small and focused p
| |
| 79 }; | |
| 80 | |
| 56 class CORE_EXPORT DocumentMarkerController final | 81 class CORE_EXPORT DocumentMarkerController final |
| 57 : public GarbageCollected<DocumentMarkerController>, | 82 : public GarbageCollected<DocumentMarkerController>, |
| 58 public SynchronousMutationObserver { | 83 public SynchronousMutationObserver { |
| 59 WTF_MAKE_NONCOPYABLE(DocumentMarkerController); | 84 WTF_MAKE_NONCOPYABLE(DocumentMarkerController); |
| 60 USING_GARBAGE_COLLECTED_MIXIN(DocumentMarkerController); | 85 USING_GARBAGE_COLLECTED_MIXIN(DocumentMarkerController); |
| 61 | 86 |
| 62 public: | 87 public: |
| 63 explicit DocumentMarkerController(Document&); | 88 explicit DocumentMarkerController(Document&); |
| 64 | 89 |
| 65 void Clear(); | 90 void Clear(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 void ShowMarkers() const; | 145 void ShowMarkers() const; |
| 121 #endif | 146 #endif |
| 122 | 147 |
| 123 // SynchronousMutationObserver | 148 // SynchronousMutationObserver |
| 124 void DidUpdateCharacterData(CharacterData*, | 149 void DidUpdateCharacterData(CharacterData*, |
| 125 unsigned offset, | 150 unsigned offset, |
| 126 unsigned old_length, | 151 unsigned old_length, |
| 127 unsigned new_length) final; | 152 unsigned new_length) final; |
| 128 | 153 |
| 129 private: | 154 private: |
| 130 void AddMarker(Node*, const DocumentMarker&); | 155 void AddMarker(Node*, const DocumentMarker*); |
| 131 | 156 |
| 132 using MarkerList = HeapVector<Member<RenderedDocumentMarker>>; | 157 using MarkerLists = HeapVector<Member<DocumentMarkerList>, |
| 133 using MarkerLists = | 158 DocumentMarker::kMarkerTypeIndexesCount>; |
| 134 HeapVector<Member<MarkerList>, DocumentMarker::kMarkerTypeIndexesCount>; | |
| 135 using MarkerMap = HeapHashMap<WeakMember<const Node>, Member<MarkerLists>>; | 159 using MarkerMap = HeapHashMap<WeakMember<const Node>, Member<MarkerLists>>; |
| 136 void MergeOverlapping(MarkerList*, RenderedDocumentMarker*); | |
| 137 bool PossiblyHasMarkers(DocumentMarker::MarkerTypes); | 160 bool PossiblyHasMarkers(DocumentMarker::MarkerTypes); |
| 138 void RemoveMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes); | 161 void RemoveMarkersFromList(MarkerMap::iterator, DocumentMarker::MarkerTypes); |
| 139 void RemoveMarkers(TextIterator&, DocumentMarker::MarkerTypes); | 162 void RemoveMarkers(TextIterator&, DocumentMarker::MarkerTypes); |
| 140 | 163 |
| 141 MarkerMap markers_; | 164 MarkerMap markers_; |
| 142 // Provide a quick way to determine whether a particular marker type is absent | 165 // Provide a quick way to determine whether a particular marker type is absent |
| 143 // without going through the map. | 166 // without going through the map. |
| 144 DocumentMarker::MarkerTypes possibly_existing_marker_types_; | 167 DocumentMarker::MarkerTypes possibly_existing_marker_types_; |
| 145 const Member<const Document> document_; | 168 const Member<const Document> document_; |
| 146 }; | 169 }; |
| 147 | 170 |
| 148 } // namespace blink | 171 } // namespace blink |
| 149 | 172 |
| 150 #ifndef NDEBUG | 173 #ifndef NDEBUG |
| 151 void showDocumentMarkers(const blink::DocumentMarkerController*); | 174 void showDocumentMarkers(const blink::DocumentMarkerController*); |
| 152 #endif | 175 #endif |
| 153 | 176 |
| 154 #endif // DocumentMarkerController_h | 177 #endif // DocumentMarkerController_h |
| OLD | NEW |