Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Unified Diff: third_party/WebKit/Source/core/editing/markers/TextMatchMarker.h

Issue 2805553003: DocumentMarkerList refactor as an interface (Closed)
Patch Set: Respond to comments, fill in unimplemented methods Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..cb86516efd0121f8307bf10d3fcfa7516a2a8704
--- /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 startOffset,
+ unsigned endOffset,
+ DocumentMarker::MatchStatus);
+
+ bool isRendered() const { return m_state == State::kValidNotNull; }
+
+ void setRenderedRect(const LayoutRect& rect) {
+ if (m_state == State::kValidNotNull && rect == m_renderedRect)
+ return;
+ m_state = State::kValidNotNull;
+ m_renderedRect = rect;
+ }
+
+ const LayoutRect& renderedRect() const {
+ DCHECK_EQ(m_state, State::kValidNotNull);
+ return m_renderedRect;
+ }
+
+ void updateRenderedRectIfNeeded(const Node&);
+ void updateRenderedRect(const Node&);
+
+ void nullifyRenderedRect() {
+ m_state = State::kValidNull;
+ // Now |m_renderedRect| can not be accessed until |setRenderedRect| is
+ // called.
+ }
+
+ void invalidate() { m_state = State::kInvalid; }
+ bool isValid() const { return m_state != State::kInvalid; }
+
+ protected:
+ TextMatchMarker(const TextMatchMarker&) = default;
+
+ private:
+ enum class State { kInvalid, kValidNull, kValidNotNull };
+
+ LayoutRect m_renderedRect;
+ State m_state;
+};
+
+DEFINE_TYPE_CASTS(TextMatchMarker,
+ DocumentMarker,
+ marker,
+ marker->type() == DocumentMarker::TextMatch,
+ marker.type() == DocumentMarker::TextMatch);
+
+} // namespace blink
+
+#endif // TextMatchMarker_h

Powered by Google App Engine
This is Rietveld 408576698