| Index: third_party/WebKit/Source/core/editing/markers/TextMatchMarkerList.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/markers/TextMatchMarkerList.cpp b/third_party/WebKit/Source/core/editing/markers/TextMatchMarkerList.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c6fd0e80f119591ba61cc83726ba8622f9654d19
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/editing/markers/TextMatchMarkerList.cpp
|
| @@ -0,0 +1,96 @@
|
| +// 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/TextMatchMarkerList.h"
|
| +
|
| +#include "core/editing/markers/DocumentMarkerListEditor.h"
|
| +
|
| +namespace blink {
|
| +
|
| +TextMatchMarkerList::TextMatchMarkerList() = default;
|
| +
|
| +bool TextMatchMarkerList::Empty() const {
|
| + return markers_.IsEmpty();
|
| +}
|
| +
|
| +void TextMatchMarkerList::Add(DocumentMarker* marker) {
|
| + // TextMatch markers must be added in order
|
| + DCHECK(markers_.IsEmpty() ||
|
| + marker->StartOffset() >= markers_.back()->EndOffset());
|
| + markers_.push_back(marker);
|
| +}
|
| +
|
| +void TextMatchMarkerList::Clear() {
|
| + markers_.Clear();
|
| +}
|
| +
|
| +void TextMatchMarkerList::AppendMarkersToInputList(
|
| + DocumentMarkerVector* list) const {
|
| + list->AppendVector(markers_);
|
| +}
|
| +
|
| +bool TextMatchMarkerList::MoveMarkers(int length,
|
| + DocumentMarkerList* dst_list) {
|
| + return DocumentMarkerListEditor::MoveSortedMarkers(&markers_, length,
|
| + dst_list);
|
| +}
|
| +
|
| +bool TextMatchMarkerList::RemoveMarkers(unsigned start_offset, int length) {
|
| + return DocumentMarkerListEditor::RemoveSortedMarkers(&markers_, start_offset,
|
| + length);
|
| +}
|
| +
|
| +bool TextMatchMarkerList::ShiftMarkers(unsigned offset,
|
| + unsigned oldLength,
|
| + unsigned newLength) {
|
| + return DocumentMarkerListEditor::ShiftSortedMarkers(&markers_, offset,
|
| + oldLength, newLength);
|
| +}
|
| +
|
| +DEFINE_TRACE(TextMatchMarkerList) {
|
| + visitor->Trace(markers_);
|
| + DocumentMarkerList::Trace(visitor);
|
| +}
|
| +
|
| +void TextMatchMarkerList::AppendRenderedRectsToInputList(
|
| + const Node& node,
|
| + Vector<IntRect>* result) const {
|
| + for (Member<DocumentMarker> marker : markers_) {
|
| + TextMatchMarker* text_match_marker = ToTextMatchMarker(marker);
|
| + text_match_marker->UpdateRenderedRectIfNeeded(node);
|
| + if (!text_match_marker->IsRendered())
|
| + continue;
|
| + result->push_back(text_match_marker->RenderedRect());
|
| + }
|
| +}
|
| +
|
| +void TextMatchMarkerList::InvalidateRects() {
|
| + for (Member<DocumentMarker> marker : markers_) {
|
| + TextMatchMarker* text_match_marker = ToTextMatchMarker(marker.Get());
|
| + text_match_marker->Invalidate();
|
| + }
|
| +}
|
| +
|
| +bool TextMatchMarkerList::SetTextMatchMarkersActive(unsigned start_offset,
|
| + unsigned end_offset,
|
| + bool active) {
|
| + bool doc_dirty = false;
|
| + for (auto it = DocumentMarkerListEditor::
|
| + GetPosOfFirstMarkerNotEndingBeforeInSortedList(&markers_,
|
| + start_offset);
|
| + it != markers_.end(); ++it) {
|
| + DocumentMarker& marker = **it;
|
| + // Markers are stored in order, so stop if we are now past the specified
|
| + // range.
|
| + if (marker.StartOffset() >= end_offset)
|
| + break;
|
| +
|
| + marker.SetIsActiveMatch(active);
|
| + doc_dirty = true;
|
| + }
|
| +
|
| + return doc_dirty;
|
| +}
|
| +
|
| +} // namespace blink
|
|
|