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, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 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 CSSValue_h | 21 #ifndef CSSValueObject_h |
22 #define CSSValue_h | 22 #define CSSValueObject_h |
23 | 23 |
24 #include "core/CoreExport.h" | 24 #include "core/CoreExport.h" |
25 #include "platform/heap/Handle.h" | 25 #include "platform/heap/Handle.h" |
26 #include "platform/weborigin/KURL.h" | |
27 #include "wtf/HashMap.h" | |
28 #include "wtf/ListHashSet.h" | |
29 #include "wtf/RefCounted.h" | 26 #include "wtf/RefCounted.h" |
30 #include "wtf/RefPtr.h" | 27 #include "wtf/RefPtr.h" |
31 | 28 |
32 namespace blink { | 29 namespace blink { |
33 | 30 |
34 class CORE_EXPORT CSSValue : public RefCountedWillBeGarbageCollectedFinalized<CS SValue> { | 31 class CORE_EXPORT CSSValueObject : public RefCountedWillBeGarbageCollectedFinali zed<CSSValueObject> { |
haraken
2015/06/11 02:48:53
CSSValue is allocated on a dedicated heap in Oilpa
sashab
2015/06/11 23:05:35
Ah, didn't know about this. Thanks; done.
| |
35 public: | 32 public: |
36 #if ENABLE(OILPAN) | 33 #if ENABLE(OILPAN) |
37 // Override operator new to allocate CSSValue subtype objects onto | 34 // Override operator new to allocate CSSValueObject subtype objects onto |
38 // a dedicated heap. | 35 // a dedicated heap. |
39 GC_PLUGIN_IGNORE("crbug.com/443854") | 36 GC_PLUGIN_IGNORE("crbug.com/443854") |
40 void* operator new(size_t size) | 37 void* operator new(size_t size) |
41 { | 38 { |
42 return allocateObject(size); | 39 return allocateObject(size); |
43 } | 40 } |
44 static void* allocateObject(size_t size) | 41 static void* allocateObject(size_t size) |
45 { | 42 { |
46 ThreadState* state = ThreadStateFor<ThreadingTrait<CSSValue>::Affinity>: :state(); | 43 ThreadState* state = ThreadStateFor<ThreadingTrait<CSSValueObject>::Affi nity>::state(); |
47 return Heap::allocateOnHeapIndex(state, size, CSSValueHeapIndex, GCInfoT rait<CSSValue>::index()); | 44 return Heap::allocateOnHeapIndex(state, size, CSSValueHeapIndex, GCInfoT rait<CSSValueObject>::index()); |
48 } | 45 } |
49 #else | 46 #else |
50 // Override RefCounted's deref() to ensure operator delete is called on | 47 // Override RefCounted's deref() to ensure operator delete is called on |
51 // the appropriate subclass type. | 48 // the appropriate subclass type. |
52 void deref() | 49 void deref() |
53 { | 50 { |
54 if (derefBase()) | 51 if (derefBase()) |
55 destroy(); | 52 destroy(); |
56 } | 53 } |
57 #endif // !ENABLE(OILPAN) | 54 #endif // !ENABLE(OILPAN) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 bool isLineBoxContainValue() const { return m_classType == LineBoxContainCla ss; } | 86 bool isLineBoxContainValue() const { return m_classType == LineBoxContainCla ss; } |
90 bool isCalcValue() const {return m_classType == CalculationClass; } | 87 bool isCalcValue() const {return m_classType == CalculationClass; } |
91 bool isGridTemplateAreasValue() const { return m_classType == GridTemplateAr easClass; } | 88 bool isGridTemplateAreasValue() const { return m_classType == GridTemplateAr easClass; } |
92 bool isSVGDocumentValue() const { return m_classType == CSSSVGDocumentClass; } | 89 bool isSVGDocumentValue() const { return m_classType == CSSSVGDocumentClass; } |
93 bool isContentDistributionValue() const { return m_classType == CSSContentDi stributionClass; } | 90 bool isContentDistributionValue() const { return m_classType == CSSContentDi stributionClass; } |
94 bool isUnicodeRangeValue() const { return m_classType == UnicodeRangeClass; } | 91 bool isUnicodeRangeValue() const { return m_classType == UnicodeRangeClass; } |
95 bool isGridLineNamesValue() const { return m_classType == GridLineNamesClass ; } | 92 bool isGridLineNamesValue() const { return m_classType == GridLineNamesClass ; } |
96 | 93 |
97 bool hasFailedOrCanceledSubresources() const; | 94 bool hasFailedOrCanceledSubresources() const; |
98 | 95 |
99 bool equals(const CSSValue&) const; | 96 bool equals(const CSSValueObject&) const; |
100 | 97 |
101 void finalizeGarbageCollectedObject(); | 98 void finalizeGarbageCollectedObject(); |
102 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { } | 99 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { } |
103 DECLARE_TRACE(); | 100 DECLARE_TRACE(); |
104 | 101 |
105 // ~CSSValue should be public, because non-public ~CSSValue causes C2248 | 102 // ~CSSValueObject should be public, because non-public ~CSSValueObject caus es C2248 |
106 // error: 'blink::CSSValue::~CSSValue' : cannot access protected member | 103 // error: 'blink::CSSValueObject::~CSSValueObject' : cannot access protected member |
107 // declared in class 'blink::CSSValue' when compiling | 104 // declared in class 'blink::CSSValueObject' when compiling |
108 // 'source\wtf\refcounted.h' by using msvc. | 105 // 'source\wtf\refcounted.h' by using msvc. |
109 ~CSSValue() { } | 106 ~CSSValueObject() { } |
110 | 107 |
111 protected: | 108 protected: |
112 | 109 |
113 static const size_t ClassTypeBits = 6; | 110 static const size_t ClassTypeBits = 6; |
114 enum ClassType { | 111 enum ClassType { |
115 PrimitiveClass, | 112 PrimitiveClass, |
116 | 113 |
117 // Image classes. | 114 // Image classes. |
118 ImageClass, | 115 ImageClass, |
119 CursorImageClass, | 116 CursorImageClass, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 | 157 |
161 static const size_t ValueListSeparatorBits = 2; | 158 static const size_t ValueListSeparatorBits = 2; |
162 enum ValueListSeparator { | 159 enum ValueListSeparator { |
163 SpaceSeparator, | 160 SpaceSeparator, |
164 CommaSeparator, | 161 CommaSeparator, |
165 SlashSeparator | 162 SlashSeparator |
166 }; | 163 }; |
167 | 164 |
168 ClassType classType() const { return static_cast<ClassType>(m_classType); } | 165 ClassType classType() const { return static_cast<ClassType>(m_classType); } |
169 | 166 |
170 explicit CSSValue(ClassType classType) | 167 explicit CSSValueObject(ClassType classType) |
171 : m_primitiveUnitType(0) | 168 : m_primitiveUnitType(0) |
172 , m_hasCachedCSSText(false) | 169 , m_hasCachedCSSText(false) |
173 , m_isQuirkValue(false) | 170 , m_isQuirkValue(false) |
174 , m_valueListSeparator(SpaceSeparator) | 171 , m_valueListSeparator(SpaceSeparator) |
175 , m_classType(classType) | 172 , m_classType(classType) |
176 { | 173 { |
177 } | 174 } |
178 | 175 |
179 // NOTE: This class is non-virtual for memory and performance reasons. | 176 // NOTE: This class is non-virtual for memory and performance reasons. |
180 // Don't go making it virtual again unless you know exactly what you're doin g! | 177 // Don't go making it virtual again unless you know exactly what you're doin g! |
181 | 178 |
182 private: | 179 private: |
183 void destroy(); | 180 void destroy(); |
184 | 181 |
185 protected: | 182 protected: |
186 // The bits in this section are only used by specific subclasses but kept he re | 183 // The bits in this section are only used by specific subclasses but kept he re |
187 // to maximize struct packing. | 184 // to maximize struct packing. |
188 | 185 |
189 // CSSPrimitiveValue bits: | 186 // CSSPrimitiveValue bits: |
190 unsigned m_primitiveUnitType : 7; // CSSPrimitiveValue::UnitType | 187 unsigned m_primitiveUnitType : 7; // CSSPrimitiveValue::UnitType |
191 mutable unsigned m_hasCachedCSSText : 1; | 188 mutable unsigned m_hasCachedCSSText : 1; |
192 unsigned m_isQuirkValue : 1; | 189 unsigned m_isQuirkValue : 1; |
193 | 190 |
194 unsigned m_valueListSeparator : ValueListSeparatorBits; | 191 unsigned m_valueListSeparator : ValueListSeparatorBits; |
195 | 192 |
196 private: | 193 private: |
197 unsigned m_classType : ClassTypeBits; // ClassType | 194 unsigned m_classType : ClassTypeBits; // ClassType |
198 }; | 195 }; |
199 | 196 |
200 template<typename CSSValueType, size_t inlineCapacity> | 197 // TODO(sashab): Remove this; only compareCSSValueVector is needed. |
201 inline bool compareCSSValueVector(const WillBeHeapVector<RefPtrWillBeMember<CSSV alueType>, inlineCapacity>& firstVector, const WillBeHeapVector<RefPtrWillBeMemb er<CSSValueType>, inlineCapacity>& secondVector) | 198 template<typename CSSValueObjectType, size_t inlineCapacity> |
199 inline bool compareCSSValueObjectVector(const WillBeHeapVector<RefPtrWillBeMembe r<CSSValueObjectType>, inlineCapacity>& firstVector, const WillBeHeapVector<RefP trWillBeMember<CSSValueObjectType>, inlineCapacity>& secondVector) | |
202 { | 200 { |
203 size_t size = firstVector.size(); | 201 size_t size = firstVector.size(); |
204 if (size != secondVector.size()) | 202 if (size != secondVector.size()) |
205 return false; | 203 return false; |
206 | 204 |
207 for (size_t i = 0; i < size; i++) { | 205 for (size_t i = 0; i < size; i++) { |
208 const RefPtrWillBeMember<CSSValueType>& firstPtr = firstVector[i]; | 206 const RefPtrWillBeMember<CSSValueObjectType>& firstPtr = firstVector[i]; |
209 const RefPtrWillBeMember<CSSValueType>& secondPtr = secondVector[i]; | 207 const RefPtrWillBeMember<CSSValueObjectType>& secondPtr = secondVector[i ]; |
210 if (firstPtr == secondPtr || (firstPtr && secondPtr && firstPtr->equals( *secondPtr))) | 208 if (firstPtr == secondPtr || (firstPtr && secondPtr && firstPtr->equals( *secondPtr))) |
211 continue; | 209 continue; |
212 return false; | 210 return false; |
213 } | 211 } |
214 return true; | 212 return true; |
215 } | 213 } |
216 | 214 |
217 template<typename CSSValueType> | 215 template<typename CSSValueType> |
218 inline bool compareCSSValuePtr(const RefPtr<CSSValueType>& first, const RefPtr<C SSValueType>& second) | 216 inline bool compareCSSValuePtr(const RefPtr<CSSValueType>& first, const RefPtr<C SSValueType>& second) |
219 { | 217 { |
220 return first ? second && first->equals(*second) : !second; | 218 return first ? second && first->equals(*second) : !second; |
221 } | 219 } |
222 | 220 |
223 template<typename CSSValueType> | 221 template<typename CSSValueType> |
224 inline bool compareCSSValuePtr(const RawPtr<CSSValueType>& first, const RawPtr<C SSValueType>& second) | 222 inline bool compareCSSValuePtr(const RawPtr<CSSValueType>& first, const RawPtr<C SSValueType>& second) |
225 { | 223 { |
226 return first ? second && first->equals(*second) : !second; | 224 return first ? second && first->equals(*second) : !second; |
227 } | 225 } |
228 | 226 |
229 template<typename CSSValueType> | 227 template<typename CSSValueType> |
230 inline bool compareCSSValuePtr(const Member<CSSValueType>& first, const Member<C SSValueType>& second) | 228 inline bool compareCSSValuePtr(const Member<CSSValueType>& first, const Member<C SSValueType>& second) |
231 { | 229 { |
232 return first ? second && first->equals(*second) : !second; | 230 return first ? second && first->equals(*second) : !second; |
233 } | 231 } |
234 | 232 |
235 #define DEFINE_CSS_VALUE_TYPE_CASTS(thisType, predicate) \ | |
236 DEFINE_TYPE_CASTS(thisType, CSSValue, value, value->predicate, value.predica te) | |
237 | |
238 } // namespace blink | 233 } // namespace blink |
239 | 234 |
240 #endif // CSSValue_h | 235 #endif // CSSValueObject_h |
OLD | NEW |