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

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: Rebase 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 state_(State::kInvalid) {} 44 match_status_(status),
45 layout_state_(State::kInvalid) {}
yosin_UTC9 2017/05/29 05:05:33 Let's initialize |layout_state_| inline, .e.g |St
45 46
46 bool IsRendered() const { return state_ == State::kValidNotNull; } 47 bool IsActiveMatch() const { return match_status_ == MatchStatus::kActive; }
48 void SetIsActiveMatch(bool active) {
49 match_status_ = active ? MatchStatus::kActive : MatchStatus::kInactive;
50 }
51
52 bool IsRendered() const { return layout_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(layout_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 (layout_state_ == State::kValidNotNull && rect == rendered_rect_)
53 return; 59 return;
54 state_ = State::kValidNotNull; 60 layout_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(layout_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 layout_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() { layout_state_ = State::kInvalid; }
70 bool IsValid() const { return state_ != State::kInvalid; } 76 bool IsValid() const { return layout_state_ != State::kInvalid; }
71 77
72 private: 78 private:
79 MatchStatus match_status_;
80
yosin_UTC9 2017/05/29 05:05:33 nit: No need to have blank line.
73 LayoutRect rendered_rect_; 81 LayoutRect rendered_rect_;
74 State state_; 82 State layout_state_;
75 }; 83 };
76 84
77 DEFINE_TYPE_CASTS(TextMatchMarker, 85 DEFINE_TYPE_CASTS(TextMatchMarker,
78 DocumentMarker, 86 DocumentMarker,
79 marker, 87 marker,
80 marker->GetType() == DocumentMarker::kTextMatch, 88 marker->GetType() == DocumentMarker::kTextMatch,
81 marker.GetType() == DocumentMarker::kTextMatch); 89 marker.GetType() == DocumentMarker::kTextMatch);
82 90
83 } // namespace blink 91 } // namespace blink
84 92
85 #endif 93 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698