Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef DocumentMarkerList_h | |
| 6 #define DocumentMarkerList_h | |
| 7 | |
| 8 #include "core/editing/markers/DocumentMarker.h" | |
| 9 #include "platform/heap/Handle.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 class CORE_EXPORT DocumentMarkerList | |
| 14 : public GarbageCollected<DocumentMarkerList> { | |
| 15 public: | |
| 16 explicit DocumentMarkerList(); | |
| 17 using iterator = Member<DocumentMarker>*; | |
| 18 using const_iterator = const Member<DocumentMarker>*; | |
| 19 | |
| 20 virtual DocumentMarker::MarkerType allowedMarkerType() const = 0; | |
| 21 virtual bool isEditingMarkerList() const; | |
| 22 virtual bool isSpellCheckMarkerList() const; | |
| 23 | |
| 24 size_t size() const { return m_markers.size(); } | |
| 25 bool empty() const { return m_markers.isEmpty(); } | |
| 26 DocumentMarker* at(size_t index) { return m_markers[index].get(); } | |
| 27 | |
| 28 virtual void add(DocumentMarker*); | |
| 29 virtual void clear(); | |
| 30 | |
| 31 iterator begin() { return m_markers.begin(); } | |
| 32 iterator end() { return m_markers.end(); } | |
| 33 const_iterator begin() const { return m_markers.begin(); } | |
| 34 const_iterator end() const { return m_markers.end(); } | |
| 35 | |
| 36 void appendMarkersToInputList(DocumentMarkerVector* list) const; | |
| 37 | |
| 38 enum DidCopyMarkerOrNot { DidNotCopyMarker, DidCopyMarker }; | |
|
Xiaocheng
2017/03/27 22:38:20
nit: use |enum class|. Ditto for the other two.
| |
| 39 DidCopyMarkerOrNot copyMarkers(unsigned startOffset, | |
|
Xiaocheng
2017/03/27 22:38:20
These functions also have quadratic running time..
rlanday
2017/03/27 23:57:40
- copyMarkers() appears to be O(n) to me when inse
rlanday
2017/03/28 00:06:19
Actually I think copyMarkers() is only ever going
| |
| 40 int length, | |
| 41 DocumentMarkerList* dstList, | |
| 42 int delta) const; | |
| 43 | |
| 44 enum DidRemoveMarkerOrNot { DidNotRemoveMarker, DidRemoveMarker }; | |
| 45 DidRemoveMarkerOrNot removeMarkers( | |
| 46 unsigned startOffset, | |
| 47 int length, | |
| 48 bool shouldRemovePartiallyOverlappingMarkers); | |
| 49 | |
| 50 enum DidShiftMarkerOrNot { DidNotShiftMarker, DidShiftMarker }; | |
| 51 DidShiftMarkerOrNot shiftMarkers(unsigned offset, | |
| 52 unsigned oldLength, | |
| 53 unsigned newLength); | |
| 54 | |
| 55 DECLARE_VIRTUAL_TRACE(); | |
| 56 | |
| 57 protected: | |
| 58 iterator getPosOfFirstMarkerNotEndingBefore(size_t startOffset); | |
| 59 virtual bool markerListIsSorted() const = 0; | |
| 60 | |
| 61 HeapVector<Member<DocumentMarker>> m_markers; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(DocumentMarkerList); | |
| 64 }; | |
| 65 | |
| 66 } // namespace blink | |
| 67 | |
| 68 #endif // DocumentMarkerList_h | |
| OLD | NEW |