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/CSSValueKeywords.h" | |
28 #include "core/style/CounterContent.h" | 29 #include "core/style/CounterContent.h" |
29 #include "core/style/StyleImage.h" | 30 #include "core/style/StyleImage.h" |
30 #include "wtf/OwnPtr.h" | 31 #include "wtf/OwnPtr.h" |
31 #include "wtf/PassOwnPtr.h" | 32 #include "wtf/PassOwnPtr.h" |
32 | 33 |
33 namespace blink { | 34 namespace blink { |
34 | 35 |
35 class Document; | 36 class Document; |
36 class LayoutObject; | 37 class LayoutObject; |
37 class ComputedStyle; | 38 class ComputedStyle; |
38 | 39 |
39 class ContentData : public NoBaseWillBeGarbageCollectedFinalized<ContentData> { | 40 class ContentData : public NoBaseWillBeGarbageCollectedFinalized<ContentData> { |
40 USING_FAST_MALLOC_WILL_BE_REMOVED(ContentData); | 41 USING_FAST_MALLOC_WILL_BE_REMOVED(ContentData); |
41 public: | 42 public: |
42 static PassOwnPtrWillBeRawPtr<ContentData> create(PassRefPtrWillBeRawPtr<Sty leImage>); | 43 static PassOwnPtrWillBeRawPtr<ContentData> create(PassRefPtrWillBeRawPtr<Sty leImage>); |
43 static PassOwnPtrWillBeRawPtr<ContentData> create(const String&); | 44 static PassOwnPtrWillBeRawPtr<ContentData> create(const String&); |
44 static PassOwnPtrWillBeRawPtr<ContentData> create(PassOwnPtr<CounterContent> ); | 45 static PassOwnPtrWillBeRawPtr<ContentData> create(PassOwnPtr<CounterContent> ); |
45 static PassOwnPtrWillBeRawPtr<ContentData> create(QuoteType); | 46 static PassOwnPtrWillBeRawPtr<ContentData> create(QuoteType); |
47 static PassOwnPtrWillBeRawPtr<ContentData> create(CSSValueID); | |
46 | 48 |
47 virtual ~ContentData() { } | 49 virtual ~ContentData() { } |
48 | 50 |
49 virtual bool isCounter() const { return false; } | 51 virtual bool isCounter() const { return false; } |
50 virtual bool isImage() const { return false; } | 52 virtual bool isImage() const { return false; } |
51 virtual bool isQuote() const { return false; } | 53 virtual bool isQuote() const { return false; } |
52 virtual bool isText() const { return false; } | 54 virtual bool isText() const { return false; } |
55 virtual bool isCSSValueID() const { return false; } | |
53 | 56 |
54 virtual LayoutObject* createLayoutObject(Document&, ComputedStyle&) const = 0; | 57 virtual LayoutObject* createLayoutObject(Document&, ComputedStyle&) const = 0; |
55 | 58 |
56 virtual PassOwnPtrWillBeRawPtr<ContentData> clone() const; | 59 virtual PassOwnPtrWillBeRawPtr<ContentData> clone() const; |
57 | 60 |
58 ContentData* next() const { return m_next.get(); } | 61 ContentData* next() const { return m_next.get(); } |
59 void setNext(PassOwnPtrWillBeRawPtr<ContentData> next) { m_next = next; } | 62 void setNext(PassOwnPtrWillBeRawPtr<ContentData> next) { m_next = next; } |
60 | 63 |
61 virtual bool equals(const ContentData&) const = 0; | 64 virtual bool equals(const ContentData&) const = 0; |
62 | 65 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 { | 195 { |
193 } | 196 } |
194 | 197 |
195 PassOwnPtrWillBeRawPtr<ContentData> cloneInternal() const override { return create(quote()); } | 198 PassOwnPtrWillBeRawPtr<ContentData> cloneInternal() const override { return create(quote()); } |
196 | 199 |
197 QuoteType m_quote; | 200 QuoteType m_quote; |
198 }; | 201 }; |
199 | 202 |
200 DEFINE_CONTENT_DATA_TYPE_CASTS(Quote); | 203 DEFINE_CONTENT_DATA_TYPE_CASTS(Quote); |
201 | 204 |
205 class CSSValueIDContentData final : public ContentData { | |
206 friend class ContentData; | |
207 public: | |
208 CSSValueID cssValueID() const { return m_cssValueID; } | |
209 void setCSSValueID(CSSValueID cssValueID) { m_cssValueID = cssValueID; } | |
210 | |
211 bool isCSSValueID() const override { return true; } | |
212 LayoutObject* createLayoutObject(Document&, ComputedStyle&) const override; | |
213 | |
214 bool equals(const ContentData& data) const override | |
215 { | |
216 if (!data.isCSSValueID()) | |
217 return false; | |
218 return static_cast<const CSSValueIDContentData&>(data).cssValueID() == c ssValueID(); | |
219 } | |
220 | |
221 private: | |
222 CSSValueIDContentData(CSSValueID cssValueID) | |
223 : m_cssValueID(cssValueID) | |
224 { | |
225 } | |
226 | |
227 PassOwnPtrWillBeRawPtr<ContentData> cloneInternal() const override { return create(cssValueID()); } | |
228 | |
229 CSSValueID m_cssValueID; | |
alancutter (OOO until 2018)
2016/03/19 08:01:23
How many different CSSValueIDs could be stored her
nainar
2016/03/21 00:12:08
Done.
| |
230 }; | |
231 | |
232 DEFINE_CONTENT_DATA_TYPE_CASTS(CSSValueID); | |
233 | |
202 inline bool operator==(const ContentData& a, const ContentData& b) | 234 inline bool operator==(const ContentData& a, const ContentData& b) |
203 { | 235 { |
204 return a.equals(b); | 236 return a.equals(b); |
205 } | 237 } |
206 | 238 |
207 inline bool operator!=(const ContentData& a, const ContentData& b) | 239 inline bool operator!=(const ContentData& a, const ContentData& b) |
208 { | 240 { |
209 return !(a == b); | 241 return !(a == b); |
210 } | 242 } |
211 | 243 |
212 } // namespace blink | 244 } // namespace blink |
213 | 245 |
214 #endif // ContentData_h | 246 #endif // ContentData_h |
OLD | NEW |