| 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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 result.append(' '); | 696 result.append(' '); |
| 697 result.append(value); | 697 result.append(value); |
| 698 } | 698 } |
| 699 if (isInitialOrInherit(commonValue)) | 699 if (isInitialOrInherit(commonValue)) |
| 700 return commonValue; | 700 return commonValue; |
| 701 return result.isEmpty() ? String() : result.toString(); | 701 return result.isEmpty() ? String() : result.toString(); |
| 702 } | 702 } |
| 703 | 703 |
| 704 String StylePropertySerializer::backgroundRepeatPropertyValue() const | 704 String StylePropertySerializer::backgroundRepeatPropertyValue() const |
| 705 { | 705 { |
| 706 RefPtrWillBeRawPtr<CSSValue> repeatX = m_propertySet.getPropertyCSSValue(CSS
PropertyBackgroundRepeatX); | 706 RefPtr<CSSValue> repeatX = m_propertySet.getPropertyCSSValue(CSSPropertyBack
groundRepeatX); |
| 707 RefPtrWillBeRawPtr<CSSValue> repeatY = m_propertySet.getPropertyCSSValue(CSS
PropertyBackgroundRepeatY); | 707 RefPtr<CSSValue> repeatY = m_propertySet.getPropertyCSSValue(CSSPropertyBack
groundRepeatY); |
| 708 if (!repeatX || !repeatY) | 708 if (!repeatX || !repeatY) |
| 709 return String(); | 709 return String(); |
| 710 if (repeatX->cssValueType() != repeatY->cssValueType()) | 710 if (repeatX->cssValueType() != repeatY->cssValueType()) |
| 711 return String(); | 711 return String(); |
| 712 if (m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX) != m_pro
pertySet.propertyIsImportant(CSSPropertyBackgroundRepeatY)) | 712 if (m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX) != m_pro
pertySet.propertyIsImportant(CSSPropertyBackgroundRepeatY)) |
| 713 return String(); | 713 return String(); |
| 714 | 714 |
| 715 StringBuilder builder; | 715 StringBuilder builder; |
| 716 switch (repeatX->cssValueType()) { | 716 switch (repeatX->cssValueType()) { |
| 717 case CSSValue::CSS_INHERIT: | 717 case CSSValue::CSS_INHERIT: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 748 | 748 |
| 749 void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu
lt, unsigned& numDecls) const | 749 void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu
lt, unsigned& numDecls) const |
| 750 { | 750 { |
| 751 if (isPropertyShorthandAvailable(backgroundShorthand())) { | 751 if (isPropertyShorthandAvailable(backgroundShorthand())) { |
| 752 String backgroundValue = getPropertyValue(CSSPropertyBackground); | 752 String backgroundValue = getPropertyValue(CSSPropertyBackground); |
| 753 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); | 753 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); |
| 754 result.append(getPropertyText(CSSPropertyBackground, backgroundValue, is
Important, numDecls++)); | 754 result.append(getPropertyText(CSSPropertyBackground, backgroundValue, is
Important, numDecls++)); |
| 755 return; | 755 return; |
| 756 } | 756 } |
| 757 if (shorthandHasOnlyInitialOrInheritedValue(backgroundShorthand())) { | 757 if (shorthandHasOnlyInitialOrInheritedValue(backgroundShorthand())) { |
| 758 RefPtrWillBeRawPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(C
SSPropertyBackgroundImage); | 758 RefPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(CSSPropertyBa
ckgroundImage); |
| 759 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); | 759 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); |
| 760 result.append(getPropertyText(CSSPropertyBackground, value->cssText(), i
sImportant, numDecls++)); | 760 result.append(getPropertyText(CSSPropertyBackground, value->cssText(), i
sImportant, numDecls++)); |
| 761 return; | 761 return; |
| 762 } | 762 } |
| 763 | 763 |
| 764 // backgroundShorthandProperty without layered shorhand properties | 764 // backgroundShorthandProperty without layered shorhand properties |
| 765 const CSSPropertyID backgroundPropertyIds[] = { | 765 const CSSPropertyID backgroundPropertyIds[] = { |
| 766 CSSPropertyBackgroundImage, | 766 CSSPropertyBackgroundImage, |
| 767 CSSPropertyBackgroundAttachment, | 767 CSSPropertyBackgroundAttachment, |
| 768 CSSPropertyBackgroundColor, | 768 CSSPropertyBackgroundColor, |
| 769 CSSPropertyBackgroundSize, | 769 CSSPropertyBackgroundSize, |
| 770 CSSPropertyBackgroundOrigin, | 770 CSSPropertyBackgroundOrigin, |
| 771 CSSPropertyBackgroundClip | 771 CSSPropertyBackgroundClip |
| 772 }; | 772 }; |
| 773 | 773 |
| 774 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(backgroundPropertyIds); ++i) { | 774 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(backgroundPropertyIds); ++i) { |
| 775 CSSPropertyID propertyID = backgroundPropertyIds[i]; | 775 CSSPropertyID propertyID = backgroundPropertyIds[i]; |
| 776 RefPtrWillBeRawPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(p
ropertyID); | 776 RefPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(propertyID); |
| 777 if (!value) | 777 if (!value) |
| 778 continue; | 778 continue; |
| 779 result.append(getPropertyText(propertyID, value->cssText(), m_propertySe
t.propertyIsImportant(propertyID), numDecls++)); | 779 result.append(getPropertyText(propertyID, value->cssText(), m_propertySe
t.propertyIsImportant(propertyID), numDecls++)); |
| 780 } | 780 } |
| 781 | 781 |
| 782 // FIXME: This is a not-so-nice way to turn x/y positions into single backgr
ound-position in output. | 782 // FIXME: This is a not-so-nice way to turn x/y positions into single backgr
ound-position in output. |
| 783 // It is required because background-position-x/y are non-standard propertie
s and WebKit generated output | 783 // It is required because background-position-x/y are non-standard propertie
s and WebKit generated output |
| 784 // would not work in Firefox (<rdar://problem/5143183>) | 784 // would not work in Firefox (<rdar://problem/5143183>) |
| 785 // It would be a better solution if background-position was CSS_PAIR. | 785 // It would be a better solution if background-position was CSS_PAIR. |
| 786 if (shorthandHasOnlyInitialOrInheritedValue(backgroundPositionShorthand()))
{ | 786 if (shorthandHasOnlyInitialOrInheritedValue(backgroundPositionShorthand()))
{ |
| 787 RefPtrWillBeRawPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(C
SSPropertyBackgroundPositionX); | 787 RefPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(CSSPropertyBa
ckgroundPositionX); |
| 788 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); | 788 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); |
| 789 result.append(getPropertyText(CSSPropertyBackgroundPosition, value->cssT
ext(), isImportant, numDecls++)); | 789 result.append(getPropertyText(CSSPropertyBackgroundPosition, value->cssT
ext(), isImportant, numDecls++)); |
| 790 } else if (isPropertyShorthandAvailable(backgroundPositionShorthand())) { | 790 } else if (isPropertyShorthandAvailable(backgroundPositionShorthand())) { |
| 791 String positionValue = m_propertySet.getPropertyValue(CSSPropertyBackgro
undPosition); | 791 String positionValue = m_propertySet.getPropertyValue(CSSPropertyBackgro
undPosition); |
| 792 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); | 792 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); |
| 793 if (!positionValue.isNull()) | 793 if (!positionValue.isNull()) |
| 794 result.append(getPropertyText(CSSPropertyBackgroundPosition, positio
nValue, isImportant, numDecls++)); | 794 result.append(getPropertyText(CSSPropertyBackgroundPosition, positio
nValue, isImportant, numDecls++)); |
| 795 } else { | 795 } else { |
| 796 // should check background-position-x or background-position-y. | 796 // should check background-position-x or background-position-y. |
| 797 if (RefPtrWillBeRawPtr<CSSValue> value = m_propertySet.getPropertyCSSVal
ue(CSSPropertyBackgroundPositionX)) { | 797 if (RefPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(CSSProper
tyBackgroundPositionX)) { |
| 798 if (!value->isImplicitInitialValue()) { | 798 if (!value->isImplicitInitialValue()) { |
| 799 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionX); | 799 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionX); |
| 800 result.append(getPropertyText(CSSPropertyBackgroundPositionX, va
lue->cssText(), isImportant, numDecls++)); | 800 result.append(getPropertyText(CSSPropertyBackgroundPositionX, va
lue->cssText(), isImportant, numDecls++)); |
| 801 } | 801 } |
| 802 } | 802 } |
| 803 if (RefPtrWillBeRawPtr<CSSValue> value = m_propertySet.getPropertyCSSVal
ue(CSSPropertyBackgroundPositionY)) { | 803 if (RefPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(CSSProper
tyBackgroundPositionY)) { |
| 804 if (!value->isImplicitInitialValue()) { | 804 if (!value->isImplicitInitialValue()) { |
| 805 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionY); | 805 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionY); |
| 806 result.append(getPropertyText(CSSPropertyBackgroundPositionY, va
lue->cssText(), isImportant, numDecls++)); | 806 result.append(getPropertyText(CSSPropertyBackgroundPositionY, va
lue->cssText(), isImportant, numDecls++)); |
| 807 } | 807 } |
| 808 } | 808 } |
| 809 } | 809 } |
| 810 | 810 |
| 811 String repeatValue = m_propertySet.getPropertyValue(CSSPropertyBackgroundRep
eat); | 811 String repeatValue = m_propertySet.getPropertyValue(CSSPropertyBackgroundRep
eat); |
| 812 if (!repeatValue.isNull()) | 812 if (!repeatValue.isNull()) |
| 813 result.append(getPropertyText(CSSPropertyBackgroundRepeat, repeatValue,
m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX), numDecls++)); | 813 result.append(getPropertyText(CSSPropertyBackgroundRepeat, repeatValue,
m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX), numDecls++)); |
| 814 } | 814 } |
| 815 | 815 |
| 816 bool StylePropertySerializer::isPropertyShorthandAvailable(const StylePropertySh
orthand& shorthand) const | 816 bool StylePropertySerializer::isPropertyShorthandAvailable(const StylePropertySh
orthand& shorthand) const |
| 817 { | 817 { |
| 818 ASSERT(shorthand.length() > 0); | 818 ASSERT(shorthand.length() > 0); |
| 819 | 819 |
| 820 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); | 820 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); |
| 821 for (unsigned i = 0; i < shorthand.length(); ++i) { | 821 for (unsigned i = 0; i < shorthand.length(); ++i) { |
| 822 RefPtrWillBeRawPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(s
horthand.properties()[i]); | 822 RefPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(shorthand.pro
perties()[i]); |
| 823 if (!value || (value->isInitialValue() && !value->isImplicitInitialValue
()) || value->isInheritedValue()) | 823 if (!value || (value->isInitialValue() && !value->isImplicitInitialValue
()) || value->isInheritedValue()) |
| 824 return false; | 824 return false; |
| 825 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) | 825 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) |
| 826 return false; | 826 return false; |
| 827 } | 827 } |
| 828 return true; | 828 return true; |
| 829 } | 829 } |
| 830 | 830 |
| 831 bool StylePropertySerializer::shorthandHasOnlyInitialOrInheritedValue(const Styl
ePropertyShorthand& shorthand) const | 831 bool StylePropertySerializer::shorthandHasOnlyInitialOrInheritedValue(const Styl
ePropertyShorthand& shorthand) const |
| 832 { | 832 { |
| 833 ASSERT(shorthand.length() > 0); | 833 ASSERT(shorthand.length() > 0); |
| 834 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); | 834 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); |
| 835 bool isInitialValue = true; | 835 bool isInitialValue = true; |
| 836 bool isInheritedValue = true; | 836 bool isInheritedValue = true; |
| 837 for (unsigned i = 0; i < shorthand.length(); ++i) { | 837 for (unsigned i = 0; i < shorthand.length(); ++i) { |
| 838 RefPtrWillBeRawPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(s
horthand.properties()[i]); | 838 RefPtr<CSSValue> value = m_propertySet.getPropertyCSSValue(shorthand.pro
perties()[i]); |
| 839 if (!value) | 839 if (!value) |
| 840 return false; | 840 return false; |
| 841 if (!value->isInitialValue()) | 841 if (!value->isInitialValue()) |
| 842 isInitialValue = false; | 842 isInitialValue = false; |
| 843 if (!value->isInheritedValue()) | 843 if (!value->isInheritedValue()) |
| 844 isInheritedValue = false; | 844 isInheritedValue = false; |
| 845 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) | 845 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) |
| 846 return false; | 846 return false; |
| 847 } | 847 } |
| 848 return isInitialValue || isInheritedValue; | 848 return isInitialValue || isInheritedValue; |
| 849 } | 849 } |
| 850 | 850 |
| 851 } | 851 } |
| OLD | NEW |