Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp

Issue 2228313002: Make a function to query whether a CSSPropertyID is valid and whether it has a name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@asan
Patch Set: Revert incorrect changes Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 keyframes.append(keyframe); 109 keyframes.append(keyframe);
110 // The last keyframe specified at a given offset is used. 110 // The last keyframe specified at a given offset is used.
111 for (size_t j = 1; j < offsets.size(); ++j) { 111 for (size_t j = 1; j < offsets.size(); ++j) {
112 keyframes.append(toStringKeyframe(keyframe->cloneWithOffset(offsets[ j]).get())); 112 keyframes.append(toStringKeyframe(keyframe->cloneWithOffset(offsets[ j]).get()));
113 } 113 }
114 } 114 }
115 115
116 DEFINE_STATIC_LOCAL(SparseHistogram, propertyHistogram, ("WebCore.Animation. CSSProperties")); 116 DEFINE_STATIC_LOCAL(SparseHistogram, propertyHistogram, ("WebCore.Animation. CSSProperties"));
117 for (CSSPropertyID property : specifiedPropertiesForUseCounter) { 117 for (CSSPropertyID property : specifiedPropertiesForUseCounter) {
118 DCHECK_NE(property, CSSPropertyInvalid); 118 DCHECK(isValidCSSPropertyID(property));
119 propertyHistogram.sample(UseCounter::mapCSSPropertyIdToCSSSampleIdForHis togram(property)); 119 propertyHistogram.sample(UseCounter::mapCSSPropertyIdToCSSSampleIdForHis togram(property));
120 } 120 }
121 121
122 // Merge duplicate keyframes. 122 // Merge duplicate keyframes.
123 std::stable_sort(keyframes.begin(), keyframes.end(), Keyframe::compareOffset s); 123 std::stable_sort(keyframes.begin(), keyframes.end(), Keyframe::compareOffset s);
124 size_t targetIndex = 0; 124 size_t targetIndex = 0;
125 for (size_t i = 1; i < keyframes.size(); i++) { 125 for (size_t i = 1; i < keyframes.size(); i++) {
126 if (keyframes[i]->offset() == keyframes[targetIndex]->offset()) { 126 if (keyframes[i]->offset() == keyframes[targetIndex]->offset()) {
127 for (const auto& property : keyframes[i]->properties()) 127 for (const auto& property : keyframes[i]->properties())
128 keyframes[targetIndex]->setCSSPropertyValue(property.cssProperty (), keyframes[i]->cssPropertyValue(property)); 128 keyframes[targetIndex]->setCSSPropertyValue(property.cssProperty (), keyframes[i]->cssPropertyValue(property));
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 513
514 KeyframeEffect* transition = KeyframeEffect::create(element, model, iner tAnimation->specifiedTiming(), KeyframeEffect::TransitionPriority, eventDelegate ); 514 KeyframeEffect* transition = KeyframeEffect::create(element, model, iner tAnimation->specifiedTiming(), KeyframeEffect::TransitionPriority, eventDelegate );
515 Animation* animation = element->document().timeline().play(transition); 515 Animation* animation = element->document().timeline().play(transition);
516 animation->setId(getPropertyName(newTransition.id)); 516 animation->setId(getPropertyName(newTransition.id));
517 // Set the current time as the start time for retargeted transitions 517 // Set the current time as the start time for retargeted transitions
518 if (retargetedCompositorTransitions.contains(id)) 518 if (retargetedCompositorTransitions.contains(id))
519 animation->setStartTime(element->document().timeline().currentTime() ); 519 animation->setStartTime(element->document().timeline().currentTime() );
520 animation->update(TimingUpdateOnDemand); 520 animation->update(TimingUpdateOnDemand);
521 runningTransition.animation = animation; 521 runningTransition.animation = animation;
522 m_transitions.set(id, runningTransition); 522 m_transitions.set(id, runningTransition);
523 DCHECK_NE(id, CSSPropertyInvalid); 523 DCHECK(isValidCSSPropertyID(id));
524 524
525 DEFINE_STATIC_LOCAL(SparseHistogram, propertyHistogram, ("WebCore.Animat ion.CSSProperties")); 525 DEFINE_STATIC_LOCAL(SparseHistogram, propertyHistogram, ("WebCore.Animat ion.CSSProperties"));
526 propertyHistogram.sample(UseCounter::mapCSSPropertyIdToCSSSampleIdForHis togram(id)); 526 propertyHistogram.sample(UseCounter::mapCSSPropertyIdToCSSSampleIdForHis togram(id));
527 } 527 }
528 clearPendingUpdate(); 528 clearPendingUpdate();
529 } 529 }
530 530
531 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const CSSTransitionData& transitionData, size_t transitionIndex, const ComputedStyle& oldStyle, const ComputedStyle& style, const TransitionMap* activeTransitions, C SSAnimationUpdate& update, const Element* element) 531 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const CSSTransitionData& transitionData, size_t transitionIndex, const ComputedStyle& oldStyle, const ComputedStyle& style, const TransitionMap* activeTransitions, C SSAnimationUpdate& update, const Element* element)
532 { 532 {
533 RefPtr<AnimatableValue> to = nullptr; 533 RefPtr<AnimatableValue> to = nullptr;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 continue; 645 continue;
646 646
647 CSSPropertyID property = resolveCSSPropertyID(transitionProperty.unr esolvedProperty); 647 CSSPropertyID property = resolveCSSPropertyID(transitionProperty.unr esolvedProperty);
648 bool animateAll = property == CSSPropertyAll; 648 bool animateAll = property == CSSPropertyAll;
649 if (animateAll) 649 if (animateAll)
650 anyTransitionHadTransitionAll = true; 650 anyTransitionHadTransitionAll = true;
651 const StylePropertyShorthand& propertyList = animateAll ? CSSAnimati ons::propertiesForTransitionAll() : shorthandForProperty(property); 651 const StylePropertyShorthand& propertyList = animateAll ? CSSAnimati ons::propertiesForTransitionAll() : shorthandForProperty(property);
652 // If not a shorthand we only execute one iteration of this loop, an d refer to the property directly. 652 // If not a shorthand we only execute one iteration of this loop, an d refer to the property directly.
653 for (unsigned j = 0; !j || j < propertyList.length(); ++j) { 653 for (unsigned j = 0; !j || j < propertyList.length(); ++j) {
654 CSSPropertyID id = propertyList.length() ? propertyList.properti es()[j] : property; 654 CSSPropertyID id = propertyList.length() ? propertyList.properti es()[j] : property;
655 DCHECK_GE(id, firstCSSProperty); 655 DCHECK(isPropertyIDWithName(id));
656 656
657 if (!animateAll) { 657 if (!animateAll) {
658 if (CSSPropertyMetadata::isInterpolableProperty(id)) 658 if (CSSPropertyMetadata::isInterpolableProperty(id))
659 listedProperties.set(id - firstCSSProperty); 659 listedProperties.set(id - firstCSSProperty);
660 else 660 else
661 continue; 661 continue;
662 } 662 }
663 663
664 // FIXME: We should transition if an !important property changes even when an animation is running, 664 // FIXME: We should transition if an !important property changes even when an animation is running,
665 // but this is a bit hard to do with the current applyMatchedPro perties system. 665 // but this is a bit hard to do with the current applyMatchedPro perties system.
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 } 908 }
909 909
910 DEFINE_TRACE(CSSAnimations) 910 DEFINE_TRACE(CSSAnimations)
911 { 911 {
912 visitor->trace(m_transitions); 912 visitor->trace(m_transitions);
913 visitor->trace(m_pendingUpdate); 913 visitor->trace(m_pendingUpdate);
914 visitor->trace(m_runningAnimations); 914 visitor->trace(m_runningAnimations);
915 } 915 }
916 916
917 } // namespace blink 917 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698