| 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..57bdaa7f13490e2c41e778973aedb2b1f547cd7c
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/editing/markers/TextMatchMarker.h
|
| @@ -0,0 +1,65 @@
|
| +// 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 TextMatchMarker : public DocumentMarker {
|
| + public:
|
| + static TextMatchMarker* create(const DocumentMarker& marker) {
|
| + DCHECK(marker.type() == DocumentMarker::TextMatch);
|
| + return new TextMatchMarker(marker);
|
| + }
|
| +
|
| + bool isRendered() const { return m_state == State::ValidNotNull; }
|
| +
|
| + void setRenderedRect(const LayoutRect& rect) {
|
| + if (m_state == State::ValidNotNull && rect == m_renderedRect)
|
| + return;
|
| + m_state = State::ValidNotNull;
|
| + m_renderedRect = rect;
|
| + }
|
| +
|
| + const LayoutRect& renderedRect() const {
|
| + DCHECK_EQ(m_state, State::ValidNotNull);
|
| + return m_renderedRect;
|
| + }
|
| +
|
| + void updateRenderedRectIfNeeded(const Node&);
|
| + void updateRenderedRect(const Node&);
|
| +
|
| + void nullifyRenderedRect() {
|
| + m_state = State::ValidNull;
|
| + // Now |m_renderedRect| can not be accessed until |setRenderedRect| is
|
| + // called.
|
| + }
|
| +
|
| + void invalidate() { m_state = State::Invalid; }
|
| + bool isValid() const { return m_state != State::Invalid; }
|
| +
|
| + private:
|
| + explicit TextMatchMarker(const DocumentMarker& marker)
|
| + : DocumentMarker(marker), m_state(State::Invalid) {}
|
| +
|
| + enum class State { Invalid, ValidNull, ValidNotNull };
|
| +
|
| + 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
|
|
|