| 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 class ImageContentData : public ContentData { | 69 class ImageContentData FINAL : public ContentData { |
| 70 friend class ContentData; | 70 friend class ContentData; |
| 71 public: | 71 public: |
| 72 const StyleImage* image() const { return m_image.get(); } | 72 const StyleImage* image() const { return m_image.get(); } |
| 73 StyleImage* image() { return m_image.get(); } | 73 StyleImage* image() { return m_image.get(); } |
| 74 void setImage(PassRefPtr<StyleImage> image) { m_image = image; } | 74 void setImage(PassRefPtr<StyleImage> image) { m_image = image; } |
| 75 | 75 |
| 76 virtual bool isImage() const OVERRIDE { return true; } | 76 virtual bool isImage() const OVERRIDE { return true; } |
| 77 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; | 77 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; |
| 78 | 78 |
| 79 virtual bool equals(const ContentData& data) const OVERRIDE | 79 virtual bool equals(const ContentData& data) const OVERRIDE |
| 80 { | 80 { |
| 81 if (!data.isImage()) | 81 if (!data.isImage()) |
| 82 return false; | 82 return false; |
| 83 return *static_cast<const ImageContentData&>(data).image() == *image(); | 83 return *static_cast<const ImageContentData&>(data).image() == *image(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 ImageContentData(PassRefPtr<StyleImage> image) | 87 ImageContentData(PassRefPtr<StyleImage> image) |
| 88 : m_image(image) | 88 : m_image(image) |
| 89 { | 89 { |
| 90 } | 90 } |
| 91 | 91 |
| 92 virtual PassOwnPtr<ContentData> cloneInternal() const | 92 virtual PassOwnPtr<ContentData> cloneInternal() const OVERRIDE |
| 93 { | 93 { |
| 94 RefPtr<StyleImage> image = const_cast<StyleImage*>(this->image()); | 94 RefPtr<StyleImage> image = const_cast<StyleImage*>(this->image()); |
| 95 return create(image.release()); | 95 return create(image.release()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 RefPtr<StyleImage> m_image; | 98 RefPtr<StyleImage> m_image; |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 class TextContentData : public ContentData { | 101 class TextContentData FINAL : public ContentData { |
| 102 friend class ContentData; | 102 friend class ContentData; |
| 103 public: | 103 public: |
| 104 const String& text() const { return m_text; } | 104 const String& text() const { return m_text; } |
| 105 void setText(const String& text) { m_text = text; } | 105 void setText(const String& text) { m_text = text; } |
| 106 | 106 |
| 107 virtual bool isText() const OVERRIDE { return true; } | 107 virtual bool isText() const OVERRIDE { return true; } |
| 108 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; | 108 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; |
| 109 | 109 |
| 110 virtual bool equals(const ContentData& data) const OVERRIDE | 110 virtual bool equals(const ContentData& data) const OVERRIDE |
| 111 { | 111 { |
| 112 if (!data.isText()) | 112 if (!data.isText()) |
| 113 return false; | 113 return false; |
| 114 return static_cast<const TextContentData&>(data).text() == text(); | 114 return static_cast<const TextContentData&>(data).text() == text(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 private: | 117 private: |
| 118 TextContentData(const String& text) | 118 TextContentData(const String& text) |
| 119 : m_text(text) | 119 : m_text(text) |
| 120 { | 120 { |
| 121 } | 121 } |
| 122 | 122 |
| 123 virtual PassOwnPtr<ContentData> cloneInternal() const { return create(text()
); } | 123 virtual PassOwnPtr<ContentData> cloneInternal() const OVERRIDE { return crea
te(text()); } |
| 124 | 124 |
| 125 String m_text; | 125 String m_text; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 class CounterContentData : public ContentData { | 128 class CounterContentData FINAL : public ContentData { |
| 129 friend class ContentData; | 129 friend class ContentData; |
| 130 public: | 130 public: |
| 131 const CounterContent* counter() const { return m_counter.get(); } | 131 const CounterContent* counter() const { return m_counter.get(); } |
| 132 void setCounter(PassOwnPtr<CounterContent> counter) { m_counter = counter; } | 132 void setCounter(PassOwnPtr<CounterContent> counter) { m_counter = counter; } |
| 133 | 133 |
| 134 virtual bool isCounter() const OVERRIDE { return true; } | 134 virtual bool isCounter() const OVERRIDE { return true; } |
| 135 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; | 135 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; |
| 136 | 136 |
| 137 private: | 137 private: |
| 138 CounterContentData(PassOwnPtr<CounterContent> counter) | 138 CounterContentData(PassOwnPtr<CounterContent> counter) |
| 139 : m_counter(counter) | 139 : m_counter(counter) |
| 140 { | 140 { |
| 141 } | 141 } |
| 142 | 142 |
| 143 virtual PassOwnPtr<ContentData> cloneInternal() const | 143 virtual PassOwnPtr<ContentData> cloneInternal() const OVERRIDE |
| 144 { | 144 { |
| 145 OwnPtr<CounterContent> counterData = adoptPtr(new CounterContent(*counte
r())); | 145 OwnPtr<CounterContent> counterData = adoptPtr(new CounterContent(*counte
r())); |
| 146 return create(counterData.release()); | 146 return create(counterData.release()); |
| 147 } | 147 } |
| 148 | 148 |
| 149 virtual bool equals(const ContentData& data) const OVERRIDE | 149 virtual bool equals(const ContentData& data) const OVERRIDE |
| 150 { | 150 { |
| 151 if (!data.isCounter()) | 151 if (!data.isCounter()) |
| 152 return false; | 152 return false; |
| 153 return *static_cast<const CounterContentData&>(data).counter() == *count
er(); | 153 return *static_cast<const CounterContentData&>(data).counter() == *count
er(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 OwnPtr<CounterContent> m_counter; | 156 OwnPtr<CounterContent> m_counter; |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 class QuoteContentData : public ContentData { | 159 class QuoteContentData FINAL : public ContentData { |
| 160 friend class ContentData; | 160 friend class ContentData; |
| 161 public: | 161 public: |
| 162 QuoteType quote() const { return m_quote; } | 162 QuoteType quote() const { return m_quote; } |
| 163 void setQuote(QuoteType quote) { m_quote = quote; } | 163 void setQuote(QuoteType quote) { m_quote = quote; } |
| 164 | 164 |
| 165 virtual bool isQuote() const OVERRIDE { return true; } | 165 virtual bool isQuote() const OVERRIDE { return true; } |
| 166 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; | 166 virtual RenderObject* createRenderer(Document&, RenderStyle*) const OVERRIDE
; |
| 167 | 167 |
| 168 virtual bool equals(const ContentData& data) const OVERRIDE | 168 virtual bool equals(const ContentData& data) const OVERRIDE |
| 169 { | 169 { |
| 170 if (!data.isQuote()) | 170 if (!data.isQuote()) |
| 171 return false; | 171 return false; |
| 172 return static_cast<const QuoteContentData&>(data).quote() == quote(); | 172 return static_cast<const QuoteContentData&>(data).quote() == quote(); |
| 173 } | 173 } |
| 174 | 174 |
| 175 private: | 175 private: |
| 176 QuoteContentData(QuoteType quote) | 176 QuoteContentData(QuoteType quote) |
| 177 : m_quote(quote) | 177 : m_quote(quote) |
| 178 { | 178 { |
| 179 } | 179 } |
| 180 | 180 |
| 181 virtual PassOwnPtr<ContentData> cloneInternal() const { return create(quote(
)); } | 181 virtual PassOwnPtr<ContentData> cloneInternal() const OVERRIDE { return crea
te(quote()); } |
| 182 | 182 |
| 183 QuoteType m_quote; | 183 QuoteType m_quote; |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 inline bool operator==(const ContentData& a, const ContentData& b) | 186 inline bool operator==(const ContentData& a, const ContentData& b) |
| 187 { | 187 { |
| 188 return a.equals(b); | 188 return a.equals(b); |
| 189 } | 189 } |
| 190 | 190 |
| 191 inline bool operator!=(const ContentData& a, const ContentData& b) | 191 inline bool operator!=(const ContentData& a, const ContentData& b) |
| 192 { | 192 { |
| 193 return !(a == b); | 193 return !(a == b); |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace WebCore | 196 } // namespace WebCore |
| 197 | 197 |
| 198 #endif // ContentData_h | 198 #endif // ContentData_h |
| OLD | NEW |