Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 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, |
|
yosin_UTC9
2017/06/01 05:48:59
In following patch, could you move inline function
| |
| 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 26 matching lines...) Expand all Loading... | |
| 90 | 93 |
| 91 DEFINE_TYPE_CASTS(TextMatchMarker, | 94 DEFINE_TYPE_CASTS(TextMatchMarker, |
| 92 DocumentMarker, | 95 DocumentMarker, |
| 93 marker, | 96 marker, |
| 94 marker->GetType() == DocumentMarker::kTextMatch, | 97 marker->GetType() == DocumentMarker::kTextMatch, |
| 95 marker.GetType() == DocumentMarker::kTextMatch); | 98 marker.GetType() == DocumentMarker::kTextMatch); |
| 96 | 99 |
| 97 } // namespace blink | 100 } // namespace blink |
| 98 | 101 |
| 99 #endif | 102 #endif |
| OLD | NEW |