| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sky/engine/core/animation/DeferredLegacyStyleInterpolation.h" | |
| 6 | |
| 7 #include "sky/engine/core/animation/LegacyStyleInterpolation.h" | |
| 8 #include "sky/engine/core/css/CSSPrimitiveValue.h" | |
| 9 #include "sky/engine/core/css/CSSShadowValue.h" | |
| 10 #include "sky/engine/core/css/CSSValueList.h" | |
| 11 #include "sky/engine/core/css/Pair.h" | |
| 12 #include "sky/engine/core/css/Rect.h" | |
| 13 #include "sky/engine/core/css/resolver/StyleResolver.h" | |
| 14 #include "sky/engine/core/css/resolver/StyleResolverState.h" | |
| 15 | |
| 16 namespace blink { | |
| 17 | |
| 18 void DeferredLegacyStyleInterpolation::apply(StyleResolverState& state) const | |
| 19 { | |
| 20 RefPtr<LegacyStyleInterpolation> innerInterpolation = LegacyStyleInterpolati
on::create( | |
| 21 StyleResolver::createAnimatableValueSnapshot(state, m_id, *m_startCSSVal
ue), | |
| 22 StyleResolver::createAnimatableValueSnapshot(state, m_id, *m_endCSSValue
), | |
| 23 m_id); | |
| 24 innerInterpolation->interpolate(m_cachedIteration, m_cachedFraction); | |
| 25 innerInterpolation->apply(state); | |
| 26 } | |
| 27 | |
| 28 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C
SSValue& value) | |
| 29 { | |
| 30 switch (value.cssValueType()) { | |
| 31 case CSSValue::CSS_INHERIT: | |
| 32 return true; | |
| 33 case CSSValue::CSS_PRIMITIVE_VALUE: | |
| 34 return interpolationRequiresStyleResolve(toCSSPrimitiveValue(value)); | |
| 35 case CSSValue::CSS_VALUE_LIST: | |
| 36 return interpolationRequiresStyleResolve(toCSSValueList(value)); | |
| 37 case CSSValue::CSS_CUSTOM: | |
| 38 if (value.isShadowValue()) | |
| 39 return interpolationRequiresStyleResolve(toCSSShadowValue(value)); | |
| 40 // FIXME: consider other custom types. | |
| 41 return true; | |
| 42 case CSSValue::CSS_INITIAL: | |
| 43 // FIXME: should not require resolving styles for initial. | |
| 44 return true; | |
| 45 default: | |
| 46 ASSERT_NOT_REACHED(); | |
| 47 return true; | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C
SSPrimitiveValue& primitiveValue) | |
| 52 { | |
| 53 // FIXME: consider other types. | |
| 54 if (primitiveValue.isNumber() || primitiveValue.isPercentage() || primitiveV
alue.isAngle() || primitiveValue.isRGBColor() || primitiveValue.isURI()) | |
| 55 return false; | |
| 56 | |
| 57 if (primitiveValue.isLength()) | |
| 58 return primitiveValue.isFontRelativeLength() || primitiveValue.isViewpor
tPercentageLength(); | |
| 59 | |
| 60 if (primitiveValue.isCalculated()) { | |
| 61 CSSLengthArray lengthArray(CSSPrimitiveValue::LengthUnitTypeCount); | |
| 62 primitiveValue.accumulateLengthArray(lengthArray); | |
| 63 return lengthArray[CSSPrimitiveValue::UnitTypeFontSize] != 0 | |
| 64 || lengthArray[CSSPrimitiveValue::UnitTypeFontXSize] != 0 | |
| 65 || lengthArray[CSSPrimitiveValue::UnitTypeZeroCharacterWidth] != 0 | |
| 66 || lengthArray[CSSPrimitiveValue::UnitTypeViewportWidth] != 0 | |
| 67 || lengthArray[CSSPrimitiveValue::UnitTypeViewportHeight] != 0 | |
| 68 || lengthArray[CSSPrimitiveValue::UnitTypeViewportMin] != 0 | |
| 69 || lengthArray[CSSPrimitiveValue::UnitTypeViewportMax] != 0; | |
| 70 } | |
| 71 | |
| 72 if (Pair* pair = primitiveValue.getPairValue()) { | |
| 73 return interpolationRequiresStyleResolve(*pair->first()) | |
| 74 || interpolationRequiresStyleResolve(*pair->second()); | |
| 75 } | |
| 76 | |
| 77 if (Rect* rect = primitiveValue.getRectValue()) { | |
| 78 return interpolationRequiresStyleResolve(*rect->top()) | |
| 79 || interpolationRequiresStyleResolve(*rect->right()) | |
| 80 || interpolationRequiresStyleResolve(*rect->bottom()) | |
| 81 || interpolationRequiresStyleResolve(*rect->left()); | |
| 82 } | |
| 83 | |
| 84 if (Quad* quad = primitiveValue.getQuadValue()) { | |
| 85 return interpolationRequiresStyleResolve(*quad->top()) | |
| 86 || interpolationRequiresStyleResolve(*quad->right()) | |
| 87 || interpolationRequiresStyleResolve(*quad->bottom()) | |
| 88 || interpolationRequiresStyleResolve(*quad->left()); | |
| 89 } | |
| 90 | |
| 91 if (primitiveValue.isShape()) | |
| 92 return interpolationRequiresStyleResolve(*primitiveValue.getShapeValue()
); | |
| 93 | |
| 94 return (primitiveValue.getValueID() != CSSValueNone); | |
| 95 } | |
| 96 | |
| 97 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C
SSShadowValue& shadowValue) | |
| 98 { | |
| 99 return (shadowValue.x && interpolationRequiresStyleResolve(*shadowValue.x)) | |
| 100 || (shadowValue.y && interpolationRequiresStyleResolve(*shadowValue.y)) | |
| 101 || (shadowValue.blur && interpolationRequiresStyleResolve(*shadowValue.b
lur)) | |
| 102 || (shadowValue.spread && interpolationRequiresStyleResolve(*shadowValue
.spread)) | |
| 103 || (shadowValue.style && interpolationRequiresStyleResolve(*shadowValue.
style)) | |
| 104 || (shadowValue.color && interpolationRequiresStyleResolve(*shadowValue.
color)); | |
| 105 } | |
| 106 | |
| 107 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C
SSValueList& valueList) | |
| 108 { | |
| 109 size_t length = valueList.length(); | |
| 110 for (size_t index = 0; index < length; ++index) { | |
| 111 if (interpolationRequiresStyleResolve(*valueList.item(index))) | |
| 112 return true; | |
| 113 } | |
| 114 return false; | |
| 115 } | |
| 116 | |
| 117 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C
SSBasicShape& shape) | |
| 118 { | |
| 119 // FIXME: Should determine the specific shape, and inspect the members. | |
| 120 return false; | |
| 121 } | |
| 122 | |
| 123 } | |
| OLD | NEW |