| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 { | 178 { |
| 179 ASSERT(property.id() == CSSPropertyVariable); | 179 ASSERT(property.id() == CSSPropertyVariable); |
| 180 StringBuilder result; | 180 StringBuilder result; |
| 181 if (isNotFirstDecl) | 181 if (isNotFirstDecl) |
| 182 result.append(' '); | 182 result.append(' '); |
| 183 const CSSCustomPropertyDeclaration* value = toCSSCustomPropertyDeclaration(p
roperty.value()); | 183 const CSSCustomPropertyDeclaration* value = toCSSCustomPropertyDeclaration(p
roperty.value()); |
| 184 result.append(value->name()); | 184 result.append(value->name()); |
| 185 result.append(':'); | 185 result.append(':'); |
| 186 result.append(value->customCSSText()); | 186 result.append(value->customCSSText()); |
| 187 if (property.isImportant()) | 187 if (property.isImportant()) |
| 188 result.appendLiteral(" !important"); | 188 result.append(" !important"); |
| 189 result.append(';'); | 189 result.append(';'); |
| 190 return result.toString(); | 190 return result.toString(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 static String getApplyAtRuleText(const CSSValue* value, bool isNotFirstDecl) | 193 static String getApplyAtRuleText(const CSSValue* value, bool isNotFirstDecl) |
| 194 { | 194 { |
| 195 StringBuilder result; | 195 StringBuilder result; |
| 196 if (isNotFirstDecl) | 196 if (isNotFirstDecl) |
| 197 result.append(' '); | 197 result.append(' '); |
| 198 result.appendLiteral("@apply "); | 198 result.append("@apply "); |
| 199 result.append(toCSSCustomIdentValue(value)->value()); | 199 result.append(toCSSCustomIdentValue(value)->value()); |
| 200 result.append(';'); | 200 result.append(';'); |
| 201 return result.toString(); | 201 return result.toString(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 String StylePropertySerializer::getPropertyText(CSSPropertyID propertyID, const
String& value, bool isImportant, bool isNotFirstDecl) const | 204 String StylePropertySerializer::getPropertyText(CSSPropertyID propertyID, const
String& value, bool isImportant, bool isNotFirstDecl) const |
| 205 { | 205 { |
| 206 StringBuilder result; | 206 StringBuilder result; |
| 207 if (isNotFirstDecl) | 207 if (isNotFirstDecl) |
| 208 result.append(' '); | 208 result.append(' '); |
| 209 result.append(getPropertyName(propertyID)); | 209 result.append(getPropertyName(propertyID)); |
| 210 result.appendLiteral(": "); | 210 result.append(": "); |
| 211 result.append(value); | 211 result.append(value); |
| 212 if (isImportant) | 212 if (isImportant) |
| 213 result.appendLiteral(" !important"); | 213 result.append(" !important"); |
| 214 result.append(';'); | 214 result.append(';'); |
| 215 return result.toString(); | 215 return result.toString(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 String StylePropertySerializer::asText() const | 218 String StylePropertySerializer::asText() const |
| 219 { | 219 { |
| 220 StringBuilder result; | 220 StringBuilder result; |
| 221 | 221 |
| 222 std::bitset<numCSSProperties> longhandSerialized; | 222 std::bitset<numCSSProperties> longhandSerialized; |
| 223 std::bitset<numCSSProperties> shorthandAppeared; | 223 std::bitset<numCSSProperties> shorthandAppeared; |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 property = shorthand.properties()[++propertyIndex]; | 735 property = shorthand.properties()[++propertyIndex]; |
| 736 } else if (xId == CSSValueNoRepeat && yId == CSSValueRepeat) { | 736 } else if (xId == CSSValueNoRepeat && yId == CSSValueRepeat) { |
| 737 useRepeatYShorthand = true; | 737 useRepeatYShorthand = true; |
| 738 property = shorthand.properties()[++propertyIndex]; | 738 property = shorthand.properties()[++propertyIndex]; |
| 739 } | 739 } |
| 740 } | 740 } |
| 741 | 741 |
| 742 if (!(value->isInitialValue() && toCSSInitialValue(value)->isImplici
t())) { | 742 if (!(value->isInitialValue() && toCSSInitialValue(value)->isImplici
t())) { |
| 743 if (property == CSSPropertyBackgroundSize || property == CSSProp
ertyWebkitMaskSize) { | 743 if (property == CSSPropertyBackgroundSize || property == CSSProp
ertyWebkitMaskSize) { |
| 744 if (foundPositionYCSSProperty || foundPositionXCSSProperty) | 744 if (foundPositionYCSSProperty || foundPositionXCSSProperty) |
| 745 layerResult.appendLiteral(" / "); | 745 layerResult.append(" / "); |
| 746 else | 746 else |
| 747 layerResult.appendLiteral(" 0% 0% / "); | 747 layerResult.append(" 0% 0% / "); |
| 748 } else if (!layerResult.isEmpty()) { | 748 } else if (!layerResult.isEmpty()) { |
| 749 // Do this second to avoid ending up with an extra space in
the output if we hit the continue above. | 749 // Do this second to avoid ending up with an extra space in
the output if we hit the continue above. |
| 750 layerResult.append(' '); | 750 layerResult.append(' '); |
| 751 } | 751 } |
| 752 | 752 |
| 753 if (useRepeatXShorthand) { | 753 if (useRepeatXShorthand) { |
| 754 useRepeatXShorthand = false; | 754 useRepeatXShorthand = false; |
| 755 layerResult.append(getValueName(CSSValueRepeatX)); | 755 layerResult.append(getValueName(CSSValueRepeatX)); |
| 756 } else if (useRepeatYShorthand) { | 756 } else if (useRepeatYShorthand) { |
| 757 useRepeatYShorthand = false; | 757 useRepeatYShorthand = false; |
| 758 layerResult.append(getValueName(CSSValueRepeatY)); | 758 layerResult.append(getValueName(CSSValueRepeatY)); |
| 759 } else { | 759 } else { |
| 760 if (useSingleWordShorthand) | 760 if (useSingleWordShorthand) |
| 761 useSingleWordShorthand = false; | 761 useSingleWordShorthand = false; |
| 762 layerResult.append(value->cssText()); | 762 layerResult.append(value->cssText()); |
| 763 } | 763 } |
| 764 if (property == CSSPropertyBackgroundPositionX || property == CS
SPropertyWebkitMaskPositionX) | 764 if (property == CSSPropertyBackgroundPositionX || property == CS
SPropertyWebkitMaskPositionX) |
| 765 foundPositionXCSSProperty = true; | 765 foundPositionXCSSProperty = true; |
| 766 if (property == CSSPropertyBackgroundPositionY || property == CS
SPropertyWebkitMaskPositionY) { | 766 if (property == CSSPropertyBackgroundPositionY || property == CS
SPropertyWebkitMaskPositionY) { |
| 767 foundPositionYCSSProperty = true; | 767 foundPositionYCSSProperty = true; |
| 768 // background-position is a special case. If only the first
offset is specified, | 768 // background-position is a special case. If only the first
offset is specified, |
| 769 // the second one defaults to "center", not the same value. | 769 // the second one defaults to "center", not the same value. |
| 770 } | 770 } |
| 771 } | 771 } |
| 772 } | 772 } |
| 773 if (!layerResult.isEmpty()) { | 773 if (!layerResult.isEmpty()) { |
| 774 if (!result.isEmpty()) | 774 if (!result.isEmpty()) |
| 775 result.appendLiteral(", "); | 775 result.append(", "); |
| 776 result.append(layerResult); | 776 result.append(layerResult); |
| 777 } | 777 } |
| 778 } | 778 } |
| 779 | 779 |
| 780 return result.toString(); | 780 return result.toString(); |
| 781 } | 781 } |
| 782 | 782 |
| 783 String StylePropertySerializer::getShorthandValue(const StylePropertyShorthand&
shorthand, String separator) const | 783 String StylePropertySerializer::getShorthandValue(const StylePropertyShorthand&
shorthand, String separator) const |
| 784 { | 784 { |
| 785 StringBuilder result; | 785 StringBuilder result; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 { | 832 { |
| 833 // FIXME: Ensure initial values do not appear in CSS_VALUE_LISTS. | 833 // FIXME: Ensure initial values do not appear in CSS_VALUE_LISTS. |
| 834 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, initialRepeatValue, (CSSPrimitiveValu
e::createIdentifier(CSSValueRepeat))); | 834 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, initialRepeatValue, (CSSPrimitiveValu
e::createIdentifier(CSSValueRepeat))); |
| 835 const CSSPrimitiveValue& repeatX = repeatXCSSValue.isInitialValue() ? initia
lRepeatValue : toCSSPrimitiveValue(repeatXCSSValue); | 835 const CSSPrimitiveValue& repeatX = repeatXCSSValue.isInitialValue() ? initia
lRepeatValue : toCSSPrimitiveValue(repeatXCSSValue); |
| 836 const CSSPrimitiveValue& repeatY = repeatYCSSValue.isInitialValue() ? initia
lRepeatValue : toCSSPrimitiveValue(repeatYCSSValue); | 836 const CSSPrimitiveValue& repeatY = repeatYCSSValue.isInitialValue() ? initia
lRepeatValue : toCSSPrimitiveValue(repeatYCSSValue); |
| 837 CSSValueID repeatXValueId = repeatX.getValueID(); | 837 CSSValueID repeatXValueId = repeatX.getValueID(); |
| 838 CSSValueID repeatYValueId = repeatY.getValueID(); | 838 CSSValueID repeatYValueId = repeatY.getValueID(); |
| 839 if (repeatXValueId == repeatYValueId) { | 839 if (repeatXValueId == repeatYValueId) { |
| 840 builder.append(repeatX.cssText()); | 840 builder.append(repeatX.cssText()); |
| 841 } else if (repeatXValueId == CSSValueNoRepeat && repeatYValueId == CSSValueR
epeat) { | 841 } else if (repeatXValueId == CSSValueNoRepeat && repeatYValueId == CSSValueR
epeat) { |
| 842 builder.appendLiteral("repeat-y"); | 842 builder.append("repeat-y"); |
| 843 } else if (repeatXValueId == CSSValueRepeat && repeatYValueId == CSSValueNoR
epeat) { | 843 } else if (repeatXValueId == CSSValueRepeat && repeatYValueId == CSSValueNoR
epeat) { |
| 844 builder.appendLiteral("repeat-x"); | 844 builder.append("repeat-x"); |
| 845 } else { | 845 } else { |
| 846 builder.append(repeatX.cssText()); | 846 builder.append(repeatX.cssText()); |
| 847 builder.appendLiteral(" "); | 847 builder.append(" "); |
| 848 builder.append(repeatY.cssText()); | 848 builder.append(repeatY.cssText()); |
| 849 } | 849 } |
| 850 } | 850 } |
| 851 | 851 |
| 852 String StylePropertySerializer::backgroundRepeatPropertyValue() const | 852 String StylePropertySerializer::backgroundRepeatPropertyValue() const |
| 853 { | 853 { |
| 854 const CSSValue* repeatX = m_propertySet.getPropertyCSSValue(CSSPropertyBackg
roundRepeatX); | 854 const CSSValue* repeatX = m_propertySet.getPropertyCSSValue(CSSPropertyBackg
roundRepeatX); |
| 855 const CSSValue* repeatY = m_propertySet.getPropertyCSSValue(CSSPropertyBackg
roundRepeatY); | 855 const CSSValue* repeatY = m_propertySet.getPropertyCSSValue(CSSPropertyBackg
roundRepeatY); |
| 856 | 856 |
| 857 const CSSValueList* repeatXList = 0; | 857 const CSSValueList* repeatXList = 0; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 869 repeatYList = toCSSValueList(repeatY); | 869 repeatYList = toCSSValueList(repeatY); |
| 870 repeatYLength = repeatYList->length(); | 870 repeatYLength = repeatYList->length(); |
| 871 } else if (!repeatY->isPrimitiveValue()) { | 871 } else if (!repeatY->isPrimitiveValue()) { |
| 872 return String(); | 872 return String(); |
| 873 } | 873 } |
| 874 | 874 |
| 875 size_t shorthandLength = lowestCommonMultiple(repeatXLength, repeatYLength); | 875 size_t shorthandLength = lowestCommonMultiple(repeatXLength, repeatYLength); |
| 876 StringBuilder builder; | 876 StringBuilder builder; |
| 877 for (size_t i = 0; i < shorthandLength; ++i) { | 877 for (size_t i = 0; i < shorthandLength; ++i) { |
| 878 if (i) | 878 if (i) |
| 879 builder.appendLiteral(", "); | 879 builder.append(", "); |
| 880 | 880 |
| 881 const CSSValue* xValue = repeatXList ? repeatXList->item(i % repeatXList
->length()) : repeatX; | 881 const CSSValue* xValue = repeatXList ? repeatXList->item(i % repeatXList
->length()) : repeatX; |
| 882 const CSSValue* yValue = repeatYList ? repeatYList->item(i % repeatYList
->length()) : repeatY; | 882 const CSSValue* yValue = repeatYList ? repeatYList->item(i % repeatYList
->length()) : repeatY; |
| 883 appendBackgroundRepeatValue(builder, *xValue, *yValue); | 883 appendBackgroundRepeatValue(builder, *xValue, *yValue); |
| 884 } | 884 } |
| 885 return builder.toString(); | 885 return builder.toString(); |
| 886 } | 886 } |
| 887 | 887 |
| 888 } // namespace blink | 888 } // namespace blink |
| OLD | NEW |