OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/editing/markers/TextMatchMarker.h" | 5 #include "core/editing/markers/TextMatchMarker.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
| 9 TextMatchMarker::TextMatchMarker(unsigned start_offset, |
| 10 unsigned end_offset, |
| 11 MatchStatus status) |
| 12 : DocumentMarker(start_offset, end_offset), match_status_(status) {} |
| 13 |
9 DocumentMarker::MarkerType TextMatchMarker::GetType() const { | 14 DocumentMarker::MarkerType TextMatchMarker::GetType() const { |
10 return DocumentMarker::kTextMatch; | 15 return DocumentMarker::kTextMatch; |
11 } | 16 } |
12 | 17 |
| 18 bool TextMatchMarker::IsActiveMatch() const { |
| 19 return match_status_ == MatchStatus::kActive; |
| 20 } |
| 21 |
| 22 void TextMatchMarker::SetIsActiveMatch(bool active) { |
| 23 match_status_ = active ? MatchStatus::kActive : MatchStatus::kInactive; |
| 24 } |
| 25 |
| 26 bool TextMatchMarker::IsRendered() const { |
| 27 return layout_state_ == State::kValidNotNull; |
| 28 } |
| 29 |
| 30 bool TextMatchMarker::Contains(const LayoutPoint& point) const { |
| 31 DCHECK_EQ(layout_state_, State::kValidNotNull); |
| 32 return rendered_rect_.Contains(point); |
| 33 } |
| 34 |
| 35 void TextMatchMarker::SetRenderedRect(const LayoutRect& rect) { |
| 36 if (layout_state_ == State::kValidNotNull && rect == rendered_rect_) |
| 37 return; |
| 38 layout_state_ = State::kValidNotNull; |
| 39 rendered_rect_ = rect; |
| 40 } |
| 41 |
| 42 const LayoutRect& TextMatchMarker::RenderedRect() const { |
| 43 DCHECK_EQ(layout_state_, State::kValidNotNull); |
| 44 return rendered_rect_; |
| 45 } |
| 46 |
| 47 void TextMatchMarker::NullifyRenderedRect() { |
| 48 layout_state_ = State::kValidNull; |
| 49 // Now |rendered_rect_| can not be accessed until |SetRenderedRect| is |
| 50 // called. |
| 51 } |
| 52 |
| 53 void TextMatchMarker::Invalidate() { |
| 54 layout_state_ = State::kInvalid; |
| 55 } |
| 56 |
| 57 bool TextMatchMarker::IsValid() const { |
| 58 return layout_state_ != State::kInvalid; |
| 59 } |
| 60 |
13 } // namespace blink | 61 } // namespace blink |
OLD | NEW |