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..6bf395ad1c9f0d3909154a71d4898e42ee72526e |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/editing/markers/TextMatchMarkerList.cpp |
@@ -0,0 +1,76 @@ |
+// 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/DocumentMarkerController.h" |
+ |
+namespace blink { |
+ |
+TextMatchMarkerList::TextMatchMarkerList() {} |
+ |
+DocumentMarker::MarkerType TextMatchMarkerList::allowedMarkerType() const { |
+ return DocumentMarker::TextMatch; |
+} |
+ |
+TextMatchMarker* TextMatchMarkerList::at(size_t index) { |
+ return toTextMatchMarker(DocumentMarkerList::at(index)); |
+} |
+ |
+void TextMatchMarkerList::appendRenderedRectsToInputList( |
+ const Node& node, |
+ Vector<IntRect>* result) const { |
+ for (Member<DocumentMarker> marker : m_markers) { |
+ TextMatchMarker* textMatchMarker = toTextMatchMarker(marker); |
+ textMatchMarker->updateRenderedRectIfNeeded(node); |
+ if (!textMatchMarker->isRendered()) |
+ continue; |
+ result->push_back(textMatchMarker->renderedRect()); |
+ } |
+} |
+ |
+void TextMatchMarkerList::add(DocumentMarker* marker) { |
+ // TextMatch markers must be added in order |
+ DCHECK(marker->type() == allowedMarkerType()); |
+ DCHECK(m_markers.isEmpty() || |
+ marker->startOffset() >= m_markers.back()->endOffset()); |
+ m_markers.push_back(marker); |
+} |
+ |
+void TextMatchMarkerList::invalidateRects() { |
+ for (Member<DocumentMarker> marker : m_markers) { |
+ TextMatchMarker* textMatchMarker = toTextMatchMarker(marker.get()); |
+ textMatchMarker->invalidate(); |
+ } |
+} |
+ |
+bool TextMatchMarkerList::setTextMatchMarkersActive(unsigned startOffset, |
+ unsigned endOffset, |
+ bool active) { |
+ bool docDirty = false; |
+ for (auto it = getPosOfFirstMarkerNotEndingBefore(startOffset); |
+ it != m_markers.end(); ++it) { |
+ DocumentMarker& marker = **it; |
+ // Markers are stored in order, so stop if we are now past the specified |
+ // range. |
+ if (marker.startOffset() >= endOffset) |
+ break; |
+ |
+ marker.setActiveMatch(active); |
+ docDirty = true; |
+ } |
+ |
+ return docDirty; |
+} |
+ |
+bool TextMatchMarkerList::markerListIsSorted() const { |
+ return true; |
+} |
+ |
+DEFINE_TRACE(TextMatchMarkerList) { |
+ visitor->trace(m_markers); |
+ DocumentMarkerList::trace(visitor); |
+} |
+ |
+} // namespace blink |