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.h

Issue 2919603005: [DMC #27] Move TextMatchMarker method implementations to TextMatchMarker.cpp (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 25 matching lines...) Expand all
36 // markers. We store whether or not the match is active, a LayoutRect used for 36 // markers. We store whether or not the match is active, a LayoutRect used for
37 // rendering the marker, and whether or not the LayoutRect is currently 37 // rendering the marker, and whether or not the LayoutRect is currently
38 // up-to-date. 38 // up-to-date.
39 class CORE_EXPORT TextMatchMarker final : public DocumentMarker { 39 class CORE_EXPORT TextMatchMarker final : public DocumentMarker {
40 private: 40 private:
41 enum class State { kInvalid, kValidNull, kValidNotNull }; 41 enum class State { kInvalid, kValidNull, kValidNotNull };
42 42
43 public: 43 public:
44 enum class MatchStatus { kInactive, kActive }; 44 enum class MatchStatus { kInactive, kActive };
45 45
46 TextMatchMarker(unsigned start_offset, 46 TextMatchMarker(unsigned start_offset, unsigned end_offset, MatchStatus);
47 unsigned end_offset,
48 MatchStatus status)
49 : DocumentMarker(start_offset, end_offset), match_status_(status) {
50 layout_state_ = State::kInvalid;
51 }
52 47
53 // DocumentMarker implementations 48 // DocumentMarker implementations
54 MarkerType GetType() const final; 49 MarkerType GetType() const final;
55 50
56 // TextMatchMarker-specific 51 // TextMatchMarker-specific
57 bool IsActiveMatch() const { return match_status_ == MatchStatus::kActive; } 52 bool IsActiveMatch() const;
58 void SetIsActiveMatch(bool active) { 53 void SetIsActiveMatch(bool active);
59 match_status_ = active ? MatchStatus::kActive : MatchStatus::kInactive;
60 }
61 54
62 bool IsRendered() const { return layout_state_ == State::kValidNotNull; } 55 bool IsRendered() const;
63 bool Contains(const LayoutPoint& point) const { 56 bool Contains(const LayoutPoint&) const;
64 DCHECK_EQ(layout_state_, State::kValidNotNull); 57 void SetRenderedRect(const LayoutRect&);
65 return rendered_rect_.Contains(point);
66 }
67 void SetRenderedRect(const LayoutRect& rect) {
68 if (layout_state_ == State::kValidNotNull && rect == rendered_rect_)
69 return;
70 layout_state_ = State::kValidNotNull;
71 rendered_rect_ = rect;
72 }
73 58
Xiaocheng 2017/06/01 21:42:50 nit: Could you remove the empty lines at L58, L60
74 const LayoutRect& RenderedRect() const { 59 const LayoutRect& RenderedRect() const;
75 DCHECK_EQ(layout_state_, State::kValidNotNull);
76 return rendered_rect_;
77 }
78 60
79 void NullifyRenderedRect() { 61 void NullifyRenderedRect();
80 layout_state_ = State::kValidNull;
81 // Now |m_renderedRect| can not be accessed until |setRenderedRect| is
82 // called.
83 }
84 62
85 void Invalidate() { layout_state_ = State::kInvalid; } 63 void Invalidate();
86 bool IsValid() const { return layout_state_ != State::kInvalid; } 64 bool IsValid() const;
87 65
88 private: 66 private:
89 MatchStatus match_status_; 67 MatchStatus match_status_;
90 LayoutRect rendered_rect_; 68 LayoutRect rendered_rect_;
91 State layout_state_; 69 State layout_state_;
92 70
93 DISALLOW_COPY_AND_ASSIGN(TextMatchMarker); 71 DISALLOW_COPY_AND_ASSIGN(TextMatchMarker);
94 }; 72 };
95 73
96 DEFINE_TYPE_CASTS(TextMatchMarker, 74 DEFINE_TYPE_CASTS(TextMatchMarker,
97 DocumentMarker, 75 DocumentMarker,
98 marker, 76 marker,
99 marker->GetType() == DocumentMarker::kTextMatch, 77 marker->GetType() == DocumentMarker::kTextMatch,
100 marker.GetType() == DocumentMarker::kTextMatch); 78 marker.GetType() == DocumentMarker::kTextMatch);
101 79
102 } // namespace blink 80 } // namespace blink
103 81
104 #endif 82 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698