Commit bb2881f8 authored by rlanday's avatar rlanday Committed by Commit Bot

Move TextMatchMarker method implementations to TextMatchMarker.cpp

TextMatchMarker used to be RenderedDocumentMarker, which didn't have a .cpp
file, and had all its method implementations in a header file. This CL moves
TextMatchMarker's method implementations to its .cpp file for cleanliness, as
well as consistency with the classes for the other marker types.

BUG=707867

Review-Url: https://codereview.chromium.org/2919603005
Cr-Commit-Position: refs/heads/master@{#476550}
parent bce5642d
...@@ -6,8 +6,56 @@ ...@@ -6,8 +6,56 @@
namespace blink { namespace blink {
TextMatchMarker::TextMatchMarker(unsigned start_offset,
unsigned end_offset,
MatchStatus status)
: DocumentMarker(start_offset, end_offset), match_status_(status) {}
DocumentMarker::MarkerType TextMatchMarker::GetType() const { DocumentMarker::MarkerType TextMatchMarker::GetType() const {
return DocumentMarker::kTextMatch; return DocumentMarker::kTextMatch;
} }
bool TextMatchMarker::IsActiveMatch() const {
return match_status_ == MatchStatus::kActive;
}
void TextMatchMarker::SetIsActiveMatch(bool active) {
match_status_ = active ? MatchStatus::kActive : MatchStatus::kInactive;
}
bool TextMatchMarker::IsRendered() const {
return layout_state_ == State::kValidNotNull;
}
bool TextMatchMarker::Contains(const LayoutPoint& point) const {
DCHECK_EQ(layout_state_, State::kValidNotNull);
return rendered_rect_.Contains(point);
}
void TextMatchMarker::SetRenderedRect(const LayoutRect& rect) {
if (layout_state_ == State::kValidNotNull && rect == rendered_rect_)
return;
layout_state_ = State::kValidNotNull;
rendered_rect_ = rect;
}
const LayoutRect& TextMatchMarker::RenderedRect() const {
DCHECK_EQ(layout_state_, State::kValidNotNull);
return rendered_rect_;
}
void TextMatchMarker::NullifyRenderedRect() {
layout_state_ = State::kValidNull;
// Now |rendered_rect_| can not be accessed until |SetRenderedRect| is
// called.
}
void TextMatchMarker::Invalidate() {
layout_state_ = State::kInvalid;
}
bool TextMatchMarker::IsValid() const {
return layout_state_ != State::kInvalid;
}
} // namespace blink } // namespace blink
...@@ -43,52 +43,27 @@ class CORE_EXPORT TextMatchMarker final : public DocumentMarker { ...@@ -43,52 +43,27 @@ class CORE_EXPORT TextMatchMarker final : public DocumentMarker {
public: public:
enum class MatchStatus { kInactive, kActive }; enum class MatchStatus { kInactive, kActive };
TextMatchMarker(unsigned start_offset, TextMatchMarker(unsigned start_offset, unsigned end_offset, MatchStatus);
unsigned end_offset,
MatchStatus status)
: DocumentMarker(start_offset, end_offset), match_status_(status) {
layout_state_ = State::kInvalid;
}
// DocumentMarker implementations // DocumentMarker implementations
MarkerType GetType() const final; MarkerType GetType() const final;
// TextMatchMarker-specific // TextMatchMarker-specific
bool IsActiveMatch() const { return match_status_ == MatchStatus::kActive; } bool IsActiveMatch() const;
void SetIsActiveMatch(bool active) { void SetIsActiveMatch(bool active);
match_status_ = active ? MatchStatus::kActive : MatchStatus::kInactive;
}
bool IsRendered() const { return layout_state_ == State::kValidNotNull; } bool IsRendered() const;
bool Contains(const LayoutPoint& point) const { bool Contains(const LayoutPoint&) const;
DCHECK_EQ(layout_state_, State::kValidNotNull); void SetRenderedRect(const LayoutRect&);
return rendered_rect_.Contains(point); const LayoutRect& RenderedRect() const;
} void NullifyRenderedRect();
void SetRenderedRect(const LayoutRect& rect) { void Invalidate();
if (layout_state_ == State::kValidNotNull && rect == rendered_rect_) bool IsValid() const;
return;
layout_state_ = State::kValidNotNull;
rendered_rect_ = rect;
}
const LayoutRect& RenderedRect() const {
DCHECK_EQ(layout_state_, State::kValidNotNull);
return rendered_rect_;
}
void NullifyRenderedRect() {
layout_state_ = State::kValidNull;
// Now |m_renderedRect| can not be accessed until |setRenderedRect| is
// called.
}
void Invalidate() { layout_state_ = State::kInvalid; }
bool IsValid() const { return layout_state_ != State::kInvalid; }
private: private:
MatchStatus match_status_; MatchStatus match_status_;
LayoutRect rendered_rect_; LayoutRect rendered_rect_;
State layout_state_; State layout_state_ = State::kInvalid;
DISALLOW_COPY_AND_ASSIGN(TextMatchMarker); DISALLOW_COPY_AND_ASSIGN(TextMatchMarker);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment