| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // destructor. This can be removed once the MutableStylePropertySet's OwnPtr
is moved | 49 // destructor. This can be removed once the MutableStylePropertySet's OwnPtr
is moved |
| 50 // to the heap. | 50 // to the heap. |
| 51 void finalizeGarbageCollectedObject(); | 51 void finalizeGarbageCollectedObject(); |
| 52 #else | 52 #else |
| 53 // Override RefCounted's deref() to ensure operator delete is called on | 53 // Override RefCounted's deref() to ensure operator delete is called on |
| 54 // the appropriate subclass type. | 54 // the appropriate subclass type. |
| 55 void deref(); | 55 void deref(); |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 class PropertyReference { | 58 class PropertyReference { |
| 59 STACK_ALLOCATED(); |
| 59 public: | 60 public: |
| 60 PropertyReference(const StylePropertySet& propertySet, unsigned index) | 61 PropertyReference(const StylePropertySet& propertySet, unsigned index) |
| 61 : m_propertySet(propertySet) | 62 : m_propertySet(&propertySet) |
| 62 , m_index(index) | 63 , m_index(index) |
| 63 { | 64 { |
| 64 } | 65 } |
| 65 | 66 |
| 66 CSSPropertyID id() const { return static_cast<CSSPropertyID>(propertyMet
adata().m_propertyID); } | 67 CSSPropertyID id() const { return static_cast<CSSPropertyID>(propertyMet
adata().m_propertyID); } |
| 67 CSSPropertyID shorthandID() const { return propertyMetadata().shorthandI
D(); } | 68 CSSPropertyID shorthandID() const { return propertyMetadata().shorthandI
D(); } |
| 68 | 69 |
| 69 bool isImportant() const { return propertyMetadata().m_important; } | 70 bool isImportant() const { return propertyMetadata().m_important; } |
| 70 bool isInherited() const { return propertyMetadata().m_inherited; } | 71 bool isInherited() const { return propertyMetadata().m_inherited; } |
| 71 bool isImplicit() const { return propertyMetadata().m_implicit; } | 72 bool isImplicit() const { return propertyMetadata().m_implicit; } |
| 72 | 73 |
| 73 const CSSValue* value() const { return propertyValue(); } | 74 const CSSValue* value() const { return propertyValue(); } |
| 74 // FIXME: We should try to remove this mutable overload. | 75 // FIXME: We should try to remove this mutable overload. |
| 75 CSSValue* value() { return const_cast<CSSValue*>(propertyValue()); } | 76 CSSValue* value() { return const_cast<CSSValue*>(propertyValue()); } |
| 76 | 77 |
| 77 // FIXME: Remove this. | 78 // FIXME: Remove this. |
| 78 CSSProperty toCSSProperty() const { return CSSProperty(propertyMetadata(
), const_cast<CSSValue*>(propertyValue())); } | 79 CSSProperty toCSSProperty() const { return CSSProperty(propertyMetadata(
), const_cast<CSSValue*>(propertyValue())); } |
| 79 | 80 |
| 80 const StylePropertyMetadata& propertyMetadata() const; | 81 const StylePropertyMetadata& propertyMetadata() const; |
| 81 | 82 |
| 82 private: | 83 private: |
| 83 const CSSValue* propertyValue() const; | 84 const CSSValue* propertyValue() const; |
| 84 | 85 |
| 85 const StylePropertySet& m_propertySet; | 86 RawPtrWillBeMember<const StylePropertySet> m_propertySet; |
| 86 unsigned m_index; | 87 unsigned m_index; |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 unsigned propertyCount() const; | 90 unsigned propertyCount() const; |
| 90 bool isEmpty() const; | 91 bool isEmpty() const; |
| 91 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc
e(*this, index); } | 92 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc
e(*this, index); } |
| 92 int findPropertyIndex(CSSPropertyID) const; | 93 int findPropertyIndex(CSSPropertyID) const; |
| 93 bool hasProperty(CSSPropertyID property) const { return findPropertyIndex(pr
operty) != -1; } | 94 bool hasProperty(CSSPropertyID property) const { return findPropertyIndex(pr
operty) != -1; } |
| 94 | 95 |
| 95 PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const; | 96 PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 return toMutableStylePropertySet(set.get()); | 244 return toMutableStylePropertySet(set.get()); |
| 244 } | 245 } |
| 245 | 246 |
| 246 inline MutableStylePropertySet* toMutableStylePropertySet(const Member<StyleProp
ertySet>& set) | 247 inline MutableStylePropertySet* toMutableStylePropertySet(const Member<StyleProp
ertySet>& set) |
| 247 { | 248 { |
| 248 return toMutableStylePropertySet(set.get()); | 249 return toMutableStylePropertySet(set.get()); |
| 249 } | 250 } |
| 250 | 251 |
| 251 inline const StylePropertyMetadata& StylePropertySet::PropertyReference::propert
yMetadata() const | 252 inline const StylePropertyMetadata& StylePropertySet::PropertyReference::propert
yMetadata() const |
| 252 { | 253 { |
| 253 if (m_propertySet.isMutable()) | 254 if (m_propertySet->isMutable()) |
| 254 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in
dex).metadata(); | 255 return toMutableStylePropertySet(*m_propertySet).m_propertyVector.at(m_i
ndex).metadata(); |
| 255 return toImmutableStylePropertySet(m_propertySet).metadataArray()[m_index]; | 256 return toImmutableStylePropertySet(*m_propertySet).metadataArray()[m_index]; |
| 256 } | 257 } |
| 257 | 258 |
| 258 inline const CSSValue* StylePropertySet::PropertyReference::propertyValue() cons
t | 259 inline const CSSValue* StylePropertySet::PropertyReference::propertyValue() cons
t |
| 259 { | 260 { |
| 260 if (m_propertySet.isMutable()) | 261 if (m_propertySet->isMutable()) |
| 261 return toMutableStylePropertySet(m_propertySet).m_propertyVector.at(m_in
dex).value(); | 262 return toMutableStylePropertySet(*m_propertySet).m_propertyVector.at(m_i
ndex).value(); |
| 262 return toImmutableStylePropertySet(m_propertySet).valueArray()[m_index]; | 263 return toImmutableStylePropertySet(*m_propertySet).valueArray()[m_index]; |
| 263 } | 264 } |
| 264 | 265 |
| 265 inline unsigned StylePropertySet::propertyCount() const | 266 inline unsigned StylePropertySet::propertyCount() const |
| 266 { | 267 { |
| 267 if (m_isMutable) | 268 if (m_isMutable) |
| 268 return toMutableStylePropertySet(this)->m_propertyVector.size(); | 269 return toMutableStylePropertySet(this)->m_propertyVector.size(); |
| 269 return m_arraySize; | 270 return m_arraySize; |
| 270 } | 271 } |
| 271 | 272 |
| 272 inline bool StylePropertySet::isEmpty() const | 273 inline bool StylePropertySet::isEmpty() const |
| (...skipping 17 matching lines...) Expand all Loading... |
| 290 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const | 291 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const |
| 291 { | 292 { |
| 292 if (m_isMutable) | 293 if (m_isMutable) |
| 293 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID); | 294 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID); |
| 294 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID); | 295 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID); |
| 295 } | 296 } |
| 296 | 297 |
| 297 } // namespace blink | 298 } // namespace blink |
| 298 | 299 |
| 299 #endif // StylePropertySet_h | 300 #endif // StylePropertySet_h |
| OLD | NEW |