| Index: third_party/WebKit/Source/core/editing/markers/TextMatchMarker.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/markers/TextMatchMarker.cpp b/third_party/WebKit/Source/core/editing/markers/TextMatchMarker.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..edb82e3a629763da8484e60d40a229e451349987
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/editing/markers/TextMatchMarker.cpp
|
| @@ -0,0 +1,46 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "core/editing/markers/TextMatchMarker.h"
|
| +
|
| +#include "core/dom/Range.h"
|
| +
|
| +namespace blink {
|
| +
|
| +TextMatchMarker::TextMatchMarker(unsigned startOffset,
|
| + unsigned endOffset,
|
| + bool activeMatch)
|
| + : DocumentMarker(startOffset, endOffset, activeMatch),
|
| + m_state(State::Invalid) {}
|
| +
|
| +TextMatchMarker* TextMatchMarker::clone() const {
|
| + return new TextMatchMarker(*this);
|
| +}
|
| +
|
| +void TextMatchMarker::updateRenderedRectIfNeeded(const Node& node) {
|
| + if (!isValid())
|
| + updateRenderedRect(node);
|
| +}
|
| +
|
| +void TextMatchMarker::updateRenderedRect(const Node& node) {
|
| + Range* range = Range::create(node.document());
|
| + // The offsets of the marker may be out-dated, so check for exceptions.
|
| + DummyExceptionStateForTesting exceptionState;
|
| + range->setStart(&const_cast<Node&>(node), startOffset(), exceptionState);
|
| + if (!exceptionState.hadException()) {
|
| + range->setEnd(&const_cast<Node&>(node), endOffset(),
|
| + IGNORE_EXCEPTION_FOR_TESTING);
|
| + }
|
| +
|
| + if (!exceptionState.hadException()) {
|
| + // TODO(yosin): Once we have a |EphemeralRange| version of
|
| + // |boundingBox()|, we should use it instead of |Range| version.
|
| + setRenderedRect(LayoutRect(range->boundingBox()));
|
| + } else {
|
| + nullifyRenderedRect();
|
| + }
|
| + range->dispose();
|
| +}
|
| +
|
| +} // namespace blink
|
|
|