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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 static unsigned averageSizeInBytes(); | 118 static unsigned averageSizeInBytes(); |
119 | 119 |
120 #ifndef NDEBUG | 120 #ifndef NDEBUG |
121 void showStyle(); | 121 void showStyle(); |
122 #endif | 122 #endif |
123 | 123 |
124 bool propertyMatches(CSSPropertyID, const CSSValue*) const; | 124 bool propertyMatches(CSSPropertyID, const CSSValue*) const; |
125 | 125 |
126 protected: | 126 protected: |
| 127 |
| 128 enum { MaxArraySize = (1 << 28) - 1 }; |
| 129 |
127 StylePropertySet(CSSParserMode cssParserMode) | 130 StylePropertySet(CSSParserMode cssParserMode) |
128 : m_cssParserMode(cssParserMode) | 131 : m_cssParserMode(cssParserMode) |
129 , m_isMutable(true) | 132 , m_isMutable(true) |
130 , m_arraySize(0) | 133 , m_arraySize(0) |
131 { } | 134 { } |
132 | 135 |
133 StylePropertySet(CSSParserMode cssParserMode, unsigned immutableArraySize) | 136 StylePropertySet(CSSParserMode cssParserMode, unsigned immutableArraySize) |
134 : m_cssParserMode(cssParserMode) | 137 : m_cssParserMode(cssParserMode) |
135 , m_isMutable(false) | 138 , m_isMutable(false) |
136 , m_arraySize(immutableArraySize) | 139 , m_arraySize(std::min(immutableArraySize, unsigned(MaxArraySize))) |
137 { } | 140 { } |
138 | 141 |
139 unsigned m_cssParserMode : 2; | 142 unsigned m_cssParserMode : 3; |
140 mutable unsigned m_isMutable : 1; | 143 mutable unsigned m_isMutable : 1; |
141 unsigned m_arraySize : 29; | 144 unsigned m_arraySize : 28; |
142 | 145 |
143 friend class PropertySetCSSStyleDeclaration; | 146 friend class PropertySetCSSStyleDeclaration; |
144 }; | 147 }; |
145 | 148 |
146 class ImmutableStylePropertySet : public StylePropertySet { | 149 class ImmutableStylePropertySet : public StylePropertySet { |
147 public: | 150 public: |
148 ~ImmutableStylePropertySet(); | 151 ~ImmutableStylePropertySet(); |
149 static PassRefPtr<ImmutableStylePropertySet> create(const CSSProperty* prope
rties, unsigned count, CSSParserMode); | 152 static PassRefPtr<ImmutableStylePropertySet> create(const CSSProperty* prope
rties, unsigned count, CSSParserMode); |
150 | 153 |
151 unsigned propertyCount() const { return m_arraySize; } | 154 unsigned propertyCount() const { return m_arraySize; } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 259 |
257 if (m_isMutable) | 260 if (m_isMutable) |
258 delete static_cast<MutableStylePropertySet*>(this); | 261 delete static_cast<MutableStylePropertySet*>(this); |
259 else | 262 else |
260 delete static_cast<ImmutableStylePropertySet*>(this); | 263 delete static_cast<ImmutableStylePropertySet*>(this); |
261 } | 264 } |
262 | 265 |
263 } // namespace WebCore | 266 } // namespace WebCore |
264 | 267 |
265 #endif // StylePropertySet_h | 268 #endif // StylePropertySet_h |
OLD | NEW |