Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: Source/core/css/CSSValue.cpp

Issue 26623002: Use toCSSFooValue() instead of using static_cast<const CSSFooValue*> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/CSSImageGeneratorValue.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 bool CSSValue::isImplicitInitialValue() const 88 bool CSSValue::isImplicitInitialValue() const
89 { 89 {
90 return m_classType == InitialClass && static_cast<const CSSInitialValue*>(th is)->isImplicit(); 90 return m_classType == InitialClass && toCSSInitialValue(this)->isImplicit();
91 } 91 }
92 92
93 CSSValue::Type CSSValue::cssValueType() const 93 CSSValue::Type CSSValue::cssValueType() const
94 { 94 {
95 if (isInheritedValue()) 95 if (isInheritedValue())
96 return CSS_INHERIT; 96 return CSS_INHERIT;
97 if (isPrimitiveValue()) 97 if (isPrimitiveValue())
98 return CSS_PRIMITIVE_VALUE; 98 return CSS_PRIMITIVE_VALUE;
99 if (isValueList()) 99 if (isValueList())
100 return CSS_VALUE_LIST; 100 return CSS_VALUE_LIST;
101 if (isInitialValue()) 101 if (isInitialValue())
102 return CSS_INITIAL; 102 return CSS_INITIAL;
103 return CSS_CUSTOM; 103 return CSS_CUSTOM;
104 } 104 }
105 105
106 void CSSValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheet Contents* styleSheet) const 106 void CSSValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheet Contents* styleSheet) const
107 { 107 {
108 // This should get called for internal instances only. 108 // This should get called for internal instances only.
109 ASSERT(!isCSSOMSafe()); 109 ASSERT(!isCSSOMSafe());
110 110
111 if (isPrimitiveValue()) 111 if (isPrimitiveValue())
112 toCSSPrimitiveValue(this)->addSubresourceStyleURLs(urls, styleSheet); 112 toCSSPrimitiveValue(this)->addSubresourceStyleURLs(urls, styleSheet);
113 else if (isValueList()) 113 else if (isValueList())
114 toCSSValueList(this)->addSubresourceStyleURLs(urls, styleSheet); 114 toCSSValueList(this)->addSubresourceStyleURLs(urls, styleSheet);
115 else if (classType() == FontFaceSrcClass) 115 else if (classType() == FontFaceSrcClass)
116 static_cast<const CSSFontFaceSrcValue*>(this)->addSubresourceStyleURLs(u rls, styleSheet); 116 toCSSFontFaceSrcValue(this)->addSubresourceStyleURLs(urls, styleSheet);
117 else if (classType() == ReflectClass) 117 else if (classType() == ReflectClass)
118 static_cast<const CSSReflectValue*>(this)->addSubresourceStyleURLs(urls, styleSheet); 118 toCSSReflectValue(this)->addSubresourceStyleURLs(urls, styleSheet);
119 } 119 }
120 120
121 bool CSSValue::hasFailedOrCanceledSubresources() const 121 bool CSSValue::hasFailedOrCanceledSubresources() const
122 { 122 {
123 // This should get called for internal instances only. 123 // This should get called for internal instances only.
124 ASSERT(!isCSSOMSafe()); 124 ASSERT(!isCSSOMSafe());
125 125
126 if (isValueList()) 126 if (isValueList())
127 return toCSSValueList(this)->hasFailedOrCanceledSubresources(); 127 return toCSSValueList(this)->hasFailedOrCanceledSubresources();
128 if (classType() == FontFaceSrcClass) 128 if (classType() == FontFaceSrcClass)
129 return static_cast<const CSSFontFaceSrcValue*>(this)->hasFailedOrCancele dSubresources(); 129 return toCSSFontFaceSrcValue(this)->hasFailedOrCanceledSubresources();
130 if (classType() == ImageClass) 130 if (classType() == ImageClass)
131 return toCSSImageValue(this)->hasFailedOrCanceledSubresources(); 131 return toCSSImageValue(this)->hasFailedOrCanceledSubresources();
132 if (classType() == CrossfadeClass) 132 if (classType() == CrossfadeClass)
133 return static_cast<const CSSCrossfadeValue*>(this)->hasFailedOrCanceledS ubresources(); 133 return toCSSCrossfadeValue(this)->hasFailedOrCanceledSubresources();
134 if (classType() == ImageSetClass) 134 if (classType() == ImageSetClass)
135 return static_cast<const CSSImageSetValue*>(this)->hasFailedOrCanceledSu bresources(); 135 return toCSSImageSetValue(this)->hasFailedOrCanceledSubresources();
136 136
137 return false; 137 return false;
138 } 138 }
139 139
140 template<class ChildClassType> 140 template<class ChildClassType>
141 inline static bool compareCSSValues(const CSSValue& first, const CSSValue& secon d) 141 inline static bool compareCSSValues(const CSSValue& first, const CSSValue& secon d)
142 { 142 {
143 return static_cast<const ChildClassType&>(first).equals(static_cast<const Ch ildClassType&>(second)); 143 return static_cast<const ChildClassType&>(first).equals(static_cast<const Ch ildClassType&>(second));
144 } 144 }
145 145
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 String CSSValue::cssText() const 234 String CSSValue::cssText() const
235 { 235 {
236 if (m_isTextClone) { 236 if (m_isTextClone) {
237 ASSERT(isCSSOMSafe()); 237 ASSERT(isCSSOMSafe());
238 return static_cast<const TextCloneCSSValue*>(this)->cssText(); 238 return static_cast<const TextCloneCSSValue*>(this)->cssText();
239 } 239 }
240 ASSERT(!isCSSOMSafe() || isSubtypeExposedToCSSOM()); 240 ASSERT(!isCSSOMSafe() || isSubtypeExposedToCSSOM());
241 241
242 switch (classType()) { 242 switch (classType()) {
243 case AspectRatioClass: 243 case AspectRatioClass:
244 return static_cast<const CSSAspectRatioValue*>(this)->customCssText(); 244 return toCSSAspectRatioValue(this)->customCssText();
245 case BorderImageSliceClass: 245 case BorderImageSliceClass:
246 return static_cast<const CSSBorderImageSliceValue*>(this)->customCssText (); 246 return toCSSBorderImageSliceValue(this)->customCssText();
247 case CanvasClass: 247 case CanvasClass:
248 return static_cast<const CSSCanvasValue*>(this)->customCssText(); 248 return toCSSCanvasValue(this)->customCssText();
249 case CursorImageClass: 249 case CursorImageClass:
250 return static_cast<const CSSCursorImageValue*>(this)->customCssText(); 250 return toCSSCursorImageValue(this)->customCssText();
251 case FontClass: 251 case FontClass:
252 return toCSSFontValue(this)->customCssText(); 252 return toCSSFontValue(this)->customCssText();
253 case FontFaceSrcClass: 253 case FontFaceSrcClass:
254 return static_cast<const CSSFontFaceSrcValue*>(this)->customCssText(); 254 return toCSSFontFaceSrcValue(this)->customCssText();
255 case FontFeatureClass: 255 case FontFeatureClass:
256 return toCSSFontFeatureValue(this)->customCssText(); 256 return toCSSFontFeatureValue(this)->customCssText();
257 case FunctionClass: 257 case FunctionClass:
258 return static_cast<const CSSFunctionValue*>(this)->customCssText(); 258 return toCSSFunctionValue(this)->customCssText();
259 case LinearGradientClass: 259 case LinearGradientClass:
260 return static_cast<const CSSLinearGradientValue*>(this)->customCssText() ; 260 return toCSSLinearGradientValue(this)->customCssText();
261 case RadialGradientClass: 261 case RadialGradientClass:
262 return static_cast<const CSSRadialGradientValue*>(this)->customCssText() ; 262 return toCSSRadialGradientValue(this)->customCssText();
263 case CrossfadeClass: 263 case CrossfadeClass:
264 return static_cast<const CSSCrossfadeValue*>(this)->customCssText(); 264 return toCSSCrossfadeValue(this)->customCssText();
265 case ImageClass: 265 case ImageClass:
266 return toCSSImageValue(this)->customCssText(); 266 return toCSSImageValue(this)->customCssText();
267 case InheritedClass: 267 case InheritedClass:
268 return static_cast<const CSSInheritedValue*>(this)->customCssText(); 268 return toCSSInheritedValue(this)->customCssText();
269 case InitialClass: 269 case InitialClass:
270 return static_cast<const CSSInitialValue*>(this)->customCssText(); 270 return toCSSInitialValue(this)->customCssText();
271 case GridTemplateClass: 271 case GridTemplateClass:
272 return static_cast<const CSSGridTemplateValue*>(this)->customCssText(); 272 return toCSSGridTemplateValue(this)->customCssText();
273 case PrimitiveClass: 273 case PrimitiveClass:
274 return toCSSPrimitiveValue(this)->customCssText(); 274 return toCSSPrimitiveValue(this)->customCssText();
275 case ReflectClass: 275 case ReflectClass:
276 return static_cast<const CSSReflectValue*>(this)->customCssText(); 276 return toCSSReflectValue(this)->customCssText();
277 case ShadowClass: 277 case ShadowClass:
278 return toCSSShadowValue(this)->customCssText(); 278 return toCSSShadowValue(this)->customCssText();
279 case CubicBezierTimingFunctionClass: 279 case CubicBezierTimingFunctionClass:
280 return static_cast<const CSSCubicBezierTimingFunctionValue*>(this)->cust omCssText(); 280 return toCSSCubicBezierTimingFunctionValue(this)->customCssText();
281 case StepsTimingFunctionClass: 281 case StepsTimingFunctionClass:
282 return static_cast<const CSSStepsTimingFunctionValue*>(this)->customCssT ext(); 282 return toCSSStepsTimingFunctionValue(this)->customCssText();
283 case UnicodeRangeClass: 283 case UnicodeRangeClass:
284 return static_cast<const CSSUnicodeRangeValue*>(this)->customCssText(); 284 return toCSSUnicodeRangeValue(this)->customCssText();
285 case ValueListClass: 285 case ValueListClass:
286 return toCSSValueList(this)->customCssText(); 286 return toCSSValueList(this)->customCssText();
287 case CSSTransformClass: 287 case CSSTransformClass:
288 return static_cast<const CSSTransformValue*>(this)->customCssText(); 288 return toCSSTransformValue(this)->customCssText();
289 case LineBoxContainClass: 289 case LineBoxContainClass:
290 return static_cast<const CSSLineBoxContainValue*>(this)->customCssText() ; 290 return toCSSLineBoxContainValue(this)->customCssText();
291 case CalculationClass: 291 case CalculationClass:
292 return static_cast<const CSSCalcValue*>(this)->customCssText(); 292 return toCSSCalcValue(this)->customCssText();
293 case ImageSetClass: 293 case ImageSetClass:
294 return static_cast<const CSSImageSetValue*>(this)->customCssText(); 294 return toCSSImageSetValue(this)->customCssText();
295 case CSSFilterClass: 295 case CSSFilterClass:
296 return static_cast<const CSSFilterValue*>(this)->customCssText(); 296 return toCSSFilterValue(this)->customCssText();
297 case CSSArrayFunctionValueClass: 297 case CSSArrayFunctionValueClass:
298 return static_cast<const CSSArrayFunctionValue*>(this)->customCssText(); 298 return toCSSArrayFunctionValue(this)->customCssText();
299 case CSSMixFunctionValueClass: 299 case CSSMixFunctionValueClass:
300 return static_cast<const CSSMixFunctionValue*>(this)->customCssText(); 300 return toCSSMixFunctionValue(this)->customCssText();
301 case CSSShaderClass: 301 case CSSShaderClass:
302 return static_cast<const CSSShaderValue*>(this)->customCssText(); 302 return toCSSShaderValue(this)->customCssText();
303 case VariableClass: 303 case VariableClass:
304 return toCSSVariableValue(this)->value(); 304 return toCSSVariableValue(this)->value();
305 case SVGColorClass: 305 case SVGColorClass:
306 return static_cast<const SVGColor*>(this)->customCssText(); 306 return static_cast<const SVGColor*>(this)->customCssText();
307 case SVGPaintClass: 307 case SVGPaintClass:
308 return static_cast<const SVGPaint*>(this)->customCssText(); 308 return static_cast<const SVGPaint*>(this)->customCssText();
309 case CSSSVGDocumentClass: 309 case CSSSVGDocumentClass:
310 return static_cast<const CSSSVGDocumentValue*>(this)->customCssText(); 310 return toCSSSVGDocumentValue(this)->customCssText();
311 } 311 }
312 ASSERT_NOT_REACHED(); 312 ASSERT_NOT_REACHED();
313 return String(); 313 return String();
314 } 314 }
315 315
316 String CSSValue::serializeResolvingVariables(const HashMap<AtomicString, String> & variables) const 316 String CSSValue::serializeResolvingVariables(const HashMap<AtomicString, String> & variables) const
317 { 317 {
318 switch (classType()) { 318 switch (classType()) {
319 case PrimitiveClass: 319 case PrimitiveClass:
320 return toCSSPrimitiveValue(this)->customSerializeResolvingVariables(vari ables); 320 return toCSSPrimitiveValue(this)->customSerializeResolvingVariables(vari ables);
321 case ReflectClass: 321 case ReflectClass:
322 return static_cast<const CSSReflectValue*>(this)->customSerializeResolvi ngVariables(variables); 322 return toCSSReflectValue(this)->customSerializeResolvingVariables(variab les);
323 case ValueListClass: 323 case ValueListClass:
324 return toCSSValueList(this)->customSerializeResolvingVariables(variables ); 324 return toCSSValueList(this)->customSerializeResolvingVariables(variables );
325 case CSSTransformClass: 325 case CSSTransformClass:
326 return static_cast<const CSSTransformValue*>(this)->customSerializeResol vingVariables(variables); 326 return toCSSTransformValue(this)->customSerializeResolvingVariables(vari ables);
327 default: 327 default:
328 return cssText(); 328 return cssText();
329 } 329 }
330 } 330 }
331 331
332 void CSSValue::destroy() 332 void CSSValue::destroy()
333 { 333 {
334 if (m_isTextClone) { 334 if (m_isTextClone) {
335 ASSERT(isCSSOMSafe()); 335 ASSERT(isCSSOMSafe());
336 delete static_cast<TextCloneCSSValue*>(this); 336 delete static_cast<TextCloneCSSValue*>(this);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 { 449 {
450 switch (classType()) { 450 switch (classType()) {
451 case PrimitiveClass: 451 case PrimitiveClass:
452 return toCSSPrimitiveValue(this)->cloneForCSSOM(); 452 return toCSSPrimitiveValue(this)->cloneForCSSOM();
453 case ValueListClass: 453 case ValueListClass:
454 return toCSSValueList(this)->cloneForCSSOM(); 454 return toCSSValueList(this)->cloneForCSSOM();
455 case ImageClass: 455 case ImageClass:
456 case CursorImageClass: 456 case CursorImageClass:
457 return toCSSImageValue(this)->cloneForCSSOM(); 457 return toCSSImageValue(this)->cloneForCSSOM();
458 case CSSFilterClass: 458 case CSSFilterClass:
459 return static_cast<const CSSFilterValue*>(this)->cloneForCSSOM(); 459 return toCSSFilterValue(this)->cloneForCSSOM();
460 case CSSArrayFunctionValueClass: 460 case CSSArrayFunctionValueClass:
461 return static_cast<const CSSArrayFunctionValue*>(this)->cloneForCSSOM(); 461 return toCSSArrayFunctionValue(this)->cloneForCSSOM();
462 case CSSMixFunctionValueClass: 462 case CSSMixFunctionValueClass:
463 return static_cast<const CSSMixFunctionValue*>(this)->cloneForCSSOM(); 463 return toCSSMixFunctionValue(this)->cloneForCSSOM();
464 case CSSTransformClass: 464 case CSSTransformClass:
465 return static_cast<const CSSTransformValue*>(this)->cloneForCSSOM(); 465 return toCSSTransformValue(this)->cloneForCSSOM();
466 case ImageSetClass: 466 case ImageSetClass:
467 return static_cast<const CSSImageSetValue*>(this)->cloneForCSSOM(); 467 return toCSSImageSetValue(this)->cloneForCSSOM();
468 case SVGColorClass: 468 case SVGColorClass:
469 return static_cast<const SVGColor*>(this)->cloneForCSSOM(); 469 return static_cast<const SVGColor*>(this)->cloneForCSSOM();
470 case SVGPaintClass: 470 case SVGPaintClass:
471 return static_cast<const SVGPaint*>(this)->cloneForCSSOM(); 471 return static_cast<const SVGPaint*>(this)->cloneForCSSOM();
472 default: 472 default:
473 ASSERT(!isSubtypeExposedToCSSOM()); 473 ASSERT(!isSubtypeExposedToCSSOM());
474 return TextCloneCSSValue::create(classType(), cssText()); 474 return TextCloneCSSValue::create(classType(), cssText());
475 } 475 }
476 } 476 }
477 477
478 } 478 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSImageGeneratorValue.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698