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" |
| 8 #include "core/dom/Range.h" |
| 9 #include "core/editing/EphemeralRange.h" |
7 #include "core/editing/markers/DocumentMarkerListEditor.h" | 10 #include "core/editing/markers/DocumentMarkerListEditor.h" |
8 #include "core/editing/markers/RenderedDocumentMarker.h" | 11 #include "core/editing/markers/RenderedDocumentMarker.h" |
| 12 #include "third_party/WebKit/Source/core/editing/VisibleUnits.h" |
9 | 13 |
10 namespace blink { | 14 namespace blink { |
11 | 15 |
12 DocumentMarker::MarkerType TextMatchMarkerListImpl::MarkerType() const { | 16 DocumentMarker::MarkerType TextMatchMarkerListImpl::MarkerType() const { |
13 return DocumentMarker::kTextMatch; | 17 return DocumentMarker::kTextMatch; |
14 } | 18 } |
15 | 19 |
16 bool TextMatchMarkerListImpl::IsEmpty() const { | 20 bool TextMatchMarkerListImpl::IsEmpty() const { |
17 return markers_.IsEmpty(); | 21 return markers_.IsEmpty(); |
18 } | 22 } |
(...skipping 27 matching lines...) Expand all Loading... |
46 unsigned new_length) { | 50 unsigned new_length) { |
47 return DocumentMarkerListEditor::ShiftMarkersContentDependent( | 51 return DocumentMarkerListEditor::ShiftMarkersContentDependent( |
48 &markers_, offset, old_length, new_length); | 52 &markers_, offset, old_length, new_length); |
49 } | 53 } |
50 | 54 |
51 DEFINE_TRACE(TextMatchMarkerListImpl) { | 55 DEFINE_TRACE(TextMatchMarkerListImpl) { |
52 visitor->Trace(markers_); | 56 visitor->Trace(markers_); |
53 DocumentMarkerList::Trace(visitor); | 57 DocumentMarkerList::Trace(visitor); |
54 } | 58 } |
55 | 59 |
| 60 static void UpdateMarkerRenderedRect(const Node& node, |
| 61 RenderedDocumentMarker& marker) { |
| 62 const Position start_position(&const_cast<Node&>(node), marker.StartOffset()); |
| 63 const Position end_position(&const_cast<Node&>(node), marker.EndOffset()); |
| 64 EphemeralRange range(start_position, end_position); |
| 65 marker.SetRenderedRect(LayoutRect(ComputeTextRect(range))); |
| 66 } |
| 67 |
| 68 Vector<IntRect> TextMatchMarkerListImpl::RenderedRects(const Node& node) const { |
| 69 Vector<IntRect> result; |
| 70 |
| 71 for (DocumentMarker* marker : markers_) { |
| 72 RenderedDocumentMarker* const rendered_marker = |
| 73 ToRenderedDocumentMarker(marker); |
| 74 if (!rendered_marker->IsValid()) |
| 75 UpdateMarkerRenderedRect(node, *rendered_marker); |
| 76 if (!rendered_marker->IsRendered()) |
| 77 continue; |
| 78 result.push_back(rendered_marker->RenderedRect()); |
| 79 } |
| 80 |
| 81 return result; |
| 82 } |
| 83 |
56 } // namespace blink | 84 } // namespace blink |
OLD | NEW |