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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 case CSSPropertyWebkitMarginCollapse: | 318 case CSSPropertyWebkitMarginCollapse: |
319 case CSSPropertyListStyle: | 319 case CSSPropertyListStyle: |
320 case CSSPropertyWebkitTextEmphasis: | 320 case CSSPropertyWebkitTextEmphasis: |
321 case CSSPropertyWebkitTextStroke: | 321 case CSSPropertyWebkitTextStroke: |
322 return true; | 322 return true; |
323 default: | 323 default: |
324 return false; | 324 return false; |
325 } | 325 } |
326 } | 326 } |
327 | 327 |
328 // TODO(timloh): This should go away eventually, see crbug.com/471917 | |
329 static bool allowImplicitInitialInShorthand(CSSPropertyID propertyID) | |
330 { | |
331 return propertyID == CSSPropertyBackground || propertyID == CSSPropertyWebki
tMask; | |
332 } | |
333 | |
334 String StylePropertySerializer::commonShorthandChecks(const StylePropertyShortha
nd& shorthand) const | 328 String StylePropertySerializer::commonShorthandChecks(const StylePropertyShortha
nd& shorthand) const |
335 { | 329 { |
336 int longhandCount = shorthand.length(); | 330 int longhandCount = shorthand.length(); |
337 DCHECK_LE(longhandCount, 17); | 331 DCHECK_LE(longhandCount, 17); |
338 const CSSValue* longhands[17] = {}; | 332 const CSSValue* longhands[17] = {}; |
339 | 333 |
340 bool hasImportant = false; | 334 bool hasImportant = false; |
341 bool hasNonImportant = false; | 335 bool hasNonImportant = false; |
342 | 336 |
343 for (int i = 0; i < longhandCount; i++) { | 337 for (int i = 0; i < longhandCount; i++) { |
(...skipping 21 matching lines...) Expand all Loading... |
365 } | 359 } |
366 } | 360 } |
367 if (success) { | 361 if (success) { |
368 if (longhands[0]->isPendingSubstitutionValue()) | 362 if (longhands[0]->isPendingSubstitutionValue()) |
369 return toCSSPendingSubstitutionValue(longhands[0])->shorthandVal
ue()->cssText(); | 363 return toCSSPendingSubstitutionValue(longhands[0])->shorthandVal
ue()->cssText(); |
370 return longhands[0]->cssText(); | 364 return longhands[0]->cssText(); |
371 } | 365 } |
372 } | 366 } |
373 | 367 |
374 bool allowInitial = allowInitialInShorthand(shorthand.id()); | 368 bool allowInitial = allowInitialInShorthand(shorthand.id()); |
375 bool allowImplicitInitial = allowInitial || allowImplicitInitialInShorthand(
shorthand.id()); | |
376 for (int i = 0; i < longhandCount; i++) { | 369 for (int i = 0; i < longhandCount; i++) { |
377 const CSSValue& value = *longhands[i]; | 370 const CSSValue& value = *longhands[i]; |
378 if (value.isImplicitInitialValue()) { | 371 if (value.isImplicit()) |
379 if (allowImplicitInitial) | |
380 continue; | 372 continue; |
381 return emptyString(); | |
382 } | |
383 if (!allowInitial && value.isInitialValue()) | 373 if (!allowInitial && value.isInitialValue()) |
384 return emptyString(); | 374 return emptyString(); |
385 if (value.isInheritedValue() || value.isUnsetValue() || value.isPendingS
ubstitutionValue()) | 375 if (value.isInheritedValue() || value.isUnsetValue() || value.isPendingS
ubstitutionValue()) |
386 return emptyString(); | 376 return emptyString(); |
387 if (value.isVariableReferenceValue()) | 377 if (value.isVariableReferenceValue()) |
388 return emptyString(); | 378 return emptyString(); |
389 } | 379 } |
390 | 380 |
391 return String(); | 381 return String(); |
392 } | 382 } |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 if ((propertyIndex < size - 1 && m_propertySet.isPropertyImplicit(pr
operty)) | 692 if ((propertyIndex < size - 1 && m_propertySet.isPropertyImplicit(pr
operty)) |
703 && (property == CSSPropertyBackgroundRepeatX || property == CSSP
ropertyWebkitMaskRepeatX)) { | 693 && (property == CSSPropertyBackgroundRepeatX || property == CSSP
ropertyWebkitMaskRepeatX)) { |
704 ASSERT(shorthand.properties()[propertyIndex + 1] == CSSPropertyB
ackgroundRepeatY | 694 ASSERT(shorthand.properties()[propertyIndex + 1] == CSSPropertyB
ackgroundRepeatY |
705 || shorthand.properties()[propertyIndex + 1] == CSSPropertyW
ebkitMaskRepeatY); | 695 || shorthand.properties()[propertyIndex + 1] == CSSPropertyW
ebkitMaskRepeatY); |
706 const CSSValue& yValue = values[propertyIndex + 1]->isValueList(
) ? | 696 const CSSValue& yValue = values[propertyIndex + 1]->isValueList(
) ? |
707 toCSSValueList(values[propertyIndex + 1])->item(layer) : *va
lues[propertyIndex + 1]; | 697 toCSSValueList(values[propertyIndex + 1])->item(layer) : *va
lues[propertyIndex + 1]; |
708 | 698 |
709 | 699 |
710 // FIXME: At some point we need to fix this code to avoid return
ing an invalid shorthand, | 700 // FIXME: At some point we need to fix this code to avoid return
ing an invalid shorthand, |
711 // since some longhand combinations are not serializable into a
single shorthand. | 701 // since some longhand combinations are not serializable into a
single shorthand. |
712 if (!value->isPrimitiveValue() || !yValue.isPrimitiveValue()) | 702 if (!value->isPrimitiveValue() || !yValue.isPrimitiveValue() ||
value->isImplicit() || yValue.isImplicit()) |
713 continue; | 703 continue; |
714 | 704 |
715 CSSValueID xId = toCSSPrimitiveValue(value)->getValueID(); | 705 CSSValueID xId = toCSSPrimitiveValue(value)->getValueID(); |
716 CSSValueID yId = toCSSPrimitiveValue(yValue).getValueID(); | 706 CSSValueID yId = toCSSPrimitiveValue(yValue).getValueID(); |
717 // Maybe advance propertyIndex to look at the next CSSValue in t
he list for the checks below. | 707 // Maybe advance propertyIndex to look at the next CSSValue in t
he list for the checks below. |
718 if (xId == yId) { | 708 if (xId == yId) { |
719 useSingleWordShorthand = true; | 709 useSingleWordShorthand = true; |
720 property = shorthand.properties()[++propertyIndex]; | 710 property = shorthand.properties()[++propertyIndex]; |
721 } else if (xId == CSSValueRepeat && yId == CSSValueNoRepeat) { | 711 } else if (xId == CSSValueRepeat && yId == CSSValueNoRepeat) { |
722 useRepeatXShorthand = true; | 712 useRepeatXShorthand = true; |
723 property = shorthand.properties()[++propertyIndex]; | 713 property = shorthand.properties()[++propertyIndex]; |
724 } else if (xId == CSSValueNoRepeat && yId == CSSValueRepeat) { | 714 } else if (xId == CSSValueNoRepeat && yId == CSSValueRepeat) { |
725 useRepeatYShorthand = true; | 715 useRepeatYShorthand = true; |
726 property = shorthand.properties()[++propertyIndex]; | 716 property = shorthand.properties()[++propertyIndex]; |
727 } | 717 } |
728 } | 718 } |
729 | 719 |
730 if (!(value->isInitialValue() && toCSSInitialValue(value)->isImplici
t())) { | 720 if (!(value->isImplicit())) { |
731 if (property == CSSPropertyBackgroundSize || property == CSSProp
ertyWebkitMaskSize) { | 721 if (property == CSSPropertyBackgroundSize || property == CSSProp
ertyWebkitMaskSize) { |
732 if (foundPositionYCSSProperty || foundPositionXCSSProperty) | 722 if (foundPositionYCSSProperty || foundPositionXCSSProperty) |
733 layerResult.append(" / "); | 723 layerResult.append(" / "); |
734 else | 724 else |
735 layerResult.append(" 0% 0% / "); | 725 layerResult.append(" 0% 0% / "); |
736 } else if (!layerResult.isEmpty()) { | 726 } else if (!layerResult.isEmpty()) { |
737 // Do this second to avoid ending up with an extra space in
the output if we hit the continue above. | 727 // Do this second to avoid ending up with an extra space in
the output if we hit the continue above. |
738 layerResult.append(' '); | 728 layerResult.append(' '); |
739 } | 729 } |
740 | 730 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 } | 772 } |
783 return result.toString(); | 773 return result.toString(); |
784 } | 774 } |
785 | 775 |
786 // only returns a non-null value if all properties have the same, non-null value | 776 // only returns a non-null value if all properties have the same, non-null value |
787 String StylePropertySerializer::getCommonValue(const StylePropertyShorthand& sho
rthand) const | 777 String StylePropertySerializer::getCommonValue(const StylePropertyShorthand& sho
rthand) const |
788 { | 778 { |
789 String res; | 779 String res; |
790 for (unsigned i = 0; i < shorthand.length(); ++i) { | 780 for (unsigned i = 0; i < shorthand.length(); ++i) { |
791 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.prop
erties()[i]); | 781 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.prop
erties()[i]); |
792 // FIXME: CSSInitialValue::cssText should generate the right value. | |
793 String text = value->cssText(); | 782 String text = value->cssText(); |
| 783 if (value->isImplicit()) |
| 784 text = "initial"; |
794 if (res.isNull()) | 785 if (res.isNull()) |
795 res = text; | 786 res = text; |
796 else if (res != text) | 787 else if (res != text) |
797 return String(); | 788 return String(); |
798 } | 789 } |
799 return res; | 790 return res; |
800 } | 791 } |
801 | 792 |
802 String StylePropertySerializer::borderPropertyValue() const | 793 String StylePropertySerializer::borderPropertyValue() const |
803 { | 794 { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 builder.append(", "); | 858 builder.append(", "); |
868 | 859 |
869 const CSSValue& xValue = repeatXList ? repeatXList->item(i % repeatXList
->length()) : repeatX; | 860 const CSSValue& xValue = repeatXList ? repeatXList->item(i % repeatXList
->length()) : repeatX; |
870 const CSSValue& yValue = repeatYList ? repeatYList->item(i % repeatYList
->length()) : repeatY; | 861 const CSSValue& yValue = repeatYList ? repeatYList->item(i % repeatYList
->length()) : repeatY; |
871 appendBackgroundRepeatValue(builder, xValue, yValue); | 862 appendBackgroundRepeatValue(builder, xValue, yValue); |
872 } | 863 } |
873 return builder.toString(); | 864 return builder.toString(); |
874 } | 865 } |
875 | 866 |
876 } // namespace blink | 867 } // namespace blink |
OLD | NEW |