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

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

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 #ifndef TextMatchMarker_h
6 #define TextMatchMarker_h
7
8 #include <utility>
9 #include "core/editing/markers/DocumentMarker.h"
10 #include "platform/geometry/LayoutRect.h"
11
12 namespace blink {
13
14 class CORE_EXPORT TextMatchMarker final : public DocumentMarker {
15 public:
16 TextMatchMarker(unsigned startOffset, unsigned endOffset, bool activeMatch);
17
18 TextMatchMarker* clone() const final;
19
20 bool isRendered() const { return m_state == State::ValidNotNull; }
21
22 void setRenderedRect(const LayoutRect& rect) {
23 if (m_state == State::ValidNotNull && rect == m_renderedRect)
24 return;
25 m_state = State::ValidNotNull;
26 m_renderedRect = rect;
27 }
28
29 const LayoutRect& renderedRect() const {
30 DCHECK_EQ(m_state, State::ValidNotNull);
31 return m_renderedRect;
32 }
33
34 void updateRenderedRectIfNeeded(const Node&);
35 void updateRenderedRect(const Node&);
36
37 void nullifyRenderedRect() {
38 m_state = State::ValidNull;
39 // Now |m_renderedRect| can not be accessed until |setRenderedRect| is
40 // called.
41 }
42
43 void invalidate() { m_state = State::Invalid; }
44 bool isValid() const { return m_state != State::Invalid; }
45
46 protected:
47 TextMatchMarker(const TextMatchMarker&) = default;
48
49 private:
50 enum class State { Invalid, ValidNull, ValidNotNull };
51
52 LayoutRect m_renderedRect;
53 State m_state;
54 };
55
56 DEFINE_TYPE_CASTS(TextMatchMarker,
57 DocumentMarker,
58 marker,
59 marker->type() == DocumentMarker::TextMatch,
60 marker.type() == DocumentMarker::TextMatch);
61
62 } // namespace blink
63
64 #endif // TextMatchMarker_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/BUILD.gn ('k') | third_party/WebKit/Source/core/editing/markers/TextMatchMarker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698