Chromium Code Reviews| 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 "CSSPropertyNames.h" | 24 #include "CSSPropertyNames.h" |
| 25 #include "core/css/CSSParserMode.h" | 25 #include "core/css/CSSParserMode.h" |
| 26 #include "core/css/CSSPrimitiveValue.h" | 26 #include "core/css/CSSPrimitiveValue.h" |
| 27 #include "core/css/CSSProperty.h" | 27 #include "core/css/CSSProperty.h" |
| 28 #include "core/css/PropertySetCSSStyleDeclaration.h" | |
| 28 #include <wtf/ListHashSet.h> | 29 #include <wtf/ListHashSet.h> |
| 29 #include <wtf/text/WTFString.h> | 30 #include <wtf/text/WTFString.h> |
| 30 #include <wtf/Vector.h> | 31 #include <wtf/Vector.h> |
| 31 | 32 |
| 32 namespace WebCore { | 33 namespace WebCore { |
| 33 | 34 |
| 34 class CSSRule; | 35 class CSSRule; |
| 35 class CSSStyleDeclaration; | 36 class CSSStyleDeclaration; |
| 36 class Element; | 37 class Element; |
| 37 class ImmutableStylePropertySet; | 38 class ImmutableStylePropertySet; |
| 38 class KURL; | 39 class KURL; |
| 39 class MutableStylePropertySet; | 40 class MutableStylePropertySet; |
| 40 class PropertySetCSSStyleDeclaration; | |
| 41 class StylePropertyShorthand; | 41 class StylePropertyShorthand; |
| 42 class StyleSheetContents; | 42 class StyleSheetContents; |
| 43 | 43 |
| 44 class StylePropertySet : public RefCounted<StylePropertySet> { | 44 class StylePropertySet : public RefCounted<StylePropertySet> { |
| 45 friend class PropertyReference; | 45 friend class PropertyReference; |
| 46 public: | 46 public: |
| 47 // Override RefCounted's deref() to ensure operator delete is called on | 47 // Override RefCounted's deref() to ensure operator delete is called on |
| 48 // the appropriate subclass type. | 48 // the appropriate subclass type. |
| 49 void deref(); | 49 void deref(); |
| 50 | 50 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 { } | 128 { } |
| 129 | 129 |
| 130 StylePropertySet(CSSParserMode cssParserMode, unsigned immutableArraySize) | 130 StylePropertySet(CSSParserMode cssParserMode, unsigned immutableArraySize) |
| 131 : m_cssParserMode(cssParserMode) | 131 : m_cssParserMode(cssParserMode) |
| 132 , m_ownsCSSOMWrapper(false) | 132 , m_ownsCSSOMWrapper(false) |
| 133 , m_isMutable(false) | 133 , m_isMutable(false) |
| 134 , m_arraySize(immutableArraySize) | 134 , m_arraySize(immutableArraySize) |
| 135 { } | 135 { } |
| 136 | 136 |
| 137 unsigned m_cssParserMode : 2; | 137 unsigned m_cssParserMode : 2; |
| 138 mutable unsigned m_ownsCSSOMWrapper : 1; | 138 mutable unsigned m_ownsCSSOMWrapper : 1; |
|
abarth-chromium
2013/07/03 18:25:42
Do we still need this field?
Mads Ager (chromium)
2013/07/04 06:05:47
Thanks, no we don't need it. See later comment on
| |
| 139 mutable unsigned m_isMutable : 1; | 139 mutable unsigned m_isMutable : 1; |
| 140 unsigned m_arraySize : 28; | 140 unsigned m_arraySize : 28; |
| 141 | 141 |
| 142 friend class PropertySetCSSStyleDeclaration; | 142 friend class PropertySetCSSStyleDeclaration; |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 class ImmutableStylePropertySet : public StylePropertySet { | 145 class ImmutableStylePropertySet : public StylePropertySet { |
| 146 // This is needed because we malloc() space for an | 146 // This is needed because we malloc() space for an |
| 147 // ImmutableStylePropertySet plus following properties, as a performance | 147 // ImmutableStylePropertySet plus following properties, as a performance |
| 148 // tweak. | 148 // tweak. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 167 return reinterpret_cast<const CSSValue**>(const_cast<const void**>((&static_ cast<const ImmutableStylePropertySet*>(this)->m_storage))); | 167 return reinterpret_cast<const CSSValue**>(const_cast<const void**>((&static_ cast<const ImmutableStylePropertySet*>(this)->m_storage))); |
| 168 } | 168 } |
| 169 | 169 |
| 170 inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() c onst | 170 inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() c onst |
| 171 { | 171 { |
| 172 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons t char*>((&static_cast<const ImmutableStylePropertySet*>(this)->m_storage))[m_ar raySize * sizeof(CSSValue*)]); | 172 return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<cons t char*>((&static_cast<const ImmutableStylePropertySet*>(this)->m_storage))[m_ar raySize * sizeof(CSSValue*)]); |
| 173 } | 173 } |
| 174 | 174 |
| 175 class MutableStylePropertySet : public StylePropertySet { | 175 class MutableStylePropertySet : public StylePropertySet { |
| 176 public: | 176 public: |
| 177 ~MutableStylePropertySet(); | |
| 178 | |
| 179 static PassRefPtr<MutableStylePropertySet> create(CSSParserMode = CSSQuirksM ode); | 177 static PassRefPtr<MutableStylePropertySet> create(CSSParserMode = CSSQuirksM ode); |
| 180 static PassRefPtr<MutableStylePropertySet> create(const CSSProperty* propert ies, unsigned count); | 178 static PassRefPtr<MutableStylePropertySet> create(const CSSProperty* propert ies, unsigned count); |
| 181 | 179 |
| 182 MutableStylePropertySet(const StylePropertySet&); | 180 MutableStylePropertySet(const StylePropertySet&); |
| 183 | 181 |
| 184 unsigned propertyCount() const { return m_propertyVector.size(); } | 182 unsigned propertyCount() const { return m_propertyVector.size(); } |
| 185 PropertySetCSSStyleDeclaration* cssStyleDeclaration(); | 183 PropertySetCSSStyleDeclaration* cssStyleDeclaration(); |
| 186 | 184 |
| 187 void addParsedProperties(const Vector<CSSProperty>&); | 185 void addParsedProperties(const Vector<CSSProperty>&); |
| 188 void addParsedProperty(const CSSProperty&); | 186 void addParsedProperty(const CSSProperty&); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 209 | 207 |
| 210 void clear(); | 208 void clear(); |
| 211 void parseDeclaration(const String& styleDeclaration, StyleSheetContents* co ntextStyleSheet); | 209 void parseDeclaration(const String& styleDeclaration, StyleSheetContents* co ntextStyleSheet); |
| 212 | 210 |
| 213 CSSStyleDeclaration* ensureCSSStyleDeclaration(); | 211 CSSStyleDeclaration* ensureCSSStyleDeclaration(); |
| 214 CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(Element* parentElement) ; | 212 CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(Element* parentElement) ; |
| 215 | 213 |
| 216 Vector<CSSProperty, 4> m_propertyVector; | 214 Vector<CSSProperty, 4> m_propertyVector; |
| 217 | 215 |
| 218 private: | 216 private: |
| 219 MutableStylePropertySet(CSSParserMode cssParserMode) | 217 MutableStylePropertySet(CSSParserMode); |
|
abarth-chromium
2013/07/03 18:25:42
Please mark one-argument constructors "explicit"
Mads Ager (chromium)
2013/07/04 06:05:47
Done for this one and the constructor in the publi
| |
| 220 : StylePropertySet(cssParserMode) | |
| 221 { } | |
| 222 | |
| 223 MutableStylePropertySet(const CSSProperty* properties, unsigned count); | 218 MutableStylePropertySet(const CSSProperty* properties, unsigned count); |
| 224 | 219 |
| 225 bool removeShorthandProperty(CSSPropertyID); | 220 bool removeShorthandProperty(CSSPropertyID); |
| 226 CSSProperty* findCSSPropertyWithID(CSSPropertyID); | 221 CSSProperty* findCSSPropertyWithID(CSSPropertyID); |
| 222 OwnPtr<PropertySetCSSStyleDeclaration> m_cssomWrapper; | |
| 227 }; | 223 }; |
| 228 | 224 |
| 229 inline StylePropertyMetadata StylePropertySet::PropertyReference::propertyMetada ta() const | 225 inline StylePropertyMetadata StylePropertySet::PropertyReference::propertyMetada ta() const |
| 230 { | 226 { |
| 231 if (m_propertySet.isMutable()) | 227 if (m_propertySet.isMutable()) |
| 232 return static_cast<const MutableStylePropertySet&>(m_propertySet).m_prop ertyVector.at(m_index).metadata(); | 228 return static_cast<const MutableStylePropertySet&>(m_propertySet).m_prop ertyVector.at(m_index).metadata(); |
| 233 return static_cast<const ImmutableStylePropertySet&>(m_propertySet).metadata Array()[m_index]; | 229 return static_cast<const ImmutableStylePropertySet&>(m_propertySet).metadata Array()[m_index]; |
| 234 } | 230 } |
| 235 | 231 |
| 236 inline const CSSValue* StylePropertySet::PropertyReference::propertyValue() cons t | 232 inline const CSSValue* StylePropertySet::PropertyReference::propertyValue() cons t |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 259 | 255 |
| 260 if (m_isMutable) | 256 if (m_isMutable) |
| 261 delete static_cast<MutableStylePropertySet*>(this); | 257 delete static_cast<MutableStylePropertySet*>(this); |
| 262 else | 258 else |
| 263 delete static_cast<ImmutableStylePropertySet*>(this); | 259 delete static_cast<ImmutableStylePropertySet*>(this); |
| 264 } | 260 } |
| 265 | 261 |
| 266 } // namespace WebCore | 262 } // namespace WebCore |
| 267 | 263 |
| 268 #endif // StylePropertySet_h | 264 #endif // StylePropertySet_h |
| OLD | NEW |