Chromium Code Reviews| 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::ShiftMarkers(&markers_, offset, old_length, | 51 return DocumentMarkerListEditor::ShiftMarkers(&markers_, offset, old_length, |
| 48 new_length); | 52 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 Vector<IntRect> TextMatchMarkerListImpl::RenderedRects(const Node& node) { | |
| 61 Vector<IntRect> result; | |
| 62 | |
| 63 for (DocumentMarker* marker : markers_) { | |
| 64 RenderedDocumentMarker* const rendered_marker = | |
| 65 ToRenderedDocumentMarker(marker); | |
| 66 UpdateMarkerRenderedRectIfNeeded(node, *rendered_marker); | |
| 67 if (!rendered_marker->IsRendered()) | |
| 68 continue; | |
| 69 result.push_back(rendered_marker->RenderedRect()); | |
| 70 } | |
| 71 | |
| 72 return result; | |
| 73 } | |
| 74 | |
| 75 void TextMatchMarkerListImpl::UpdateMarkerRenderedRectIfNeeded( | |
| 76 const Node& node, | |
| 77 RenderedDocumentMarker& marker) { | |
| 78 if (marker.IsValid()) | |
| 79 return; | |
| 80 | |
| 81 const Position startPosition(&const_cast<Node&>(node), marker.StartOffset()); | |
|
yosin_UTC9
2017/05/24 09:21:50
Is it useful to have DomcumentMaker::AsRange(const
rlanday
2017/05/24 20:25:06
Might be useful in a few places. I still wish Docu
| |
| 82 const Position endPostion(&const_cast<Node&>(node), marker.EndOffset()); | |
| 83 EphemeralRange range(startPosition, endPostion); | |
| 84 marker.SetRenderedRect(LayoutRect(ComputeTextRect(range))); | |
| 85 } | |
| 86 | |
| 56 } // namespace blink | 87 } // namespace blink |
| OLD | NEW |