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

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

Issue 2904093002: [DMC #18] Eliminate DocumentMarkerTextMatch (subclass of DocumentMarkerDetails) (Closed)
Patch Set: Created 3 years, 6 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 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 22 matching lines...) Expand all
33 namespace blink { 33 namespace blink {
34 34
35 class TextMatchMarker final : public DocumentMarker { 35 class TextMatchMarker final : public DocumentMarker {
36 private: 36 private:
37 enum class State { kInvalid, kValidNull, kValidNotNull }; 37 enum class State { kInvalid, kValidNull, kValidNotNull };
38 38
39 public: 39 public:
40 TextMatchMarker(unsigned start_offset, 40 TextMatchMarker(unsigned start_offset,
41 unsigned end_offset, 41 unsigned end_offset,
42 MatchStatus status) 42 MatchStatus status)
43 : DocumentMarker(start_offset, end_offset, status), 43 : DocumentMarker(DocumentMarker::kTextMatch, start_offset, end_offset),
44 status_(status),
44 state_(State::kInvalid) {} 45 state_(State::kInvalid) {}
45 46
47 bool IsActiveMatch() const { return status_ == MatchStatus::kActive; }
48 void SetIsActiveMatch(bool active) {
49 status_ = active ? MatchStatus::kActive : MatchStatus::kInactive;
50 }
51
46 bool IsRendered() const { return state_ == State::kValidNotNull; } 52 bool IsRendered() const { return state_ == State::kValidNotNull; }
47 bool Contains(const LayoutPoint& point) const { 53 bool Contains(const LayoutPoint& point) const {
48 DCHECK_EQ(state_, State::kValidNotNull); 54 DCHECK_EQ(state_, State::kValidNotNull);
49 return rendered_rect_.Contains(point); 55 return rendered_rect_.Contains(point);
50 } 56 }
51 void SetRenderedRect(const LayoutRect& rect) { 57 void SetRenderedRect(const LayoutRect& rect) {
52 if (state_ == State::kValidNotNull && rect == rendered_rect_) 58 if (state_ == State::kValidNotNull && rect == rendered_rect_)
53 return; 59 return;
54 state_ = State::kValidNotNull; 60 state_ = State::kValidNotNull;
55 rendered_rect_ = rect; 61 rendered_rect_ = rect;
56 } 62 }
57 63
58 const LayoutRect& RenderedRect() const { 64 const LayoutRect& RenderedRect() const {
59 DCHECK_EQ(state_, State::kValidNotNull); 65 DCHECK_EQ(state_, State::kValidNotNull);
60 return rendered_rect_; 66 return rendered_rect_;
61 } 67 }
62 68
63 void NullifyRenderedRect() { 69 void NullifyRenderedRect() {
64 state_ = State::kValidNull; 70 state_ = State::kValidNull;
65 // Now |m_renderedRect| can not be accessed until |setRenderedRect| is 71 // Now |m_renderedRect| can not be accessed until |setRenderedRect| is
66 // called. 72 // called.
67 } 73 }
68 74
69 void Invalidate() { state_ = State::kInvalid; } 75 void Invalidate() { state_ = State::kInvalid; }
70 bool IsValid() const { return state_ != State::kInvalid; } 76 bool IsValid() const { return state_ != State::kInvalid; }
71 77
72 private: 78 private:
73 explicit TextMatchMarker(const DocumentMarker& marker) 79 MatchStatus status_;
yosin_UTC9 2017/05/26 04:39:47 nit: s/status_/match_status_/ It is confusing to
74 : DocumentMarker(marker), state_(State::kInvalid) {}
75 80
76 LayoutRect rendered_rect_; 81 LayoutRect rendered_rect_;
77 State state_; 82 State state_;
78 }; 83 };
79 84
80 DEFINE_TYPE_CASTS(TextMatchMarker, DocumentMarker, marker, true, true); 85 DEFINE_TYPE_CASTS(TextMatchMarker, DocumentMarker, marker, true, true);
81 86
82 } // namespace blink 87 } // namespace blink
83 88
84 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::TextMatchMarker); 89 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::TextMatchMarker);
85 90
86 #endif 91 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698