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 CSSValue_h |
22 #define CSSValue_h | 22 #define CSSValue_h |
23 | 23 |
24 #include "bindings/core/v8/ScriptWrappable.h" | |
25 #include "core/dom/ExceptionCode.h" | |
26 #include "platform/heap/Handle.h" | 24 #include "platform/heap/Handle.h" |
27 #include "platform/weborigin/KURL.h" | 25 #include "platform/weborigin/KURL.h" |
28 #include "wtf/HashMap.h" | 26 #include "wtf/HashMap.h" |
29 #include "wtf/ListHashSet.h" | 27 #include "wtf/ListHashSet.h" |
30 #include "wtf/RefCounted.h" | 28 #include "wtf/RefCounted.h" |
31 #include "wtf/RefPtr.h" | 29 #include "wtf/RefPtr.h" |
32 | 30 |
33 namespace blink { | 31 namespace blink { |
34 | 32 |
35 class ExceptionState; | |
36 | |
37 enum CSSTextFormattingFlags { QuoteCSSStringIfNeeded, AlwaysQuoteCSSString }; | 33 enum CSSTextFormattingFlags { QuoteCSSStringIfNeeded, AlwaysQuoteCSSString }; |
38 | 34 |
39 // FIXME: The current CSSValue and subclasses should be turned into internal typ
es (StyleValue). | 35 class CSSValue : public RefCountedWillBeGarbageCollectedFinalized<CSSValue> { |
40 // The few subtypes that are actually exposed in CSSOM can be seen in the cloneF
orCSSOM() function. | |
41 // They should be handled by separate wrapper classes. | |
42 | |
43 // Please don't expose more CSSValue types to the web. | |
44 class CSSValue : public RefCountedWillBeGarbageCollectedFinalized<CSSValue>, pub
lic ScriptWrappableBase { | |
45 public: | 36 public: |
46 enum Type { | 37 enum Type { |
47 CSS_INHERIT = 0, | 38 CSS_INHERIT = 0, |
48 CSS_PRIMITIVE_VALUE = 1, | 39 CSS_PRIMITIVE_VALUE = 1, |
49 CSS_VALUE_LIST = 2, | 40 CSS_VALUE_LIST = 2, |
50 CSS_CUSTOM = 3, | 41 CSS_CUSTOM = 3, |
51 CSS_INITIAL = 4 | 42 CSS_INITIAL = 4 |
52 | |
53 }; | 43 }; |
54 | 44 |
55 // Override RefCounted's deref() to ensure operator delete is called on | 45 // Override RefCounted's deref() to ensure operator delete is called on |
56 // the appropriate subclass type. | 46 // the appropriate subclass type. |
57 // When oilpan is enabled the finalize method is called by the garbage | 47 // When oilpan is enabled the finalize method is called by the garbage |
58 // collector and not immediately when deref reached zero. | 48 // collector and not immediately when deref reached zero. |
59 #if !ENABLE(OILPAN) | 49 #if !ENABLE(OILPAN) |
60 void deref() | 50 void deref() |
61 { | 51 { |
62 if (derefBase()) | 52 if (derefBase()) |
63 destroy(); | 53 destroy(); |
64 } | 54 } |
65 #endif // !ENABLE(OILPAN) | 55 #endif // !ENABLE(OILPAN) |
66 | 56 |
67 Type cssValueType() const; | 57 Type cssValueType() const; |
68 | 58 |
69 String cssText() const; | 59 String cssText() const; |
70 void setCSSText(const String&, ExceptionState&) { } // FIXME: Not implemente
d. | |
71 | 60 |
72 bool isPrimitiveValue() const { return m_classType == PrimitiveClass; } | 61 bool isPrimitiveValue() const { return m_classType == PrimitiveClass; } |
73 bool isValueList() const { return m_classType >= ValueListClass; } | 62 bool isValueList() const { return m_classType >= ValueListClass; } |
74 | 63 |
75 bool isBaseValueList() const { return m_classType == ValueListClass; } | 64 bool isBaseValueList() const { return m_classType == ValueListClass; } |
76 | 65 |
77 bool isBorderImageSliceValue() const { return m_classType == BorderImageSlic
eClass; } | 66 bool isBorderImageSliceValue() const { return m_classType == BorderImageSlic
eClass; } |
78 bool isCanvasValue() const { return m_classType == CanvasClass; } | 67 bool isCanvasValue() const { return m_classType == CanvasClass; } |
79 bool isCursorImageValue() const { return m_classType == CursorImageClass; } | 68 bool isCursorImageValue() const { return m_classType == CursorImageClass; } |
80 bool isCrossfadeValue() const { return m_classType == CrossfadeClass; } | 69 bool isCrossfadeValue() const { return m_classType == CrossfadeClass; } |
81 bool isFontFeatureValue() const { return m_classType == FontFeatureClass; } | 70 bool isFontFeatureValue() const { return m_classType == FontFeatureClass; } |
82 bool isFontValue() const { return m_classType == FontClass; } | 71 bool isFontValue() const { return m_classType == FontClass; } |
83 bool isFontFaceSrcValue() const { return m_classType == FontFaceSrcClass; } | 72 bool isFontFaceSrcValue() const { return m_classType == FontFaceSrcClass; } |
84 bool isFunctionValue() const { return m_classType == FunctionClass; } | 73 bool isFunctionValue() const { return m_classType == FunctionClass; } |
85 bool isImageGeneratorValue() const { return m_classType >= CanvasClass && m_
classType <= RadialGradientClass; } | 74 bool isImageGeneratorValue() const { return m_classType >= CanvasClass && m_
classType <= RadialGradientClass; } |
86 bool isGradientValue() const { return m_classType >= LinearGradientClass &&
m_classType <= RadialGradientClass; } | 75 bool isGradientValue() const { return m_classType >= LinearGradientClass &&
m_classType <= RadialGradientClass; } |
87 bool isImageSetValue() const { return m_classType == ImageSetClass; } | 76 bool isImageSetValue() const { return m_classType == ImageSetClass; } |
88 bool isImageValue() const { return m_classType == ImageClass; } | 77 bool isImageValue() const { return m_classType == ImageClass; } |
89 bool isImplicitInitialValue() const; | 78 bool isImplicitInitialValue() const; |
90 bool isInheritedValue() const { return m_classType == InheritedClass; } | 79 bool isInheritedValue() const { return m_classType == InheritedClass; } |
91 bool isInitialValue() const { return m_classType == InitialClass; } | 80 bool isInitialValue() const { return m_classType == InitialClass; } |
92 bool isLinearGradientValue() const { return m_classType == LinearGradientCla
ss; } | 81 bool isLinearGradientValue() const { return m_classType == LinearGradientCla
ss; } |
93 bool isRadialGradientValue() const { return m_classType == RadialGradientCla
ss; } | 82 bool isRadialGradientValue() const { return m_classType == RadialGradientCla
ss; } |
94 bool isReflectValue() const { return m_classType == ReflectClass; } | 83 bool isReflectValue() const { return m_classType == ReflectClass; } |
95 bool isShadowValue() const { return m_classType == ShadowClass; } | 84 bool isShadowValue() const { return m_classType == ShadowClass; } |
96 bool isTextCloneCSSValue() const { return m_isTextClone; } | |
97 bool isCubicBezierTimingFunctionValue() const { return m_classType == CubicB
ezierTimingFunctionClass; } | 85 bool isCubicBezierTimingFunctionValue() const { return m_classType == CubicB
ezierTimingFunctionClass; } |
98 bool isStepsTimingFunctionValue() const { return m_classType == StepsTimingF
unctionClass; } | 86 bool isStepsTimingFunctionValue() const { return m_classType == StepsTimingF
unctionClass; } |
99 bool isTransformValue() const { return m_classType == CSSTransformClass; } | 87 bool isTransformValue() const { return m_classType == CSSTransformClass; } |
100 bool isLineBoxContainValue() const { return m_classType == LineBoxContainCla
ss; } | 88 bool isLineBoxContainValue() const { return m_classType == LineBoxContainCla
ss; } |
101 bool isCalcValue() const {return m_classType == CalculationClass; } | 89 bool isCalcValue() const {return m_classType == CalculationClass; } |
102 bool isFilterValue() const { return m_classType == CSSFilterClass; } | 90 bool isFilterValue() const { return m_classType == CSSFilterClass; } |
103 bool isGridTemplateAreasValue() const { return m_classType == GridTemplateAr
easClass; } | 91 bool isGridTemplateAreasValue() const { return m_classType == GridTemplateAr
easClass; } |
104 bool isSVGDocumentValue() const { return m_classType == CSSSVGDocumentClass;
} | 92 bool isSVGDocumentValue() const { return m_classType == CSSSVGDocumentClass;
} |
105 bool isContentDistributionValue() const { return m_classType == CSSContentDi
stributionClass; } | 93 bool isContentDistributionValue() const { return m_classType == CSSContentDi
stributionClass; } |
106 bool isUnicodeRangeValue() const { return m_classType == UnicodeRangeClass;
} | 94 bool isUnicodeRangeValue() const { return m_classType == UnicodeRangeClass;
} |
107 bool isGridLineNamesValue() const { return m_classType == GridLineNamesClass
; } | 95 bool isGridLineNamesValue() const { return m_classType == GridLineNamesClass
; } |
108 | 96 |
109 bool isCSSOMSafe() const { return m_isCSSOMSafe; } | |
110 bool isSubtypeExposedToCSSOM() const | |
111 { | |
112 return isPrimitiveValue() || isValueList(); | |
113 } | |
114 | |
115 PassRefPtrWillBeRawPtr<CSSValue> cloneForCSSOM() const; | |
116 | |
117 bool hasFailedOrCanceledSubresources() const; | 97 bool hasFailedOrCanceledSubresources() const; |
118 | 98 |
119 bool equals(const CSSValue&) const; | 99 bool equals(const CSSValue&) const; |
120 | 100 |
121 void finalizeGarbageCollectedObject(); | 101 void finalizeGarbageCollectedObject(); |
122 void traceAfterDispatch(Visitor*) { } | 102 void traceAfterDispatch(Visitor*) { } |
123 void trace(Visitor*); | 103 void trace(Visitor*); |
124 | 104 |
125 protected: | 105 protected: |
126 | 106 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 155 |
176 static const size_t ValueListSeparatorBits = 2; | 156 static const size_t ValueListSeparatorBits = 2; |
177 enum ValueListSeparator { | 157 enum ValueListSeparator { |
178 SpaceSeparator, | 158 SpaceSeparator, |
179 CommaSeparator, | 159 CommaSeparator, |
180 SlashSeparator | 160 SlashSeparator |
181 }; | 161 }; |
182 | 162 |
183 ClassType classType() const { return static_cast<ClassType>(m_classType); } | 163 ClassType classType() const { return static_cast<ClassType>(m_classType); } |
184 | 164 |
185 explicit CSSValue(ClassType classType, bool isCSSOMSafe = false) | 165 explicit CSSValue(ClassType classType) |
186 : m_isCSSOMSafe(isCSSOMSafe) | 166 : m_primitiveUnitType(0) |
187 , m_isTextClone(false) | |
188 , m_primitiveUnitType(0) | |
189 , m_hasCachedCSSText(false) | 167 , m_hasCachedCSSText(false) |
190 , m_isQuirkValue(false) | 168 , m_isQuirkValue(false) |
191 , m_valueListSeparator(SpaceSeparator) | 169 , m_valueListSeparator(SpaceSeparator) |
192 , m_classType(classType) | 170 , m_classType(classType) |
193 { | 171 { |
194 } | 172 } |
195 | 173 |
196 // NOTE: This class is non-virtual for memory and performance reasons. | 174 // NOTE: This class is non-virtual for memory and performance reasons. |
197 // Don't go making it virtual again unless you know exactly what you're doin
g! | 175 // Don't go making it virtual again unless you know exactly what you're doin
g! |
198 | 176 |
199 ~CSSValue() { } | 177 ~CSSValue() { } |
200 | 178 |
201 private: | 179 private: |
202 void destroy(); | 180 void destroy(); |
203 | 181 |
204 protected: | 182 protected: |
205 unsigned m_isCSSOMSafe : 1; | |
206 unsigned m_isTextClone : 1; | |
207 // 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 |
208 // to maximize struct packing. | 184 // to maximize struct packing. |
209 | 185 |
210 // CSSPrimitiveValue bits: | 186 // CSSPrimitiveValue bits: |
211 unsigned m_primitiveUnitType : 7; // CSSPrimitiveValue::UnitType | 187 unsigned m_primitiveUnitType : 7; // CSSPrimitiveValue::UnitType |
212 mutable unsigned m_hasCachedCSSText : 1; | 188 mutable unsigned m_hasCachedCSSText : 1; |
213 unsigned m_isQuirkValue : 1; | 189 unsigned m_isQuirkValue : 1; |
214 | 190 |
215 unsigned m_valueListSeparator : ValueListSeparatorBits; | 191 unsigned m_valueListSeparator : ValueListSeparatorBits; |
216 | 192 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 { | 228 { |
253 return first ? second && first->equals(*second) : !second; | 229 return first ? second && first->equals(*second) : !second; |
254 } | 230 } |
255 | 231 |
256 #define DEFINE_CSS_VALUE_TYPE_CASTS(thisType, predicate) \ | 232 #define DEFINE_CSS_VALUE_TYPE_CASTS(thisType, predicate) \ |
257 DEFINE_TYPE_CASTS(thisType, CSSValue, value, value->predicate, value.predica
te) | 233 DEFINE_TYPE_CASTS(thisType, CSSValue, value, value->predicate, value.predica
te) |
258 | 234 |
259 } // namespace blink | 235 } // namespace blink |
260 | 236 |
261 #endif // CSSValue_h | 237 #endif // CSSValue_h |
OLD | NEW |