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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 RawPtrWillBeMember<const StylePropertySet> m_propertySet; | 86 RawPtrWillBeMember<const StylePropertySet> m_propertySet; |
87 unsigned m_index; | 87 unsigned m_index; |
88 }; | 88 }; |
89 | 89 |
90 unsigned propertyCount() const; | 90 unsigned propertyCount() const; |
91 bool isEmpty() const; | 91 bool isEmpty() const; |
92 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc
e(*this, index); } | 92 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc
e(*this, index); } |
93 int findPropertyIndex(CSSPropertyID) const; | 93 int findPropertyIndex(CSSPropertyID) const; |
94 bool hasProperty(CSSPropertyID property) const { return findPropertyIndex(pr
operty) != -1; } | 94 bool hasProperty(CSSPropertyID property) const { return findPropertyIndex(pr
operty) != -1; } |
95 | 95 |
96 PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const; | 96 PassRefPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const; |
97 String getPropertyValue(CSSPropertyID) const; | 97 String getPropertyValue(CSSPropertyID) const; |
98 | 98 |
99 bool propertyIsImportant(CSSPropertyID) const; | 99 bool propertyIsImportant(CSSPropertyID) const; |
100 CSSPropertyID getPropertyShorthand(CSSPropertyID) const; | 100 CSSPropertyID getPropertyShorthand(CSSPropertyID) const; |
101 bool isPropertyImplicit(CSSPropertyID) const; | 101 bool isPropertyImplicit(CSSPropertyID) const; |
102 | 102 |
103 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cs
sParserMode); } | 103 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cs
sParserMode); } |
104 | 104 |
105 PassRefPtrWillBeRawPtr<MutableStylePropertySet> mutableCopy() const; | 105 PassRefPtrWillBeRawPtr<MutableStylePropertySet> mutableCopy() const; |
106 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() co
nst; | 106 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() co
nst; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 friend class PropertySetCSSStyleDeclaration; | 147 friend class PropertySetCSSStyleDeclaration; |
148 }; | 148 }; |
149 | 149 |
150 class CORE_EXPORT ImmutableStylePropertySet : public StylePropertySet { | 150 class CORE_EXPORT ImmutableStylePropertySet : public StylePropertySet { |
151 public: | 151 public: |
152 ~ImmutableStylePropertySet(); | 152 ~ImmutableStylePropertySet(); |
153 static PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> create(const CSSPro
perty* properties, unsigned count, CSSParserMode); | 153 static PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> create(const CSSPro
perty* properties, unsigned count, CSSParserMode); |
154 | 154 |
155 unsigned propertyCount() const { return m_arraySize; } | 155 unsigned propertyCount() const { return m_arraySize; } |
156 | 156 |
157 const RawPtrWillBeMember<CSSValue>* valueArray() const; | 157 const RawPtr<CSSValue>* valueArray() const; |
158 const StylePropertyMetadata* metadataArray() const; | 158 const StylePropertyMetadata* metadataArray() const; |
159 int findPropertyIndex(CSSPropertyID) const; | 159 int findPropertyIndex(CSSPropertyID) const; |
160 | 160 |
161 DECLARE_TRACE_AFTER_DISPATCH(); | 161 DECLARE_TRACE_AFTER_DISPATCH(); |
162 | 162 |
163 void* operator new(std::size_t, void* location) | 163 void* operator new(std::size_t, void* location) |
164 { | 164 { |
165 return location; | 165 return location; |
166 } | 166 } |
167 | 167 |
168 void* m_storage; | 168 void* m_storage; |
169 | 169 |
170 private: | 170 private: |
171 ImmutableStylePropertySet(const CSSProperty*, unsigned count, CSSParserMode)
; | 171 ImmutableStylePropertySet(const CSSProperty*, unsigned count, CSSParserMode)
; |
172 }; | 172 }; |
173 | 173 |
174 inline const RawPtrWillBeMember<CSSValue>* ImmutableStylePropertySet::valueArray
() const | 174 inline const RawPtr<CSSValue>* ImmutableStylePropertySet::valueArray() const |
175 { | 175 { |
176 return reinterpret_cast<const RawPtrWillBeMember<CSSValue>*>(const_cast<cons
t void**>(&(this->m_storage))); | 176 return reinterpret_cast<const RawPtr<CSSValue>*>(const_cast<const void**>(&(
this->m_storage))); |
177 } | 177 } |
178 | 178 |
179 inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() c
onst | 179 inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() c
onst |
180 { | 180 { |
181 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons
t char*>(&(this->m_storage))[m_arraySize * sizeof(RawPtrWillBeMember<CSSValue>)]
); | 181 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons
t char*>(&(this->m_storage))[m_arraySize * sizeof(RawPtr<CSSValue>)]); |
182 } | 182 } |
183 | 183 |
184 DEFINE_TYPE_CASTS(ImmutableStylePropertySet, StylePropertySet, set, !set->isMuta
ble(), !set.isMutable()); | 184 DEFINE_TYPE_CASTS(ImmutableStylePropertySet, StylePropertySet, set, !set->isMuta
ble(), !set.isMutable()); |
185 | 185 |
186 class CORE_EXPORT MutableStylePropertySet : public StylePropertySet { | 186 class CORE_EXPORT MutableStylePropertySet : public StylePropertySet { |
187 public: | 187 public: |
188 ~MutableStylePropertySet() { } | 188 ~MutableStylePropertySet() { } |
189 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(CSSParserMode
= HTMLQuirksMode); | 189 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(CSSParserMode
= HTMLQuirksMode); |
190 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(const CSSPrope
rty* properties, unsigned count); | 190 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(const CSSPrope
rty* properties, unsigned count); |
191 | 191 |
192 unsigned propertyCount() const { return m_propertyVector.size(); } | 192 unsigned propertyCount() const { return m_propertyVector.size(); } |
193 | 193 |
194 // Returns whether this style set was changed. | 194 // Returns whether this style set was changed. |
195 bool addParsedProperties(const WillBeHeapVector<CSSProperty, 256>&); | 195 bool addParsedProperties(const Vector<CSSProperty, 256>&); |
196 bool addRespectingCascade(const CSSProperty&); | 196 bool addRespectingCascade(const CSSProperty&); |
197 | 197 |
198 // These expand shorthand properties into multiple properties. | 198 // These expand shorthand properties into multiple properties. |
199 bool setProperty(CSSPropertyID unresolvedProperty, const String& value, bool
important = false, StyleSheetContents* contextStyleSheet = 0); | 199 bool setProperty(CSSPropertyID unresolvedProperty, const String& value, bool
important = false, StyleSheetContents* contextStyleSheet = 0); |
200 void setProperty(CSSPropertyID, PassRefPtrWillBeRawPtr<CSSValue>, bool impor
tant = false); | 200 void setProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important = false
); |
201 | 201 |
202 // These do not. FIXME: This is too messy, we can do better. | 202 // These do not. FIXME: This is too messy, we can do better. |
203 bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = fals
e); | 203 bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = fals
e); |
204 bool setProperty(const CSSProperty&, CSSProperty* slot = 0); | 204 bool setProperty(const CSSProperty&, CSSProperty* slot = 0); |
205 | 205 |
206 bool removeProperty(CSSPropertyID, String* returnText = 0); | 206 bool removeProperty(CSSPropertyID, String* returnText = 0); |
207 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length); | 207 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length); |
208 void removeEquivalentProperties(const StylePropertySet*); | 208 void removeEquivalentProperties(const StylePropertySet*); |
209 void removeEquivalentProperties(const CSSStyleDeclaration*); | 209 void removeEquivalentProperties(const CSSStyleDeclaration*); |
210 | 210 |
(...skipping 11 matching lines...) Expand all Loading... |
222 explicit MutableStylePropertySet(CSSParserMode); | 222 explicit MutableStylePropertySet(CSSParserMode); |
223 explicit MutableStylePropertySet(const StylePropertySet&); | 223 explicit MutableStylePropertySet(const StylePropertySet&); |
224 MutableStylePropertySet(const CSSProperty* properties, unsigned count); | 224 MutableStylePropertySet(const CSSProperty* properties, unsigned count); |
225 | 225 |
226 bool removeShorthandProperty(CSSPropertyID); | 226 bool removeShorthandProperty(CSSPropertyID); |
227 CSSProperty* findCSSPropertyWithID(CSSPropertyID); | 227 CSSProperty* findCSSPropertyWithID(CSSPropertyID); |
228 OwnPtrWillBeMember<PropertySetCSSStyleDeclaration> m_cssomWrapper; | 228 OwnPtrWillBeMember<PropertySetCSSStyleDeclaration> m_cssomWrapper; |
229 | 229 |
230 friend class StylePropertySet; | 230 friend class StylePropertySet; |
231 | 231 |
232 WillBeHeapVector<CSSProperty, 4> m_propertyVector; | 232 Vector<CSSProperty, 4> m_propertyVector; |
233 }; | 233 }; |
234 | 234 |
235 DEFINE_TYPE_CASTS(MutableStylePropertySet, StylePropertySet, set, set->isMutable
(), set.isMutable()); | 235 DEFINE_TYPE_CASTS(MutableStylePropertySet, StylePropertySet, set, set->isMutable
(), set.isMutable()); |
236 | 236 |
237 inline MutableStylePropertySet* toMutableStylePropertySet(const RefPtrWillBeRawP
tr<StylePropertySet>& set) | 237 inline MutableStylePropertySet* toMutableStylePropertySet(const RefPtrWillBeRawP
tr<StylePropertySet>& set) |
238 { | 238 { |
239 return toMutableStylePropertySet(set.get()); | 239 return toMutableStylePropertySet(set.get()); |
240 } | 240 } |
241 | 241 |
242 inline MutableStylePropertySet* toMutableStylePropertySet(const Persistent<Style
PropertySet>& set) | 242 inline MutableStylePropertySet* toMutableStylePropertySet(const Persistent<Style
PropertySet>& set) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const | 291 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const |
292 { | 292 { |
293 if (m_isMutable) | 293 if (m_isMutable) |
294 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID); | 294 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID); |
295 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID); | 295 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID); |
296 } | 296 } |
297 | 297 |
298 } // namespace blink | 298 } // namespace blink |
299 | 299 |
300 #endif // StylePropertySet_h | 300 #endif // StylePropertySet_h |
OLD | NEW |