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