Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/markers/CompositionMarkerListImpl.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/markers/CompositionMarkerListImpl.cpp b/third_party/WebKit/Source/core/editing/markers/CompositionMarkerListImpl.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a15cfe5db958c897cb053a8d428d63796e555ced |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/editing/markers/CompositionMarkerListImpl.cpp |
| @@ -0,0 +1,68 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "core/editing/markers/CompositionMarkerListImpl.h" |
| + |
| +#include "core/editing/markers/DocumentMarkerListEditor.h" |
| +#include "core/editing/markers/RenderedDocumentMarker.h" |
| + |
| +namespace blink { |
| + |
| +bool CompositionMarkerListImpl::IsEmpty() const { |
| + return markers_.IsEmpty(); |
| +} |
| + |
| +void CompositionMarkerListImpl::Add(DocumentMarker* marker) { |
| + // TODO(rlanday): make this list impl not create/store RenderedDocumentMarkers |
| + 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
|
| + RenderedDocumentMarker::Create(*marker); |
| + |
| + if (markers_.IsEmpty() || |
| + markers_.back()->EndOffset() <= marker->StartOffset()) { |
| + markers_.push_back(rendered_marker); |
| + return; |
| + } |
| + |
| + const auto pos = std::lower_bound( |
| + markers_.begin(), markers_.end(), rendered_marker, |
| + [](const Member<RenderedDocumentMarker>& marker_in_list, |
| + const RenderedDocumentMarker* marker_to_insert) { |
| + return marker_in_list->StartOffset() < marker_to_insert->StartOffset(); |
| + }); |
| + markers_.insert(pos - markers_.begin(), rendered_marker); |
| +} |
| + |
| +void CompositionMarkerListImpl::Clear() { |
| + markers_.clear(); |
| +} |
| + |
| +const HeapVector<Member<RenderedDocumentMarker>>& |
| +CompositionMarkerListImpl::GetMarkers() const { |
| + return markers_; |
| +} |
| + |
| +bool CompositionMarkerListImpl::MoveMarkers(int length, |
| + DocumentMarkerList* dst_markers_) { |
| + return DocumentMarkerListEditor::MoveMarkers(&markers_, length, dst_markers_); |
| +} |
| + |
| +bool CompositionMarkerListImpl::RemoveMarkers(unsigned start_offset, |
| + int length) { |
| + return DocumentMarkerListEditor::RemoveMarkers(&markers_, start_offset, |
| + length); |
| +} |
| + |
| +bool CompositionMarkerListImpl::ShiftMarkers(unsigned offset, |
| + unsigned old_length, |
| + unsigned new_length) { |
| + return DocumentMarkerListEditor::ShiftMarkers(&markers_, offset, old_length, |
| + new_length); |
| +} |
| + |
| +DEFINE_TRACE(CompositionMarkerListImpl) { |
| + visitor->Trace(markers_); |
| + DocumentMarkerList::Trace(visitor); |
| +} |
| + |
| +} // namespace blink |