OLD | NEW |
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 19 matching lines...) Expand all Loading... |
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 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 static TextMatchMarker* Create(const DocumentMarker& marker) { | 40 TextMatchMarker(unsigned start_offset, |
41 return new TextMatchMarker(marker); | 41 unsigned end_offset, |
42 } | 42 MatchStatus status) |
| 43 : DocumentMarker(start_offset, end_offset, status), |
| 44 state_(State::kInvalid) {} |
43 | 45 |
44 bool IsRendered() const { return state_ == State::kValidNotNull; } | 46 bool IsRendered() const { return state_ == State::kValidNotNull; } |
45 bool Contains(const LayoutPoint& point) const { | 47 bool Contains(const LayoutPoint& point) const { |
46 DCHECK_EQ(state_, State::kValidNotNull); | 48 DCHECK_EQ(state_, State::kValidNotNull); |
47 return rendered_rect_.Contains(point); | 49 return rendered_rect_.Contains(point); |
48 } | 50 } |
49 void SetRenderedRect(const LayoutRect& rect) { | 51 void SetRenderedRect(const LayoutRect& rect) { |
50 if (state_ == State::kValidNotNull && rect == rendered_rect_) | 52 if (state_ == State::kValidNotNull && rect == rendered_rect_) |
51 return; | 53 return; |
52 state_ = State::kValidNotNull; | 54 state_ = State::kValidNotNull; |
(...skipping 24 matching lines...) Expand all Loading... |
77 | 79 |
78 DEFINE_TYPE_CASTS(TextMatchMarker, | 80 DEFINE_TYPE_CASTS(TextMatchMarker, |
79 DocumentMarker, | 81 DocumentMarker, |
80 marker, | 82 marker, |
81 marker->GetType() == DocumentMarker::kTextMatch, | 83 marker->GetType() == DocumentMarker::kTextMatch, |
82 marker.GetType() == DocumentMarker::kTextMatch); | 84 marker.GetType() == DocumentMarker::kTextMatch); |
83 | 85 |
84 } // namespace blink | 86 } // namespace blink |
85 | 87 |
86 #endif | 88 #endif |
OLD | NEW |