| 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 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 void setNext(PassOwnPtr<ContentData> next) { m_next = next; } | 59 void setNext(PassOwnPtr<ContentData> next) { m_next = next; } |
| 60 | 60 |
| 61 virtual bool equals(const ContentData&) const = 0; | 61 virtual bool equals(const ContentData&) const = 0; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 virtual PassOwnPtr<ContentData> cloneInternal() const = 0; | 64 virtual PassOwnPtr<ContentData> cloneInternal() const = 0; |
| 65 | 65 |
| 66 OwnPtr<ContentData> m_next; | 66 OwnPtr<ContentData> m_next; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 #define DEFINE_CONTENT_DATA_TYPE_CASTS(typeName) \ |
| 70 DEFINE_TYPE_CASTS(typeName##ContentData, ContentData, content, content->is##
typeName(), content.is##typeName()) |
| 71 |
| 69 class ImageContentData FINAL : public ContentData { | 72 class ImageContentData FINAL : public ContentData { |
| 70 friend class ContentData; | 73 friend class ContentData; |
| 71 public: | 74 public: |
| 72 const StyleImage* image() const { return m_image.get(); } | 75 const StyleImage* image() const { return m_image.get(); } |
| 73 StyleImage* image() { return m_image.get(); } | 76 StyleImage* image() { return m_image.get(); } |
| 74 void setImage(PassRefPtr<StyleImage> image) { m_image = image; } | 77 void setImage(PassRefPtr<StyleImage> image) { m_image = image; } |
| 75 | 78 |
| 76 virtual bool isImage() const OVERRIDE { return true; } | 79 virtual bool isImage() const OVERRIDE { return true; } |
| 77 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; | 80 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; |
| 78 | 81 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 91 | 94 |
| 92 virtual PassOwnPtr<ContentData> cloneInternal() const OVERRIDE | 95 virtual PassOwnPtr<ContentData> cloneInternal() const OVERRIDE |
| 93 { | 96 { |
| 94 RefPtr<StyleImage> image = const_cast<StyleImage*>(this->image()); | 97 RefPtr<StyleImage> image = const_cast<StyleImage*>(this->image()); |
| 95 return create(image.release()); | 98 return create(image.release()); |
| 96 } | 99 } |
| 97 | 100 |
| 98 RefPtr<StyleImage> m_image; | 101 RefPtr<StyleImage> m_image; |
| 99 }; | 102 }; |
| 100 | 103 |
| 104 DEFINE_CONTENT_DATA_TYPE_CASTS(Image); |
| 105 |
| 101 class TextContentData FINAL : public ContentData { | 106 class TextContentData FINAL : public ContentData { |
| 102 friend class ContentData; | 107 friend class ContentData; |
| 103 public: | 108 public: |
| 104 const String& text() const { return m_text; } | 109 const String& text() const { return m_text; } |
| 105 void setText(const String& text) { m_text = text; } | 110 void setText(const String& text) { m_text = text; } |
| 106 | 111 |
| 107 virtual bool isText() const OVERRIDE { return true; } | 112 virtual bool isText() const OVERRIDE { return true; } |
| 108 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; | 113 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; |
| 109 | 114 |
| 110 virtual bool equals(const ContentData& data) const OVERRIDE | 115 virtual bool equals(const ContentData& data) const OVERRIDE |
| 111 { | 116 { |
| 112 if (!data.isText()) | 117 if (!data.isText()) |
| 113 return false; | 118 return false; |
| 114 return static_cast<const TextContentData&>(data).text() == text(); | 119 return static_cast<const TextContentData&>(data).text() == text(); |
| 115 } | 120 } |
| 116 | 121 |
| 117 private: | 122 private: |
| 118 TextContentData(const String& text) | 123 TextContentData(const String& text) |
| 119 : m_text(text) | 124 : m_text(text) |
| 120 { | 125 { |
| 121 } | 126 } |
| 122 | 127 |
| 123 virtual PassOwnPtr<ContentData> cloneInternal() const OVERRIDE { return crea
te(text()); } | 128 virtual PassOwnPtr<ContentData> cloneInternal() const OVERRIDE { return crea
te(text()); } |
| 124 | 129 |
| 125 String m_text; | 130 String m_text; |
| 126 }; | 131 }; |
| 127 | 132 |
| 133 DEFINE_CONTENT_DATA_TYPE_CASTS(Text); |
| 134 |
| 128 class CounterContentData FINAL : public ContentData { | 135 class CounterContentData FINAL : public ContentData { |
| 129 friend class ContentData; | 136 friend class ContentData; |
| 130 public: | 137 public: |
| 131 const CounterContent* counter() const { return m_counter.get(); } | 138 const CounterContent* counter() const { return m_counter.get(); } |
| 132 void setCounter(PassOwnPtr<CounterContent> counter) { m_counter = counter; } | 139 void setCounter(PassOwnPtr<CounterContent> counter) { m_counter = counter; } |
| 133 | 140 |
| 134 virtual bool isCounter() const OVERRIDE { return true; } | 141 virtual bool isCounter() const OVERRIDE { return true; } |
| 135 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; | 142 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; |
| 136 | 143 |
| 137 private: | 144 private: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 149 virtual bool equals(const ContentData& data) const OVERRIDE | 156 virtual bool equals(const ContentData& data) const OVERRIDE |
| 150 { | 157 { |
| 151 if (!data.isCounter()) | 158 if (!data.isCounter()) |
| 152 return false; | 159 return false; |
| 153 return *static_cast<const CounterContentData&>(data).counter() == *count
er(); | 160 return *static_cast<const CounterContentData&>(data).counter() == *count
er(); |
| 154 } | 161 } |
| 155 | 162 |
| 156 OwnPtr<CounterContent> m_counter; | 163 OwnPtr<CounterContent> m_counter; |
| 157 }; | 164 }; |
| 158 | 165 |
| 166 DEFINE_CONTENT_DATA_TYPE_CASTS(Counter); |
| 167 |
| 159 class QuoteContentData FINAL : public ContentData { | 168 class QuoteContentData FINAL : public ContentData { |
| 160 friend class ContentData; | 169 friend class ContentData; |
| 161 public: | 170 public: |
| 162 QuoteType quote() const { return m_quote; } | 171 QuoteType quote() const { return m_quote; } |
| 163 void setQuote(QuoteType quote) { m_quote = quote; } | 172 void setQuote(QuoteType quote) { m_quote = quote; } |
| 164 | 173 |
| 165 virtual bool isQuote() const OVERRIDE { return true; } | 174 virtual bool isQuote() const OVERRIDE { return true; } |
| 166 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; | 175 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; |
| 167 | 176 |
| 168 virtual bool equals(const ContentData& data) const OVERRIDE | 177 virtual bool equals(const ContentData& data) const OVERRIDE |
| 169 { | 178 { |
| 170 if (!data.isQuote()) | 179 if (!data.isQuote()) |
| 171 return false; | 180 return false; |
| 172 return static_cast<const QuoteContentData&>(data).quote() == quote(); | 181 return static_cast<const QuoteContentData&>(data).quote() == quote(); |
| 173 } | 182 } |
| 174 | 183 |
| 175 private: | 184 private: |
| 176 QuoteContentData(QuoteType quote) | 185 QuoteContentData(QuoteType quote) |
| 177 : m_quote(quote) | 186 : m_quote(quote) |
| 178 { | 187 { |
| 179 } | 188 } |
| 180 | 189 |
| 181 virtual PassOwnPtr<ContentData> cloneInternal() const OVERRIDE { return crea
te(quote()); } | 190 virtual PassOwnPtr<ContentData> cloneInternal() const OVERRIDE { return crea
te(quote()); } |
| 182 | 191 |
| 183 QuoteType m_quote; | 192 QuoteType m_quote; |
| 184 }; | 193 }; |
| 185 | 194 |
| 195 DEFINE_CONTENT_DATA_TYPE_CASTS(Quote); |
| 196 |
| 186 inline bool operator==(const ContentData& a, const ContentData& b) | 197 inline bool operator==(const ContentData& a, const ContentData& b) |
| 187 { | 198 { |
| 188 return a.equals(b); | 199 return a.equals(b); |
| 189 } | 200 } |
| 190 | 201 |
| 191 inline bool operator!=(const ContentData& a, const ContentData& b) | 202 inline bool operator!=(const ContentData& a, const ContentData& b) |
| 192 { | 203 { |
| 193 return !(a == b); | 204 return !(a == b); |
| 194 } | 205 } |
| 195 | 206 |
| 196 } // namespace blink | 207 } // namespace blink |
| 197 | 208 |
| 198 #endif // ContentData_h | 209 #endif // ContentData_h |
| OLD | NEW |