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, 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 "core/CoreExport.h" | 24 #include "core/CoreExport.h" |
| 25 #include "core/css/CSSValueObject.h" | |
| 25 #include "platform/heap/Handle.h" | 26 #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" | 27 #include "wtf/RefCounted.h" |
| 30 #include "wtf/RefPtr.h" | 28 #include "wtf/RefPtr.h" |
| 31 | 29 |
| 32 namespace blink { | 30 namespace blink { |
| 33 | 31 |
| 34 class CORE_EXPORT CSSValue : public RefCountedWillBeGarbageCollectedFinalized<CS SValue> { | 32 // A non-nullable container for CSSValueObject. Takes ownership of the passed |
| 33 // CSSValueObject. | |
| 34 class CORE_EXPORT CSSValue { | |
| 35 ALLOW_ONLY_INLINE_ALLOCATION(); | |
| 36 friend class NullableCSSValue; | |
| 35 public: | 37 public: |
| 36 #if ENABLE(OILPAN) | 38 // Not explicit to allow for casting. |
| 37 // Override operator new to allocate CSSValue subtype objects onto | 39 CSSValue(const CSSValueObject& cssValueObject) |
| 38 // a dedicated heap. | 40 : m_data(const_cast<CSSValueObject*>(&cssValueObject)) |
| 39 GC_PLUGIN_IGNORE("crbug.com/443854") | 41 { |
| 40 void* operator new(size_t size) | 42 ASSERT(m_data); |
| 41 { | 43 ref(); |
| 42 return allocateObject(size); | 44 } |
| 43 } | 45 |
| 44 static void* allocateObject(size_t size) | 46 // TODO(sashab): Remove these; construction should only be available with |
| 45 { | 47 // CSSValueObject&. |
| 46 ThreadState* state = ThreadStateFor<ThreadingTrait<CSSValue>::Affinity>: :state(); | 48 template<class T> CSSValue(PassRefPtrWillBeRawPtr<T> cssValueObject) |
| 47 return Heap::allocateOnHeapIndex(state, size, CSSValueHeapIndex, GCInfoT rait<CSSValue>::index()); | 49 : m_data(cssValueObject.leakRef()) |
| 48 } | 50 { |
| 49 #else | 51 static_assert(WTF::IsSubclass<T, CSSValueObject>::value, "Parameter must be a container for CSSValueObject"); |
| 50 // Override RefCounted's deref() to ensure operator delete is called on | 52 ASSERT(m_data); |
| 51 // the appropriate subclass type. | 53 } |
| 52 void deref() | 54 |
| 53 { | 55 #if !ENABLE(OILPAN) |
| 54 if (derefBase()) | 56 template<class T> CSSValue(RefPtrWillBeRawPtr<T> cssValueObject) |
| 55 destroy(); | 57 : m_data(cssValueObject.release().leakRef()) |
| 56 } | 58 { |
| 57 #endif // !ENABLE(OILPAN) | 59 static_assert(WTF::IsSubclass<T, CSSValueObject>::value, "Parameter must be a container for CSSValueObject"); |
| 58 | 60 ASSERT(m_data); |
| 59 String cssText() const; | 61 } |
| 60 | 62 #endif |
| 61 bool isPrimitiveValue() const { return m_classType == PrimitiveClass; } | 63 |
| 62 bool isValueList() const { return m_classType >= ValueListClass; } | 64 CSSValue(const CSSValue& cssValue) |
| 63 | 65 : m_data(cssValue.m_data) |
| 64 bool isBaseValueList() const { return m_classType == ValueListClass; } | 66 { |
| 65 | 67 ref(); |
| 66 bool isBorderImageSliceValue() const { return m_classType == BorderImageSlic eClass; } | 68 } |
| 67 bool isCanvasValue() const { return m_classType == CanvasClass; } | 69 |
| 68 bool isCursorImageValue() const { return m_classType == CursorImageClass; } | 70 ~CSSValue() |
| 69 bool isCrossfadeValue() const { return m_classType == CrossfadeClass; } | 71 { |
| 70 bool isFontFeatureValue() const { return m_classType == FontFeatureClass; } | 72 deref(); |
| 71 bool isFontFaceSrcValue() const { return m_classType == FontFaceSrcClass; } | 73 } |
| 72 bool isFunctionValue() const { return m_classType == FunctionClass; } | 74 |
| 73 bool isImageGeneratorValue() const { return m_classType >= CanvasClass && m_ classType <= RadialGradientClass; } | 75 CSSValue& operator=(const CSSValue& rhs) |
| 74 bool isGradientValue() const { return m_classType >= LinearGradientClass && m_classType <= RadialGradientClass; } | 76 { |
| 75 bool isImageSetValue() const { return m_classType == ImageSetClass; } | 77 rhs.ref(); |
| 76 bool isImageValue() const { return m_classType == ImageClass; } | 78 deref(); |
| 77 bool isImplicitInitialValue() const; | 79 m_data = rhs.m_data; |
| 78 bool isInheritedValue() const { return m_classType == InheritedClass; } | 80 return *this; |
| 79 bool isInitialValue() const { return m_classType == InitialClass; } | 81 } |
| 80 bool isUnsetValue() const { return m_classType == UnsetClass; } | 82 |
| 81 bool isCSSWideKeyword() const { return m_classType >= InheritedClass && m_cl assType <= UnsetClass; } | 83 bool operator==(const CSSValue& other) const |
| 82 bool isLinearGradientValue() const { return m_classType == LinearGradientCla ss; } | 84 { |
| 83 bool isPathValue() const { return m_classType == PathClass; } | 85 return m_data->equals(*other.m_data); |
| 84 bool isRadialGradientValue() const { return m_classType == RadialGradientCla ss; } | 86 } |
| 85 bool isReflectValue() const { return m_classType == ReflectClass; } | 87 |
| 86 bool isShadowValue() const { return m_classType == ShadowClass; } | 88 // TODO: Remove this and update callsites to use operator== instead. |
| 87 bool isCubicBezierTimingFunctionValue() const { return m_classType == CubicB ezierTimingFunctionClass; } | 89 bool equals(const CSSValue& other) const |
| 88 bool isStepsTimingFunctionValue() const { return m_classType == StepsTimingF unctionClass; } | 90 { |
| 89 bool isLineBoxContainValue() const { return m_classType == LineBoxContainCla ss; } | 91 return m_data->equals(*other.m_data); |
| 90 bool isCalcValue() const {return m_classType == CalculationClass; } | 92 } |
| 91 bool isGridTemplateAreasValue() const { return m_classType == GridTemplateAr easClass; } | 93 |
| 92 bool isSVGDocumentValue() const { return m_classType == CSSSVGDocumentClass; } | 94 bool ptrEquals(const CSSValue& other) const |
| 93 bool isContentDistributionValue() const { return m_classType == CSSContentDi stributionClass; } | 95 { |
| 94 bool isUnicodeRangeValue() const { return m_classType == UnicodeRangeClass; } | 96 return m_data == other.m_data; |
| 95 bool isGridLineNamesValue() const { return m_classType == GridLineNamesClass ; } | 97 } |
| 96 | 98 |
| 97 bool hasFailedOrCanceledSubresources() const; | 99 // Methods that proxy to CSSValueObject. |
| 98 | 100 String cssText() const { return m_data->cssText(); } |
| 99 bool equals(const CSSValue&) const; | 101 bool hasFailedOrCanceledSubresources() const { return m_data->hasFailedOrCan celedSubresources(); }; |
| 100 | 102 bool isPrimitiveValue() const { return m_data->isPrimitiveValue(); } |
| 101 void finalizeGarbageCollectedObject(); | 103 bool isValueList() const { return m_data->isValueList(); } |
| 102 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { } | 104 bool isBaseValueList() const { return m_data->isBaseValueList(); } |
| 103 DECLARE_TRACE(); | 105 bool isBorderImageSliceValue() const { return m_data->isBorderImageSliceValu e(); } |
| 104 | 106 bool isCanvasValue() const { return m_data->isCanvasValue(); } |
| 105 // ~CSSValue should be public, because non-public ~CSSValue causes C2248 | 107 bool isCursorImageValue() const { return m_data->isCursorImageValue(); } |
| 106 // error: 'blink::CSSValue::~CSSValue' : cannot access protected member | 108 bool isCrossfadeValue() const { return m_data->isCrossfadeValue(); } |
| 107 // declared in class 'blink::CSSValue' when compiling | 109 bool isFontFeatureValue() const { return m_data->isFontFeatureValue(); } |
| 108 // 'source\wtf\refcounted.h' by using msvc. | 110 bool isFontFaceSrcValue() const { return m_data->isFontFaceSrcValue(); } |
| 109 ~CSSValue() { } | 111 bool isFunctionValue() const { return m_data->isFunctionValue(); } |
| 110 | 112 bool isImageGeneratorValue() const { return m_data->isImageGeneratorValue(); } |
| 111 protected: | 113 bool isGradientValue() const { return m_data->isGradientValue(); } |
| 112 | 114 bool isImageSetValue() const { return m_data->isImageSetValue(); } |
| 113 static const size_t ClassTypeBits = 6; | 115 bool isImageValue() const { return m_data->isImageValue(); } |
| 114 enum ClassType { | 116 bool isImplicitInitialValue() const { return m_data->isImplicitInitialValue( ); }; |
| 115 PrimitiveClass, | 117 bool isInheritedValue() const { return m_data->isInheritedValue(); }; |
| 116 | 118 bool isInitialValue() const { return m_data->isInitialValue(); }; |
| 117 // Image classes. | 119 bool isUnsetValue() const { return m_data->isUnsetValue(); }; |
| 118 ImageClass, | 120 bool isCSSWideKeyword() const { return m_data->isCSSWideKeyword(); }; |
| 119 CursorImageClass, | 121 bool isLinearGradientValue() const { return m_data->isLinearGradientValue(); }; |
| 120 | 122 bool isPathValue() const { return m_data->isPathValue(); }; |
| 121 // Image generator classes. | 123 bool isRadialGradientValue() const { return m_data->isRadialGradientValue(); }; |
| 122 CanvasClass, | 124 bool isReflectValue() const { return m_data->isReflectValue(); }; |
| 123 CrossfadeClass, | 125 bool isShadowValue() const { return m_data->isShadowValue(); }; |
| 124 LinearGradientClass, | 126 bool isCubicBezierTimingFunctionValue() const { return m_data->isCubicBezier TimingFunctionValue(); }; |
| 125 RadialGradientClass, | 127 bool isStepsTimingFunctionValue() const { return m_data->isStepsTimingFuncti onValue(); }; |
| 126 | 128 bool isLineBoxContainValue() const { return m_data->isLineBoxContainValue(); }; |
| 127 // Timing function classes. | 129 bool isCalcValue() const { return m_data->isCalcValue(); }; |
| 128 CubicBezierTimingFunctionClass, | 130 bool isGridTemplateAreasValue() const { return m_data->isGridTemplateAreasVa lue(); }; |
| 129 StepsTimingFunctionClass, | 131 bool isSVGDocumentValue() const { return m_data->isSVGDocumentValue(); }; |
| 130 | 132 bool isContentDistributionValue() const { return m_data->isContentDistributi onValue(); }; |
| 131 // Other class types. | 133 bool isUnicodeRangeValue() const { return m_data->isUnicodeRangeValue(); }; |
| 132 BorderImageSliceClass, | 134 bool isGridLineNamesValue() const { return m_data->isGridLineNamesValue(); } ; |
| 133 FontFeatureClass, | 135 |
| 134 FontFaceSrcClass, | 136 DEFINE_INLINE_TRACE() |
| 135 | 137 { |
| 136 InheritedClass, | 138 visitor->trace(m_data); |
|
haraken
2015/06/12 00:02:16
Add ASSERT(m_data).
sashab
2015/06/16 21:26:37
oh, sorry about that, I misinterpreted your last c
| |
| 137 InitialClass, | 139 } |
| 138 UnsetClass, | 140 |
| 139 | 141 private: |
| 140 ReflectClass, | 142 // To ensure these are never called. Without this, the compiler may accident ally call |
| 141 ShadowClass, | 143 // CSSValue(nullptr) with the CSSValueObject* constructor to store an interm ediate value. |
| 142 UnicodeRangeClass, | 144 // e.g. NullableCSSValue n = x ? CSSValue(foo) : nullptr; |
| 143 LineBoxContainClass, | 145 CSSValue() = delete; |
| 144 CalculationClass, | 146 CSSValue(std::nullptr_t) = delete; |
| 145 GridTemplateAreasClass, | 147 |
| 146 PathClass, | 148 void ref() const |
| 147 | 149 { |
| 148 // SVG classes. | 150 #if !ENABLE(OILPAN) |
| 149 CSSSVGDocumentClass, | 151 if (m_data) |
| 150 | 152 m_data->ref(); |
| 151 CSSContentDistributionClass, | 153 #endif |
| 152 | 154 } |
| 153 // List class types must appear after ValueListClass. | 155 |
| 154 ValueListClass, | 156 void deref() const |
| 155 FunctionClass, | 157 { |
| 156 ImageSetClass, | 158 #if !ENABLE(OILPAN) |
| 157 GridLineNamesClass, | 159 if (m_data) |
| 158 // Do not append non-list class types here. | 160 m_data->deref(); |
| 161 #endif | |
| 162 } | |
| 163 | |
| 164 RawPtrWillBeMember<CSSValueObject> m_data; | |
| 165 }; | |
| 166 | |
| 167 // A nullable container for CSSValueObject. Contents are the same as CSSValue. | |
| 168 // Behavior is similar to a CSSValue*. | |
| 169 class CORE_EXPORT NullableCSSValue { | |
| 170 ALLOW_ONLY_INLINE_ALLOCATION(); | |
| 171 public: | |
| 172 // Not explicit to allow for casting. | |
| 173 NullableCSSValue() | |
| 174 : m_data(nullptr) | |
| 175 { | |
| 176 } | |
| 177 | |
| 178 NullableCSSValue(const CSSValueObject* cssValueObject) | |
| 179 : m_data(const_cast<CSSValueObject*>(cssValueObject)) | |
| 180 { | |
| 181 ref(); | |
| 182 } | |
| 183 | |
| 184 NullableCSSValue(const CSSValueObject& cssValueObject) | |
| 185 : m_data(const_cast<CSSValueObject*>(&cssValueObject)) | |
| 186 { | |
| 187 ref(); | |
| 188 } | |
| 189 | |
| 190 // TODO(sashab): Remove these; construction should only be available with | |
| 191 // CSSValueObject& or CSSValueObject*. | |
| 192 template <class T> NullableCSSValue(PassRefPtrWillBeRawPtr<T> cssValueObject ) | |
| 193 : m_data(cssValueObject.leakRef()) | |
| 194 { | |
| 195 static_assert(WTF::IsSubclass<T, CSSValueObject>::value, "Parameter must be a container for CSSValueObject"); | |
| 196 } | |
| 197 | |
| 198 #if !ENABLE(OILPAN) | |
| 199 template <class T> NullableCSSValue(RefPtrWillBeRawPtr<T> cssValueObject) | |
| 200 : m_data(cssValueObject.release().leakRef()) | |
| 201 { | |
| 202 static_assert(WTF::IsSubclass<T, CSSValueObject>::value, "Parameter must be a container for CSSValueObject"); | |
| 203 } | |
| 204 #endif | |
| 205 | |
| 206 NullableCSSValue(const NullableCSSValue& cssValue) | |
| 207 : m_data(cssValue.m_data) | |
| 208 { | |
| 209 ref(); | |
| 210 } | |
| 211 | |
| 212 NullableCSSValue(const CSSValue& cssValue) | |
| 213 : m_data(cssValue.m_data) | |
| 214 { | |
| 215 ref(); | |
| 216 } | |
| 217 | |
| 218 ~NullableCSSValue() | |
| 219 { | |
| 220 deref(); | |
| 159 }; | 221 }; |
| 160 | 222 |
| 161 static const size_t ValueListSeparatorBits = 2; | 223 operator bool() const |
| 162 enum ValueListSeparator { | 224 { |
| 163 SpaceSeparator, | 225 return m_data; |
| 164 CommaSeparator, | 226 } |
| 165 SlashSeparator | 227 |
| 166 }; | 228 NullableCSSValue& operator=(const NullableCSSValue& rhs) |
| 167 | 229 { |
| 168 ClassType classType() const { return static_cast<ClassType>(m_classType); } | 230 rhs.ref(); |
| 169 | 231 deref(); |
| 170 explicit CSSValue(ClassType classType) | 232 m_data = rhs.m_data; |
| 171 : m_primitiveUnitType(0) | 233 return *this; |
| 172 , m_hasCachedCSSText(false) | 234 } |
| 173 , m_isQuirkValue(false) | 235 |
| 174 , m_valueListSeparator(SpaceSeparator) | 236 bool operator==(const NullableCSSValue& rhs) |
| 175 , m_classType(classType) | 237 { |
| 176 { | 238 return m_data ? rhs.m_data && m_data->equals(*rhs.m_data) : bool(rhs.m_d ata); |
| 177 } | 239 } |
| 178 | 240 |
| 179 // NOTE: This class is non-virtual for memory and performance reasons. | 241 bool operator!=(const NullableCSSValue& rhs) |
| 180 // Don't go making it virtual again unless you know exactly what you're doin g! | 242 { |
| 243 return !(*this == rhs); | |
| 244 } | |
| 245 | |
| 246 CSSValue& operator*() | |
| 247 { | |
| 248 ASSERT(m_data); | |
| 249 // reinterpret_casts used to avoid ref-churn. | |
| 250 return *reinterpret_cast<CSSValue*>(this); | |
| 251 } | |
| 252 | |
| 253 const CSSValue& operator*() const | |
| 254 { | |
| 255 ASSERT(m_data); | |
| 256 return *reinterpret_cast<const CSSValue*>(this); | |
| 257 } | |
| 258 | |
| 259 CSSValue* operator->() | |
| 260 { | |
| 261 ASSERT(m_data); | |
| 262 return reinterpret_cast<CSSValue*>(this); | |
| 263 } | |
| 264 | |
| 265 const CSSValue* operator->() const | |
| 266 { | |
| 267 ASSERT(m_data); | |
| 268 return reinterpret_cast<const CSSValue*>(this); | |
| 269 } | |
| 270 | |
| 271 void swap(NullableCSSValue& rhs) | |
| 272 { | |
| 273 std::swap(this->m_data, rhs.m_data); | |
| 274 } | |
| 275 | |
| 276 DEFINE_INLINE_TRACE() | |
| 277 { | |
| 278 visitor->trace(m_data); | |
| 279 } | |
| 181 | 280 |
| 182 private: | 281 private: |
| 183 void destroy(); | 282 void ref() const |
| 184 | 283 { |
| 185 protected: | 284 #if !ENABLE(OILPAN) |
| 186 // The bits in this section are only used by specific subclasses but kept he re | 285 if (m_data) |
| 187 // to maximize struct packing. | 286 m_data->ref(); |
| 188 | 287 #endif |
| 189 // CSSPrimitiveValue bits: | 288 } |
| 190 unsigned m_primitiveUnitType : 7; // CSSPrimitiveValue::UnitType | 289 |
| 191 mutable unsigned m_hasCachedCSSText : 1; | 290 void deref() const |
| 192 unsigned m_isQuirkValue : 1; | 291 { |
| 193 | 292 #if !ENABLE(OILPAN) |
| 194 unsigned m_valueListSeparator : ValueListSeparatorBits; | 293 if (m_data) |
| 195 | 294 m_data->deref(); |
| 196 private: | 295 #endif |
| 197 unsigned m_classType : ClassTypeBits; // ClassType | 296 } |
| 297 | |
| 298 RawPtrWillBeMember<CSSValueObject> m_data; | |
| 198 }; | 299 }; |
| 199 | 300 |
| 200 template<typename CSSValueType, size_t inlineCapacity> | 301 static_assert(sizeof(CSSValue) == sizeof(void*), "CSSValue should be pointer-siz ed"); |
| 201 inline bool compareCSSValueVector(const WillBeHeapVector<RefPtrWillBeMember<CSSV alueType>, inlineCapacity>& firstVector, const WillBeHeapVector<RefPtrWillBeMemb er<CSSValueType>, inlineCapacity>& secondVector) | 302 static_assert(sizeof(NullableCSSValue) == sizeof(void*), "CSSValue should be poi nter-sized"); |
| 303 static_assert(sizeof(CSSValue) == sizeof(NullableCSSValue), "Both CSSValue conta iners must contain the same data"); | |
| 304 | |
| 305 template<size_t inlineCapacity> | |
| 306 inline bool compareCSSValueVector(const WillBeHeapVector<CSSValue, inlineCapacit y>& firstVector, const WillBeHeapVector<CSSValue, inlineCapacity>& secondVector) | |
| 202 { | 307 { |
| 203 size_t size = firstVector.size(); | 308 size_t size = firstVector.size(); |
| 204 if (size != secondVector.size()) | 309 if (size != secondVector.size()) |
| 205 return false; | 310 return false; |
| 206 | 311 |
| 207 for (size_t i = 0; i < size; i++) { | 312 for (size_t i = 0; i < size; i++) { |
| 208 const RefPtrWillBeMember<CSSValueType>& firstPtr = firstVector[i]; | 313 const CSSValue& firstPtr = firstVector[i]; |
| 209 const RefPtrWillBeMember<CSSValueType>& secondPtr = secondVector[i]; | 314 const CSSValue& secondPtr = secondVector[i]; |
| 210 if (firstPtr == secondPtr || (firstPtr && secondPtr && firstPtr->equals( *secondPtr))) | 315 if (firstPtr.ptrEquals(secondPtr) || firstPtr.equals(secondPtr)) |
| 211 continue; | 316 continue; |
| 212 return false; | 317 return false; |
| 213 } | 318 } |
| 214 return true; | 319 return true; |
| 215 } | 320 } |
| 216 | 321 |
| 217 template<typename CSSValueType> | |
| 218 inline bool compareCSSValuePtr(const RefPtr<CSSValueType>& first, const RefPtr<C SSValueType>& second) | |
| 219 { | |
| 220 return first ? second && first->equals(*second) : !second; | |
| 221 } | |
| 222 | |
| 223 template<typename CSSValueType> | |
| 224 inline bool compareCSSValuePtr(const RawPtr<CSSValueType>& first, const RawPtr<C SSValueType>& second) | |
| 225 { | |
| 226 return first ? second && first->equals(*second) : !second; | |
| 227 } | |
| 228 | |
| 229 template<typename CSSValueType> | |
| 230 inline bool compareCSSValuePtr(const Member<CSSValueType>& first, const Member<C SSValueType>& second) | |
| 231 { | |
| 232 return first ? second && first->equals(*second) : !second; | |
| 233 } | |
| 234 | |
| 235 #define DEFINE_CSS_VALUE_TYPE_CASTS(thisType, predicate) \ | 322 #define DEFINE_CSS_VALUE_TYPE_CASTS(thisType, predicate) \ |
| 236 DEFINE_TYPE_CASTS(thisType, CSSValue, value, value->predicate, value.predica te) | 323 DEFINE_TYPE_CASTS(thisType, CSSValueObject, value, value->predicate, value.p redicate); \ |
| 324 inline thisType& to##thisType(CSSValue value) \ | |
| 325 { \ | |
| 326 ASSERT_WITH_SECURITY_IMPLICATION(value.predicate); \ | |
| 327 return **reinterpret_cast<thisType**>(&value); \ | |
| 328 } \ | |
| 329 inline thisType* to##thisType(NullableCSSValue value) \ | |
| 330 { \ | |
| 331 if (!value) \ | |
| 332 return nullptr; \ | |
| 333 ASSERT_WITH_SECURITY_IMPLICATION(value->predicate); \ | |
| 334 return *reinterpret_cast<thisType**>(&value); \ | |
| 335 } | |
| 237 | 336 |
| 238 } // namespace blink | 337 } // namespace blink |
| 239 | 338 |
| 339 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSValue); | |
| 340 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::NullableCSSValue); | |
|
haraken
2015/06/12 00:02:16
As discussed offline, shall we add a comment and m
sashab
2015/06/16 21:26:37
Done.
| |
| 341 | |
| 240 #endif // CSSValue_h | 342 #endif // CSSValue_h |
| OLD | NEW |