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

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

Issue 2781623010: Add DocumentMarker::clone() (Closed)
Patch Set: 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 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 23 matching lines...) Expand all
34 34
35 class RenderedDocumentMarker final : public DocumentMarker { 35 class RenderedDocumentMarker final : public DocumentMarker {
36 private: 36 private:
37 enum class State { Invalid, ValidNull, ValidNotNull }; 37 enum class State { Invalid, ValidNull, ValidNotNull };
38 38
39 public: 39 public:
40 static RenderedDocumentMarker* create(const DocumentMarker& marker) { 40 static RenderedDocumentMarker* create(const DocumentMarker& marker) {
41 return new RenderedDocumentMarker(marker); 41 return new RenderedDocumentMarker(marker);
42 } 42 }
43 43
44 RenderedDocumentMarker* clone() const final;
Xiaocheng 2017/03/30 02:20:28 Implementation is still needed. It doesn't matter
45
44 bool isRendered() const { return m_state == State::ValidNotNull; } 46 bool isRendered() const { return m_state == State::ValidNotNull; }
45 bool contains(const LayoutPoint& point) const { 47 bool contains(const LayoutPoint& point) const {
46 DCHECK_EQ(m_state, State::ValidNotNull); 48 DCHECK_EQ(m_state, State::ValidNotNull);
47 return m_renderedRect.contains(point); 49 return m_renderedRect.contains(point);
48 } 50 }
49 void setRenderedRect(const LayoutRect& rect) { 51 void setRenderedRect(const LayoutRect& rect) {
50 if (m_state == State::ValidNotNull && rect == m_renderedRect) 52 if (m_state == State::ValidNotNull && rect == m_renderedRect)
51 return; 53 return;
52 m_state = State::ValidNotNull; 54 m_state = State::ValidNotNull;
53 m_renderedRect = rect; 55 m_renderedRect = rect;
54 } 56 }
55 57
56 const LayoutRect& renderedRect() const { 58 const LayoutRect& renderedRect() const {
57 DCHECK_EQ(m_state, State::ValidNotNull); 59 DCHECK_EQ(m_state, State::ValidNotNull);
58 return m_renderedRect; 60 return m_renderedRect;
59 } 61 }
60 62
61 void nullifyRenderedRect() { 63 void nullifyRenderedRect() {
62 m_state = State::ValidNull; 64 m_state = State::ValidNull;
63 // Now |m_renderedRect| can not be accessed until |setRenderedRect| is 65 // Now |m_renderedRect| can not be accessed until |setRenderedRect| is
64 // called. 66 // called.
65 } 67 }
66 68
67 void invalidate() { m_state = State::Invalid; } 69 void invalidate() { m_state = State::Invalid; }
68 bool isValid() const { return m_state != State::Invalid; } 70 bool isValid() const { return m_state != State::Invalid; }
69 71
72 protected:
73 RenderedDocumentMarker(RenderedDocumentMarker&) = default;
74
70 private: 75 private:
71 explicit RenderedDocumentMarker(const DocumentMarker& marker) 76 explicit RenderedDocumentMarker(const DocumentMarker& marker)
72 : DocumentMarker(marker), m_state(State::Invalid) {} 77 : DocumentMarker(marker), m_state(State::Invalid) {}
73 78
74 LayoutRect m_renderedRect; 79 LayoutRect m_renderedRect;
75 State m_state; 80 State m_state;
76 }; 81 };
77 82
78 DEFINE_TYPE_CASTS(RenderedDocumentMarker, DocumentMarker, marker, true, true); 83 DEFINE_TYPE_CASTS(RenderedDocumentMarker, DocumentMarker, marker, true, true);
79 84
80 } // namespace blink 85 } // namespace blink
81 86
82 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS( 87 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(
83 blink::RenderedDocumentMarker); 88 blink::RenderedDocumentMarker);
84 89
85 #endif 90 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698