Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: third_party/WebKit/Source/core/css/StylePropertySet.h

Issue 1405293012: [Variables] Enable get/setProperty and similar APIs from the CSSOM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix CSSPropertyMetadata::isEnabledProperty Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
26 #include "core/css/CSSPrimitiveValue.h" 27 #include "core/css/CSSPrimitiveValue.h"
27 #include "core/css/CSSProperty.h" 28 #include "core/css/CSSProperty.h"
28 #include "core/css/PropertySetCSSStyleDeclaration.h" 29 #include "core/css/PropertySetCSSStyleDeclaration.h"
29 #include "core/css/parser/CSSParserMode.h" 30 #include "core/css/parser/CSSParserMode.h"
30 #include "wtf/ListHashSet.h" 31 #include "wtf/ListHashSet.h"
31 #include "wtf/Noncopyable.h" 32 #include "wtf/Noncopyable.h"
32 #include "wtf/Vector.h" 33 #include "wtf/Vector.h"
33 #include "wtf/text/WTFString.h" 34 #include "wtf/text/WTFString.h"
34 35
35 namespace blink { 36 namespace blink {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 const CSSValue* propertyValue() const; 85 const CSSValue* propertyValue() const;
85 86
86 RawPtrWillBeMember<const StylePropertySet> m_propertySet; 87 RawPtrWillBeMember<const StylePropertySet> m_propertySet;
87 unsigned m_index; 88 unsigned m_index;
88 }; 89 };
89 90
90 unsigned propertyCount() const; 91 unsigned propertyCount() const;
91 bool isEmpty() const; 92 bool isEmpty() const;
92 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc e(*this, index); } 93 PropertyReference propertyAt(unsigned index) const { return PropertyReferenc e(*this, index); }
93 int findPropertyIndex(CSSPropertyID) const; 94 int findPropertyIndex(CSSPropertyID) const;
95 int findCustomPropertyIndex(const AtomicString& propertyName) const;
94 bool hasProperty(CSSPropertyID property) const { return findPropertyIndex(pr operty) != -1; } 96 bool hasProperty(CSSPropertyID property) const { return findPropertyIndex(pr operty) != -1; }
95 97
96 PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const; 98 PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const;
99 PassRefPtrWillBeRawPtr<CSSCustomPropertyDeclaration> getCustomPropertyCSSVal ue(const AtomicString&) const;
97 String getPropertyValue(CSSPropertyID) const; 100 String getPropertyValue(CSSPropertyID) const;
101 String getCustomPropertyValue(const AtomicString&) const;
98 102
99 bool propertyIsImportant(CSSPropertyID) const; 103 bool propertyIsImportant(CSSPropertyID) const;
104 bool customPropertyIsImportant(const AtomicString&) const;
100 CSSPropertyID getPropertyShorthand(CSSPropertyID) const; 105 CSSPropertyID getPropertyShorthand(CSSPropertyID) const;
101 bool isPropertyImplicit(CSSPropertyID) const; 106 bool isPropertyImplicit(CSSPropertyID) const;
102 107
103 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cs sParserMode); } 108 CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cs sParserMode); }
104 109
105 PassRefPtrWillBeRawPtr<MutableStylePropertySet> mutableCopy() const; 110 PassRefPtrWillBeRawPtr<MutableStylePropertySet> mutableCopy() const;
106 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() co nst; 111 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> immutableCopyIfNeeded() co nst;
107 112
108 PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyPropertiesInSet(const Ve ctor<CSSPropertyID>&) const; 113 PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyPropertiesInSet(const Ve ctor<CSSPropertyID>&) const;
109 114
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 class CORE_EXPORT ImmutableStylePropertySet : public StylePropertySet { 155 class CORE_EXPORT ImmutableStylePropertySet : public StylePropertySet {
151 public: 156 public:
152 ~ImmutableStylePropertySet(); 157 ~ImmutableStylePropertySet();
153 static PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> create(const CSSPro perty* properties, unsigned count, CSSParserMode); 158 static PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> create(const CSSPro perty* properties, unsigned count, CSSParserMode);
154 159
155 unsigned propertyCount() const { return m_arraySize; } 160 unsigned propertyCount() const { return m_arraySize; }
156 161
157 const RawPtrWillBeMember<CSSValue>* valueArray() const; 162 const RawPtrWillBeMember<CSSValue>* valueArray() const;
158 const StylePropertyMetadata* metadataArray() const; 163 const StylePropertyMetadata* metadataArray() const;
159 int findPropertyIndex(CSSPropertyID) const; 164 int findPropertyIndex(CSSPropertyID) const;
165 int findCustomPropertyIndex(const AtomicString& propertyName) const;
160 166
161 DECLARE_TRACE_AFTER_DISPATCH(); 167 DECLARE_TRACE_AFTER_DISPATCH();
162 168
163 void* operator new(std::size_t, void* location) 169 void* operator new(std::size_t, void* location)
164 { 170 {
165 return location; 171 return location;
166 } 172 }
167 173
168 void* m_storage; 174 void* m_storage;
169 175
(...skipping 21 matching lines...) Expand all
191 197
192 unsigned propertyCount() const { return m_propertyVector.size(); } 198 unsigned propertyCount() const { return m_propertyVector.size(); }
193 199
194 // Returns whether this style set was changed. 200 // Returns whether this style set was changed.
195 bool addParsedProperties(const WillBeHeapVector<CSSProperty, 256>&); 201 bool addParsedProperties(const WillBeHeapVector<CSSProperty, 256>&);
196 bool addRespectingCascade(const CSSProperty&); 202 bool addRespectingCascade(const CSSProperty&);
197 203
198 // These expand shorthand properties into multiple properties. 204 // These expand shorthand properties into multiple properties.
199 bool setProperty(CSSPropertyID unresolvedProperty, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0); 205 bool setProperty(CSSPropertyID unresolvedProperty, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);
200 void setProperty(CSSPropertyID, PassRefPtrWillBeRawPtr<CSSValue>, bool impor tant = false); 206 void setProperty(CSSPropertyID, PassRefPtrWillBeRawPtr<CSSValue>, bool impor tant = false);
207 bool setCustomProperty(const AtomicString& propertyName, const String& value , bool important = false, StyleSheetContents* contextStyleSheet = 0);
201 208
202 // These do not. FIXME: This is too messy, we can do better. 209 // These do not. FIXME: This is too messy, we can do better.
203 bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = fals e); 210 bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = fals e);
204 bool setProperty(const CSSProperty&, CSSProperty* slot = 0); 211 bool setProperty(const CSSProperty&, CSSProperty* slot = 0);
205 212
206 bool removeProperty(CSSPropertyID, String* returnText = 0); 213 bool removeProperty(CSSPropertyID, String* returnText = 0);
214 bool removeCustomProperty(const AtomicString&, String* returnText = 0);
207 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length); 215 bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
208 void removeEquivalentProperties(const StylePropertySet*); 216 void removeEquivalentProperties(const StylePropertySet*);
209 void removeEquivalentProperties(const CSSStyleDeclaration*); 217 void removeEquivalentProperties(const CSSStyleDeclaration*);
210 218
211 void mergeAndOverrideOnConflict(const StylePropertySet*); 219 void mergeAndOverrideOnConflict(const StylePropertySet*);
212 220
213 void clear(); 221 void clear();
214 void parseDeclarationList(const String& styleDeclaration, StyleSheetContents * contextStyleSheet); 222 void parseDeclarationList(const String& styleDeclaration, StyleSheetContents * contextStyleSheet);
215 223
216 CSSStyleDeclaration* ensureCSSStyleDeclaration(); 224 CSSStyleDeclaration* ensureCSSStyleDeclaration();
217 int findPropertyIndex(CSSPropertyID) const; 225 int findPropertyIndex(CSSPropertyID) const;
226 int findCustomPropertyIndex(const AtomicString& propertyName) const;
218 227
219 DECLARE_TRACE_AFTER_DISPATCH(); 228 DECLARE_TRACE_AFTER_DISPATCH();
220 229
221 private: 230 private:
222 explicit MutableStylePropertySet(CSSParserMode); 231 explicit MutableStylePropertySet(CSSParserMode);
223 explicit MutableStylePropertySet(const StylePropertySet&); 232 explicit MutableStylePropertySet(const StylePropertySet&);
224 MutableStylePropertySet(const CSSProperty* properties, unsigned count); 233 MutableStylePropertySet(const CSSProperty* properties, unsigned count);
225 234
235 bool removePropertyAtIndex(int, String* returnText);
236
226 bool removeShorthandProperty(CSSPropertyID); 237 bool removeShorthandProperty(CSSPropertyID);
227 CSSProperty* findCSSPropertyWithID(CSSPropertyID); 238 CSSProperty* findCSSPropertyWithID(CSSPropertyID);
228 OwnPtrWillBeMember<PropertySetCSSStyleDeclaration> m_cssomWrapper; 239 OwnPtrWillBeMember<PropertySetCSSStyleDeclaration> m_cssomWrapper;
229 240
230 friend class StylePropertySet; 241 friend class StylePropertySet;
231 242
232 WillBeHeapVector<CSSProperty, 4> m_propertyVector; 243 WillBeHeapVector<CSSProperty, 4> m_propertyVector;
233 }; 244 };
234 245
235 DEFINE_TYPE_CASTS(MutableStylePropertySet, StylePropertySet, set, set->isMutable (), set.isMutable()); 246 DEFINE_TYPE_CASTS(MutableStylePropertySet, StylePropertySet, set, set->isMutable (), set.isMutable());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 299 }
289 #endif // !ENABLE(OILPAN) 300 #endif // !ENABLE(OILPAN)
290 301
291 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const 302 inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
292 { 303 {
293 if (m_isMutable) 304 if (m_isMutable)
294 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID); 305 return toMutableStylePropertySet(this)->findPropertyIndex(propertyID);
295 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID); 306 return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID);
296 } 307 }
297 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 }
315
298 } // namespace blink 316 } // namespace blink
299 317
300 #endif // StylePropertySet_h 318 #endif // StylePropertySet_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698