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 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 case CSSPropertyWebkitFlexFlow: | 165 case CSSPropertyWebkitFlexFlow: |
166 return getShorthandValue(webkitFlexFlowShorthand()); | 166 return getShorthandValue(webkitFlexFlowShorthand()); |
167 case CSSPropertyFont: | 167 case CSSPropertyFont: |
168 return fontValue(); | 168 return fontValue(); |
169 case CSSPropertyMargin: | 169 case CSSPropertyMargin: |
170 return get4Values(marginShorthand()); | 170 return get4Values(marginShorthand()); |
171 case CSSPropertyOverflow: | 171 case CSSPropertyOverflow: |
172 return getCommonValue(overflowShorthand()); | 172 return getCommonValue(overflowShorthand()); |
173 case CSSPropertyPadding: | 173 case CSSPropertyPadding: |
174 return get4Values(paddingShorthand()); | 174 return get4Values(paddingShorthand()); |
| 175 case CSSPropertyTransition: |
| 176 return getLayeredShorthandValue(transitionShorthand()); |
175 case CSSPropertyListStyle: | 177 case CSSPropertyListStyle: |
176 return getShorthandValue(listStyleShorthand()); | 178 return getShorthandValue(listStyleShorthand()); |
177 case CSSPropertyWebkitMaskPosition: | 179 case CSSPropertyWebkitMaskPosition: |
178 return getLayeredShorthandValue(webkitMaskPositionShorthand()); | 180 return getLayeredShorthandValue(webkitMaskPositionShorthand()); |
179 case CSSPropertyWebkitMaskRepeat: | 181 case CSSPropertyWebkitMaskRepeat: |
180 return getLayeredShorthandValue(webkitMaskRepeatShorthand()); | 182 return getLayeredShorthandValue(webkitMaskRepeatShorthand()); |
181 case CSSPropertyWebkitMask: | 183 case CSSPropertyWebkitMask: |
182 return getLayeredShorthandValue(webkitMaskShorthand()); | 184 return getLayeredShorthandValue(webkitMaskShorthand()); |
183 case CSSPropertyWebkitTextEmphasis: | 185 case CSSPropertyWebkitTextEmphasis: |
184 return getShorthandValue(webkitTextEmphasisShorthand()); | 186 return getShorthandValue(webkitTextEmphasisShorthand()); |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 return 0; | 573 return 0; |
572 return propertyAt(foundPropertyIndex).value(); | 574 return propertyAt(foundPropertyIndex).value(); |
573 } | 575 } |
574 | 576 |
575 bool StylePropertySet::removeShorthandProperty(CSSPropertyID propertyID) | 577 bool StylePropertySet::removeShorthandProperty(CSSPropertyID propertyID) |
576 { | 578 { |
577 ASSERT(isMutable()); | 579 ASSERT(isMutable()); |
578 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); | 580 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); |
579 if (!shorthand.length()) | 581 if (!shorthand.length()) |
580 return false; | 582 return false; |
581 return removePropertiesInSet(shorthand.properties(), shorthand.length()); | 583 |
| 584 bool ret = removePropertiesInSet(shorthand.properties(), shorthand.length())
; |
| 585 |
| 586 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propertyID); |
| 587 if (prefixingVariant == propertyID) |
| 588 return ret; |
| 589 |
| 590 StylePropertyShorthand shorthandPrefixingVariant = shorthandForProperty(pref
ixingVariant); |
| 591 return removePropertiesInSet(shorthandPrefixingVariant.properties(), shortha
ndPrefixingVariant.length()); |
582 } | 592 } |
583 | 593 |
584 bool StylePropertySet::removeProperty(CSSPropertyID propertyID, String* returnTe
xt) | 594 bool StylePropertySet::removeProperty(CSSPropertyID propertyID, String* returnTe
xt) |
585 { | 595 { |
586 ASSERT(isMutable()); | 596 ASSERT(isMutable()); |
587 if (removeShorthandProperty(propertyID)) { | 597 if (removeShorthandProperty(propertyID)) { |
588 // FIXME: Return an equivalent shorthand when possible. | 598 // FIXME: Return an equivalent shorthand when possible. |
589 if (returnText) | 599 if (returnText) |
590 *returnText = ""; | 600 *returnText = ""; |
591 return true; | 601 return true; |
592 } | 602 } |
593 | 603 |
594 int foundPropertyIndex = findPropertyIndex(propertyID); | 604 int foundPropertyIndex = findPropertyIndex(propertyID); |
595 if (foundPropertyIndex == -1) { | 605 if (foundPropertyIndex == -1) { |
596 if (returnText) | 606 if (returnText) |
597 *returnText = ""; | 607 *returnText = ""; |
598 return false; | 608 return false; |
599 } | 609 } |
600 | 610 |
601 if (returnText) | 611 if (returnText) |
602 *returnText = propertyAt(foundPropertyIndex).value()->cssText(); | 612 *returnText = propertyAt(foundPropertyIndex).value()->cssText(); |
603 | 613 |
604 // A more efficient removal strategy would involve marking entries as empty | 614 // A more efficient removal strategy would involve marking entries as empty |
605 // and sweeping them when the vector grows too big. | 615 // and sweeping them when the vector grows too big. |
606 mutablePropertyVector().remove(foundPropertyIndex); | 616 mutablePropertyVector().remove(foundPropertyIndex); |
607 | 617 |
| 618 removePrefixedOrUnprefixedProperty(propertyID); |
| 619 |
608 return true; | 620 return true; |
609 } | 621 } |
610 | 622 |
| 623 void StylePropertySet::removePrefixedOrUnprefixedProperty(CSSPropertyID property
ID) |
| 624 { |
| 625 int foundPropertyIndex = findPropertyIndex(prefixingVariantForPropertyId(pro
pertyID)); |
| 626 if (foundPropertyIndex == -1) |
| 627 return; |
| 628 mutablePropertyVector().remove(foundPropertyIndex); |
| 629 } |
| 630 |
611 bool StylePropertySet::propertyIsImportant(CSSPropertyID propertyID) const | 631 bool StylePropertySet::propertyIsImportant(CSSPropertyID propertyID) const |
612 { | 632 { |
613 int foundPropertyIndex = findPropertyIndex(propertyID); | 633 int foundPropertyIndex = findPropertyIndex(propertyID); |
614 if (foundPropertyIndex != -1) | 634 if (foundPropertyIndex != -1) |
615 return propertyAt(foundPropertyIndex).isImportant(); | 635 return propertyAt(foundPropertyIndex).isImportant(); |
616 | 636 |
617 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); | 637 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); |
618 if (!shorthand.length()) | 638 if (!shorthand.length()) |
619 return false; | 639 return false; |
620 | 640 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 mutablePropertyVector().append(CSSProperty(shorthand.properties()[i], va
lue, important)); | 692 mutablePropertyVector().append(CSSProperty(shorthand.properties()[i], va
lue, important)); |
673 } | 693 } |
674 | 694 |
675 void StylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slo
t) | 695 void StylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slo
t) |
676 { | 696 { |
677 ASSERT(isMutable()); | 697 ASSERT(isMutable()); |
678 if (!removeShorthandProperty(property.id())) { | 698 if (!removeShorthandProperty(property.id())) { |
679 CSSProperty* toReplace = slot ? slot : findMutableCSSPropertyWithID(prop
erty.id()); | 699 CSSProperty* toReplace = slot ? slot : findMutableCSSPropertyWithID(prop
erty.id()); |
680 if (toReplace) { | 700 if (toReplace) { |
681 *toReplace = property; | 701 *toReplace = property; |
| 702 setPrefixingVariantProperty(property); |
682 return; | 703 return; |
683 } | 704 } |
684 } | 705 } |
| 706 appendPrefixingVariantProperty(property); |
| 707 } |
| 708 |
| 709 void StylePropertySet::appendPrefixingVariantProperty(const CSSProperty& propert
y) |
| 710 { |
685 mutablePropertyVector().append(property); | 711 mutablePropertyVector().append(property); |
| 712 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id()
); |
| 713 if (prefixingVariant == property.id()) |
| 714 return; |
| 715 mutablePropertyVector().append(CSSProperty(prefixingVariant, property.value(
), property.isImportant(), property.shorthandID(), property.metadata().m_implici
t)); |
| 716 } |
| 717 |
| 718 void StylePropertySet::setPrefixingVariantProperty(const CSSProperty& property) |
| 719 { |
| 720 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id()
); |
| 721 CSSProperty* toReplace = findMutableCSSPropertyWithID(prefixingVariant); |
| 722 if (toReplace) |
| 723 *toReplace = CSSProperty(prefixingVariant, property.value(), property.is
Important(), property.shorthandID(), property.metadata().m_implicit); |
686 } | 724 } |
687 | 725 |
688 bool StylePropertySet::setProperty(CSSPropertyID propertyID, int identifier, boo
l important) | 726 bool StylePropertySet::setProperty(CSSPropertyID propertyID, int identifier, boo
l important) |
689 { | 727 { |
690 ASSERT(isMutable()); | 728 ASSERT(isMutable()); |
691 setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(ide
ntifier), important)); | 729 setProperty(CSSProperty(propertyID, cssValuePool().createIdentifierValue(ide
ntifier), important)); |
692 return true; | 730 return true; |
693 } | 731 } |
694 | 732 |
695 void StylePropertySet::parseDeclaration(const String& styleDeclaration, StyleShe
etContents* contextStyleSheet) | 733 void StylePropertySet::parseDeclaration(const String& styleDeclaration, StyleShe
etContents* contextStyleSheet) |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 case CSSPropertyOverflowX: | 864 case CSSPropertyOverflowX: |
827 case CSSPropertyOverflowY: | 865 case CSSPropertyOverflowY: |
828 shorthandPropertyID = CSSPropertyOverflow; | 866 shorthandPropertyID = CSSPropertyOverflow; |
829 break; | 867 break; |
830 case CSSPropertyPaddingTop: | 868 case CSSPropertyPaddingTop: |
831 case CSSPropertyPaddingRight: | 869 case CSSPropertyPaddingRight: |
832 case CSSPropertyPaddingBottom: | 870 case CSSPropertyPaddingBottom: |
833 case CSSPropertyPaddingLeft: | 871 case CSSPropertyPaddingLeft: |
834 shorthandPropertyID = CSSPropertyPadding; | 872 shorthandPropertyID = CSSPropertyPadding; |
835 break; | 873 break; |
| 874 case CSSPropertyTransitionProperty: |
| 875 case CSSPropertyTransitionDuration: |
| 876 case CSSPropertyTransitionTimingFunction: |
| 877 case CSSPropertyTransitionDelay: |
| 878 shorthandPropertyID = CSSPropertyTransition; |
| 879 break; |
836 case CSSPropertyWebkitAnimationName: | 880 case CSSPropertyWebkitAnimationName: |
837 case CSSPropertyWebkitAnimationDuration: | 881 case CSSPropertyWebkitAnimationDuration: |
838 case CSSPropertyWebkitAnimationTimingFunction: | 882 case CSSPropertyWebkitAnimationTimingFunction: |
839 case CSSPropertyWebkitAnimationDelay: | 883 case CSSPropertyWebkitAnimationDelay: |
840 case CSSPropertyWebkitAnimationIterationCount: | 884 case CSSPropertyWebkitAnimationIterationCount: |
841 case CSSPropertyWebkitAnimationDirection: | 885 case CSSPropertyWebkitAnimationDirection: |
842 case CSSPropertyWebkitAnimationFillMode: | 886 case CSSPropertyWebkitAnimationFillMode: |
843 shorthandPropertyID = CSSPropertyWebkitAnimation; | 887 shorthandPropertyID = CSSPropertyWebkitAnimation; |
844 break; | 888 break; |
845 case CSSPropertyWebkitFlexDirection: | 889 case CSSPropertyWebkitFlexDirection: |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 void StylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other) | 1028 void StylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other) |
985 { | 1029 { |
986 ASSERT(isMutable()); | 1030 ASSERT(isMutable()); |
987 unsigned size = other->propertyCount(); | 1031 unsigned size = other->propertyCount(); |
988 for (unsigned n = 0; n < size; ++n) { | 1032 for (unsigned n = 0; n < size; ++n) { |
989 PropertyReference toMerge = other->propertyAt(n); | 1033 PropertyReference toMerge = other->propertyAt(n); |
990 CSSProperty* old = findMutableCSSPropertyWithID(toMerge.id()); | 1034 CSSProperty* old = findMutableCSSPropertyWithID(toMerge.id()); |
991 if (old) | 1035 if (old) |
992 setProperty(toMerge.toCSSProperty(), old); | 1036 setProperty(toMerge.toCSSProperty(), old); |
993 else | 1037 else |
994 mutablePropertyVector().append(toMerge.toCSSProperty()); | 1038 appendPrefixingVariantProperty(toMerge.toCSSProperty()); |
995 } | 1039 } |
996 } | 1040 } |
997 | 1041 |
998 void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls, StyleShe
etContents* contextStyleSheet) const | 1042 void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls, StyleShe
etContents* contextStyleSheet) const |
999 { | 1043 { |
1000 unsigned size = propertyCount(); | 1044 unsigned size = propertyCount(); |
1001 for (unsigned i = 0; i < size; ++i) | 1045 for (unsigned i = 0; i < size; ++i) |
1002 propertyAt(i).value()->addSubresourceStyleURLs(urls, contextStyleSheet); | 1046 propertyAt(i).value()->addSubresourceStyleURLs(urls, contextStyleSheet); |
1003 } | 1047 } |
1004 | 1048 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 result.appendLiteral(": "); | 1306 result.appendLiteral(": "); |
1263 result.append(propertyValue()->cssText()); | 1307 result.append(propertyValue()->cssText()); |
1264 if (isImportant()) | 1308 if (isImportant()) |
1265 result.appendLiteral(" !important"); | 1309 result.appendLiteral(" !important"); |
1266 result.append(';'); | 1310 result.append(';'); |
1267 return result.toString(); | 1311 return result.toString(); |
1268 } | 1312 } |
1269 | 1313 |
1270 | 1314 |
1271 } // namespace WebCore | 1315 } // namespace WebCore |
OLD | NEW |