Changeset 144626 in webkit
- Timestamp:
- Mar 4, 2013 7:09:04 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r144624 r144626 1 2013-03-04 Alexis Menard <alexis@webkit.org> 2 3 transition properties can't be found in CSSStyleDeclaration 4 https://bugs.webkit.org/show_bug.cgi?id=110011 5 6 Reviewed by Antti Koivisto. 7 8 Updated layout test to cover the bug. 9 10 * transitions/transitions-parsing-expected.txt: 11 * transitions/transitions-parsing.html: 12 1 13 2013-03-04 Antoine Quint <graouts@apple.com> 2 14 -
trunk/LayoutTests/transitions/transitions-parsing-expected.txt
r143948 r144626 7 7 PASS computedStyle.transitionProperty is 'all' 8 8 PASS computedStyle.webkitTransitionProperty is 'all' 9 PASS Object.keys(style).indexOf('transitionProperty') is not -1 10 PASS Object.keys(style).indexOf('webkitTransitionProperty') is not -1 9 11 PASS style.transitionProperty is 'none' 10 12 PASS computedStyle.transitionProperty is 'none' … … 99 101 PASS computedStyle.transitionDuration is '0s' 100 102 PASS computedStyle.webkitTransitionDuration is '0s' 103 PASS Object.keys(style).indexOf('transitionDuration') is not -1 104 PASS Object.keys(style).indexOf('webkitTransitionDuration') is not -1 101 105 PASS style.transitionDuration is '0s' 102 106 PASS computedStyle.transitionDuration is '0s' … … 147 151 PASS computedStyle.transitionTimingFunction is 'ease' 148 152 PASS computedStyle.webkitTransitionTimingFunction is 'ease' 153 PASS Object.keys(style).indexOf('transitionTimingFunction') is not -1 154 PASS Object.keys(style).indexOf('webkitTransitionTimingFunction') is not -1 149 155 PASS style.transitionTimingFunction is 'linear' 150 156 PASS computedStyle.transitionTimingFunction is 'linear' … … 291 297 PASS computedStyle.transitionDelay is '0s' 292 298 PASS computedStyle.webkitTransitionDelay is '0s' 299 PASS Object.keys(style).indexOf('transitionDelay') is not -1 300 PASS Object.keys(style).indexOf('webkitTransitionDelay') is not -1 293 301 PASS style.transitionDelay is '0s' 294 302 PASS computedStyle.transitionDelay is '0s' … … 339 347 PASS computedStyle.transition is 'all 0s ease 0s' 340 348 PASS computedStyle.webkitTransition is 'all 0s ease 0s' 349 PASS Object.keys(style).indexOf('transition') is not -1 350 PASS Object.keys(style).indexOf('webkitTransition') is not -1 341 351 PASS style.transition is 'none' 342 352 PASS computedStyle.transition is 'none 0s ease 0s' -
trunk/LayoutTests/transitions/transitions-parsing.html
r143948 r144626 31 31 32 32 style.transitionProperty = "none"; 33 shouldNotBe("Object.keys(style).indexOf('transitionProperty')", "-1"); 34 shouldNotBe("Object.keys(style).indexOf('webkitTransitionProperty')", "-1"); 33 35 shouldBe("style.transitionProperty", "'none'"); 34 36 shouldBe("computedStyle.transitionProperty", "'none'"); … … 173 175 174 176 style.transitionDuration = "0s"; 177 shouldNotBe("Object.keys(style).indexOf('transitionDuration')", "-1"); 178 shouldNotBe("Object.keys(style).indexOf('webkitTransitionDuration')", "-1"); 175 179 shouldBe("style.transitionDuration", "'0s'"); 176 180 shouldBe("computedStyle.transitionDuration", "'0s'"); … … 251 255 252 256 style.transitionTimingFunction = "linear"; 257 shouldNotBe("Object.keys(style).indexOf('transitionTimingFunction')", "-1"); 258 shouldNotBe("Object.keys(style).indexOf('webkitTransitionTimingFunction')", "-1"); 253 259 shouldBe("style.transitionTimingFunction", "'linear'"); 254 260 shouldBe("computedStyle.transitionTimingFunction", "'linear'"); … … 472 478 473 479 style.transitionDelay = "0s"; 480 shouldNotBe("Object.keys(style).indexOf('transitionDelay')", "-1"); 481 shouldNotBe("Object.keys(style).indexOf('webkitTransitionDelay')", "-1"); 474 482 shouldBe("style.transitionDelay", "'0s'"); 475 483 shouldBe("computedStyle.transitionDelay", "'0s'"); … … 550 558 551 559 style.transition = "none"; 560 shouldNotBe("Object.keys(style).indexOf('transition')", "-1"); 561 shouldNotBe("Object.keys(style).indexOf('webkitTransition')", "-1"); 552 562 shouldBe("style.transition", "'none'"); 553 563 shouldBe("computedStyle.transition", "'none 0s ease 0s'"); -
trunk/Source/WebCore/ChangeLog
r144625 r144626 1 2013-03-04 Alexis Menard <alexis@webkit.org> 2 3 transition properties can't be found in CSSStyleDeclaration 4 https://bugs.webkit.org/show_bug.cgi?id=110011 5 6 Reviewed by Antti Koivisto. 7 8 The previous approach for handling the unprefixing was to alias the 9 unprefixed properties with the prefixed ones in CSSPropertyNames.in. 10 Unfortunately it will alias the properties in the parsing code which will just 11 identically parse the two versions. This means that when we populate StylePropertySet 12 we do not have information whether we just parsed the prefixed, the 13 unprefixed properties or we parsed both. The patch takes another 14 approach by creating two distinct sets of properties (unprefixed and 15 prefixed). Each properties have their own id and we now handle them in 16 the parsing code as disctints properties and add both versions to the 17 declared style. In order to avoid properties getting out of sync, 18 this patch adds few facilities to StylePropertySet to update the 19 prefixed and the unprefixed entries. Finally the style resolution 20 happens only for the prefixed version (to limit the size of this patch) 21 and the unprefixed versions are not resolved. This is to avoid creating 22 the animation objects twice for the resolved style. 23 24 Test : transitions/transitions-parsing.html 25 26 * css/CSSComputedStyleDeclaration.cpp: 27 (WebCore): 28 (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): 29 * css/CSSParser.cpp: 30 (WebCore::CSSParser::addPropertyWithPrefixingVariant): Always add the 31 prefixed and the unprefixed property even if only one is specified. 32 (WebCore): 33 (WebCore::CSSParser::parseValue): 34 (WebCore::CSSParser::parseTransitionShorthand): Add both prefixed and 35 unprefixed longhands to the declarated style. 36 (WebCore::CSSParser::parseAnimationProperty): 37 * css/CSSParser.h: 38 (CSSParser): 39 * css/CSSProperty.cpp: 40 (WebCore::CSSProperty::isInheritedProperty): 41 * css/CSSProperty.h: 42 (WebCore:: prefixingVariantForPropertyId): This function takes a given 43 property id and returns its prefixed or unprefixed id if it exists. If 44 not it returns the same id. 45 (WebCore): 46 * css/CSSPropertyNames.in: 47 * css/StylePropertySet.cpp: 48 (WebCore::StylePropertySet::getPropertyValue): 49 (WebCore::StylePropertySet::removeShorthandProperty): 50 (WebCore::StylePropertySet::removeProperty): 51 (WebCore::StylePropertySet::removeProperty): Remove 52 also the prefixed or unprefixed shorthand if it exists. 53 (WebCore): 54 (WebCore::StylePropertySet::setProperty): 55 (WebCore::StylePropertySet:: appendPrefixingVariantProperty): 56 (WebCore::StylePropertySet::setPrefixingVariantProperty): If it 57 exists a unprefixed or prefixed counterpart of the property we're 58 trying to set, then we update the other one. 59 (WebCore::StylePropertySet::asText): 60 (WebCore::StylePropertySet::mergeAndOverrideOnConflict): 61 * css/StylePropertySet.h: 62 (StylePropertySet): 63 * css/StylePropertyShorthand.cpp: 64 (WebCore::transitionShorthand): 65 (WebCore): 66 (WebCore::shorthandForProperty): Define the transitions unprefixed 67 longhands. 68 * css/StylePropertyShorthand.h: 69 (WebCore): 70 * css/StyleResolver.cpp: 71 (WebCore::StyleResolver::applyProperty): StyleBuilder will handle the 72 resolution and the creation of the animations for the style. As the 73 declarated style now contains declarations for the prefixed and 74 unprefixed property we do not want to resolve two times and create duplicate animations. 75 Therefore when we try to resolve the unprefixed version we just bail out. 76 1 77 2013-03-04 Ilya Tikhonovsky <loislo@chromium.org> 2 78 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r144485 r144626 199 199 CSSPropertyTextTransform, 200 200 CSSPropertyTop, 201 CSSPropertyTransitionDelay, 202 CSSPropertyTransitionDuration, 203 CSSPropertyTransitionProperty, 204 CSSPropertyTransitionTimingFunction, 201 205 CSSPropertyUnicodeBidi, 202 206 CSSPropertyVerticalAlign, … … 2518 2522 case CSSPropertyWebkitTransformStyle: 2519 2523 return cssValuePool().createIdentifierValue((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat); 2524 case CSSPropertyTransitionDelay: 2520 2525 case CSSPropertyWebkitTransitionDelay: 2521 2526 return getDelayValue(style->transitions()); 2527 case CSSPropertyTransitionDuration: 2522 2528 case CSSPropertyWebkitTransitionDuration: 2523 2529 return getDurationValue(style->transitions()); 2530 case CSSPropertyTransitionProperty: 2524 2531 case CSSPropertyWebkitTransitionProperty: 2525 2532 return getTransitionPropertyValue(style->transitions()); 2533 case CSSPropertyTransitionTimingFunction: 2526 2534 case CSSPropertyWebkitTransitionTimingFunction: 2527 2535 return getTimingFunctionValue(style->transitions()); 2536 case CSSPropertyTransition: 2528 2537 case CSSPropertyWebkitTransition: { 2529 2538 const AnimationList* animList = style->transitions(); -
trunk/Source/WebCore/css/CSSParser.cpp
r143948 r144626 1537 1537 } 1538 1538 1539 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr<CSSValue> value, bool important, bool implicit) 1540 { 1541 RefPtr<CSSValue> val = value.get(); 1542 addProperty(propId, value, important, implicit); 1543 1544 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId); 1545 if (prefixingVariant == propId) 1546 return; 1547 addProperty(prefixingVariant, val.release(), important, implicit); 1548 } 1549 1539 1550 void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bool important, bool implicit) 1540 1551 { … … 2566 2577 case CSSPropertyWebkitAnimationIterationCount: 2567 2578 case CSSPropertyWebkitAnimationTimingFunction: 2579 case CSSPropertyTransitionDelay: 2580 case CSSPropertyTransitionDuration: 2581 case CSSPropertyTransitionTimingFunction: 2582 case CSSPropertyTransitionProperty: 2568 2583 case CSSPropertyWebkitTransitionDelay: 2569 2584 case CSSPropertyWebkitTransitionDuration: … … 2573 2588 AnimationParseContext context; 2574 2589 if (parseAnimationProperty(propId, val, context)) { 2575 addProperty (propId, val.release(), important);2590 addPropertyWithPrefixingVariant(propId, val.release(), important); 2576 2591 return true; 2577 2592 } … … 2812 2827 case CSSPropertyWebkitAnimation: 2813 2828 return parseAnimationShorthand(important); 2829 case CSSPropertyTransition: 2814 2830 case CSSPropertyWebkitTransition: 2815 return parseTransitionShorthand( important);2831 return parseTransitionShorthand(propId, important); 2816 2832 case CSSPropertyInvalid: 2817 2833 return false; … … 3330 3346 } 3331 3347 3332 bool CSSParser::parseTransitionShorthand( bool important)3348 bool CSSParser::parseTransitionShorthand(CSSPropertyID propId, bool important) 3333 3349 { 3334 3350 const unsigned numProperties = 4; 3335 ASSERT(numProperties == webkitTransitionShorthand().length()); 3336 3337 ShorthandScope scope(this, CSSPropertyWebkitTransition); 3351 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); 3352 ASSERT(numProperties == shorthand.length()); 3353 3354 ShorthandScope scope(this, propId); 3338 3355 3339 3356 bool parsedProperty[numProperties] = { false }; … … 3361 3378 if (!parsedProperty[i]) { 3362 3379 RefPtr<CSSValue> val; 3363 if (parseAnimationProperty( webkitTransitionShorthand().properties()[i], val, context)) {3380 if (parseAnimationProperty(shorthand.properties()[i], val, context)) { 3364 3381 parsedProperty[i] = found = true; 3365 3382 addAnimationValue(values[i], val.release()); … … 3386 3403 // Now add all of the properties we found. 3387 3404 for (i = 0; i < numProperties; i++) 3388 addProperty (webkitTransitionShorthand().properties()[i], values[i].release(), important);3405 addPropertyWithPrefixingVariant(shorthand.properties()[i], values[i].release(), important); 3389 3406 3390 3407 return true; … … 4565 4582 switch (propId) { 4566 4583 case CSSPropertyWebkitAnimationDelay: 4584 case CSSPropertyTransitionDelay: 4567 4585 case CSSPropertyWebkitTransitionDelay: 4568 4586 currValue = parseAnimationDelay(); … … 4576 4594 break; 4577 4595 case CSSPropertyWebkitAnimationDuration: 4596 case CSSPropertyTransitionDuration: 4578 4597 case CSSPropertyWebkitTransitionDuration: 4579 4598 currValue = parseAnimationDuration(); … … 4601 4620 m_valueList->next(); 4602 4621 break; 4622 case CSSPropertyTransitionProperty: 4603 4623 case CSSPropertyWebkitTransitionProperty: 4604 4624 currValue = parseAnimationProperty(context); … … 4609 4629 break; 4610 4630 case CSSPropertyWebkitAnimationTimingFunction: 4631 case CSSPropertyTransitionTimingFunction: 4611 4632 case CSSPropertyWebkitTransitionTimingFunction: 4612 4633 currValue = parseAnimationTimingFunction(); -
trunk/Source/WebCore/css/CSSParser.h
r143028 r144626 95 95 PassOwnPtr<MediaQuery> parseMediaQuery(const String&); 96 96 97 void addPropertyWithPrefixingVariant(CSSPropertyID, PassRefPtr<CSSValue>, bool important, bool implicit = false); 97 98 void addProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important, bool implicit = false); 98 99 void rollbackLastProperties(int num); … … 152 153 bool parseCubicBezierTimingFunctionValue(CSSParserValueList*& args, double& result); 153 154 bool parseAnimationProperty(CSSPropertyID, RefPtr<CSSValue>&, AnimationParseContext&); 154 bool parseTransitionShorthand( bool important);155 bool parseTransitionShorthand(CSSPropertyID, bool important); 155 156 bool parseAnimationShorthand(bool important); 156 157 -
trunk/Source/WebCore/css/CSSProperty.cpp
r142168 r144626 490 490 case CSSPropertyTextUnderlineWidth: 491 491 case CSSPropertyTop: 492 case CSSPropertyTransition: 493 case CSSPropertyTransitionDelay: 494 case CSSPropertyTransitionDuration: 495 case CSSPropertyTransitionProperty: 496 case CSSPropertyTransitionTimingFunction: 492 497 case CSSPropertyUnicodeBidi: 493 498 case CSSPropertyUnicodeRange: -
trunk/Source/WebCore/css/CSSProperty.h
r137984 r144626 93 93 }; 94 94 95 inline CSSPropertyID prefixingVariantForPropertyId(CSSPropertyID propId) 96 { 97 CSSPropertyID propertyId = CSSPropertyInvalid; 98 switch (propId) { 99 case CSSPropertyTransitionDelay: 100 propertyId = CSSPropertyWebkitTransitionDelay; 101 break; 102 case CSSPropertyTransitionDuration: 103 propertyId = CSSPropertyWebkitTransitionDuration; 104 break; 105 case CSSPropertyTransitionProperty: 106 propertyId = CSSPropertyWebkitTransitionProperty; 107 break; 108 case CSSPropertyTransitionTimingFunction: 109 propertyId = CSSPropertyWebkitTransitionTimingFunction; 110 break; 111 case CSSPropertyTransition: 112 propertyId = CSSPropertyWebkitTransition; 113 break; 114 case CSSPropertyWebkitTransitionDelay: 115 propertyId = CSSPropertyTransitionDelay; 116 break; 117 case CSSPropertyWebkitTransitionDuration: 118 propertyId = CSSPropertyTransitionDuration; 119 break; 120 case CSSPropertyWebkitTransitionProperty: 121 propertyId = CSSPropertyTransitionProperty; 122 break; 123 case CSSPropertyWebkitTransitionTimingFunction: 124 propertyId = CSSPropertyTransitionTimingFunction; 125 break; 126 case CSSPropertyWebkitTransition: 127 propertyId = CSSPropertyTransition; 128 break; 129 default: 130 propertyId = propId; 131 break; 132 } 133 ASSERT(propertyId != CSSPropertyInvalid); 134 return propertyId; 135 } 136 95 137 } // namespace WebCore 96 138 -
trunk/Source/WebCore/css/CSSPropertyNames.in
r142168 r144626 183 183 text-underline-width 184 184 top 185 transition = -webkit-transition186 transition-delay = -webkit-transition-delay187 transition-duration = -webkit-transition-duration188 transition-property = -webkit-transition-property189 transition-timing-function = -webkit-transition-timing-function185 transition 186 transition-delay 187 transition-duration 188 transition-property 189 transition-timing-function 190 190 191 191 unicode-bidi -
trunk/Source/WebCore/css/StylePropertySet.cpp
r144146 r144626 177 177 case CSSPropertyPadding: 178 178 return get4Values(paddingShorthand()); 179 case CSSPropertyTransition: 180 return getLayeredShorthandValue(transitionShorthand()); 179 181 case CSSPropertyListStyle: 180 182 return getShorthandValue(listStyleShorthand()); … … 585 587 if (!shorthand.length()) 586 588 return false; 587 return removePropertiesInSet(shorthand.properties(), shorthand.length()); 589 590 bool ret = removePropertiesInSet(shorthand.properties(), shorthand.length()); 591 592 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propertyID); 593 if (prefixingVariant == propertyID) 594 return ret; 595 596 StylePropertyShorthand shorthandPrefixingVariant = shorthandForProperty(prefixingVariant); 597 return removePropertiesInSet(shorthandPrefixingVariant.properties(), shorthandPrefixingVariant.length()); 588 598 } 589 599 … … 611 621 // and sweeping them when the vector grows too big. 612 622 mutablePropertyVector().remove(foundPropertyIndex); 613 623 624 removePrefixedOrUnprefixedProperty(propertyID); 625 614 626 return true; 627 } 628 629 void StylePropertySet::removePrefixedOrUnprefixedProperty(CSSPropertyID propertyID) 630 { 631 int foundPropertyIndex = findPropertyIndex(prefixingVariantForPropertyId(propertyID)); 632 if (foundPropertyIndex == -1) 633 return; 634 mutablePropertyVector().remove(foundPropertyIndex); 615 635 } 616 636 … … 686 706 if (toReplace) { 687 707 *toReplace = property; 708 setPrefixingVariantProperty(property); 688 709 return; 689 710 } 690 711 } 712 appendPrefixingVariantProperty(property); 713 } 714 715 void StylePropertySet::appendPrefixingVariantProperty(const CSSProperty& property) 716 { 691 717 mutablePropertyVector().append(property); 718 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id()); 719 if (prefixingVariant == property.id()) 720 return; 721 mutablePropertyVector().append(CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.shorthandID(), property.metadata().m_implicit)); 722 } 723 724 void StylePropertySet::setPrefixingVariantProperty(const CSSProperty& property) 725 { 726 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id()); 727 CSSProperty* toReplace = findMutableCSSPropertyWithID(prefixingVariant); 728 if (toReplace) 729 *toReplace = CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.shorthandID(), property.metadata().m_implicit); 692 730 } 693 731 … … 840 878 shorthandPropertyID = CSSPropertyPadding; 841 879 break; 880 case CSSPropertyTransitionProperty: 881 case CSSPropertyTransitionDuration: 882 case CSSPropertyTransitionTimingFunction: 883 case CSSPropertyTransitionDelay: 884 shorthandPropertyID = CSSPropertyTransition; 885 break; 842 886 case CSSPropertyWebkitAnimationName: 843 887 case CSSPropertyWebkitAnimationDuration: … … 998 1042 setProperty(toMerge.toCSSProperty(), old); 999 1043 else 1000 mutablePropertyVector().append(toMerge.toCSSProperty());1044 appendPrefixingVariantProperty(toMerge.toCSSProperty()); 1001 1045 } 1002 1046 } -
trunk/Source/WebCore/css/StylePropertySet.h
r143926 r144626 115 115 // These do not. FIXME: This is too messy, we can do better. 116 116 bool setProperty(CSSPropertyID, int identifier, bool important = false); 117 void appendPrefixingVariantProperty(const CSSProperty&); 118 void setPrefixingVariantProperty(const CSSProperty&); 117 119 void setProperty(const CSSProperty&, CSSProperty* slot = 0); 118 120 119 121 bool removeProperty(CSSPropertyID, String* returnText = 0); 122 void removePrefixedOrUnprefixedProperty(CSSPropertyID); 120 123 121 124 void parseDeclaration(const String& styleDeclaration, StyleSheetContents* contextStyleSheet); -
trunk/Source/WebCore/css/StylePropertyShorthand.cpp
r136080 r144626 245 245 DEFINE_STATIC_LOCAL(StylePropertyShorthand, paddingLonghands, (paddingProperties, WTF_ARRAY_LENGTH(paddingProperties))); 246 246 return paddingLonghands; 247 } 248 249 const StylePropertyShorthand& transitionShorthand() 250 { 251 static const CSSPropertyID transitionProperties[] = { 252 CSSPropertyTransitionProperty, 253 CSSPropertyTransitionDuration, 254 CSSPropertyTransitionTimingFunction, 255 CSSPropertyTransitionDelay 256 }; 257 DEFINE_STATIC_LOCAL(StylePropertyShorthand, transitionLonghands, (transitionProperties, WTF_ARRAY_LENGTH(transitionProperties))); 258 return transitionLonghands; 247 259 } 248 260 … … 494 506 case CSSPropertyPadding: 495 507 return paddingShorthand(); 508 case CSSPropertyTransition: 509 return transitionShorthand(); 496 510 case CSSPropertyWebkitAnimation: 497 511 return webkitAnimationShorthand(); -
trunk/Source/WebCore/css/StylePropertyShorthand.h
r128572 r144626 81 81 const StylePropertyShorthand& overflowShorthand(); 82 82 const StylePropertyShorthand& paddingShorthand(); 83 const StylePropertyShorthand& transitionShorthand(); 83 84 const StylePropertyShorthand& webkitAnimationShorthand(); 84 85 const StylePropertyShorthand& webkitAnimationShorthandForParsing(); -
trunk/Source/WebCore/css/StyleResolver.cpp
r144092 r144626 3581 3581 return; 3582 3582 } 3583 // These properties are aliased and StyleBuilder already applied the property on the prefixed version. 3584 case CSSPropertyTransitionDelay: 3585 case CSSPropertyTransitionDuration: 3586 case CSSPropertyTransitionProperty: 3587 case CSSPropertyTransitionTimingFunction: 3588 return; 3583 3589 // These properties are implemented in the StyleBuilder lookup table. 3584 3590 case CSSPropertyBackgroundAttachment:
Note: See TracChangeset
for help on using the changeset viewer.