Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: third_party/WebKit/Source/core/editing/markers/TextMatchMarkerList.cpp

Issue 2784753002: Add TextMatchMarkerList in preparation for DocumentMarkerController refactor (Closed)
Patch Set: Remove "explicit" Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698