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 InterpolationPipelineStage* firstStage = interpolationEntry.value-
>first().get(); |
| 1065 RefPtrWillBeRawPtr<Interpolation> firstInterpolation = firstStage->inter
polation(); |
| 1066 |
| 1067 RefPtrWillBeRawPtr<Interpolation> underlyingInterpolation = nullptr; |
| 1068 |
| 1069 OwnPtrWillBeRawPtr<InterpolableValue> underlyingValue = nullptr; |
| 1070 OwnPtrWillBeRawPtr<InterpolableValue> multipliedValue = nullptr; |
| 1071 |
| 1072 if (!firstInterpolation->isReplaceOnly()) { |
| 1073 // Pull CSSValue from the LayoutStyle |
| 1074 RefPtrWillBeRawPtr<CSSValue> underlyingCSSValue = LayoutStyleCSSValu
eMapping::get(property, *state.style()); |
| 1075 ASSERT(underlyingCSSValue); |
| 1076 |
| 1077 // Create interpolation from underlying value |
| 1078 underlyingInterpolation = InterpolationFactory::createConstantInterp
olation( |
| 1079 property, |
| 1080 underlyingCSSValue.get(), |
| 1081 AnimationEffect::CompositeReplace, |
| 1082 AnimationEffect::CompositeReplace |
| 1083 ); |
| 1084 |
| 1085 multipliedValue = underlyingInterpolation->cachedValue().clone(); |
| 1086 underlyingValue = underlyingInterpolation->cachedValue().clone(); |
| 1087 |
| 1088 if (underlyingInterpolation->cachedValue().typesMatch(firstInterpola
tion->cachedValue())) { |
| 1089 // Multiply by the first interpolation's underlying |
| 1090 // fraction |
| 1091 underlyingInterpolation->cachedValue().multiply(firstInterpolati
on->cachedUnderlyingFraction(), *multipliedValue); |
| 1092 |
| 1093 // Add the multiplied underlying value and currentValue |
| 1094 // to produce the final underlying value for use in the |
| 1095 // additive pipeline |
| 1096 multipliedValue->add(firstInterpolation->cachedValue(), *underly
ingValue); |
| 1097 } |
| 1098 } else { |
| 1099 underlyingInterpolation = firstInterpolation.release(); |
| 1100 |
| 1101 underlyingValue = underlyingInterpolation->cachedValue().clone(); |
| 1102 multipliedValue = underlyingInterpolation->cachedValue().clone(); |
| 1103 } |
| 1104 |
| 1105 const InterpolationPipelineStage* currentStage = firstStage->next().get(
); |
| 1106 RefPtrWillBeRawPtr<Interpolation> currentInterpolation = nullptr; |
| 1107 |
| 1108 while (currentStage) { |
| 1109 currentInterpolation = currentStage->interpolation(); |
| 1110 |
| 1111 if (underlyingValue->typesMatch(currentInterpolation->cachedValue())
) { |
| 1112 underlyingValue->multiply(currentInterpolation->cachedUnderlying
Fraction(), *multipliedValue); |
| 1113 multipliedValue->add(currentInterpolation->cachedValue(), *under
lyingValue); |
| 1114 |
| 1115 underlyingInterpolation = currentInterpolation; |
| 1116 } |
| 1117 |
| 1118 currentStage = currentStage->next().get(); |
| 1119 } |
| 1120 |
| 1121 const StyleInterpolation* interpolation = toStyleInterpolation(underlyin
gInterpolation.get()); |
| 1122 interpolation->apply(state, *underlyingValue); |
1063 } | 1123 } |
1064 } | 1124 } |
1065 | 1125 |
1066 static inline bool isValidCueStyleProperty(CSSPropertyID id) | 1126 static inline bool isValidCueStyleProperty(CSSPropertyID id) |
1067 { | 1127 { |
1068 switch (id) { | 1128 switch (id) { |
1069 case CSSPropertyBackground: | 1129 case CSSPropertyBackground: |
1070 case CSSPropertyBackgroundAttachment: | 1130 case CSSPropertyBackgroundAttachment: |
1071 case CSSPropertyBackgroundClip: | 1131 case CSSPropertyBackgroundClip: |
1072 case CSSPropertyBackgroundColor: | 1132 case CSSPropertyBackgroundColor: |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 visitor->trace(m_uncommonAttributeRuleSet); | 1607 visitor->trace(m_uncommonAttributeRuleSet); |
1548 visitor->trace(m_watchedSelectorsRules); | 1608 visitor->trace(m_watchedSelectorsRules); |
1549 visitor->trace(m_treeBoundaryCrossingRules); | 1609 visitor->trace(m_treeBoundaryCrossingRules); |
1550 visitor->trace(m_styleSharingLists); | 1610 visitor->trace(m_styleSharingLists); |
1551 visitor->trace(m_pendingStyleSheets); | 1611 visitor->trace(m_pendingStyleSheets); |
1552 visitor->trace(m_document); | 1612 visitor->trace(m_document); |
1553 #endif | 1613 #endif |
1554 } | 1614 } |
1555 | 1615 |
1556 } // namespace blink | 1616 } // namespace blink |
OLD | NEW |