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, 2009, 2010, 2012 Apple Inc. All r
ights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. |
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
5 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 5 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 246 |
247 ASSERT(!numDecls ^ !result.isEmpty()); | 247 ASSERT(!numDecls ^ !result.isEmpty()); |
248 return result.toString(); | 248 return result.toString(); |
249 } | 249 } |
250 | 250 |
251 String StylePropertySerializer::getPropertyValue(CSSPropertyID propertyID) const | 251 String StylePropertySerializer::getPropertyValue(CSSPropertyID propertyID) const |
252 { | 252 { |
253 // Shorthand and 4-values properties | 253 // Shorthand and 4-values properties |
254 switch (propertyID) { | 254 switch (propertyID) { |
255 case CSSPropertyAnimation: | 255 case CSSPropertyAnimation: |
256 return getLayeredShorthandValue(animationShorthand()); | 256 return getLayeredShorthandValue(animationShorthand(), true); |
257 case CSSPropertyBorderSpacing: | 257 case CSSPropertyBorderSpacing: |
258 return borderSpacingValue(borderSpacingShorthand()); | 258 return borderSpacingValue(borderSpacingShorthand()); |
259 case CSSPropertyBackgroundPosition: | 259 case CSSPropertyBackgroundPosition: |
260 return getLayeredShorthandValue(backgroundPositionShorthand()); | 260 return getLayeredShorthandValue(backgroundPositionShorthand()); |
261 case CSSPropertyBackgroundRepeat: | 261 case CSSPropertyBackgroundRepeat: |
262 return backgroundRepeatPropertyValue(); | 262 return backgroundRepeatPropertyValue(); |
263 case CSSPropertyBackground: | 263 case CSSPropertyBackground: |
264 return getLayeredShorthandValue(backgroundShorthand()); | 264 return getLayeredShorthandValue(backgroundShorthand()); |
265 case CSSPropertyBorder: | 265 case CSSPropertyBorder: |
266 return borderPropertyValue(OmitUncommonValues); | 266 return borderPropertyValue(OmitUncommonValues); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 return fontValue(); | 298 return fontValue(); |
299 case CSSPropertyMargin: | 299 case CSSPropertyMargin: |
300 return get4Values(marginShorthand()); | 300 return get4Values(marginShorthand()); |
301 case CSSPropertyWebkitMarginCollapse: | 301 case CSSPropertyWebkitMarginCollapse: |
302 return getShorthandValue(webkitMarginCollapseShorthand()); | 302 return getShorthandValue(webkitMarginCollapseShorthand()); |
303 case CSSPropertyOverflow: | 303 case CSSPropertyOverflow: |
304 return getCommonValue(overflowShorthand()); | 304 return getCommonValue(overflowShorthand()); |
305 case CSSPropertyPadding: | 305 case CSSPropertyPadding: |
306 return get4Values(paddingShorthand()); | 306 return get4Values(paddingShorthand()); |
307 case CSSPropertyTransition: | 307 case CSSPropertyTransition: |
308 return getLayeredShorthandValue(transitionShorthand()); | 308 return getLayeredShorthandValue(transitionShorthand(), true); |
309 case CSSPropertyListStyle: | 309 case CSSPropertyListStyle: |
310 return getShorthandValue(listStyleShorthand()); | 310 return getShorthandValue(listStyleShorthand()); |
311 case CSSPropertyWebkitMaskPosition: | 311 case CSSPropertyWebkitMaskPosition: |
312 return getLayeredShorthandValue(webkitMaskPositionShorthand()); | 312 return getLayeredShorthandValue(webkitMaskPositionShorthand()); |
313 case CSSPropertyWebkitMaskRepeat: | 313 case CSSPropertyWebkitMaskRepeat: |
314 return getLayeredShorthandValue(webkitMaskRepeatShorthand()); | 314 return getLayeredShorthandValue(webkitMaskRepeatShorthand()); |
315 case CSSPropertyWebkitMask: | 315 case CSSPropertyWebkitMask: |
316 return getLayeredShorthandValue(webkitMaskShorthand()); | 316 return getLayeredShorthandValue(webkitMaskShorthand()); |
317 case CSSPropertyWebkitTextEmphasis: | 317 case CSSPropertyWebkitTextEmphasis: |
318 return getShorthandValue(webkitTextEmphasisShorthand()); | 318 return getShorthandValue(webkitTextEmphasisShorthand()); |
319 case CSSPropertyWebkitTextStroke: | 319 case CSSPropertyWebkitTextStroke: |
320 return getShorthandValue(webkitTextStrokeShorthand()); | 320 return getShorthandValue(webkitTextStrokeShorthand()); |
321 case CSSPropertyTransformOrigin: | 321 case CSSPropertyTransformOrigin: |
322 case CSSPropertyWebkitTransformOrigin: | 322 case CSSPropertyWebkitTransformOrigin: |
323 return getShorthandValue(webkitTransformOriginShorthand()); | 323 return getShorthandValue(webkitTransformOriginShorthand()); |
324 case CSSPropertyWebkitTransition: | 324 case CSSPropertyWebkitTransition: |
325 return getLayeredShorthandValue(webkitTransitionShorthand()); | 325 return getLayeredShorthandValue(webkitTransitionShorthand(), true); |
326 case CSSPropertyWebkitAnimation: | 326 case CSSPropertyWebkitAnimation: |
327 return getLayeredShorthandValue(webkitAnimationShorthand()); | 327 return getLayeredShorthandValue(webkitAnimationShorthand(), true); |
328 case CSSPropertyMarker: { | 328 case CSSPropertyMarker: { |
329 RefPtrWillBeRawPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(C
SSPropertyMarkerStart); | 329 RefPtrWillBeRawPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(C
SSPropertyMarkerStart); |
330 if (value) | 330 if (value) |
331 return value->cssText(); | 331 return value->cssText(); |
332 return String(); | 332 return String(); |
333 } | 333 } |
334 case CSSPropertyBorderRadius: | 334 case CSSPropertyBorderRadius: |
335 return get4Values(borderRadiusShorthand()); | 335 return get4Values(borderRadiusShorthand()); |
336 default: | 336 default: |
337 return String(); | 337 return String(); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 result.append(' '); | 469 result.append(' '); |
470 result.append(bottom.value()->cssText()); | 470 result.append(bottom.value()->cssText()); |
471 } | 471 } |
472 if (showLeft) { | 472 if (showLeft) { |
473 result.append(' '); | 473 result.append(' '); |
474 result.append(left.value()->cssText()); | 474 result.append(left.value()->cssText()); |
475 } | 475 } |
476 return result.toString(); | 476 return result.toString(); |
477 } | 477 } |
478 | 478 |
479 String StylePropertySerializer::getLayeredShorthandValue(const StylePropertyShor
thand& shorthand) const | 479 String StylePropertySerializer::getLayeredShorthandValue(const StylePropertyShor
thand& shorthand, bool checkShorthandAvailable) const |
480 { | 480 { |
481 StringBuilder result; | 481 StringBuilder result; |
482 | 482 |
483 const unsigned size = shorthand.length(); | 483 const unsigned size = shorthand.length(); |
484 // Begin by collecting the properties into an array. | 484 // Begin by collecting the properties into an array. |
485 WillBeHeapVector<RefPtrWillBeMember<CSSValue> > values(size); | 485 WillBeHeapVector<RefPtrWillBeMember<CSSValue> > values(size); |
486 size_t numLayers = 0; | 486 size_t numLayers = 0; |
487 | 487 |
488 for (unsigned i = 0; i < size; ++i) { | 488 for (unsigned i = 0; i < size; ++i) { |
489 values[i] = m_propertySet.getPropertyCSSValue(shorthand.properties()[i])
; | 489 values[i] = m_propertySet.getPropertyCSSValue(shorthand.properties()[i])
; |
490 if (values[i]) { | 490 if (values[i]) { |
491 if (values[i]->isBaseValueList()) { | 491 if (values[i]->isBaseValueList()) { |
492 CSSValueList* valueList = toCSSValueList(values[i].get()); | 492 CSSValueList* valueList = toCSSValueList(values[i].get()); |
493 numLayers = std::max(valueList->length(), numLayers); | 493 numLayers = std::max(valueList->length(), numLayers); |
494 } else { | 494 } else { |
495 numLayers = std::max<size_t>(1U, numLayers); | 495 numLayers = std::max<size_t>(1U, numLayers); |
496 } | 496 } |
| 497 } else if (checkShorthandAvailable) { |
| 498 return String(); |
497 } | 499 } |
498 } | 500 } |
499 | 501 |
| 502 |
500 String commonValue; | 503 String commonValue; |
501 bool commonValueInitialized = false; | 504 bool commonValueInitialized = false; |
502 | 505 |
503 // Now stitch the properties together. Implicit initial values are flagged a
s such and | 506 // Now stitch the properties together. Implicit initial values are flagged a
s such and |
504 // can safely be omitted. | 507 // can safely be omitted. |
505 for (size_t i = 0; i < numLayers; i++) { | 508 for (size_t i = 0; i < numLayers; i++) { |
506 StringBuilder layerResult; | 509 StringBuilder layerResult; |
507 bool useRepeatXShorthand = false; | 510 bool useRepeatXShorthand = false; |
508 bool useRepeatYShorthand = false; | 511 bool useRepeatYShorthand = false; |
509 bool useSingleWordShorthand = false; | 512 bool useSingleWordShorthand = false; |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 isInitialValue = false; | 875 isInitialValue = false; |
873 if (!value->isInheritedValue()) | 876 if (!value->isInheritedValue()) |
874 isInheritedValue = false; | 877 isInheritedValue = false; |
875 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) | 878 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) |
876 return false; | 879 return false; |
877 } | 880 } |
878 return isInitialValue || isInheritedValue; | 881 return isInitialValue || isInheritedValue; |
879 } | 882 } |
880 | 883 |
881 } | 884 } |
OLD | NEW |