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

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

Issue 2911733002: [DMC #25] Make DocumentMarker::GetType() virtual (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 18 matching lines...) Expand all
29 29
30 #include "core/editing/markers/DocumentMarker.h" 30 #include "core/editing/markers/DocumentMarker.h"
31 #include "platform/geometry/LayoutRect.h" 31 #include "platform/geometry/LayoutRect.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 // A subclass of DocumentMarker used to store information specific to TextMatch 35 // A subclass of DocumentMarker used to store information specific to TextMatch
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 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,
47 unsigned end_offset, 47 unsigned end_offset,
48 MatchStatus status) 48 MatchStatus status)
49 : DocumentMarker(DocumentMarker::kTextMatch, start_offset, end_offset), 49 : DocumentMarker(start_offset, end_offset), match_status_(status) {
50 match_status_(status) {
51 layout_state_ = State::kInvalid; 50 layout_state_ = State::kInvalid;
52 } 51 }
53 52
53 // DocumentMarker implementations
54 MarkerType GetType() const final;
55
56 // TextMatchMarker-specific
54 bool IsActiveMatch() const { return match_status_ == MatchStatus::kActive; } 57 bool IsActiveMatch() const { return match_status_ == MatchStatus::kActive; }
55 void SetIsActiveMatch(bool active) { 58 void SetIsActiveMatch(bool active) {
56 match_status_ = active ? MatchStatus::kActive : MatchStatus::kInactive; 59 match_status_ = active ? MatchStatus::kActive : MatchStatus::kInactive;
57 } 60 }
58 61
59 bool IsRendered() const { return layout_state_ == State::kValidNotNull; } 62 bool IsRendered() const { return layout_state_ == State::kValidNotNull; }
60 bool Contains(const LayoutPoint& point) const { 63 bool Contains(const LayoutPoint& point) const {
61 DCHECK_EQ(layout_state_, State::kValidNotNull); 64 DCHECK_EQ(layout_state_, State::kValidNotNull);
62 return rendered_rect_.Contains(point); 65 return rendered_rect_.Contains(point);
63 } 66 }
(...skipping 28 matching lines...) Expand all
92 95
93 DEFINE_TYPE_CASTS(TextMatchMarker, 96 DEFINE_TYPE_CASTS(TextMatchMarker,
94 DocumentMarker, 97 DocumentMarker,
95 marker, 98 marker,
96 marker->GetType() == DocumentMarker::kTextMatch, 99 marker->GetType() == DocumentMarker::kTextMatch,
97 marker.GetType() == DocumentMarker::kTextMatch); 100 marker.GetType() == DocumentMarker::kTextMatch);
98 101
99 } // namespace blink 102 } // namespace blink
100 103
101 #endif 104 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698