| 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 #ifndef TextMatchMarker_h | 5 #ifndef TextMatchMarker_h |
| 6 #define TextMatchMarker_h | 6 #define TextMatchMarker_h |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include "core/editing/markers/DocumentMarker.h" | 9 #include "core/editing/markers/DocumentMarker.h" |
| 10 #include "platform/geometry/LayoutRect.h" | 10 #include "platform/geometry/LayoutRect.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class CORE_EXPORT TextMatchMarker final : public DocumentMarker { | 14 class CORE_EXPORT TextMatchMarker final : public DocumentMarker { |
| 15 public: | 15 public: |
| 16 TextMatchMarker(unsigned startOffset, unsigned endOffset, bool activeMatch); | 16 TextMatchMarker(unsigned startOffset, unsigned endOffset, bool activeMatch); |
| 17 | 17 |
| 18 // DocumentMarker implementations |
| 18 TextMatchMarker* clone() const final; | 19 TextMatchMarker* clone() const final; |
| 19 | 20 |
| 21 MarkerType type() const final; |
| 22 |
| 23 bool activeMatch() const final; |
| 24 |
| 25 // TextMatchMarker-specific |
| 26 void setActiveMatch(bool active) { m_activeMatch = active; } |
| 27 |
| 20 bool isRendered() const { return m_state == State::ValidNotNull; } | 28 bool isRendered() const { return m_state == State::ValidNotNull; } |
| 21 | 29 |
| 22 void setRenderedRect(const LayoutRect& rect) { | 30 void setRenderedRect(const LayoutRect& rect) { |
| 23 if (m_state == State::ValidNotNull && rect == m_renderedRect) | 31 if (m_state == State::ValidNotNull && rect == m_renderedRect) |
| 24 return; | 32 return; |
| 25 m_state = State::ValidNotNull; | 33 m_state = State::ValidNotNull; |
| 26 m_renderedRect = rect; | 34 m_renderedRect = rect; |
| 27 } | 35 } |
| 28 | 36 |
| 29 const LayoutRect& renderedRect() const { | 37 const LayoutRect& renderedRect() const { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 42 | 50 |
| 43 void invalidate() { m_state = State::Invalid; } | 51 void invalidate() { m_state = State::Invalid; } |
| 44 bool isValid() const { return m_state != State::Invalid; } | 52 bool isValid() const { return m_state != State::Invalid; } |
| 45 | 53 |
| 46 protected: | 54 protected: |
| 47 TextMatchMarker(const TextMatchMarker&) = default; | 55 TextMatchMarker(const TextMatchMarker&) = default; |
| 48 | 56 |
| 49 private: | 57 private: |
| 50 enum class State { Invalid, ValidNull, ValidNotNull }; | 58 enum class State { Invalid, ValidNull, ValidNotNull }; |
| 51 | 59 |
| 60 bool m_activeMatch; |
| 52 LayoutRect m_renderedRect; | 61 LayoutRect m_renderedRect; |
| 53 State m_state; | 62 State m_state; |
| 54 }; | 63 }; |
| 55 | 64 |
| 56 DEFINE_TYPE_CASTS(TextMatchMarker, | 65 DEFINE_TYPE_CASTS(TextMatchMarker, |
| 57 DocumentMarker, | 66 DocumentMarker, |
| 58 marker, | 67 marker, |
| 59 marker->type() == DocumentMarker::TextMatch, | 68 marker->type() == DocumentMarker::TextMatch, |
| 60 marker.type() == DocumentMarker::TextMatch); | 69 marker.type() == DocumentMarker::TextMatch); |
| 61 | 70 |
| 62 } // namespace blink | 71 } // namespace blink |
| 63 | 72 |
| 64 #endif // TextMatchMarker_h | 73 #endif // TextMatchMarker_h |
| OLD | NEW |