OLD | NEW |
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 |
11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
12 * | 12 * |
13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
17 * | 17 * |
18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #ifndef ContentData_h | 25 #ifndef ContentData_h |
26 #define ContentData_h | 26 #define ContentData_h |
27 | 27 |
28 #include "core/style/CounterContent.h" | 28 #include "core/style/CounterContent.h" |
29 #include "core/style/StyleImage.h" | 29 #include "core/style/StyleImage.h" |
30 #include "wtf/OwnPtr.h" | 30 #include "wtf/PtrUtil.h" |
31 #include "wtf/PassOwnPtr.h" | 31 #include <memory> |
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 GarbageCollectedFinalized<ContentData> { | 39 class ContentData : public GarbageCollectedFinalized<ContentData> { |
40 public: | 40 public: |
41 static ContentData* create(StyleImage*); | 41 static ContentData* create(StyleImage*); |
42 static ContentData* create(const String&); | 42 static ContentData* create(const String&); |
43 static ContentData* create(PassOwnPtr<CounterContent>); | 43 static ContentData* create(std::unique_ptr<CounterContent>); |
44 static ContentData* create(QuoteType); | 44 static ContentData* create(QuoteType); |
45 | 45 |
46 virtual ~ContentData() { } | 46 virtual ~ContentData() { } |
47 | 47 |
48 virtual bool isCounter() const { return false; } | 48 virtual bool isCounter() const { return false; } |
49 virtual bool isImage() const { return false; } | 49 virtual bool isImage() const { return false; } |
50 virtual bool isQuote() const { return false; } | 50 virtual bool isQuote() const { return false; } |
51 virtual bool isText() const { return false; } | 51 virtual bool isText() const { return false; } |
52 | 52 |
53 virtual LayoutObject* createLayoutObject(Document&, ComputedStyle&) const =
0; | 53 virtual LayoutObject* createLayoutObject(Document&, ComputedStyle&) const =
0; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 String m_text; | 134 String m_text; |
135 }; | 135 }; |
136 | 136 |
137 DEFINE_CONTENT_DATA_TYPE_CASTS(Text); | 137 DEFINE_CONTENT_DATA_TYPE_CASTS(Text); |
138 | 138 |
139 class CounterContentData final : public ContentData { | 139 class CounterContentData final : public ContentData { |
140 friend class ContentData; | 140 friend class ContentData; |
141 public: | 141 public: |
142 const CounterContent* counter() const { return m_counter.get(); } | 142 const CounterContent* counter() const { return m_counter.get(); } |
143 void setCounter(PassOwnPtr<CounterContent> counter) { m_counter = std::move(
counter); } | 143 void setCounter(std::unique_ptr<CounterContent> counter) { m_counter = std::
move(counter); } |
144 | 144 |
145 bool isCounter() const override { return true; } | 145 bool isCounter() const override { return true; } |
146 LayoutObject* createLayoutObject(Document&, ComputedStyle&) const override; | 146 LayoutObject* createLayoutObject(Document&, ComputedStyle&) const override; |
147 | 147 |
148 private: | 148 private: |
149 CounterContentData(PassOwnPtr<CounterContent> counter) | 149 CounterContentData(std::unique_ptr<CounterContent> counter) |
150 : m_counter(std::move(counter)) | 150 : m_counter(std::move(counter)) |
151 { | 151 { |
152 } | 152 } |
153 | 153 |
154 ContentData* cloneInternal() const override | 154 ContentData* cloneInternal() const override |
155 { | 155 { |
156 OwnPtr<CounterContent> counterData = adoptPtr(new CounterContent(*counte
r())); | 156 std::unique_ptr<CounterContent> counterData = wrapUnique(new CounterCont
ent(*counter())); |
157 return create(std::move(counterData)); | 157 return create(std::move(counterData)); |
158 } | 158 } |
159 | 159 |
160 bool equals(const ContentData& data) const override | 160 bool equals(const ContentData& data) const override |
161 { | 161 { |
162 if (!data.isCounter()) | 162 if (!data.isCounter()) |
163 return false; | 163 return false; |
164 return *static_cast<const CounterContentData&>(data).counter() == *count
er(); | 164 return *static_cast<const CounterContentData&>(data).counter() == *count
er(); |
165 } | 165 } |
166 | 166 |
167 OwnPtr<CounterContent> m_counter; | 167 std::unique_ptr<CounterContent> m_counter; |
168 }; | 168 }; |
169 | 169 |
170 DEFINE_CONTENT_DATA_TYPE_CASTS(Counter); | 170 DEFINE_CONTENT_DATA_TYPE_CASTS(Counter); |
171 | 171 |
172 class QuoteContentData final : public ContentData { | 172 class QuoteContentData final : public ContentData { |
173 friend class ContentData; | 173 friend class ContentData; |
174 public: | 174 public: |
175 QuoteType quote() const { return m_quote; } | 175 QuoteType quote() const { return m_quote; } |
176 void setQuote(QuoteType quote) { m_quote = quote; } | 176 void setQuote(QuoteType quote) { m_quote = quote; } |
177 | 177 |
(...skipping 26 matching lines...) Expand all Loading... |
204 } | 204 } |
205 | 205 |
206 inline bool operator!=(const ContentData& a, const ContentData& b) | 206 inline bool operator!=(const ContentData& a, const ContentData& b) |
207 { | 207 { |
208 return !(a == b); | 208 return !(a == b); |
209 } | 209 } |
210 | 210 |
211 } // namespace blink | 211 } // namespace blink |
212 | 212 |
213 #endif // ContentData_h | 213 #endif // ContentData_h |
OLD | NEW |