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 #include "core/editing/markers/CompositionMarkerListImpl.h" | |
6 | |
7 #include "core/editing/markers/DocumentMarkerListEditor.h" | |
8 #include "core/editing/markers/RenderedDocumentMarker.h" | |
9 | |
10 namespace blink { | |
11 | |
12 bool CompositionMarkerListImpl::IsEmpty() const { | |
13 return markers_.IsEmpty(); | |
14 } | |
15 | |
16 void CompositionMarkerListImpl::Add(DocumentMarker* marker) { | |
17 // TODO(rlanday): make this list impl not create/store RenderedDocumentMarkers | |
18 RenderedDocumentMarker* rendered_marker = | |
yosin_UTC9
2017/04/26 06:45:47
It seems this impl is identical to TextMatchmarker
Xiaocheng
2017/04/26 14:17:53
Seems that we need a patch #3.5 here so that:
- DM
| |
19 RenderedDocumentMarker::Create(*marker); | |
20 | |
21 if (markers_.IsEmpty() || | |
22 markers_.back()->EndOffset() <= marker->StartOffset()) { | |
23 markers_.push_back(rendered_marker); | |
24 return; | |
25 } | |
26 | |
27 const auto pos = std::lower_bound( | |
28 markers_.begin(), markers_.end(), rendered_marker, | |
29 [](const Member<RenderedDocumentMarker>& marker_in_list, | |
30 const RenderedDocumentMarker* marker_to_insert) { | |
31 return marker_in_list->StartOffset() < marker_to_insert->StartOffset(); | |
32 }); | |
33 markers_.insert(pos - markers_.begin(), rendered_marker); | |
34 } | |
35 | |
36 void CompositionMarkerListImpl::Clear() { | |
37 markers_.clear(); | |
38 } | |
39 | |
40 const HeapVector<Member<RenderedDocumentMarker>>& | |
41 CompositionMarkerListImpl::GetMarkers() const { | |
42 return markers_; | |
43 } | |
44 | |
45 bool CompositionMarkerListImpl::MoveMarkers(int length, | |
46 DocumentMarkerList* dst_markers_) { | |
47 return DocumentMarkerListEditor::MoveMarkers(&markers_, length, dst_markers_); | |
48 } | |
49 | |
50 bool CompositionMarkerListImpl::RemoveMarkers(unsigned start_offset, | |
51 int length) { | |
52 return DocumentMarkerListEditor::RemoveMarkers(&markers_, start_offset, | |
53 length); | |
54 } | |
55 | |
56 bool CompositionMarkerListImpl::ShiftMarkers(unsigned offset, | |
57 unsigned old_length, | |
58 unsigned new_length) { | |
59 return DocumentMarkerListEditor::ShiftMarkers(&markers_, offset, old_length, | |
60 new_length); | |
61 } | |
62 | |
63 DEFINE_TRACE(CompositionMarkerListImpl) { | |
64 visitor->Trace(markers_); | |
65 DocumentMarkerList::Trace(visitor); | |
66 } | |
67 | |
68 } // namespace blink | |
OLD | NEW |