| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 3 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 { | 81 { |
| 82 return LengthPoint(blendFunc(anim, from.x(), to.x(), progress), blendFunc(an
im, from.y(), to.y(), progress)); | 82 return LengthPoint(blendFunc(anim, from.x(), to.x(), progress), blendFunc(an
im, from.y(), to.y(), progress)); |
| 83 } | 83 } |
| 84 | 84 |
| 85 static inline IntSize blendFunc(const AnimationBase* anim, const IntSize& from,
const IntSize& to, double progress) | 85 static inline IntSize blendFunc(const AnimationBase* anim, const IntSize& from,
const IntSize& to, double progress) |
| 86 { | 86 { |
| 87 return IntSize(blendFunc(anim, from.width(), to.width(), progress), | 87 return IntSize(blendFunc(anim, from.width(), to.width(), progress), |
| 88 blendFunc(anim, from.height(), to.height(), progress)); | 88 blendFunc(anim, from.height(), to.height(), progress)); |
| 89 } | 89 } |
| 90 | 90 |
| 91 static inline ShadowStyle blendFunc(const AnimationBase* anim, ShadowStyle from,
ShadowStyle to, double progress) | |
| 92 { | |
| 93 if (from == to) | |
| 94 return to; | |
| 95 | |
| 96 double fromVal = from == Normal ? 1 : 0; | |
| 97 double toVal = to == Normal ? 1 : 0; | |
| 98 double result = blendFunc(anim, fromVal, toVal, progress); | |
| 99 return result > 0 ? Normal : Inset; | |
| 100 } | |
| 101 | |
| 102 static inline ShadowData blendFunc(const AnimationBase* anim, const ShadowData&
from, const ShadowData& to, double progress) | |
| 103 { | |
| 104 if (from.style() != to.style()) | |
| 105 return to; | |
| 106 | |
| 107 return ShadowData(blend(from.location(), to.location(), progress), | |
| 108 blend(from.blur(), to.blur(), progress), | |
| 109 blend(from.spread(), to.spread(), progress), | |
| 110 blendFunc(anim, from.style(), to.style(), progress), | |
| 111 blend(from.color(), to.color(), progress)); | |
| 112 } | |
| 113 | |
| 114 static inline TransformOperations blendFunc(const AnimationBase* anim, const Tra
nsformOperations& from, const TransformOperations& to, double progress) | 91 static inline TransformOperations blendFunc(const AnimationBase* anim, const Tra
nsformOperations& from, const TransformOperations& to, double progress) |
| 115 { | 92 { |
| 116 if (anim->isTransformFunctionListValid()) | 93 if (anim->isTransformFunctionListValid()) |
| 117 return to.blendByMatchingOperations(from, progress); | 94 return to.blendByMatchingOperations(from, progress); |
| 118 return to.blendByUsingMatrixInterpolation(from, progress); | 95 return to.blendByUsingMatrixInterpolation(from, progress); |
| 119 } | 96 } |
| 120 | 97 |
| 121 static inline PassRefPtr<ClipPathOperation> blendFunc(const AnimationBase*, Clip
PathOperation* from, ClipPathOperation* to, double progress) | 98 static inline PassRefPtr<ClipPathOperation> blendFunc(const AnimationBase*, Clip
PathOperation* from, ClipPathOperation* to, double progress) |
| 122 { | 99 { |
| 123 // Other clip-path operations than BasicShapes can not be animated. | 100 // Other clip-path operations than BasicShapes can not be animated. |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 } | 493 } |
| 517 | 494 |
| 518 virtual bool animationIsAccelerated() const { return true; } | 495 virtual bool animationIsAccelerated() const { return true; } |
| 519 | 496 |
| 520 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 497 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const |
| 521 { | 498 { |
| 522 dst->setFilter(blendFunc(anim, a->filter(), b->filter(), progress)); | 499 dst->setFilter(blendFunc(anim, a->filter(), b->filter(), progress)); |
| 523 } | 500 } |
| 524 }; | 501 }; |
| 525 | 502 |
| 526 static inline size_t shadowListLength(const ShadowList* shadowList) | |
| 527 { | |
| 528 return shadowList ? shadowList->shadows().size() : 0; | |
| 529 } | |
| 530 | |
| 531 static inline const ShadowData& shadowForBlending(const ShadowData* srcShadow, c
onst ShadowData* otherShadow) | |
| 532 { | |
| 533 DEFINE_STATIC_LOCAL(ShadowData, defaultShadowData, (IntPoint(), 0, 0, Normal
, Color::transparent)); | |
| 534 DEFINE_STATIC_LOCAL(ShadowData, defaultInsetShadowData, (IntPoint(), 0, 0, I
nset, Color::transparent)); | |
| 535 | |
| 536 if (srcShadow) | |
| 537 return *srcShadow; | |
| 538 | |
| 539 return otherShadow->style() == Inset ? defaultInsetShadowData : defaultShado
wData; | |
| 540 } | |
| 541 | |
| 542 class PropertyWrapperShadow : public AnimationPropertyWrapperBase { | 503 class PropertyWrapperShadow : public AnimationPropertyWrapperBase { |
| 543 public: | 504 public: |
| 544 PropertyWrapperShadow(CSSPropertyID prop, ShadowList* (RenderStyle::*getter)
() const, void (RenderStyle::*setter)(PassRefPtr<ShadowList>)) | 505 PropertyWrapperShadow(CSSPropertyID prop, ShadowList* (RenderStyle::*getter)
() const, void (RenderStyle::*setter)(PassRefPtr<ShadowList>)) |
| 545 : AnimationPropertyWrapperBase(prop) | 506 : AnimationPropertyWrapperBase(prop) |
| 546 , m_getter(getter) | 507 , m_getter(getter) |
| 547 , m_setter(setter) | 508 , m_setter(setter) |
| 548 { | 509 { |
| 549 } | 510 } |
| 550 | 511 |
| 551 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const | 512 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const |
| 552 { | 513 { |
| 553 const ShadowList* shadowA = (a->*m_getter)(); | 514 const ShadowList* shadowA = (a->*m_getter)(); |
| 554 const ShadowList* shadowB = (b->*m_getter)(); | 515 const ShadowList* shadowB = (b->*m_getter)(); |
| 555 if (shadowA == shadowB) | 516 if (shadowA == shadowB) |
| 556 return true; | 517 return true; |
| 557 if (shadowA && shadowB) | 518 if (shadowA && shadowB) |
| 558 return *shadowA == *shadowB; | 519 return *shadowA == *shadowB; |
| 559 return false; | 520 return false; |
| 560 } | 521 } |
| 561 | 522 |
| 562 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 523 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const |
| 563 { | 524 { |
| 564 const ShadowList* shadowA = (a->*m_getter)(); | 525 (dst->*m_setter)(ShadowList::blend((a->*m_getter)(), (b->*m_getter)(), p
rogress)); |
| 565 const ShadowList* shadowB = (b->*m_getter)(); | |
| 566 | |
| 567 size_t fromLength = shadowListLength(shadowA); | |
| 568 size_t toLength = shadowListLength(shadowB); | |
| 569 if (!fromLength && !toLength) { | |
| 570 (dst->*m_setter)(0); | |
| 571 return; | |
| 572 } | |
| 573 | |
| 574 ShadowDataVector shadows; | |
| 575 | |
| 576 size_t maxLength = max(fromLength, toLength); | |
| 577 for (size_t i = 0; i < maxLength; ++i) { | |
| 578 const ShadowData* fromShadow = i < fromLength ? &shadowA->shadows()[
i] : 0; | |
| 579 const ShadowData* toShadow = i < toLength ? &shadowB->shadows()[i] :
0; | |
| 580 const ShadowData& srcShadow = shadowForBlending(fromShadow, toShadow
); | |
| 581 const ShadowData& dstShadow = shadowForBlending(toShadow, fromShadow
); | |
| 582 | |
| 583 shadows.append(blendFunc(anim, srcShadow, dstShadow, progress)); | |
| 584 } | |
| 585 | |
| 586 (dst->*m_setter)(ShadowList::adopt(shadows)); | |
| 587 } | 526 } |
| 588 | 527 |
| 589 ShadowList* (RenderStyle::*m_getter)() const; | 528 ShadowList* (RenderStyle::*m_getter)() const; |
| 590 void (RenderStyle::*m_setter)(PassRefPtr<ShadowList>); | 529 void (RenderStyle::*m_setter)(PassRefPtr<ShadowList>); |
| 591 }; | 530 }; |
| 592 | 531 |
| 593 class PropertyWrapperMaybeInvalidColor : public AnimationPropertyWrapperBase { | 532 class PropertyWrapperMaybeInvalidColor : public AnimationPropertyWrapperBase { |
| 594 public: | 533 public: |
| 595 PropertyWrapperMaybeInvalidColor(CSSPropertyID prop, Color (RenderStyle::*ge
tter)() const, void (RenderStyle::*setter)(const Color&)) | 534 PropertyWrapperMaybeInvalidColor(CSSPropertyID prop, Color (RenderStyle::*ge
tter)() const, void (RenderStyle::*setter)(const Color&)) |
| 596 : AnimationPropertyWrapperBase(prop) | 535 : AnimationPropertyWrapperBase(prop) |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 } | 1146 } |
| 1208 | 1147 |
| 1209 int CSSPropertyAnimation::getNumProperties() | 1148 int CSSPropertyAnimation::getNumProperties() |
| 1210 { | 1149 { |
| 1211 ensurePropertyMap(); | 1150 ensurePropertyMap(); |
| 1212 | 1151 |
| 1213 return gPropertyWrappers->size(); | 1152 return gPropertyWrappers->size(); |
| 1214 } | 1153 } |
| 1215 | 1154 |
| 1216 } | 1155 } |
| OLD | NEW |