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

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

Issue 2805553003: DocumentMarkerList refactor as an interface (Closed)
Patch Set: Respond to comments, fill in unimplemented methods 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 DocumentMarker::MatchStatus matchStatus)
14 : DocumentMarker(startOffset, endOffset, matchStatus),
15 m_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.document());
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698