OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * Copyright (C) 2014 Apple Inc. All rights reserved. | 3 * Copyright (C) 2014 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // or gains presentation attribute style (ex. width="10"). It does not need to | 159 // or gains presentation attribute style (ex. width="10"). It does not need to |
160 // be created to fill in values in the ElementData that are derived from | 160 // be created to fill in values in the ElementData that are derived from |
161 // attributes. For example populating the m_inlineStyle from the style attribute | 161 // attributes. For example populating the m_inlineStyle from the style attribute |
162 // doesn't require a UniqueElementData as all elements with the same style | 162 // doesn't require a UniqueElementData as all elements with the same style |
163 // attribute will have the same inline style. | 163 // attribute will have the same inline style. |
164 class UniqueElementData FINAL : public ElementData { | 164 class UniqueElementData FINAL : public ElementData { |
165 public: | 165 public: |
166 static PassRefPtrWillBeRawPtr<UniqueElementData> create(); | 166 static PassRefPtrWillBeRawPtr<UniqueElementData> create(); |
167 PassRefPtrWillBeRawPtr<ShareableElementData> makeShareableCopy() const; | 167 PassRefPtrWillBeRawPtr<ShareableElementData> makeShareableCopy() const; |
168 | 168 |
169 // These functions do no error/duplicate checking. | 169 MutableAttributeCollection attributes(); |
170 void appendAttribute(const QualifiedName&, const AtomicString&); | |
171 void removeAttributeAt(size_t index); | |
172 | |
173 AttributeCollection attributes() const; | 170 AttributeCollection attributes() const; |
174 | 171 |
175 Attribute& attributeAt(unsigned index); | |
176 Attribute* findAttributeByName(const QualifiedName&); | |
177 | |
178 UniqueElementData(); | 172 UniqueElementData(); |
179 explicit UniqueElementData(const ShareableElementData&); | 173 explicit UniqueElementData(const ShareableElementData&); |
180 explicit UniqueElementData(const UniqueElementData&); | 174 explicit UniqueElementData(const UniqueElementData&); |
181 | 175 |
182 void traceAfterDispatch(Visitor*); | 176 void traceAfterDispatch(Visitor*); |
183 | 177 |
184 // FIXME: We might want to support sharing element data for elements with | 178 // FIXME: We might want to support sharing element data for elements with |
185 // presentation attribute style. Lots of table cells likely have the same | 179 // presentation attribute style. Lots of table cells likely have the same |
186 // attributes. Most modern pages don't use presentation attributes though | 180 // attributes. Most modern pages don't use presentation attributes though |
187 // so this might not make sense. | 181 // so this might not make sense. |
188 mutable RefPtrWillBeMember<StylePropertySet> m_presentationAttributeStyle; | 182 mutable RefPtrWillBeMember<StylePropertySet> m_presentationAttributeStyle; |
189 Vector<Attribute, 4> m_attributeVector; | 183 AttributeVector m_attributeVector; |
190 }; | 184 }; |
191 | 185 |
192 DEFINE_ELEMENT_DATA_TYPE_CASTS(UniqueElementData, data->isUnique(), data.isUniqu
e()); | 186 DEFINE_ELEMENT_DATA_TYPE_CASTS(UniqueElementData, data->isUnique(), data.isUniqu
e()); |
193 | 187 |
194 #if !ENABLE(OILPAN) | 188 #if !ENABLE(OILPAN) |
195 inline void ElementData::deref() | 189 inline void ElementData::deref() |
196 { | 190 { |
197 if (!derefBase()) | 191 if (!derefBase()) |
198 return; | 192 return; |
199 destroy(); | 193 destroy(); |
(...skipping 17 matching lines...) Expand all Loading... |
217 inline AttributeCollection ShareableElementData::attributes() const | 211 inline AttributeCollection ShareableElementData::attributes() const |
218 { | 212 { |
219 return AttributeCollection(m_attributeArray, m_arraySize); | 213 return AttributeCollection(m_attributeArray, m_arraySize); |
220 } | 214 } |
221 | 215 |
222 inline AttributeCollection UniqueElementData::attributes() const | 216 inline AttributeCollection UniqueElementData::attributes() const |
223 { | 217 { |
224 return AttributeCollection(m_attributeVector.data(), m_attributeVector.size(
)); | 218 return AttributeCollection(m_attributeVector.data(), m_attributeVector.size(
)); |
225 } | 219 } |
226 | 220 |
227 inline void UniqueElementData::appendAttribute(const QualifiedName& attributeNam
e, const AtomicString& value) | 221 inline MutableAttributeCollection UniqueElementData::attributes() |
228 { | 222 { |
229 m_attributeVector.append(Attribute(attributeName, value)); | 223 return MutableAttributeCollection(m_attributeVector); |
230 } | |
231 | |
232 inline void UniqueElementData::removeAttributeAt(size_t index) | |
233 { | |
234 m_attributeVector.remove(index); | |
235 } | |
236 | |
237 inline Attribute& UniqueElementData::attributeAt(unsigned index) | |
238 { | |
239 return m_attributeVector.at(index); | |
240 } | 224 } |
241 | 225 |
242 } // namespace blink | 226 } // namespace blink |
243 | 227 |
244 #endif // ElementData_h | 228 #endif // ElementData_h |
OLD | NEW |