Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: third_party/WebKit/Source/core/editing/markers/TextMatchMarker.cpp

Issue 2784753002: Add TextMatchMarkerList in preparation for DocumentMarkerController refactor (Closed)
Patch Set: Remove "explicit" Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 startOffset,
12 unsigned endOffset,
13 bool activeMatch)
14 : DocumentMarker(startOffset, endOffset, activeMatch),
15 m_state(State::Invalid) {}
16
17 TextMatchMarker* TextMatchMarker::clone() const {
18 return new TextMatchMarker(*this);
19 }
20
21 void TextMatchMarker::updateRenderedRectIfNeeded(const Node& node) {
22 if (!isValid())
23 updateRenderedRect(node);
24 }
25
26 void TextMatchMarker::updateRenderedRect(const Node& node) {
27 Range* range = Range::create(node.document());
28 // The offsets of the marker may be out-dated, so check for exceptions.
29 DummyExceptionStateForTesting exceptionState;
30 range->setStart(&const_cast<Node&>(node), startOffset(), exceptionState);
31 if (!exceptionState.hadException()) {
32 range->setEnd(&const_cast<Node&>(node), endOffset(),
33 IGNORE_EXCEPTION_FOR_TESTING);
34 }
35
36 if (!exceptionState.hadException()) {
37 // TODO(yosin): Once we have a |EphemeralRange| version of
38 // |boundingBox()|, we should use it instead of |Range| version.
39 setRenderedRect(LayoutRect(range->boundingBox()));
40 } else {
41 nullifyRenderedRect();
42 }
43 range->dispose();
44 }
45
46 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698