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, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #ifndef StylePropertySet_h | 21 #ifndef StylePropertySet_h |
22 #define StylePropertySet_h | 22 #define StylePropertySet_h |
23 | 23 |
24 #include "core/CSSPropertyNames.h" | 24 #include "core/CSSPropertyNames.h" |
25 #include "core/CoreExport.h" | 25 #include "core/CoreExport.h" |
26 #include "core/css/CSSCustomPropertyDeclaration.h" | |
27 #include "core/css/CSSPrimitiveValue.h" | 26 #include "core/css/CSSPrimitiveValue.h" |
28 #include "core/css/CSSProperty.h" | 27 #include "core/css/CSSProperty.h" |
29 #include "core/css/PropertySetCSSStyleDeclaration.h" | 28 #include "core/css/PropertySetCSSStyleDeclaration.h" |
30 #include "core/css/parser/CSSParserMode.h" | 29 #include "core/css/parser/CSSParserMode.h" |
31 #include "wtf/ListHashSet.h" | 30 #include "wtf/ListHashSet.h" |
32 #include "wtf/Noncopyable.h" | 31 #include "wtf/Noncopyable.h" |
33 #include "wtf/Vector.h" | 32 #include "wtf/Vector.h" |
34 #include "wtf/text/WTFString.h" | 33 #include "wtf/text/WTFString.h" |
35 | 34 |
36 namespace blink { | 35 namespace blink { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 private: | 83 private: |
85 const CSSValue* propertyValue() const; | 84 const CSSValue* propertyValue() const; |
86 | 85 |
87 RawPtrWillBeMember<const StylePropertySet> m_propertySet; | 86 RawPtrWillBeMember<const StylePropertySet> m_propertySet; |
88 unsigned m_index; | 87 unsigned m_index; |
89 }; | 88 }; |
90 | 89 |
91 unsigned propertyCount() const; | 90 unsigned propertyCount() const; |
92 bool isEmpty() const; | 91 bool isEmpty() const; |
93 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc
e(*this, index); } | 92 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc
e(*this, index); } |
94 int findPropertyIndex(CSSPropertyID) const; | 93 |
95 int findCustomPropertyIndex(const AtomicString& propertyName) const; | 94 template<typename T> // CSSPropertyID or AtomicString |
| 95 int findPropertyIndex(T property) const; |
| 96 |
96 bool hasProperty(CSSPropertyID property) const { return findPropertyIndex(pr
operty) != -1; } | 97 bool hasProperty(CSSPropertyID property) const { return findPropertyIndex(pr
operty) != -1; } |
97 | 98 |
98 PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const; | 99 template<typename T> // CSSPropertyID or AtomicString |
99 PassRefPtrWillBeRawPtr<CSSCustomPropertyDeclaration> getCustomPropertyCSSVal
ue(const AtomicString&) const; | 100 PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(T property) const; |
100 String getPropertyValue(CSSPropertyID) const; | |
101 String getCustomPropertyValue(const AtomicString&) const; | |
102 | 101 |
103 bool propertyIsImportant(CSSPropertyID) const; | 102 template<typename T> // CSSPropertyID or AtomicString |
104 bool customPropertyIsImportant(const AtomicString&) const; | 103 String getPropertyValue(T property) const; |
| 104 |
| 105 template<typename T> // CSSPropertyID or AtomicString |
| 106 bool propertyIsImportant(T property) const; |
| 107 |
| 108 bool shorthandIsImportant(CSSPropertyID) const; |
| 109 bool shorthandIsImportant(const AtomicString& customPropertyName) const; |
| 110 |
105 CSSPropertyID getPropertyShorthand(CSSPropertyID) const; | 111 CSSPropertyID getPropertyShorthand(CSSPropertyID) const; |
106 bool isPropertyImplicit(CSSPropertyID) const; | 112 bool isPropertyImplicit(CSSPropertyID) const; |
107 | 113 |
108 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cs
sParserMode); } | 114 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cs
sParserMode); } |
109 | 115 |
110 PassRefPtrWillBeRawPtr<MutableStylePropertySet> mutableCopy() const; | 116 PassRefPtrWillBeRawPtr<MutableStylePropertySet> mutableCopy() const; |
111 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() co
nst; | 117 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() co
nst; |
112 | 118 |
113 PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyPropertiesInSet(const Ve
ctor<CSSPropertyID>&) const; | 119 PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyPropertiesInSet(const Ve
ctor<CSSPropertyID>&) const; |
114 | 120 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 160 |
155 class CORE_EXPORT ImmutableStylePropertySet : public StylePropertySet { | 161 class CORE_EXPORT ImmutableStylePropertySet : public StylePropertySet { |
156 public: | 162 public: |
157 ~ImmutableStylePropertySet(); | 163 ~ImmutableStylePropertySet(); |
158 static PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> create(const CSSPro
perty* properties, unsigned count, CSSParserMode); | 164 static PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> create(const CSSPro
perty* properties, unsigned count, CSSParserMode); |
159 | 165 |
160 unsigned propertyCount() const { return m_arraySize; } | 166 unsigned propertyCount() const { return m_arraySize; } |
161 | 167 |
162 const RawPtrWillBeMember<CSSValue>* valueArray() const; | 168 const RawPtrWillBeMember<CSSValue>* valueArray() const; |
163 const StylePropertyMetadata* metadataArray() const; | 169 const StylePropertyMetadata* metadataArray() const; |
164 int findPropertyIndex(CSSPropertyID) const; | 170 |
165 int findCustomPropertyIndex(const AtomicString& propertyName) const; | 171 template<typename T> // CSSPropertyID or AtomicString |
| 172 int findPropertyIndex(T property) const; |
166 | 173 |
167 DECLARE_TRACE_AFTER_DISPATCH(); | 174 DECLARE_TRACE_AFTER_DISPATCH(); |
168 | 175 |
169 void* operator new(std::size_t, void* location) | 176 void* operator new(std::size_t, void* location) |
170 { | 177 { |
171 return location; | 178 return location; |
172 } | 179 } |
173 | 180 |
174 void* m_storage; | 181 void* m_storage; |
175 | 182 |
(...skipping 20 matching lines...) Expand all Loading... |
196 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(const CSSPrope
rty* properties, unsigned count); | 203 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> create(const CSSPrope
rty* properties, unsigned count); |
197 | 204 |
198 unsigned propertyCount() const { return m_propertyVector.size(); } | 205 unsigned propertyCount() const { return m_propertyVector.size(); } |
199 | 206 |
200 // Returns whether this style set was changed. | 207 // Returns whether this style set was changed. |
201 bool addParsedProperties(const WillBeHeapVector<CSSProperty, 256>&); | 208 bool addParsedProperties(const WillBeHeapVector<CSSProperty, 256>&); |
202 bool addRespectingCascade(const CSSProperty&); | 209 bool addRespectingCascade(const CSSProperty&); |
203 | 210 |
204 // These expand shorthand properties into multiple properties. | 211 // These expand shorthand properties into multiple properties. |
205 bool setProperty(CSSPropertyID unresolvedProperty, const String& value, bool
important = false, StyleSheetContents* contextStyleSheet = 0); | 212 bool setProperty(CSSPropertyID unresolvedProperty, const String& value, bool
important = false, StyleSheetContents* contextStyleSheet = 0); |
| 213 bool setProperty(const AtomicString& customPropertyName, const String& value
, bool important = false, StyleSheetContents* contextStyleSheet = 0); |
206 void setProperty(CSSPropertyID, PassRefPtrWillBeRawPtr<CSSValue>, bool impor
tant = false); | 214 void setProperty(CSSPropertyID, PassRefPtrWillBeRawPtr<CSSValue>, bool impor
tant = false); |
207 bool setCustomProperty(const AtomicString& propertyName, const String& value
, bool important = false, StyleSheetContents* contextStyleSheet = 0); | |
208 | 215 |
209 // These do not. FIXME: This is too messy, we can do better. | 216 // These do not. FIXME: This is too messy, we can do better. |
210 bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = fals
e); | 217 bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = fals
e); |
211 bool setProperty(const CSSProperty&, CSSProperty* slot = 0); | 218 bool setProperty(const CSSProperty&, CSSProperty* slot = 0); |
212 | 219 |
213 bool removeProperty(CSSPropertyID, String* returnText = 0); | 220 template<typename T> // CSSPropertyID or AtomicString |
214 bool removeCustomProperty(const AtomicString&, String* returnText = 0); | 221 bool removeProperty(T property, String* returnText = 0); |
215 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length); | 222 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length); |
216 void removeEquivalentProperties(const StylePropertySet*); | 223 void removeEquivalentProperties(const StylePropertySet*); |
217 void removeEquivalentProperties(const CSSStyleDeclaration*); | 224 void removeEquivalentProperties(const CSSStyleDeclaration*); |
218 | 225 |
219 void mergeAndOverrideOnConflict(const StylePropertySet*); | 226 void mergeAndOverrideOnConflict(const StylePropertySet*); |
220 | 227 |
221 void clear(); | 228 void clear(); |
222 void parseDeclarationList(const String& styleDeclaration, StyleSheetContents
* contextStyleSheet); | 229 void parseDeclarationList(const String& styleDeclaration, StyleSheetContents
* contextStyleSheet); |
223 | 230 |
224 CSSStyleDeclaration* ensureCSSStyleDeclaration(); | 231 CSSStyleDeclaration* ensureCSSStyleDeclaration(); |
225 int findPropertyIndex(CSSPropertyID) const; | 232 |
226 int findCustomPropertyIndex(const AtomicString& propertyName) const; | 233 template<typename T> // CSSPropertyID or AtomicString |
| 234 int findPropertyIndex(T property) const; |
227 | 235 |
228 DECLARE_TRACE_AFTER_DISPATCH(); | 236 DECLARE_TRACE_AFTER_DISPATCH(); |
229 | 237 |
230 private: | 238 private: |
231 explicit MutableStylePropertySet(CSSParserMode); | 239 explicit MutableStylePropertySet(CSSParserMode); |
232 explicit MutableStylePropertySet(const StylePropertySet&); | 240 explicit MutableStylePropertySet(const StylePropertySet&); |
233 MutableStylePropertySet(const CSSProperty* properties, unsigned count); | 241 MutableStylePropertySet(const CSSProperty* properties, unsigned count); |
234 | 242 |
235 bool removePropertyAtIndex(int, String* returnText); | 243 bool removePropertyAtIndex(int, String* returnText); |
236 | 244 |
237 bool removeShorthandProperty(CSSPropertyID); | 245 bool removeShorthandProperty(CSSPropertyID); |
| 246 bool removeShorthandProperty(const AtomicString& customPropertyName) { retur
n false; } |
238 CSSProperty* findCSSPropertyWithID(CSSPropertyID); | 247 CSSProperty* findCSSPropertyWithID(CSSPropertyID); |
239 OwnPtrWillBeMember<PropertySetCSSStyleDeclaration> m_cssomWrapper; | 248 OwnPtrWillBeMember<PropertySetCSSStyleDeclaration> m_cssomWrapper; |
240 | 249 |
241 friend class StylePropertySet; | 250 friend class StylePropertySet; |
242 | 251 |
243 WillBeHeapVector<CSSProperty, 4> m_propertyVector; | 252 WillBeHeapVector<CSSProperty, 4> m_propertyVector; |
244 }; | 253 }; |
245 | 254 |
246 DEFINE_TYPE_CASTS(MutableStylePropertySet, StylePropertySet, set, set->isMutable
(), set.isMutable()); | 255 DEFINE_TYPE_CASTS(MutableStylePropertySet, StylePropertySet, set, set->isMutable
(), set.isMutable()); |
247 | 256 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 if (!derefBase()) | 301 if (!derefBase()) |
293 return; | 302 return; |
294 | 303 |
295 if (m_isMutable) | 304 if (m_isMutable) |
296 delete toMutableStylePropertySet(this); | 305 delete toMutableStylePropertySet(this); |
297 else | 306 else |
298 delete toImmutableStylePropertySet(this); | 307 delete toImmutableStylePropertySet(this); |
299 } | 308 } |
300 #endif // !ENABLE(OILPAN) | 309 #endif // !ENABLE(OILPAN) |
301 | 310 |
302 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const | 311 template<typename T> |
| 312 inline int StylePropertySet::findPropertyIndex(T property) const |
303 { | 313 { |
304 if (m_isMutable) | 314 if (m_isMutable) |
305 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID); | 315 return toMutableStylePropertySet(this)->findPropertyIndex(property); |
306 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID); | 316 return toImmutableStylePropertySet(this)->findPropertyIndex(property); |
307 } | |
308 | |
309 inline int StylePropertySet::findCustomPropertyIndex(const AtomicString& propert
yName) const | |
310 { | |
311 if (m_isMutable) | |
312 return toMutableStylePropertySet(this)->findCustomPropertyIndex(property
Name); | |
313 return toImmutableStylePropertySet(this)->findCustomPropertyIndex(propertyNa
me); | |
314 } | 317 } |
315 | 318 |
316 } // namespace blink | 319 } // namespace blink |
317 | 320 |
318 #endif // StylePropertySet_h | 321 #endif // StylePropertySet_h |
OLD | NEW |