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

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

Issue 2780313002: [WIP] Refactor DocumentMarker (Closed)
Patch Set: Move CompositionMarkerList::at() into this CL 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
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/TextMatchMarker.h" 5 #include "core/editing/markers/TextMatchMarker.h"
6 6
7 #include "core/dom/Range.h" 7 #include "core/dom/Range.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 TextMatchMarker::TextMatchMarker(unsigned startOffset, 11 TextMatchMarker::TextMatchMarker(unsigned startOffset,
12 unsigned endOffset, 12 unsigned endOffset,
13 bool activeMatch) 13 bool activeMatch)
14 : DocumentMarker(startOffset, endOffset, activeMatch), 14 : DocumentMarker(startOffset, endOffset),
15 m_activeMatch(activeMatch),
15 m_state(State::Invalid) {} 16 m_state(State::Invalid) {}
16 17
17 TextMatchMarker* TextMatchMarker::clone() const { 18 TextMatchMarker* TextMatchMarker::clone() const {
18 return new TextMatchMarker(*this); 19 return new TextMatchMarker(*this);
19 } 20 }
20 21
22 DocumentMarker::MarkerType TextMatchMarker::type() const {
23 return DocumentMarker::TextMatch;
24 }
25
26 bool TextMatchMarker::activeMatch() const {
27 return m_activeMatch;
28 }
29
21 void TextMatchMarker::updateRenderedRectIfNeeded(const Node& node) { 30 void TextMatchMarker::updateRenderedRectIfNeeded(const Node& node) {
22 if (!isValid()) 31 if (!isValid())
23 updateRenderedRect(node); 32 updateRenderedRect(node);
24 } 33 }
25 34
26 void TextMatchMarker::updateRenderedRect(const Node& node) { 35 void TextMatchMarker::updateRenderedRect(const Node& node) {
27 Range* range = Range::create(node.document()); 36 Range* range = Range::create(node.document());
28 // The offsets of the marker may be out-dated, so check for exceptions. 37 // The offsets of the marker may be out-dated, so check for exceptions.
29 DummyExceptionStateForTesting exceptionState; 38 DummyExceptionStateForTesting exceptionState;
30 range->setStart(&const_cast<Node&>(node), startOffset(), exceptionState); 39 range->setStart(&const_cast<Node&>(node), startOffset(), exceptionState);
31 if (!exceptionState.hadException()) { 40 if (!exceptionState.hadException()) {
32 range->setEnd(&const_cast<Node&>(node), endOffset(), 41 range->setEnd(&const_cast<Node&>(node), endOffset(),
33 IGNORE_EXCEPTION_FOR_TESTING); 42 IGNORE_EXCEPTION_FOR_TESTING);
34 } 43 }
35 44
36 if (!exceptionState.hadException()) { 45 if (!exceptionState.hadException()) {
37 // TODO(yosin): Once we have a |EphemeralRange| version of 46 // TODO(yosin): Once we have a |EphemeralRange| version of
38 // |boundingBox()|, we should use it instead of |Range| version. 47 // |boundingBox()|, we should use it instead of |Range| version.
39 setRenderedRect(LayoutRect(range->boundingBox())); 48 setRenderedRect(LayoutRect(range->boundingBox()));
40 } else { 49 } else {
41 nullifyRenderedRect(); 50 nullifyRenderedRect();
42 } 51 }
43 range->dispose(); 52 range->dispose();
44 } 53 }
45 54
46 } // namespace blink 55 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698