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

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

Issue 2912133003: Revert of [DMC #17] Make TextMatchMarkers constructible in single step (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 19 matching lines...) Expand all
30 #include "core/editing/markers/DocumentMarker.h" 30 #include "core/editing/markers/DocumentMarker.h"
31 #include "platform/geometry/LayoutRect.h" 31 #include "platform/geometry/LayoutRect.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 class TextMatchMarker final : public DocumentMarker { 35 class TextMatchMarker final : public DocumentMarker {
36 private: 36 private:
37 enum class State { kInvalid, kValidNull, kValidNotNull }; 37 enum class State { kInvalid, kValidNull, kValidNotNull };
38 38
39 public: 39 public:
40 TextMatchMarker(unsigned start_offset, 40 static TextMatchMarker* Create(const DocumentMarker& marker) {
41 unsigned end_offset, 41 return new TextMatchMarker(marker);
42 MatchStatus status) 42 }
43 : DocumentMarker(start_offset, end_offset, status),
44 state_(State::kInvalid) {}
45 43
46 bool IsRendered() const { return state_ == State::kValidNotNull; } 44 bool IsRendered() const { return state_ == State::kValidNotNull; }
47 bool Contains(const LayoutPoint& point) const { 45 bool Contains(const LayoutPoint& point) const {
48 DCHECK_EQ(state_, State::kValidNotNull); 46 DCHECK_EQ(state_, State::kValidNotNull);
49 return rendered_rect_.Contains(point); 47 return rendered_rect_.Contains(point);
50 } 48 }
51 void SetRenderedRect(const LayoutRect& rect) { 49 void SetRenderedRect(const LayoutRect& rect) {
52 if (state_ == State::kValidNotNull && rect == rendered_rect_) 50 if (state_ == State::kValidNotNull && rect == rendered_rect_)
53 return; 51 return;
54 state_ = State::kValidNotNull; 52 state_ = State::kValidNotNull;
(...skipping 24 matching lines...) Expand all
79 77
80 DEFINE_TYPE_CASTS(TextMatchMarker, 78 DEFINE_TYPE_CASTS(TextMatchMarker,
81 DocumentMarker, 79 DocumentMarker,
82 marker, 80 marker,
83 marker->GetType() == DocumentMarker::kTextMatch, 81 marker->GetType() == DocumentMarker::kTextMatch,
84 marker.GetType() == DocumentMarker::kTextMatch); 82 marker.GetType() == DocumentMarker::kTextMatch);
85 83
86 } // namespace blink 84 } // namespace blink
87 85
88 #endif 86 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698