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

Side by Side Diff: third_party/WebKit/Source/core/style/ContentData.h

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed.
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 18 matching lines...) Expand all
29 #include "core/style/StyleImage.h" 29 #include "core/style/StyleImage.h"
30 #include "wtf/OwnPtr.h" 30 #include "wtf/OwnPtr.h"
31 #include "wtf/PassOwnPtr.h" 31 #include "wtf/PassOwnPtr.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 class Document; 35 class Document;
36 class LayoutObject; 36 class LayoutObject;
37 class ComputedStyle; 37 class ComputedStyle;
38 38
39 class ContentData : public NoBaseWillBeGarbageCollectedFinalized<ContentData> { 39 class ContentData : public GarbageCollectedFinalized<ContentData> {
40 USING_FAST_MALLOC_WILL_BE_REMOVED(ContentData);
41 public: 40 public:
42 static PassOwnPtrWillBeRawPtr<ContentData> create(PassRefPtrWillBeRawPtr<Sty leImage>); 41 static RawPtr<ContentData> create(RawPtr<StyleImage>);
43 static PassOwnPtrWillBeRawPtr<ContentData> create(const String&); 42 static RawPtr<ContentData> create(const String&);
44 static PassOwnPtrWillBeRawPtr<ContentData> create(PassOwnPtr<CounterContent> ); 43 static RawPtr<ContentData> create(PassOwnPtr<CounterContent>);
45 static PassOwnPtrWillBeRawPtr<ContentData> create(QuoteType); 44 static RawPtr<ContentData> create(QuoteType);
46 45
47 virtual ~ContentData() { } 46 virtual ~ContentData() { }
48 47
49 virtual bool isCounter() const { return false; } 48 virtual bool isCounter() const { return false; }
50 virtual bool isImage() const { return false; } 49 virtual bool isImage() const { return false; }
51 virtual bool isQuote() const { return false; } 50 virtual bool isQuote() const { return false; }
52 virtual bool isText() const { return false; } 51 virtual bool isText() const { return false; }
53 52
54 virtual LayoutObject* createLayoutObject(Document&, ComputedStyle&) const = 0; 53 virtual LayoutObject* createLayoutObject(Document&, ComputedStyle&) const = 0;
55 54
56 virtual PassOwnPtrWillBeRawPtr<ContentData> clone() const; 55 virtual RawPtr<ContentData> clone() const;
57 56
58 ContentData* next() const { return m_next.get(); } 57 ContentData* next() const { return m_next.get(); }
59 void setNext(PassOwnPtrWillBeRawPtr<ContentData> next) { m_next = next; } 58 void setNext(RawPtr<ContentData> next) { m_next = next; }
60 59
61 virtual bool equals(const ContentData&) const = 0; 60 virtual bool equals(const ContentData&) const = 0;
62 61
63 DECLARE_VIRTUAL_TRACE(); 62 DECLARE_VIRTUAL_TRACE();
64 63
65 private: 64 private:
66 virtual PassOwnPtrWillBeRawPtr<ContentData> cloneInternal() const = 0; 65 virtual RawPtr<ContentData> cloneInternal() const = 0;
67 66
68 OwnPtrWillBeMember<ContentData> m_next; 67 Member<ContentData> m_next;
69 }; 68 };
70 69
71 #define DEFINE_CONTENT_DATA_TYPE_CASTS(typeName) \ 70 #define DEFINE_CONTENT_DATA_TYPE_CASTS(typeName) \
72 DEFINE_TYPE_CASTS(typeName##ContentData, ContentData, content, content->is## typeName(), content.is##typeName()) 71 DEFINE_TYPE_CASTS(typeName##ContentData, ContentData, content, content->is## typeName(), content.is##typeName())
73 72
74 class ImageContentData final : public ContentData { 73 class ImageContentData final : public ContentData {
75 friend class ContentData; 74 friend class ContentData;
76 public: 75 public:
77 const StyleImage* image() const { return m_image.get(); } 76 const StyleImage* image() const { return m_image.get(); }
78 StyleImage* image() { return m_image.get(); } 77 StyleImage* image() { return m_image.get(); }
79 void setImage(PassRefPtrWillBeRawPtr<StyleImage> image) { ASSERT(image); m_i mage = image; } 78 void setImage(RawPtr<StyleImage> image) { ASSERT(image); m_image = image; }
80 79
81 bool isImage() const override { return true; } 80 bool isImage() const override { return true; }
82 LayoutObject* createLayoutObject(Document&, ComputedStyle&) const override; 81 LayoutObject* createLayoutObject(Document&, ComputedStyle&) const override;
83 82
84 bool equals(const ContentData& data) const override 83 bool equals(const ContentData& data) const override
85 { 84 {
86 if (!data.isImage()) 85 if (!data.isImage())
87 return false; 86 return false;
88 return *static_cast<const ImageContentData&>(data).image() == *image(); 87 return *static_cast<const ImageContentData&>(data).image() == *image();
89 } 88 }
90 89
91 DECLARE_VIRTUAL_TRACE(); 90 DECLARE_VIRTUAL_TRACE();
92 91
93 private: 92 private:
94 ImageContentData(PassRefPtrWillBeRawPtr<StyleImage> image) 93 ImageContentData(RawPtr<StyleImage> image)
95 : m_image(image) 94 : m_image(image)
96 { 95 {
97 ASSERT(m_image); 96 ASSERT(m_image);
98 } 97 }
99 98
100 PassOwnPtrWillBeRawPtr<ContentData> cloneInternal() const override 99 RawPtr<ContentData> cloneInternal() const override
101 { 100 {
102 RefPtrWillBeRawPtr<StyleImage> image = const_cast<StyleImage*>(this->ima ge()); 101 RawPtr<StyleImage> image = const_cast<StyleImage*>(this->image());
103 return create(image.release()); 102 return create(image.release());
104 } 103 }
105 104
106 RefPtrWillBeMember<StyleImage> m_image; 105 Member<StyleImage> m_image;
107 }; 106 };
108 107
109 DEFINE_CONTENT_DATA_TYPE_CASTS(Image); 108 DEFINE_CONTENT_DATA_TYPE_CASTS(Image);
110 109
111 class TextContentData final : public ContentData { 110 class TextContentData final : public ContentData {
112 friend class ContentData; 111 friend class ContentData;
113 public: 112 public:
114 const String& text() const { return m_text; } 113 const String& text() const { return m_text; }
115 void setText(const String& text) { m_text = text; } 114 void setText(const String& text) { m_text = text; }
116 115
117 bool isText() const override { return true; } 116 bool isText() const override { return true; }
118 LayoutObject* createLayoutObject(Document&, ComputedStyle&) const override; 117 LayoutObject* createLayoutObject(Document&, ComputedStyle&) const override;
119 118
120 bool equals(const ContentData& data) const override 119 bool equals(const ContentData& data) const override
121 { 120 {
122 if (!data.isText()) 121 if (!data.isText())
123 return false; 122 return false;
124 return static_cast<const TextContentData&>(data).text() == text(); 123 return static_cast<const TextContentData&>(data).text() == text();
125 } 124 }
126 125
127 private: 126 private:
128 TextContentData(const String& text) 127 TextContentData(const String& text)
129 : m_text(text) 128 : m_text(text)
130 { 129 {
131 } 130 }
132 131
133 PassOwnPtrWillBeRawPtr<ContentData> cloneInternal() const override { return create(text()); } 132 RawPtr<ContentData> cloneInternal() const override { return create(text()); }
134 133
135 String m_text; 134 String m_text;
136 }; 135 };
137 136
138 DEFINE_CONTENT_DATA_TYPE_CASTS(Text); 137 DEFINE_CONTENT_DATA_TYPE_CASTS(Text);
139 138
140 class CounterContentData final : public ContentData { 139 class CounterContentData final : public ContentData {
141 friend class ContentData; 140 friend class ContentData;
142 public: 141 public:
143 const CounterContent* counter() const { return m_counter.get(); } 142 const CounterContent* counter() const { return m_counter.get(); }
144 void setCounter(PassOwnPtr<CounterContent> counter) { m_counter = counter; } 143 void setCounter(PassOwnPtr<CounterContent> counter) { m_counter = counter; }
145 144
146 bool isCounter() const override { return true; } 145 bool isCounter() const override { return true; }
147 LayoutObject* createLayoutObject(Document&, ComputedStyle&) const override; 146 LayoutObject* createLayoutObject(Document&, ComputedStyle&) const override;
148 147
149 private: 148 private:
150 CounterContentData(PassOwnPtr<CounterContent> counter) 149 CounterContentData(PassOwnPtr<CounterContent> counter)
151 : m_counter(counter) 150 : m_counter(counter)
152 { 151 {
153 } 152 }
154 153
155 PassOwnPtrWillBeRawPtr<ContentData> cloneInternal() const override 154 RawPtr<ContentData> cloneInternal() const override
156 { 155 {
157 OwnPtr<CounterContent> counterData = adoptPtr(new CounterContent(*counte r())); 156 OwnPtr<CounterContent> counterData = adoptPtr(new CounterContent(*counte r()));
158 return create(counterData.release()); 157 return create(counterData.release());
159 } 158 }
160 159
161 bool equals(const ContentData& data) const override 160 bool equals(const ContentData& data) const override
162 { 161 {
163 if (!data.isCounter()) 162 if (!data.isCounter())
164 return false; 163 return false;
165 return *static_cast<const CounterContentData&>(data).counter() == *count er(); 164 return *static_cast<const CounterContentData&>(data).counter() == *count er();
(...skipping 19 matching lines...) Expand all
185 return false; 184 return false;
186 return static_cast<const QuoteContentData&>(data).quote() == quote(); 185 return static_cast<const QuoteContentData&>(data).quote() == quote();
187 } 186 }
188 187
189 private: 188 private:
190 QuoteContentData(QuoteType quote) 189 QuoteContentData(QuoteType quote)
191 : m_quote(quote) 190 : m_quote(quote)
192 { 191 {
193 } 192 }
194 193
195 PassOwnPtrWillBeRawPtr<ContentData> cloneInternal() const override { return create(quote()); } 194 RawPtr<ContentData> cloneInternal() const override { return create(quote()); }
196 195
197 QuoteType m_quote; 196 QuoteType m_quote;
198 }; 197 };
199 198
200 DEFINE_CONTENT_DATA_TYPE_CASTS(Quote); 199 DEFINE_CONTENT_DATA_TYPE_CASTS(Quote);
201 200
202 inline bool operator==(const ContentData& a, const ContentData& b) 201 inline bool operator==(const ContentData& a, const ContentData& b)
203 { 202 {
204 return a.equals(b); 203 return a.equals(b);
205 } 204 }
206 205
207 inline bool operator!=(const ContentData& a, const ContentData& b) 206 inline bool operator!=(const ContentData& a, const ContentData& b)
208 { 207 {
209 return !(a == b); 208 return !(a == b);
210 } 209 }
211 210
212 } // namespace blink 211 } // namespace blink
213 212
214 #endif // ContentData_h 213 #endif // ContentData_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyleTest.cpp ('k') | third_party/WebKit/Source/core/style/ContentData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698