OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/editing/markers/TextMatchMarkerListImpl.h" | 5 #include "core/editing/markers/TextMatchMarkerListImpl.h" |
6 | 6 |
7 #include "core/dom/Node.h" | 7 #include "core/dom/Node.h" |
8 #include "core/dom/Range.h" | 8 #include "core/dom/Range.h" |
9 #include "core/editing/EphemeralRange.h" | 9 #include "core/editing/EphemeralRange.h" |
10 #include "core/editing/markers/DocumentMarkerListEditor.h" | 10 #include "core/editing/markers/DocumentMarkerListEditor.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 if (!rendered_marker->IsValid()) | 74 if (!rendered_marker->IsValid()) |
75 UpdateMarkerRenderedRect(node, *rendered_marker); | 75 UpdateMarkerRenderedRect(node, *rendered_marker); |
76 if (!rendered_marker->IsRendered()) | 76 if (!rendered_marker->IsRendered()) |
77 continue; | 77 continue; |
78 result.push_back(rendered_marker->RenderedRect()); | 78 result.push_back(rendered_marker->RenderedRect()); |
79 } | 79 } |
80 | 80 |
81 return result; | 81 return result; |
82 } | 82 } |
83 | 83 |
84 bool TextMatchMarkerListImpl::SetTextMatchMarkersActive(unsigned start_offset, | |
85 unsigned end_offset, | |
86 bool active) { | |
87 bool doc_dirty = false; | |
88 | |
89 const auto start_pos = std::upper_bound( | |
yosin_UTC9
2017/05/25 05:25:39
nit: s/start_pos/start/
Blink doesn't like abbrev
| |
90 markers_.begin(), markers_.end(), start_offset, | |
91 [](size_t start_offset, const Member<DocumentMarker>& marker) { | |
92 return start_offset < marker->EndOffset(); | |
93 }); | |
94 for (auto marker = start_pos; marker != markers_.end(); ++marker) { | |
yosin_UTC9
2017/05/25 05:25:39
|marker| is an iterator instead of |DocumentMarker
| |
95 // Markers are returned in order, so stop if we are now past the specified | |
96 // range. | |
97 if ((*marker)->StartOffset() >= end_offset) | |
98 break; | |
99 | |
100 (*marker)->SetIsActiveMatch(active); | |
101 doc_dirty = true; | |
102 } | |
103 | |
104 return doc_dirty; | |
105 } | |
106 | |
84 } // namespace blink | 107 } // namespace blink |
OLD | NEW |