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 #include "third_party/blink/renderer/core/editing/markers/active_suggestion_marker_list_impl.h"
6 
7 #include "third_party/blink/renderer/core/editing/markers/sorted_document_marker_list_editor.h"
8 
9 namespace blink {
10 
MarkerType() const11 DocumentMarker::MarkerType ActiveSuggestionMarkerListImpl::MarkerType() const {
12   return DocumentMarker::kActiveSuggestion;
13 }
14 
IsEmpty() const15 bool ActiveSuggestionMarkerListImpl::IsEmpty() const {
16   return markers_.IsEmpty();
17 }
18 
Add(DocumentMarker * marker)19 void ActiveSuggestionMarkerListImpl::Add(DocumentMarker* marker) {
20   DCHECK_EQ(DocumentMarker::kActiveSuggestion, marker->GetType());
21   SortedDocumentMarkerListEditor::AddMarkerWithoutMergingOverlapping(&markers_,
22                                                                      marker);
23 }
24 
Clear()25 void ActiveSuggestionMarkerListImpl::Clear() {
26   markers_.clear();
27 }
28 
29 const HeapVector<Member<DocumentMarker>>&
GetMarkers() const30 ActiveSuggestionMarkerListImpl::GetMarkers() const {
31   return markers_;
32 }
33 
FirstMarkerIntersectingRange(unsigned start_offset,unsigned end_offset) const34 DocumentMarker* ActiveSuggestionMarkerListImpl::FirstMarkerIntersectingRange(
35     unsigned start_offset,
36     unsigned end_offset) const {
37   return SortedDocumentMarkerListEditor::FirstMarkerIntersectingRange(
38       markers_, start_offset, end_offset);
39 }
40 
41 HeapVector<Member<DocumentMarker>>
MarkersIntersectingRange(unsigned start_offset,unsigned end_offset) const42 ActiveSuggestionMarkerListImpl::MarkersIntersectingRange(
43     unsigned start_offset,
44     unsigned end_offset) const {
45   return SortedDocumentMarkerListEditor::MarkersIntersectingRange(
46       markers_, start_offset, end_offset);
47 }
48 
MoveMarkers(int length,DocumentMarkerList * dst_markers_)49 bool ActiveSuggestionMarkerListImpl::MoveMarkers(
50     int length,
51     DocumentMarkerList* dst_markers_) {
52   return SortedDocumentMarkerListEditor::MoveMarkers(&markers_, length,
53                                                      dst_markers_);
54 }
55 
RemoveMarkers(unsigned start_offset,int length)56 bool ActiveSuggestionMarkerListImpl::RemoveMarkers(unsigned start_offset,
57                                                    int length) {
58   return SortedDocumentMarkerListEditor::RemoveMarkers(&markers_, start_offset,
59                                                        length);
60 }
61 
ShiftMarkers(const String &,unsigned offset,unsigned old_length,unsigned new_length)62 bool ActiveSuggestionMarkerListImpl::ShiftMarkers(const String&,
63                                                   unsigned offset,
64                                                   unsigned old_length,
65                                                   unsigned new_length) {
66   return SortedDocumentMarkerListEditor::ShiftMarkersContentIndependent(
67       &markers_, offset, old_length, new_length);
68 }
69 
Trace(Visitor * visitor) const70 void ActiveSuggestionMarkerListImpl::Trace(Visitor* visitor) const {
71   visitor->Trace(markers_);
72   DocumentMarkerList::Trace(visitor);
73 }
74 
75 }  // namespace blink
76