Index: third_party/WebKit/Source/core/editing/markers/TextMatchMarker.h |
diff --git a/third_party/WebKit/Source/core/editing/markers/TextMatchMarker.h b/third_party/WebKit/Source/core/editing/markers/TextMatchMarker.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5e5d00e2682bf12f62b729e7e2fecb7cb7e4a968 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/editing/markers/TextMatchMarker.h |
@@ -0,0 +1,64 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef TextMatchMarker_h |
+#define TextMatchMarker_h |
+ |
+#include <utility> |
+#include "core/editing/markers/DocumentMarker.h" |
+#include "platform/geometry/LayoutRect.h" |
+ |
+namespace blink { |
+ |
+class CORE_EXPORT TextMatchMarker final : public DocumentMarker { |
+ public: |
+ TextMatchMarker(unsigned start_offset, |
+ unsigned end_offset, |
+ DocumentMarker::MatchStatus); |
+ |
+ bool IsRendered() const { return state_ == State::kValidNotNull; } |
+ |
+ void SetRenderedRect(const LayoutRect& rect) { |
+ if (state_ == State::kValidNotNull && rect == renderedRect_) |
+ return; |
+ state_ = State::kValidNotNull; |
+ renderedRect_ = rect; |
+ } |
+ |
+ const LayoutRect& RenderedRect() const { |
+ DCHECK_EQ(state_, State::kValidNotNull); |
+ return renderedRect_; |
+ } |
+ |
+ void UpdateRenderedRectIfNeeded(const Node&); |
+ void UpdateRenderedRect(const Node&); |
+ |
+ void NullifyRenderedRect() { |
+ state_ = State::kValidNull; |
+ // Now |renderedRect_| can not be accessed until |setRenderedRect| is |
+ // called. |
+ } |
+ |
+ void Invalidate() { state_ = State::kInvalid; } |
+ bool IsValid() const { return state_ != State::kInvalid; } |
+ |
+ protected: |
+ TextMatchMarker(const TextMatchMarker&) = default; |
+ |
+ private: |
+ enum class State { kInvalid, kValidNull, kValidNotNull }; |
+ |
+ LayoutRect renderedRect_; |
+ State state_; |
+}; |
+ |
+DEFINE_TYPE_CASTS(TextMatchMarker, |
+ DocumentMarker, |
+ marker, |
+ marker->GetType() == DocumentMarker::kTextMatch, |
+ marker.GetType() == DocumentMarker::kTextMatch); |
+ |
+} // namespace blink |
+ |
+#endif // TextMatchMarker_h |