| 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..c06d9682d8f75000aa14d0b5e12eaa5dd08458a4
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/editing/markers/TextMatchMarkerList.cpp
|
| @@ -0,0 +1,109 @@
|
| +// 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() {}
|
| +
|
| +DocumentMarker::MarkerType TextMatchMarkerList::GetAllowedMarkerType() const {
|
| + return DocumentMarker::kTextMatch;
|
| +}
|
| +
|
| +bool TextMatchMarkerList::Empty() const {
|
| + return markers_.IsEmpty();
|
| +}
|
| +
|
| +TextMatchMarker* TextMatchMarkerList::At(size_t index) {
|
| + return ToTextMatchMarker(markers_[index]);
|
| +}
|
| +
|
| +void TextMatchMarkerList::Add(DocumentMarker* marker) {
|
| + // TextMatch markers must be added in order
|
| + DCHECK(marker->GetType() == GetAllowedMarkerType());
|
| + 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_);
|
| +}
|
| +
|
| +DocumentMarkerList::DidMoveMarkerOrNot TextMatchMarkerList::MoveMarkers(
|
| + int length,
|
| + DocumentMarkerList* dst_list) {
|
| + return DocumentMarkerListEditor::MoveSortedMarkers(&markers_, length,
|
| + dst_list);
|
| +}
|
| +
|
| +DocumentMarkerList::DidRemoveMarkerOrNot TextMatchMarkerList::RemoveMarkers(
|
| + unsigned start_offset,
|
| + int length) {
|
| + return DocumentMarkerListEditor::RemoveSortedMarkers(&markers_, start_offset,
|
| + length);
|
| +}
|
| +
|
| +DocumentMarkerList::DidShiftMarkerOrNot 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
|
|
|