Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Andreas Kling (kling@webkit.org) | 2 * Copyright (C) 2011 Andreas Kling (kling@webkit.org) |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 TextCloneCSSValue(ClassType classType, const String& text) | 78 TextCloneCSSValue(ClassType classType, const String& text) |
| 79 : CSSValue(classType, /*isCSSOMSafe*/ true) | 79 : CSSValue(classType, /*isCSSOMSafe*/ true) |
| 80 , m_cssText(text) | 80 , m_cssText(text) |
| 81 { | 81 { |
| 82 m_isTextClone = true; | 82 m_isTextClone = true; |
| 83 } | 83 } |
| 84 | 84 |
| 85 String m_cssText; | 85 String m_cssText; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 // This will catch anyone doing an unnecessary cast. | |
| 89 void toTextCloneCSSValue(const TextCloneCSSValue*); | |
|
esprehn
2013/10/15 01:17:41
We should just fix the macros. DEFINE_NODE_TYPE_CA
gyuyoung-inactive
2013/10/15 01:46:27
Yes, good idea. It looks we can change DEFINE_NODE
gyuyoung-inactive
2013/10/15 03:36:49
I upload a patch for this.
https://chromiumcoderev
| |
| 90 | |
| 91 inline TextCloneCSSValue* toTextCloneCSSValue(CSSValue* value) | |
| 92 { | |
| 93 ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isTextCloneCSSValue()); | |
| 94 return static_cast<TextCloneCSSValue*>(value); | |
| 95 } | |
| 96 | |
| 97 inline const TextCloneCSSValue* toTextCloneCSSValue(const CSSValue* value) | |
| 98 { | |
| 99 ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isTextCloneCSSValue()); | |
| 100 return static_cast<const TextCloneCSSValue*>(value); | |
| 101 } | |
| 102 | |
| 88 bool CSSValue::isImplicitInitialValue() const | 103 bool CSSValue::isImplicitInitialValue() const |
| 89 { | 104 { |
| 90 return m_classType == InitialClass && toCSSInitialValue(this)->isImplicit(); | 105 return m_classType == InitialClass && toCSSInitialValue(this)->isImplicit(); |
| 91 } | 106 } |
| 92 | 107 |
| 93 CSSValue::Type CSSValue::cssValueType() const | 108 CSSValue::Type CSSValue::cssValueType() const |
| 94 { | 109 { |
| 95 if (isInheritedValue()) | 110 if (isInheritedValue()) |
| 96 return CSS_INHERIT; | 111 return CSS_INHERIT; |
| 97 if (isPrimitiveValue()) | 112 if (isPrimitiveValue()) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 template<class ChildClassType> | 155 template<class ChildClassType> |
| 141 inline static bool compareCSSValues(const CSSValue& first, const CSSValue& secon d) | 156 inline static bool compareCSSValues(const CSSValue& first, const CSSValue& secon d) |
| 142 { | 157 { |
| 143 return static_cast<const ChildClassType&>(first).equals(static_cast<const Ch ildClassType&>(second)); | 158 return static_cast<const ChildClassType&>(first).equals(static_cast<const Ch ildClassType&>(second)); |
| 144 } | 159 } |
| 145 | 160 |
| 146 bool CSSValue::equals(const CSSValue& other) const | 161 bool CSSValue::equals(const CSSValue& other) const |
| 147 { | 162 { |
| 148 if (m_isTextClone) { | 163 if (m_isTextClone) { |
| 149 ASSERT(isCSSOMSafe()); | 164 ASSERT(isCSSOMSafe()); |
| 150 return static_cast<const TextCloneCSSValue*>(this)->cssText() == other.c ssText(); | 165 return toTextCloneCSSValue(this)->cssText() == other.cssText(); |
| 151 } | 166 } |
| 152 | 167 |
| 153 if (m_classType == other.m_classType) { | 168 if (m_classType == other.m_classType) { |
| 154 switch (m_classType) { | 169 switch (m_classType) { |
| 155 case AspectRatioClass: | 170 case AspectRatioClass: |
| 156 return compareCSSValues<CSSAspectRatioValue>(*this, other); | 171 return compareCSSValues<CSSAspectRatioValue>(*this, other); |
| 157 case BorderImageSliceClass: | 172 case BorderImageSliceClass: |
| 158 return compareCSSValues<CSSBorderImageSliceValue>(*this, other); | 173 return compareCSSValues<CSSBorderImageSliceValue>(*this, other); |
| 159 case CanvasClass: | 174 case CanvasClass: |
| 160 return compareCSSValues<CSSCanvasValue>(*this, other); | 175 return compareCSSValues<CSSCanvasValue>(*this, other); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 } else if (m_classType == ValueListClass && other.m_classType != ValueListCl ass) | 242 } else if (m_classType == ValueListClass && other.m_classType != ValueListCl ass) |
| 228 return toCSSValueList(this)->equals(other); | 243 return toCSSValueList(this)->equals(other); |
| 229 else if (m_classType != ValueListClass && other.m_classType == ValueListClas s) | 244 else if (m_classType != ValueListClass && other.m_classType == ValueListClas s) |
| 230 return static_cast<const CSSValueList&>(other).equals(*this); | 245 return static_cast<const CSSValueList&>(other).equals(*this); |
| 231 return false; | 246 return false; |
| 232 } | 247 } |
| 233 | 248 |
| 234 String CSSValue::cssText() const | 249 String CSSValue::cssText() const |
| 235 { | 250 { |
| 236 if (m_isTextClone) { | 251 if (m_isTextClone) { |
| 237 ASSERT(isCSSOMSafe()); | 252 ASSERT(isCSSOMSafe()); |
| 238 return static_cast<const TextCloneCSSValue*>(this)->cssText(); | 253 return toTextCloneCSSValue(this)->cssText(); |
| 239 } | 254 } |
| 240 ASSERT(!isCSSOMSafe() || isSubtypeExposedToCSSOM()); | 255 ASSERT(!isCSSOMSafe() || isSubtypeExposedToCSSOM()); |
| 241 | 256 |
| 242 switch (classType()) { | 257 switch (classType()) { |
| 243 case AspectRatioClass: | 258 case AspectRatioClass: |
| 244 return toCSSAspectRatioValue(this)->customCssText(); | 259 return toCSSAspectRatioValue(this)->customCssText(); |
| 245 case BorderImageSliceClass: | 260 case BorderImageSliceClass: |
| 246 return toCSSBorderImageSliceValue(this)->customCssText(); | 261 return toCSSBorderImageSliceValue(this)->customCssText(); |
| 247 case CanvasClass: | 262 case CanvasClass: |
| 248 return toCSSCanvasValue(this)->customCssText(); | 263 return toCSSCanvasValue(this)->customCssText(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 return toCSSTransformValue(this)->customSerializeResolvingVariables(vari ables); | 341 return toCSSTransformValue(this)->customSerializeResolvingVariables(vari ables); |
| 327 default: | 342 default: |
| 328 return cssText(); | 343 return cssText(); |
| 329 } | 344 } |
| 330 } | 345 } |
| 331 | 346 |
| 332 void CSSValue::destroy() | 347 void CSSValue::destroy() |
| 333 { | 348 { |
| 334 if (m_isTextClone) { | 349 if (m_isTextClone) { |
| 335 ASSERT(isCSSOMSafe()); | 350 ASSERT(isCSSOMSafe()); |
| 336 delete static_cast<TextCloneCSSValue*>(this); | 351 delete toTextCloneCSSValue(this); |
| 337 return; | 352 return; |
| 338 } | 353 } |
| 339 ASSERT(!isCSSOMSafe() || isSubtypeExposedToCSSOM()); | 354 ASSERT(!isCSSOMSafe() || isSubtypeExposedToCSSOM()); |
| 340 | 355 |
| 341 switch (classType()) { | 356 switch (classType()) { |
| 342 case AspectRatioClass: | 357 case AspectRatioClass: |
| 343 delete toCSSAspectRatioValue(this); | 358 delete toCSSAspectRatioValue(this); |
| 344 return; | 359 return; |
| 345 case BorderImageSliceClass: | 360 case BorderImageSliceClass: |
| 346 delete toCSSBorderImageSliceValue(this); | 361 delete toCSSBorderImageSliceValue(this); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 return toSVGColor(this)->cloneForCSSOM(); | 484 return toSVGColor(this)->cloneForCSSOM(); |
| 470 case SVGPaintClass: | 485 case SVGPaintClass: |
| 471 return toSVGPaint(this)->cloneForCSSOM(); | 486 return toSVGPaint(this)->cloneForCSSOM(); |
| 472 default: | 487 default: |
| 473 ASSERT(!isSubtypeExposedToCSSOM()); | 488 ASSERT(!isSubtypeExposedToCSSOM()); |
| 474 return TextCloneCSSValue::create(classType(), cssText()); | 489 return TextCloneCSSValue::create(classType(), cssText()); |
| 475 } | 490 } |
| 476 } | 491 } |
| 477 | 492 |
| 478 } | 493 } |
| OLD | NEW |