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

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

Issue 2784753002: Add TextMatchMarkerList in preparation for DocumentMarkerController refactor (Closed)
Patch Set: Make requested changes Created 3 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/editing/markers/TextMatchMarkerList.h"
6
7 #include "core/editing/markers/DocumentMarkerController.h"
8
9 namespace blink {
10
11 TextMatchMarkerList::TextMatchMarkerList() {}
12
13 DocumentMarker::MarkerType TextMatchMarkerList::allowedMarkerType() const {
14 return DocumentMarker::TextMatch;
15 }
16
17 void TextMatchMarkerList::appendRenderedRectsToInputList(
18 const Node& node,
19 Vector<IntRect>* result) const {
20 for (Member<DocumentMarker> marker : m_markers) {
21 TextMatchMarker* textMatchMarker = toTextMatchMarker(marker);
22 textMatchMarker->updateRenderedRectIfNeeded(node);
23 if (!textMatchMarker->isRendered())
24 continue;
25 result->push_back(textMatchMarker->renderedRect());
26 }
27 }
28
29 void TextMatchMarkerList::add(DocumentMarker* marker) {
30 // TextMatch markers must be added in order
31 DCHECK(marker->type() == allowedMarkerType());
32 DCHECK(m_markers.isEmpty() ||
33 marker->startOffset() >= m_markers.back()->endOffset());
34 m_markers.push_back(marker);
35 }
36
37 void TextMatchMarkerList::invalidateRects() {
38 for (Member<DocumentMarker> marker : m_markers) {
39 TextMatchMarker* textMatchMarker = toTextMatchMarker(marker.get());
40 textMatchMarker->invalidate();
41 }
42 }
43
44 bool TextMatchMarkerList::setTextMatchMarkersActive(unsigned startOffset,
45 unsigned endOffset,
46 bool active) {
47 bool docDirty = false;
48 for (auto it = getPosOfFirstMarkerNotEndingBefore(startOffset);
Xiaocheng 2017/03/30 21:12:07 I'm still not quite a fan of |getPosOf...|, but di
49 it != m_markers.end(); ++it) {
50 DocumentMarker& marker = **it;
51 // Markers are stored in order, so stop if we are now past the specified
52 // range.
53 if (marker.startOffset() >= endOffset)
54 break;
55
56 marker.setActiveMatch(active);
57 docDirty = true;
58 }
59
60 return docDirty;
61 }
62
63 bool TextMatchMarkerList::markerListIsSorted() const {
64 return true;
65 }
66
67 DEFINE_TRACE(TextMatchMarkerList) {
68 visitor->trace(m_markers);
69 DocumentMarkerList::trace(visitor);
70 }
71
72 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698