Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
| 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
| 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "core/css/resolver/StyleResolver.h" | 30 #include "core/css/resolver/StyleResolver.h" |
| 31 | 31 |
| 32 #include "core/CSSPropertyNames.h" | 32 #include "core/CSSPropertyNames.h" |
| 33 #include "core/HTMLNames.h" | 33 #include "core/HTMLNames.h" |
| 34 #include "core/MediaTypeNames.h" | 34 #include "core/MediaTypeNames.h" |
| 35 #include "core/StylePropertyShorthand.h" | 35 #include "core/StylePropertyShorthand.h" |
| 36 #include "core/animation/ActiveAnimations.h" | 36 #include "core/animation/ActiveAnimations.h" |
| 37 #include "core/animation/Animation.h" | 37 #include "core/animation/Animation.h" |
| 38 #include "core/animation/AnimationTimeline.h" | 38 #include "core/animation/AnimationTimeline.h" |
| 39 #include "core/animation/InterpolationFactory.h" | |
| 39 #include "core/animation/StyleInterpolation.h" | 40 #include "core/animation/StyleInterpolation.h" |
| 40 #include "core/animation/animatable/AnimatableValue.h" | 41 #include "core/animation/animatable/AnimatableValue.h" |
| 41 #include "core/animation/css/CSSAnimatableValueFactory.h" | 42 #include "core/animation/css/CSSAnimatableValueFactory.h" |
| 42 #include "core/animation/css/CSSAnimations.h" | 43 #include "core/animation/css/CSSAnimations.h" |
| 43 #include "core/css/CSSCalculationValue.h" | 44 #include "core/css/CSSCalculationValue.h" |
| 44 #include "core/css/CSSDefaultStyleSheets.h" | 45 #include "core/css/CSSDefaultStyleSheets.h" |
| 45 #include "core/css/CSSFontSelector.h" | 46 #include "core/css/CSSFontSelector.h" |
| 46 #include "core/css/CSSKeyframeRule.h" | 47 #include "core/css/CSSKeyframeRule.h" |
| 47 #include "core/css/CSSKeyframesRule.h" | 48 #include "core/css/CSSKeyframesRule.h" |
| 48 #include "core/css/CSSReflectValue.h" | 49 #include "core/css/CSSReflectValue.h" |
| 49 #include "core/css/CSSRuleList.h" | 50 #include "core/css/CSSRuleList.h" |
| 50 #include "core/css/CSSSelector.h" | 51 #include "core/css/CSSSelector.h" |
| 51 #include "core/css/CSSStyleRule.h" | 52 #include "core/css/CSSStyleRule.h" |
| 52 #include "core/css/CSSValueList.h" | 53 #include "core/css/CSSValueList.h" |
| 53 #include "core/css/CSSValuePool.h" | 54 #include "core/css/CSSValuePool.h" |
| 54 #include "core/css/ElementRuleCollector.h" | 55 #include "core/css/ElementRuleCollector.h" |
| 55 #include "core/css/FontFace.h" | 56 #include "core/css/FontFace.h" |
| 57 #include "core/css/LayoutStyleCSSValueMapping.h" | |
| 56 #include "core/css/MediaQueryEvaluator.h" | 58 #include "core/css/MediaQueryEvaluator.h" |
| 57 #include "core/css/PageRuleCollector.h" | 59 #include "core/css/PageRuleCollector.h" |
| 58 #include "core/css/StylePropertySet.h" | 60 #include "core/css/StylePropertySet.h" |
| 59 #include "core/css/StyleRuleImport.h" | 61 #include "core/css/StyleRuleImport.h" |
| 60 #include "core/css/StyleSheetContents.h" | 62 #include "core/css/StyleSheetContents.h" |
| 61 #include "core/css/resolver/AnimatedStyleBuilder.h" | 63 #include "core/css/resolver/AnimatedStyleBuilder.h" |
| 62 #include "core/css/resolver/MatchResult.h" | 64 #include "core/css/resolver/MatchResult.h" |
| 63 #include "core/css/resolver/MediaQueryResult.h" | 65 #include "core/css/resolver/MediaQueryResult.h" |
| 64 #include "core/css/resolver/ScopedStyleResolver.h" | 66 #include "core/css/resolver/ScopedStyleResolver.h" |
| 65 #include "core/css/resolver/SharedStyleFinder.h" | 67 #include "core/css/resolver/SharedStyleFinder.h" |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1012 ASSERT(animatingElement == element || !animatingElement || animatingElement- >parentOrShadowHostElement() == element); | 1014 ASSERT(animatingElement == element || !animatingElement || animatingElement- >parentOrShadowHostElement() == element); |
| 1013 | 1015 |
| 1014 if (!(animatingElement && animatingElement->hasActiveAnimations()) | 1016 if (!(animatingElement && animatingElement->hasActiveAnimations()) |
| 1015 && !state.style()->transitions() && !state.style()->animations()) | 1017 && !state.style()->transitions() && !state.style()->animations()) |
| 1016 return false; | 1018 return false; |
| 1017 | 1019 |
| 1018 state.setAnimationUpdate(CSSAnimations::calculateUpdate(animatingElement, *e lement, *state.style(), state.parentStyle(), this)); | 1020 state.setAnimationUpdate(CSSAnimations::calculateUpdate(animatingElement, *e lement, *state.style(), state.parentStyle(), this)); |
| 1019 if (!state.animationUpdate()) | 1021 if (!state.animationUpdate()) |
| 1020 return false; | 1022 return false; |
| 1021 | 1023 |
| 1022 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForAnimations = state.animationUpdate()->activeInterpolation sForAnimations(); | 1024 const InterpolationPipelineMap& activeInterpolationsForAnimations = state.an imationUpdate()->activeInterpolationsForAnimations(); |
| 1023 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForTransitions = state.animationUpdate()->activeInterpolatio nsForTransitions(); | 1025 const InterpolationPipelineMap& activeInterpolationsForTransitions = state.a nimationUpdate()->activeInterpolationsForTransitions(); |
| 1024 applyAnimatedProperties<HighPropertyPriority>(state, activeInterpolationsFor Animations); | 1026 applyAnimatedProperties<HighPropertyPriority>(state, activeInterpolationsFor Animations); |
| 1025 applyAnimatedProperties<HighPropertyPriority>(state, activeInterpolationsFor Transitions); | 1027 applyAnimatedProperties<HighPropertyPriority>(state, activeInterpolationsFor Transitions); |
| 1026 | 1028 |
| 1027 updateFont(state); | 1029 updateFont(state); |
| 1028 | 1030 |
| 1029 applyAnimatedProperties<LowPropertyPriority>(state, activeInterpolationsForA nimations); | 1031 applyAnimatedProperties<LowPropertyPriority>(state, activeInterpolationsForA nimations); |
| 1030 applyAnimatedProperties<LowPropertyPriority>(state, activeInterpolationsForT ransitions); | 1032 applyAnimatedProperties<LowPropertyPriority>(state, activeInterpolationsForT ransitions); |
| 1031 | 1033 |
| 1032 // Start loading resources used by animations. | 1034 // Start loading resources used by animations. |
| 1033 loadPendingResources(state); | 1035 loadPendingResources(state); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1045 resolvers.append(scopedResolver); | 1047 resolvers.append(scopedResolver); |
| 1046 | 1048 |
| 1047 for (size_t i = 0; i < resolvers.size(); ++i) { | 1049 for (size_t i = 0; i < resolvers.size(); ++i) { |
| 1048 if (StyleRuleKeyframes* keyframesRule = resolvers[i]->keyframeStylesForA nimation(animationName.impl())) | 1050 if (StyleRuleKeyframes* keyframesRule = resolvers[i]->keyframeStylesForA nimation(animationName.impl())) |
| 1049 return keyframesRule; | 1051 return keyframesRule; |
| 1050 } | 1052 } |
| 1051 return nullptr; | 1053 return nullptr; |
| 1052 } | 1054 } |
| 1053 | 1055 |
| 1054 template <CSSPropertyPriority priority> | 1056 template <CSSPropertyPriority priority> |
| 1055 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Wil lBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpo lations) | 1057 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Int erpolationPipelineMap& activeInterpolations) |
| 1056 { | 1058 { |
| 1057 for (const auto& interpolationEntry : activeInterpolations) { | 1059 for (const auto& interpolationEntry : activeInterpolations) { |
| 1058 CSSPropertyID property = interpolationEntry.key; | 1060 CSSPropertyID property = interpolationEntry.key; |
| 1059 if (!CSSPropertyPriorityData<priority>::propertyHasPriority(property)) | 1061 if (!CSSPropertyPriorityData<priority>::propertyHasPriority(property)) |
| 1060 continue; | 1062 continue; |
| 1061 const StyleInterpolation* interpolation = toStyleInterpolation(interpola tionEntry.value.get()); | 1063 |
| 1062 interpolation->apply(state); | 1064 const InterpolationPipeline& pipeline = interpolationEntry.value; |
| 1065 | |
| 1066 RefPtrWillBeRawPtr<Interpolation> firstInterpolation = pipeline.at(0); | |
| 1067 | |
| 1068 RefPtrWillBeRawPtr<Interpolation> underlyingInterpolation = nullptr; | |
| 1069 | |
| 1070 OwnPtrWillBeRawPtr<InterpolableValue> underlyingValue = nullptr; | |
| 1071 OwnPtrWillBeRawPtr<InterpolableValue> multipliedValue = nullptr; | |
| 1072 | |
| 1073 if (firstInterpolation->cachedUnderlyingFraction() != 0) { | |
| 1074 // Pull CSSValue from the LayoutStyle | |
| 1075 RefPtrWillBeRawPtr<CSSValue> underlyingCSSValue = LayoutStyleCSSValu eMapping::get(property, *state.style()); | |
| 1076 ASSERT(underlyingCSSValue); | |
| 1077 | |
| 1078 // Create interpolation from underlying value | |
| 1079 underlyingInterpolation = InterpolationFactory::createConstantInterp olation( | |
| 1080 property, | |
| 1081 underlyingCSSValue.get(), | |
| 1082 AnimationEffect::CompositeReplace, | |
| 1083 AnimationEffect::CompositeReplace | |
| 1084 ); | |
| 1085 | |
| 1086 multipliedValue = underlyingInterpolation->cachedValue().clone(); | |
| 1087 underlyingValue = underlyingInterpolation->cachedValue().clone(); | |
| 1088 | |
| 1089 if (underlyingInterpolation->cachedValue().typesMatch(firstInterpola tion->cachedValue())) { | |
| 1090 // Multiply by the first interpolation's underlying | |
| 1091 // fraction | |
| 1092 underlyingInterpolation->cachedValue().multiply(firstInterpolati on->cachedUnderlyingFraction(), *multipliedValue); | |
| 1093 | |
| 1094 // Add the multiplied underlying value and currentValue | |
| 1095 // to produce the final underlying value for use in the | |
| 1096 // additive pipeline | |
| 1097 multipliedValue->add(firstInterpolation->cachedValue(), *underly ingValue); | |
| 1098 } | |
|
alancutter (OOO until 2018)
2015/02/17 03:50:56
Instead of duplicating the loop here just set star
| |
| 1099 } else { | |
| 1100 underlyingInterpolation = firstInterpolation; | |
| 1101 | |
| 1102 underlyingValue = underlyingInterpolation->cachedValue().clone(); | |
| 1103 multipliedValue = underlyingInterpolation->cachedValue().clone(); | |
|
alancutter (OOO until 2018)
2015/02/17 03:50:56
We must try to avoid the double IV clone in the co
alancutter (OOO until 2018)
2015/02/17 04:08:37
Actually scratch that. The simpler way to do it is
| |
| 1104 } | |
| 1105 | |
| 1106 for (size_t index = 1; index < pipeline.size(); index++) { | |
| 1107 RefPtrWillBeRawPtr<Interpolation> currentInterpolation = pipeline.at (index); | |
| 1108 | |
| 1109 if (underlyingValue->typesMatch(currentInterpolation->cachedValue()) ) { | |
| 1110 underlyingValue->multiply(currentInterpolation->cachedUnderlying Fraction(), *multipliedValue); | |
| 1111 multipliedValue->add(currentInterpolation->cachedValue(), *under lyingValue); | |
| 1112 | |
| 1113 underlyingInterpolation = currentInterpolation; | |
| 1114 } | |
| 1115 } | |
| 1116 | |
| 1117 const StyleInterpolation* interpolation = toStyleInterpolation(underlyin gInterpolation.get()); | |
| 1118 interpolation->apply(state, *underlyingValue); | |
| 1063 } | 1119 } |
| 1064 } | 1120 } |
| 1065 | 1121 |
| 1066 static inline bool isValidCueStyleProperty(CSSPropertyID id) | 1122 static inline bool isValidCueStyleProperty(CSSPropertyID id) |
| 1067 { | 1123 { |
| 1068 switch (id) { | 1124 switch (id) { |
| 1069 case CSSPropertyBackground: | 1125 case CSSPropertyBackground: |
| 1070 case CSSPropertyBackgroundAttachment: | 1126 case CSSPropertyBackgroundAttachment: |
| 1071 case CSSPropertyBackgroundClip: | 1127 case CSSPropertyBackgroundClip: |
| 1072 case CSSPropertyBackgroundColor: | 1128 case CSSPropertyBackgroundColor: |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1547 visitor->trace(m_uncommonAttributeRuleSet); | 1603 visitor->trace(m_uncommonAttributeRuleSet); |
| 1548 visitor->trace(m_watchedSelectorsRules); | 1604 visitor->trace(m_watchedSelectorsRules); |
| 1549 visitor->trace(m_treeBoundaryCrossingRules); | 1605 visitor->trace(m_treeBoundaryCrossingRules); |
| 1550 visitor->trace(m_styleSharingLists); | 1606 visitor->trace(m_styleSharingLists); |
| 1551 visitor->trace(m_pendingStyleSheets); | 1607 visitor->trace(m_pendingStyleSheets); |
| 1552 visitor->trace(m_document); | 1608 visitor->trace(m_document); |
| 1553 #endif | 1609 #endif |
| 1554 } | 1610 } |
| 1555 | 1611 |
| 1556 } // namespace blink | 1612 } // namespace blink |
| OLD | NEW |