| OLD | NEW |
| 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 20 matching lines...) Expand all Loading... |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/css/resolver/AnimatedStyleBuilder.h" | 32 #include "core/css/resolver/AnimatedStyleBuilder.h" |
| 33 | 33 |
| 34 #include "core/animation/AnimatableClipPathOperation.h" | 34 #include "core/animation/AnimatableClipPathOperation.h" |
| 35 #include "core/animation/AnimatableColor.h" | 35 #include "core/animation/AnimatableColor.h" |
| 36 #include "core/animation/AnimatableDouble.h" | 36 #include "core/animation/AnimatableDouble.h" |
| 37 #include "core/animation/AnimatableImage.h" | 37 #include "core/animation/AnimatableImage.h" |
| 38 #include "core/animation/AnimatableLength.h" | 38 #include "core/animation/AnimatableLength.h" |
| 39 #include "core/animation/AnimatableLengthBox.h" | 39 #include "core/animation/AnimatableLengthBox.h" |
| 40 #include "core/animation/AnimatableLengthSize.h" | 40 #include "core/animation/AnimatableLengthSize.h" |
| 41 #include "core/animation/AnimatableRepeatable.h" |
| 41 #include "core/animation/AnimatableSVGLength.h" | 42 #include "core/animation/AnimatableSVGLength.h" |
| 42 #include "core/animation/AnimatableSVGPaint.h" | 43 #include "core/animation/AnimatableSVGPaint.h" |
| 43 #include "core/animation/AnimatableShapeValue.h" | 44 #include "core/animation/AnimatableShapeValue.h" |
| 44 #include "core/animation/AnimatableTransform.h" | 45 #include "core/animation/AnimatableTransform.h" |
| 45 #include "core/animation/AnimatableUnknown.h" | 46 #include "core/animation/AnimatableUnknown.h" |
| 46 #include "core/animation/AnimatableValue.h" | 47 #include "core/animation/AnimatableValue.h" |
| 47 #include "core/animation/AnimatableVisibility.h" | 48 #include "core/animation/AnimatableVisibility.h" |
| 48 #include "core/animation/css/CSSAnimations.h" | 49 #include "core/animation/css/CSSAnimations.h" |
| 49 #include "core/css/CSSPrimitiveValueMappings.h" | 50 #include "core/css/CSSPrimitiveValueMappings.h" |
| 50 #include "core/css/resolver/StyleBuilder.h" | 51 #include "core/css/resolver/StyleBuilder.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 93 } |
| 93 | 94 |
| 94 SVGLength animatableValueToNonNegativeSVGLength(const AnimatableValue* value) | 95 SVGLength animatableValueToNonNegativeSVGLength(const AnimatableValue* value) |
| 95 { | 96 { |
| 96 SVGLength length = toAnimatableSVGLength(value)->toSVGLength(); | 97 SVGLength length = toAnimatableSVGLength(value)->toSVGLength(); |
| 97 if (length.valueInSpecifiedUnits() < 0) | 98 if (length.valueInSpecifiedUnits() < 0) |
| 98 length.setValueInSpecifiedUnits(0); | 99 length.setValueInSpecifiedUnits(0); |
| 99 return length; | 100 return length; |
| 100 } | 101 } |
| 101 | 102 |
| 103 template <CSSPropertyID property> |
| 104 void setOnFillLayers(FillLayer* fillLayer, const AnimatableValue* value, StyleRe
solverState& state) |
| 105 { |
| 106 const Vector<RefPtr<AnimatableValue> >& values = toAnimatableRepeatable(valu
e)->values(); |
| 107 ASSERT(!values.isEmpty()); |
| 108 FillLayer* prev = 0; |
| 109 for (size_t i = 0; i < values.size(); ++i) { |
| 110 if (!fillLayer) { |
| 111 fillLayer = new FillLayer(BackgroundFillLayer); |
| 112 prev->setNext(fillLayer); |
| 113 } |
| 114 switch (property) { |
| 115 case CSSPropertyBackgroundImage: |
| 116 fillLayer->setImage(toAnimatableImage(values[i].get())->toStyleImage
()); |
| 117 break; |
| 118 case CSSPropertyBackgroundPositionX: |
| 119 fillLayer->setXPosition(animatableValueToLength(values[i].get(), sta
te)); |
| 120 break; |
| 121 case CSSPropertyBackgroundPositionY: |
| 122 fillLayer->setYPosition(animatableValueToLength(values[i].get(), sta
te)); |
| 123 break; |
| 124 default: |
| 125 ASSERT_NOT_REACHED(); |
| 126 } |
| 127 prev = fillLayer; |
| 128 fillLayer = fillLayer->next(); |
| 129 } |
| 130 while (fillLayer) { |
| 131 switch (property) { |
| 132 case CSSPropertyBackgroundImage: |
| 133 fillLayer->clearImage(); |
| 134 break; |
| 135 case CSSPropertyBackgroundPositionX: |
| 136 fillLayer->clearXPosition(); |
| 137 break; |
| 138 case CSSPropertyBackgroundPositionY: |
| 139 fillLayer->clearYPosition(); |
| 140 break; |
| 141 default: |
| 142 ASSERT_NOT_REACHED(); |
| 143 } |
| 144 fillLayer = fillLayer->next(); |
| 145 } |
| 146 } |
| 147 |
| 102 } // namespace | 148 } // namespace |
| 103 | 149 |
| 104 // FIXME: Generate this function. | 150 // FIXME: Generate this function. |
| 105 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt
ate& state, const AnimatableValue* value) | 151 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt
ate& state, const AnimatableValue* value) |
| 106 { | 152 { |
| 107 if (value->isUnknown()) { | 153 if (value->isUnknown()) { |
| 108 StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)-
>toCSSValue().get()); | 154 StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)-
>toCSSValue().get()); |
| 109 return; | 155 return; |
| 110 } | 156 } |
| 111 RenderStyle* style = state.style(); | 157 RenderStyle* style = state.style(); |
| 112 switch (property) { | 158 switch (property) { |
| 113 case CSSPropertyBackgroundColor: | 159 case CSSPropertyBackgroundColor: |
| 114 style->setBackgroundColor(toAnimatableColor(value)->color()); | 160 style->setBackgroundColor(toAnimatableColor(value)->color()); |
| 115 style->setVisitedLinkBackgroundColor(toAnimatableColor(value)->visitedLi
nkColor()); | 161 style->setVisitedLinkBackgroundColor(toAnimatableColor(value)->visitedLi
nkColor()); |
| 116 return; | 162 return; |
| 163 case CSSPropertyBackgroundImage: |
| 164 setOnFillLayers<CSSPropertyBackgroundImage>(style->accessBackgroundLayer
s(), value, state); |
| 165 return; |
| 166 case CSSPropertyBackgroundPositionX: |
| 167 setOnFillLayers<CSSPropertyBackgroundPositionX>(style->accessBackgroundL
ayers(), value, state); |
| 168 return; |
| 169 case CSSPropertyBackgroundPositionY: |
| 170 setOnFillLayers<CSSPropertyBackgroundPositionY>(style->accessBackgroundL
ayers(), value, state); |
| 171 return; |
| 117 case CSSPropertyBaselineShift: | 172 case CSSPropertyBaselineShift: |
| 118 style->setBaselineShiftValue(toAnimatableSVGLength(value)->toSVGLength()
); | 173 style->setBaselineShiftValue(toAnimatableSVGLength(value)->toSVGLength()
); |
| 119 return; | 174 return; |
| 120 case CSSPropertyBorderBottomColor: | 175 case CSSPropertyBorderBottomColor: |
| 121 style->setBorderBottomColor(toAnimatableColor(value)->color()); | 176 style->setBorderBottomColor(toAnimatableColor(value)->color()); |
| 122 style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visited
LinkColor()); | 177 style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visited
LinkColor()); |
| 123 return; | 178 return; |
| 124 case CSSPropertyBorderBottomLeftRadius: | 179 case CSSPropertyBorderBottomLeftRadius: |
| 125 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat
e, NonNegativeValues)); | 180 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat
e, NonNegativeValues)); |
| 126 return; | 181 return; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 case CSSPropertyZoom: | 435 case CSSPropertyZoom: |
| 381 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble())); | 436 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble())); |
| 382 return; | 437 return; |
| 383 default: | 438 default: |
| 384 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert
y), "Web Animations not yet implemented: Unable to apply AnimatableValue to Rend
erStyle: %s", getPropertyNameString(property).utf8().data()); | 439 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert
y), "Web Animations not yet implemented: Unable to apply AnimatableValue to Rend
erStyle: %s", getPropertyNameString(property).utf8().data()); |
| 385 ASSERT_NOT_REACHED(); | 440 ASSERT_NOT_REACHED(); |
| 386 } | 441 } |
| 387 } | 442 } |
| 388 | 443 |
| 389 } // namespace WebCore | 444 } // namespace WebCore |
| OLD | NEW |