OLD | NEW |
(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/TextMatchMarker.h" |
| 6 |
| 7 #include "core/dom/Range.h" |
| 8 |
| 9 namespace blink { |
| 10 |
| 11 TextMatchMarker::TextMatchMarker(unsigned start_offset, |
| 12 unsigned end_offset, |
| 13 DocumentMarker::MatchStatus match_status) |
| 14 : DocumentMarker(start_offset, end_offset, match_status), |
| 15 state_(State::kInvalid) {} |
| 16 |
| 17 void TextMatchMarker::UpdateRenderedRectIfNeeded(const Node& node) { |
| 18 if (!IsValid()) |
| 19 UpdateRenderedRect(node); |
| 20 } |
| 21 |
| 22 void TextMatchMarker::UpdateRenderedRect(const Node& node) { |
| 23 Range* range = Range::Create(node.GetDocument()); |
| 24 // The offsets of the marker may be out-dated, so check for exceptions. |
| 25 DummyExceptionStateForTesting exceptionState; |
| 26 range->setStart(&const_cast<Node&>(node), StartOffset(), exceptionState); |
| 27 if (!exceptionState.HadException()) { |
| 28 range->setEnd(&const_cast<Node&>(node), EndOffset(), |
| 29 IGNORE_EXCEPTION_FOR_TESTING); |
| 30 } |
| 31 |
| 32 if (!exceptionState.HadException()) { |
| 33 // TODO(yosin): Once we have a |EphemeralRange| version of |
| 34 // |boundingBox()|, we should use it instead of |Range| version. |
| 35 SetRenderedRect(LayoutRect(range->BoundingBox())); |
| 36 } else { |
| 37 NullifyRenderedRect(); |
| 38 } |
| 39 range->Dispose(); |
| 40 } |
| 41 |
| 42 } // namespace blink |
OLD | NEW |