Changeset 259538 in webkit
- Timestamp:
- Apr 4, 2020, 3:39:18 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
animation/WebAnimationUtilities.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r259534 r259538 1 2020-04-04 Doug Kelly <dougk@apple.com> 2 3 Additional sanity checks in compareAnimationsByCompositeOrder() 4 https://bugs.webkit.org/show_bug.cgi?id=209996 5 6 Reviewed by Geoffrey Garen. 7 8 compareAnimationsByCompositeOrder() is used by std::sort() which requires strict weak ordering. 9 This adds additional checks to ensure strict weak ordering is maintained, first by ensuring 10 the transitionProperty string is different before returning that comparison, then by only using 11 if the animation is a CSSTransition or CSSAnimation if the left hand and right hand sides differ. 12 This should leave all remaining cases to sort by the global animation list. 13 14 No new tests; this should be covered by existing tests and should not change functionality 15 otherwise. 16 17 * animation/WebAnimationUtilities.cpp: 18 (WebCore::compareAnimationsByCompositeOrder): 19 1 20 2020-04-04 Wenson Hsieh <wenson_hsieh@apple.com> 2 21 -
trunk/Source/WebCore/animation/WebAnimationUtilities.cpp
r255076 r259538 45 45 bool rhsIsCSSTransition = rhsHasOwningElement && is<CSSTransition>(rhsAnimation); 46 46 if (lhsIsCSSTransition || rhsIsCSSTransition) { 47 if (lhsIsCSSTransition == rhsIsCSSTransition) { 48 // Sort transitions first by their generation time, and then by transition-property. 49 // https://drafts.csswg.org/css-transitions-2/#animation-composite-order 50 auto& lhsCSSTransition = downcast<CSSTransition>(lhsAnimation); 51 auto& rhsCSSTransition = downcast<CSSTransition>(rhsAnimation); 52 if (lhsCSSTransition.generationTime() != rhsCSSTransition.generationTime()) 53 return lhsCSSTransition.generationTime() < rhsCSSTransition.generationTime(); 54 return lhsCSSTransition.transitionProperty().utf8() < rhsCSSTransition.transitionProperty().utf8(); 55 } 56 return !rhsIsCSSTransition; 47 if (lhsIsCSSTransition != rhsIsCSSTransition) 48 return !rhsIsCSSTransition; 49 50 // Sort transitions first by their generation time, and then by transition-property. 51 // https://drafts.csswg.org/css-transitions-2/#animation-composite-order 52 auto& lhsCSSTransition = downcast<CSSTransition>(lhsAnimation); 53 auto& rhsCSSTransition = downcast<CSSTransition>(rhsAnimation); 54 if (lhsCSSTransition.generationTime() != rhsCSSTransition.generationTime()) 55 return lhsCSSTransition.generationTime() < rhsCSSTransition.generationTime(); 56 auto lhsCSSTransitionProperty = lhsCSSTransition.transitionProperty().utf8(); 57 auto rhsCSSTransitionProperty = rhsCSSTransition.transitionProperty().utf8(); 58 if (lhsCSSTransitionProperty != rhsCSSTransitionProperty) 59 return lhsCSSTransitionProperty < rhsCSSTransitionProperty; 57 60 } 58 61 … … 61 64 bool rhsIsCSSAnimation = rhsHasOwningElement && is<CSSAnimation>(rhsAnimation); 62 65 if (lhsIsCSSAnimation || rhsIsCSSAnimation) { 63 if (lhsIsCSSAnimation == rhsIsCSSAnimation) { 64 // We must have a list of CSS Animations if we have CSS Animations to sort through. 65 ASSERT(cssAnimationList); 66 ASSERT(!cssAnimationList->isEmpty()); 66 if (lhsIsCSSAnimation != rhsIsCSSAnimation) 67 return !rhsIsCSSAnimation; 67 68 68 // https://drafts.csswg.org/css-animations-2/#animation-composite-order 69 // Sort A and B based on their position in the computed value of the animation-name property of the (common) owning element. 70 auto& lhsBackingAnimation = downcast<CSSAnimation>(lhsAnimation).backingAnimation(); 71 auto& rhsBackingAnimation = downcast<CSSAnimation>(rhsAnimation).backingAnimation(); 69 // We must have a list of CSS Animations if we have CSS Animations to sort through. 70 ASSERT(cssAnimationList); 71 ASSERT(!cssAnimationList->isEmpty()); 72 72 73 for (size_t i = 0; i < cssAnimationList->size(); ++i) { 74 auto& animation = cssAnimationList->animation(i); 75 if (animation == lhsBackingAnimation) 76 return true; 77 if (animation == rhsBackingAnimation) 78 return false; 79 } 73 // https://drafts.csswg.org/css-animations-2/#animation-composite-order 74 // Sort A and B based on their position in the computed value of the animation-name property of the (common) owning element. 75 auto& lhsBackingAnimation = downcast<CSSAnimation>(lhsAnimation).backingAnimation(); 76 auto& rhsBackingAnimation = downcast<CSSAnimation>(rhsAnimation).backingAnimation(); 80 77 81 // We should have found either of those CSS animations in the CSS animations list. 82 ASSERT_NOT_REACHED(); 78 for (size_t i = 0; i < cssAnimationList->size(); ++i) { 79 auto& animation = cssAnimationList->animation(i); 80 if (animation == lhsBackingAnimation) 81 return true; 82 if (animation == rhsBackingAnimation) 83 return false; 83 84 } 84 return !rhsIsCSSAnimation; 85 86 // We should have found either of those CSS animations in the CSS animations list. 87 ASSERT_NOT_REACHED(); 85 88 } 86 89
Note:
See TracChangeset
for help on using the changeset viewer.