| 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 | 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights |
| 6 * reserved. | 6 * reserved. |
| 7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #ifndef ContentData_h | 26 #ifndef ContentData_h |
| 27 #define ContentData_h | 27 #define ContentData_h |
| 28 | 28 |
| 29 #include "core/style/CounterContent.h" | 29 #include "core/style/CounterContent.h" |
| 30 #include "core/style/StyleImage.h" | 30 #include "core/style/StyleImage.h" |
| 31 #include "wtf/PtrUtil.h" | 31 #include "wtf/PtrUtil.h" |
| 32 #include <memory> | 32 #include <memory> |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class Document; | 36 class ComputedStyle; |
| 37 class LayoutObject; | 37 class LayoutObject; |
| 38 class ComputedStyle; | 38 class PseudoElement; |
| 39 | 39 |
| 40 class ContentData : public GarbageCollectedFinalized<ContentData> { | 40 class ContentData : public GarbageCollectedFinalized<ContentData> { |
| 41 public: | 41 public: |
| 42 static ContentData* create(StyleImage*); | 42 static ContentData* create(StyleImage*); |
| 43 static ContentData* create(const String&); | 43 static ContentData* create(const String&); |
| 44 static ContentData* create(std::unique_ptr<CounterContent>); | 44 static ContentData* create(std::unique_ptr<CounterContent>); |
| 45 static ContentData* create(QuoteType); | 45 static ContentData* create(QuoteType); |
| 46 | 46 |
| 47 virtual ~ContentData() {} | 47 virtual ~ContentData() {} |
| 48 | 48 |
| 49 virtual bool isCounter() const { return false; } | 49 virtual bool isCounter() const { return false; } |
| 50 virtual bool isImage() const { return false; } | 50 virtual bool isImage() const { return false; } |
| 51 virtual bool isQuote() const { return false; } | 51 virtual bool isQuote() const { return false; } |
| 52 virtual bool isText() const { return false; } | 52 virtual bool isText() const { return false; } |
| 53 | 53 |
| 54 virtual LayoutObject* createLayoutObject(Document&, ComputedStyle&) const = 0; | 54 virtual LayoutObject* createLayoutObject(PseudoElement&, |
| 55 ComputedStyle&) const = 0; |
| 55 | 56 |
| 56 virtual ContentData* clone() const; | 57 virtual ContentData* clone() const; |
| 57 | 58 |
| 58 ContentData* next() const { return m_next.get(); } | 59 ContentData* next() const { return m_next.get(); } |
| 59 void setNext(ContentData* next) { m_next = next; } | 60 void setNext(ContentData* next) { m_next = next; } |
| 60 | 61 |
| 61 virtual bool equals(const ContentData&) const = 0; | 62 virtual bool equals(const ContentData&) const = 0; |
| 62 | 63 |
| 63 DECLARE_VIRTUAL_TRACE(); | 64 DECLARE_VIRTUAL_TRACE(); |
| 64 | 65 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 77 | 78 |
| 78 public: | 79 public: |
| 79 const StyleImage* image() const { return m_image.get(); } | 80 const StyleImage* image() const { return m_image.get(); } |
| 80 StyleImage* image() { return m_image.get(); } | 81 StyleImage* image() { return m_image.get(); } |
| 81 void setImage(StyleImage* image) { | 82 void setImage(StyleImage* image) { |
| 82 ASSERT(image); | 83 ASSERT(image); |
| 83 m_image = image; | 84 m_image = image; |
| 84 } | 85 } |
| 85 | 86 |
| 86 bool isImage() const override { return true; } | 87 bool isImage() const override { return true; } |
| 87 LayoutObject* createLayoutObject(Document&, ComputedStyle&) const override; | 88 LayoutObject* createLayoutObject(PseudoElement&, |
| 89 ComputedStyle&) const override; |
| 88 | 90 |
| 89 bool equals(const ContentData& data) const override { | 91 bool equals(const ContentData& data) const override { |
| 90 if (!data.isImage()) | 92 if (!data.isImage()) |
| 91 return false; | 93 return false; |
| 92 return *static_cast<const ImageContentData&>(data).image() == *image(); | 94 return *static_cast<const ImageContentData&>(data).image() == *image(); |
| 93 } | 95 } |
| 94 | 96 |
| 95 DECLARE_VIRTUAL_TRACE(); | 97 DECLARE_VIRTUAL_TRACE(); |
| 96 | 98 |
| 97 private: | 99 private: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 108 DEFINE_CONTENT_DATA_TYPE_CASTS(Image); | 110 DEFINE_CONTENT_DATA_TYPE_CASTS(Image); |
| 109 | 111 |
| 110 class TextContentData final : public ContentData { | 112 class TextContentData final : public ContentData { |
| 111 friend class ContentData; | 113 friend class ContentData; |
| 112 | 114 |
| 113 public: | 115 public: |
| 114 const String& text() const { return m_text; } | 116 const String& text() const { return m_text; } |
| 115 void setText(const String& text) { m_text = text; } | 117 void setText(const String& text) { m_text = text; } |
| 116 | 118 |
| 117 bool isText() const override { return true; } | 119 bool isText() const override { return true; } |
| 118 LayoutObject* createLayoutObject(Document&, ComputedStyle&) const override; | 120 LayoutObject* createLayoutObject(PseudoElement&, |
| 121 ComputedStyle&) const override; |
| 119 | 122 |
| 120 bool equals(const ContentData& data) const override { | 123 bool equals(const ContentData& data) const override { |
| 121 if (!data.isText()) | 124 if (!data.isText()) |
| 122 return false; | 125 return false; |
| 123 return static_cast<const TextContentData&>(data).text() == text(); | 126 return static_cast<const TextContentData&>(data).text() == text(); |
| 124 } | 127 } |
| 125 | 128 |
| 126 private: | 129 private: |
| 127 TextContentData(const String& text) : m_text(text) {} | 130 TextContentData(const String& text) : m_text(text) {} |
| 128 | 131 |
| 129 ContentData* cloneInternal() const override { return create(text()); } | 132 ContentData* cloneInternal() const override { return create(text()); } |
| 130 | 133 |
| 131 String m_text; | 134 String m_text; |
| 132 }; | 135 }; |
| 133 | 136 |
| 134 DEFINE_CONTENT_DATA_TYPE_CASTS(Text); | 137 DEFINE_CONTENT_DATA_TYPE_CASTS(Text); |
| 135 | 138 |
| 136 class CounterContentData final : public ContentData { | 139 class CounterContentData final : public ContentData { |
| 137 friend class ContentData; | 140 friend class ContentData; |
| 138 | 141 |
| 139 public: | 142 public: |
| 140 const CounterContent* counter() const { return m_counter.get(); } | 143 const CounterContent* counter() const { return m_counter.get(); } |
| 141 void setCounter(std::unique_ptr<CounterContent> counter) { | 144 void setCounter(std::unique_ptr<CounterContent> counter) { |
| 142 m_counter = std::move(counter); | 145 m_counter = std::move(counter); |
| 143 } | 146 } |
| 144 | 147 |
| 145 bool isCounter() const override { return true; } | 148 bool isCounter() const override { return true; } |
| 146 LayoutObject* createLayoutObject(Document&, ComputedStyle&) const override; | 149 LayoutObject* createLayoutObject(PseudoElement&, |
| 150 ComputedStyle&) const override; |
| 147 | 151 |
| 148 private: | 152 private: |
| 149 CounterContentData(std::unique_ptr<CounterContent> counter) | 153 CounterContentData(std::unique_ptr<CounterContent> counter) |
| 150 : m_counter(std::move(counter)) {} | 154 : m_counter(std::move(counter)) {} |
| 151 | 155 |
| 152 ContentData* cloneInternal() const override { | 156 ContentData* cloneInternal() const override { |
| 153 std::unique_ptr<CounterContent> counterData = | 157 std::unique_ptr<CounterContent> counterData = |
| 154 WTF::wrapUnique(new CounterContent(*counter())); | 158 WTF::wrapUnique(new CounterContent(*counter())); |
| 155 return create(std::move(counterData)); | 159 return create(std::move(counterData)); |
| 156 } | 160 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 168 DEFINE_CONTENT_DATA_TYPE_CASTS(Counter); | 172 DEFINE_CONTENT_DATA_TYPE_CASTS(Counter); |
| 169 | 173 |
| 170 class QuoteContentData final : public ContentData { | 174 class QuoteContentData final : public ContentData { |
| 171 friend class ContentData; | 175 friend class ContentData; |
| 172 | 176 |
| 173 public: | 177 public: |
| 174 QuoteType quote() const { return m_quote; } | 178 QuoteType quote() const { return m_quote; } |
| 175 void setQuote(QuoteType quote) { m_quote = quote; } | 179 void setQuote(QuoteType quote) { m_quote = quote; } |
| 176 | 180 |
| 177 bool isQuote() const override { return true; } | 181 bool isQuote() const override { return true; } |
| 178 LayoutObject* createLayoutObject(Document&, ComputedStyle&) const override; | 182 LayoutObject* createLayoutObject(PseudoElement&, |
| 183 ComputedStyle&) const override; |
| 179 | 184 |
| 180 bool equals(const ContentData& data) const override { | 185 bool equals(const ContentData& data) const override { |
| 181 if (!data.isQuote()) | 186 if (!data.isQuote()) |
| 182 return false; | 187 return false; |
| 183 return static_cast<const QuoteContentData&>(data).quote() == quote(); | 188 return static_cast<const QuoteContentData&>(data).quote() == quote(); |
| 184 } | 189 } |
| 185 | 190 |
| 186 private: | 191 private: |
| 187 QuoteContentData(QuoteType quote) : m_quote(quote) {} | 192 QuoteContentData(QuoteType quote) : m_quote(quote) {} |
| 188 | 193 |
| 189 ContentData* cloneInternal() const override { return create(quote()); } | 194 ContentData* cloneInternal() const override { return create(quote()); } |
| 190 | 195 |
| 191 QuoteType m_quote; | 196 QuoteType m_quote; |
| 192 }; | 197 }; |
| 193 | 198 |
| 194 DEFINE_CONTENT_DATA_TYPE_CASTS(Quote); | 199 DEFINE_CONTENT_DATA_TYPE_CASTS(Quote); |
| 195 | 200 |
| 196 inline bool operator==(const ContentData& a, const ContentData& b) { | 201 inline bool operator==(const ContentData& a, const ContentData& b) { |
| 197 return a.equals(b); | 202 return a.equals(b); |
| 198 } | 203 } |
| 199 | 204 |
| 200 inline bool operator!=(const ContentData& a, const ContentData& b) { | 205 inline bool operator!=(const ContentData& a, const ContentData& b) { |
| 201 return !(a == b); | 206 return !(a == b); |
| 202 } | 207 } |
| 203 | 208 |
| 204 } // namespace blink | 209 } // namespace blink |
| 205 | 210 |
| 206 #endif // ContentData_h | 211 #endif // ContentData_h |
| OLD | NEW |