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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 347 |
348 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 348 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const |
349 { | 349 { |
350 (dst->*m_setter)(blendFunc(anim, (a->*PropertyWrapperGetter<T>::m_getter
)(), (b->*PropertyWrapperGetter<T>::m_getter)(), progress)); | 350 (dst->*m_setter)(blendFunc(anim, (a->*PropertyWrapperGetter<T>::m_getter
)(), (b->*PropertyWrapperGetter<T>::m_getter)(), progress)); |
351 } | 351 } |
352 | 352 |
353 protected: | 353 protected: |
354 void (RenderStyle::*m_setter)(T); | 354 void (RenderStyle::*m_setter)(T); |
355 }; | 355 }; |
356 | 356 |
357 class NonNegativeLengthWrapper : public PropertyWrapper<Length> { | 357 class NonNegativeLengthWrapper FINAL : public PropertyWrapper<Length> { |
358 public: | 358 public: |
359 NonNegativeLengthWrapper(CSSPropertyID prop, Length (RenderStyle::*getter)()
const, void (RenderStyle::*setter)(Length)) | 359 NonNegativeLengthWrapper(CSSPropertyID prop, Length (RenderStyle::*getter)()
const, void (RenderStyle::*setter)(Length)) |
360 : PropertyWrapper<Length>(prop, getter, setter) | 360 : PropertyWrapper<Length>(prop, getter, setter) |
361 { | 361 { |
362 } | 362 } |
363 | 363 |
364 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 364 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const OVERRIDE |
365 { | 365 { |
366 Length from = (a->*PropertyWrapperGetter<Length>::m_getter)(); | 366 Length from = (a->*PropertyWrapperGetter<Length>::m_getter)(); |
367 Length to = (b->*PropertyWrapperGetter<Length>::m_getter)(); | 367 Length to = (b->*PropertyWrapperGetter<Length>::m_getter)(); |
368 (dst->*PropertyWrapper<Length>::m_setter)(to.blend(from, progress, Value
RangeNonNegative)); | 368 (dst->*PropertyWrapper<Length>::m_setter)(to.blend(from, progress, Value
RangeNonNegative)); |
369 } | 369 } |
370 }; | 370 }; |
371 | 371 |
372 template <typename T> | 372 template <typename T> |
373 class RefCountedPropertyWrapper : public PropertyWrapperGetter<T*> { | 373 class RefCountedPropertyWrapper : public PropertyWrapperGetter<T*> { |
374 public: | 374 public: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 }; | 412 }; |
413 | 413 |
414 class PropertyWrapperShape : public RefCountedPropertyWrapper<ShapeValue> { | 414 class PropertyWrapperShape : public RefCountedPropertyWrapper<ShapeValue> { |
415 public: | 415 public: |
416 PropertyWrapperShape(CSSPropertyID prop, ShapeValue* (RenderStyle::*getter)(
) const, void (RenderStyle::*setter)(PassRefPtr<ShapeValue>)) | 416 PropertyWrapperShape(CSSPropertyID prop, ShapeValue* (RenderStyle::*getter)(
) const, void (RenderStyle::*setter)(PassRefPtr<ShapeValue>)) |
417 : RefCountedPropertyWrapper<ShapeValue>(prop, getter, setter) | 417 : RefCountedPropertyWrapper<ShapeValue>(prop, getter, setter) |
418 { | 418 { |
419 } | 419 } |
420 }; | 420 }; |
421 | 421 |
422 class StyleImagePropertyWrapper : public RefCountedPropertyWrapper<StyleImage> { | 422 class StyleImagePropertyWrapper FINAL : public RefCountedPropertyWrapper<StyleIm
age> { |
423 public: | 423 public: |
424 StyleImagePropertyWrapper(CSSPropertyID prop, StyleImage* (RenderStyle::*get
ter)() const, void (RenderStyle::*setter)(PassRefPtr<StyleImage>)) | 424 StyleImagePropertyWrapper(CSSPropertyID prop, StyleImage* (RenderStyle::*get
ter)() const, void (RenderStyle::*setter)(PassRefPtr<StyleImage>)) |
425 : RefCountedPropertyWrapper<StyleImage>(prop, getter, setter) | 425 : RefCountedPropertyWrapper<StyleImage>(prop, getter, setter) |
426 { | 426 { |
427 } | 427 } |
428 | 428 |
429 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const | 429 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const OVERRI
DE |
430 { | 430 { |
431 // If the style pointers are the same, don't bother doing the test. | 431 // If the style pointers are the same, don't bother doing the test. |
432 // If either is null, return false. If both are null, return true. | 432 // If either is null, return false. If both are null, return true. |
433 if (a == b) | 433 if (a == b) |
434 return true; | 434 return true; |
435 if (!a || !b) | 435 if (!a || !b) |
436 return false; | 436 return false; |
437 | 437 |
438 StyleImage* imageA = (a->*m_getter)(); | 438 StyleImage* imageA = (a->*m_getter)(); |
439 StyleImage* imageB = (b->*m_getter)(); | 439 StyleImage* imageB = (b->*m_getter)(); |
440 return StyleImage::imagesEquivalent(imageA, imageB); | 440 return StyleImage::imagesEquivalent(imageA, imageB); |
441 } | 441 } |
442 }; | 442 }; |
443 | 443 |
444 class PropertyWrapperColor : public PropertyWrapperGetter<Color> { | 444 class PropertyWrapperColor FINAL : public PropertyWrapperGetter<Color> { |
445 public: | 445 public: |
446 PropertyWrapperColor(CSSPropertyID prop, Color (RenderStyle::*getter)() cons
t, void (RenderStyle::*setter)(const Color&)) | 446 PropertyWrapperColor(CSSPropertyID prop, Color (RenderStyle::*getter)() cons
t, void (RenderStyle::*setter)(const Color&)) |
447 : PropertyWrapperGetter<Color>(prop, getter) | 447 : PropertyWrapperGetter<Color>(prop, getter) |
448 , m_setter(setter) | 448 , m_setter(setter) |
449 { | 449 { |
450 } | 450 } |
451 | 451 |
452 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 452 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const OVERRIDE |
453 { | 453 { |
454 (dst->*m_setter)(blendFunc(anim, (a->*PropertyWrapperGetter<Color>::m_ge
tter)(), (b->*PropertyWrapperGetter<Color>::m_getter)(), progress)); | 454 (dst->*m_setter)(blendFunc(anim, (a->*PropertyWrapperGetter<Color>::m_ge
tter)(), (b->*PropertyWrapperGetter<Color>::m_getter)(), progress)); |
455 } | 455 } |
456 | 456 |
457 protected: | 457 protected: |
458 void (RenderStyle::*m_setter)(const Color&); | 458 void (RenderStyle::*m_setter)(const Color&); |
459 }; | 459 }; |
460 | 460 |
461 class PropertyWrapperAcceleratedOpacity : public PropertyWrapper<float> { | 461 class PropertyWrapperAcceleratedOpacity FINAL : public PropertyWrapper<float> { |
462 public: | 462 public: |
463 PropertyWrapperAcceleratedOpacity() | 463 PropertyWrapperAcceleratedOpacity() |
464 : PropertyWrapper<float>(CSSPropertyOpacity, &RenderStyle::opacity, &Ren
derStyle::setOpacity) | 464 : PropertyWrapper<float>(CSSPropertyOpacity, &RenderStyle::opacity, &Ren
derStyle::setOpacity) |
465 { | 465 { |
466 } | 466 } |
467 | 467 |
468 virtual bool animationIsAccelerated() const { return true; } | 468 virtual bool animationIsAccelerated() const OVERRIDE { return true; } |
469 | 469 |
470 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 470 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const OVERRIDE |
471 { | 471 { |
472 float fromOpacity = a->opacity(); | 472 float fromOpacity = a->opacity(); |
473 | 473 |
474 // This makes sure we put the object being animated into a RenderLayer d
uring the animation | 474 // This makes sure we put the object being animated into a RenderLayer d
uring the animation |
475 dst->setOpacity(blendFunc(anim, (fromOpacity == 1) ? 0.999999f : fromOpa
city, b->opacity(), progress)); | 475 dst->setOpacity(blendFunc(anim, (fromOpacity == 1) ? 0.999999f : fromOpa
city, b->opacity(), progress)); |
476 } | 476 } |
477 }; | 477 }; |
478 | 478 |
479 class PropertyWrapperAcceleratedTransform : public PropertyWrapper<const Transfo
rmOperations&> { | 479 class PropertyWrapperAcceleratedTransform FINAL : public PropertyWrapper<const T
ransformOperations&> { |
480 public: | 480 public: |
481 PropertyWrapperAcceleratedTransform() | 481 PropertyWrapperAcceleratedTransform() |
482 : PropertyWrapper<const TransformOperations&>(CSSPropertyWebkitTransform
, &RenderStyle::transform, &RenderStyle::setTransform) | 482 : PropertyWrapper<const TransformOperations&>(CSSPropertyWebkitTransform
, &RenderStyle::transform, &RenderStyle::setTransform) |
483 { | 483 { |
484 } | 484 } |
485 | 485 |
486 virtual bool animationIsAccelerated() const { return true; } | 486 virtual bool animationIsAccelerated() const OVERRIDE { return true; } |
487 | 487 |
488 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 488 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const OVERRIDE |
489 { | 489 { |
490 dst->setTransform(blendFunc(anim, a->transform(), b->transform(), progre
ss)); | 490 dst->setTransform(blendFunc(anim, a->transform(), b->transform(), progre
ss)); |
491 } | 491 } |
492 }; | 492 }; |
493 | 493 |
494 class PropertyWrapperAcceleratedFilter : public PropertyWrapper<const FilterOper
ations&> { | 494 class PropertyWrapperAcceleratedFilter FINAL : public PropertyWrapper<const Filt
erOperations&> { |
495 public: | 495 public: |
496 PropertyWrapperAcceleratedFilter() | 496 PropertyWrapperAcceleratedFilter() |
497 : PropertyWrapper<const FilterOperations&>(CSSPropertyWebkitFilter, &Ren
derStyle::filter, &RenderStyle::setFilter) | 497 : PropertyWrapper<const FilterOperations&>(CSSPropertyWebkitFilter, &Ren
derStyle::filter, &RenderStyle::setFilter) |
498 { | 498 { |
499 } | 499 } |
500 | 500 |
501 virtual bool animationIsAccelerated() const { return true; } | 501 virtual bool animationIsAccelerated() const OVERRIDE { return true; } |
502 | 502 |
503 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 503 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const OVERRIDE |
504 { | 504 { |
505 dst->setFilter(blendFunc(anim, a->filter(), b->filter(), progress)); | 505 dst->setFilter(blendFunc(anim, a->filter(), b->filter(), progress)); |
506 } | 506 } |
507 }; | 507 }; |
508 | 508 |
509 class PropertyWrapperShadow : public AnimationPropertyWrapperBase { | 509 class PropertyWrapperShadow FINAL : public AnimationPropertyWrapperBase { |
510 public: | 510 public: |
511 PropertyWrapperShadow(CSSPropertyID prop, ShadowList* (RenderStyle::*getter)
() const, void (RenderStyle::*setter)(PassRefPtr<ShadowList>)) | 511 PropertyWrapperShadow(CSSPropertyID prop, ShadowList* (RenderStyle::*getter)
() const, void (RenderStyle::*setter)(PassRefPtr<ShadowList>)) |
512 : AnimationPropertyWrapperBase(prop) | 512 : AnimationPropertyWrapperBase(prop) |
513 , m_getter(getter) | 513 , m_getter(getter) |
514 , m_setter(setter) | 514 , m_setter(setter) |
515 { | 515 { |
516 } | 516 } |
517 | 517 |
518 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const | 518 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const OVERRI
DE |
519 { | 519 { |
520 const ShadowList* shadowA = (a->*m_getter)(); | 520 const ShadowList* shadowA = (a->*m_getter)(); |
521 const ShadowList* shadowB = (b->*m_getter)(); | 521 const ShadowList* shadowB = (b->*m_getter)(); |
522 if (shadowA == shadowB) | 522 if (shadowA == shadowB) |
523 return true; | 523 return true; |
524 if (shadowA && shadowB) | 524 if (shadowA && shadowB) |
525 return *shadowA == *shadowB; | 525 return *shadowA == *shadowB; |
526 return false; | 526 return false; |
527 } | 527 } |
528 | 528 |
529 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 529 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const OVERRIDE |
530 { | 530 { |
531 (dst->*m_setter)(ShadowList::blend((a->*m_getter)(), (b->*m_getter)(), p
rogress)); | 531 (dst->*m_setter)(ShadowList::blend((a->*m_getter)(), (b->*m_getter)(), p
rogress)); |
532 } | 532 } |
533 | 533 |
534 ShadowList* (RenderStyle::*m_getter)() const; | 534 ShadowList* (RenderStyle::*m_getter)() const; |
535 void (RenderStyle::*m_setter)(PassRefPtr<ShadowList>); | 535 void (RenderStyle::*m_setter)(PassRefPtr<ShadowList>); |
536 }; | 536 }; |
537 | 537 |
538 class PropertyWrapperMaybeInvalidColor : public AnimationPropertyWrapperBase { | 538 class PropertyWrapperMaybeInvalidColor FINAL : public AnimationPropertyWrapperBa
se { |
539 public: | 539 public: |
540 PropertyWrapperMaybeInvalidColor(CSSPropertyID prop, Color (RenderStyle::*ge
tter)() const, void (RenderStyle::*setter)(const Color&)) | 540 PropertyWrapperMaybeInvalidColor(CSSPropertyID prop, Color (RenderStyle::*ge
tter)() const, void (RenderStyle::*setter)(const Color&)) |
541 : AnimationPropertyWrapperBase(prop) | 541 : AnimationPropertyWrapperBase(prop) |
542 , m_getter(getter) | 542 , m_getter(getter) |
543 , m_setter(setter) | 543 , m_setter(setter) |
544 { | 544 { |
545 } | 545 } |
546 | 546 |
547 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const | 547 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const OVERRI
DE |
548 { | 548 { |
549 Color fromColor = (a->*m_getter)(); | 549 Color fromColor = (a->*m_getter)(); |
550 Color toColor = (b->*m_getter)(); | 550 Color toColor = (b->*m_getter)(); |
551 | 551 |
552 if (!fromColor.isValid() && !toColor.isValid()) | 552 if (!fromColor.isValid() && !toColor.isValid()) |
553 return true; | 553 return true; |
554 | 554 |
555 if (!fromColor.isValid()) | 555 if (!fromColor.isValid()) |
556 fromColor = a->color(); | 556 fromColor = a->color(); |
557 if (!toColor.isValid()) | 557 if (!toColor.isValid()) |
558 toColor = b->color(); | 558 toColor = b->color(); |
559 | 559 |
560 return fromColor == toColor; | 560 return fromColor == toColor; |
561 } | 561 } |
562 | 562 |
563 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 563 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const OVERRIDE |
564 { | 564 { |
565 Color fromColor = (a->*m_getter)(); | 565 Color fromColor = (a->*m_getter)(); |
566 Color toColor = (b->*m_getter)(); | 566 Color toColor = (b->*m_getter)(); |
567 | 567 |
568 if (!fromColor.isValid() && !toColor.isValid()) | 568 if (!fromColor.isValid() && !toColor.isValid()) |
569 return; | 569 return; |
570 | 570 |
571 if (!fromColor.isValid()) | 571 if (!fromColor.isValid()) |
572 fromColor = a->color(); | 572 fromColor = a->color(); |
573 if (!toColor.isValid()) | 573 if (!toColor.isValid()) |
574 toColor = b->color(); | 574 toColor = b->color(); |
575 (dst->*m_setter)(blendFunc(anim, fromColor, toColor, progress)); | 575 (dst->*m_setter)(blendFunc(anim, fromColor, toColor, progress)); |
576 } | 576 } |
577 | 577 |
578 private: | 578 private: |
579 Color (RenderStyle::*m_getter)() const; | 579 Color (RenderStyle::*m_getter)() const; |
580 void (RenderStyle::*m_setter)(const Color&); | 580 void (RenderStyle::*m_setter)(const Color&); |
581 }; | 581 }; |
582 | 582 |
583 | 583 |
584 enum MaybeInvalidColorTag { MaybeInvalidColor }; | 584 enum MaybeInvalidColorTag { MaybeInvalidColor }; |
585 class PropertyWrapperVisitedAffectedColor : public AnimationPropertyWrapperBase
{ | 585 class PropertyWrapperVisitedAffectedColor FINAL : public AnimationPropertyWrappe
rBase { |
586 public: | 586 public: |
587 PropertyWrapperVisitedAffectedColor(CSSPropertyID prop, Color (RenderStyle::
*getter)() const, void (RenderStyle::*setter)(const Color&), | 587 PropertyWrapperVisitedAffectedColor(CSSPropertyID prop, Color (RenderStyle::
*getter)() const, void (RenderStyle::*setter)(const Color&), |
588 Color (RenderStyle::*visitedGetter)() const, void (RenderStyle::*visited
Setter)(const Color&)) | 588 Color (RenderStyle::*visitedGetter)() const, void (RenderStyle::*visited
Setter)(const Color&)) |
589 : AnimationPropertyWrapperBase(prop) | 589 : AnimationPropertyWrapperBase(prop) |
590 , m_wrapper(adoptPtr(new PropertyWrapperColor(prop, getter, setter))) | 590 , m_wrapper(adoptPtr(new PropertyWrapperColor(prop, getter, setter))) |
591 , m_visitedWrapper(adoptPtr(new PropertyWrapperColor(prop, visitedGetter
, visitedSetter))) | 591 , m_visitedWrapper(adoptPtr(new PropertyWrapperColor(prop, visitedGetter
, visitedSetter))) |
592 { | 592 { |
593 } | 593 } |
594 PropertyWrapperVisitedAffectedColor(CSSPropertyID prop, MaybeInvalidColorTag
, Color (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&
), | 594 PropertyWrapperVisitedAffectedColor(CSSPropertyID prop, MaybeInvalidColorTag
, Color (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&
), |
595 Color (RenderStyle::*visitedGetter)() const, void (RenderStyle::*visited
Setter)(const Color&)) | 595 Color (RenderStyle::*visitedGetter)() const, void (RenderStyle::*visited
Setter)(const Color&)) |
596 : AnimationPropertyWrapperBase(prop) | 596 : AnimationPropertyWrapperBase(prop) |
597 , m_wrapper(adoptPtr(new PropertyWrapperMaybeInvalidColor(prop, getter,
setter))) | 597 , m_wrapper(adoptPtr(new PropertyWrapperMaybeInvalidColor(prop, getter,
setter))) |
598 , m_visitedWrapper(adoptPtr(new PropertyWrapperMaybeInvalidColor(prop, v
isitedGetter, visitedSetter))) | 598 , m_visitedWrapper(adoptPtr(new PropertyWrapperMaybeInvalidColor(prop, v
isitedGetter, visitedSetter))) |
599 { | 599 { |
600 } | 600 } |
601 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const | 601 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const OVERRI
DE |
602 { | 602 { |
603 return m_wrapper->equals(a, b) && m_visitedWrapper->equals(a, b); | 603 return m_wrapper->equals(a, b) && m_visitedWrapper->equals(a, b); |
604 } | 604 } |
605 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 605 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const OVERRIDE |
606 { | 606 { |
607 m_wrapper->blend(anim, dst, a, b, progress); | 607 m_wrapper->blend(anim, dst, a, b, progress); |
608 m_visitedWrapper->blend(anim, dst, a, b, progress); | 608 m_visitedWrapper->blend(anim, dst, a, b, progress); |
609 } | 609 } |
610 | 610 |
611 private: | 611 private: |
612 OwnPtr<AnimationPropertyWrapperBase> m_wrapper; | 612 OwnPtr<AnimationPropertyWrapperBase> m_wrapper; |
613 OwnPtr<AnimationPropertyWrapperBase> m_visitedWrapper; | 613 OwnPtr<AnimationPropertyWrapperBase> m_visitedWrapper; |
614 }; | 614 }; |
615 | 615 |
(...skipping 28 matching lines...) Expand all Loading... |
644 if (!a || !b) | 644 if (!a || !b) |
645 return false; | 645 return false; |
646 return (a->*m_getter)() == (b->*m_getter)(); | 646 return (a->*m_getter)() == (b->*m_getter)(); |
647 } | 647 } |
648 | 648 |
649 protected: | 649 protected: |
650 T (FillLayer::*m_getter)() const; | 650 T (FillLayer::*m_getter)() const; |
651 }; | 651 }; |
652 | 652 |
653 template <typename T> | 653 template <typename T> |
654 class FillLayerPropertyWrapper : public FillLayerPropertyWrapperGetter<T> { | 654 class FillLayerPropertyWrapper FINAL : public FillLayerPropertyWrapperGetter<T>
{ |
655 public: | 655 public: |
656 FillLayerPropertyWrapper(T (FillLayer::*getter)() const, void (FillLayer::*s
etter)(T)) | 656 FillLayerPropertyWrapper(T (FillLayer::*getter)() const, void (FillLayer::*s
etter)(T)) |
657 : FillLayerPropertyWrapperGetter<T>(getter) | 657 : FillLayerPropertyWrapperGetter<T>(getter) |
658 , m_setter(setter) | 658 , m_setter(setter) |
659 { | 659 { |
660 } | 660 } |
661 | 661 |
662 virtual void blend(const AnimationBase* anim, FillLayer* dst, const FillLaye
r* a, const FillLayer* b, double progress) const | 662 virtual void blend(const AnimationBase* anim, FillLayer* dst, const FillLaye
r* a, const FillLayer* b, double progress) const OVERRIDE |
663 { | 663 { |
664 (dst->*m_setter)(blendFunc(anim, (a->*FillLayerPropertyWrapperGetter<T>:
:m_getter)(), (b->*FillLayerPropertyWrapperGetter<T>::m_getter)(), progress)); | 664 (dst->*m_setter)(blendFunc(anim, (a->*FillLayerPropertyWrapperGetter<T>:
:m_getter)(), (b->*FillLayerPropertyWrapperGetter<T>::m_getter)(), progress)); |
665 } | 665 } |
666 | 666 |
667 protected: | 667 protected: |
668 void (FillLayer::*m_setter)(T); | 668 void (FillLayer::*m_setter)(T); |
669 }; | 669 }; |
670 | 670 |
671 template <typename T> | 671 template <typename T> |
672 class FillLayerRefCountedPropertyWrapper : public FillLayerPropertyWrapperGetter
<T*> { | 672 class FillLayerRefCountedPropertyWrapper : public FillLayerPropertyWrapperGetter
<T*> { |
673 public: | 673 public: |
674 FillLayerRefCountedPropertyWrapper(T* (FillLayer::*getter)() const, void (Fi
llLayer::*setter)(PassRefPtr<T>)) | 674 FillLayerRefCountedPropertyWrapper(T* (FillLayer::*getter)() const, void (Fi
llLayer::*setter)(PassRefPtr<T>)) |
675 : FillLayerPropertyWrapperGetter<T*>(getter) | 675 : FillLayerPropertyWrapperGetter<T*>(getter) |
676 , m_setter(setter) | 676 , m_setter(setter) |
677 { | 677 { |
678 } | 678 } |
679 | 679 |
680 virtual void blend(const AnimationBase* anim, FillLayer* dst, const FillLaye
r* a, const FillLayer* b, double progress) const | 680 virtual void blend(const AnimationBase* anim, FillLayer* dst, const FillLaye
r* a, const FillLayer* b, double progress) const |
681 { | 681 { |
682 (dst->*m_setter)(blendFunc(anim, (a->*FillLayerPropertyWrapperGetter<T*>
::m_getter)(), (b->*FillLayerPropertyWrapperGetter<T*>::m_getter)(), progress)); | 682 (dst->*m_setter)(blendFunc(anim, (a->*FillLayerPropertyWrapperGetter<T*>
::m_getter)(), (b->*FillLayerPropertyWrapperGetter<T*>::m_getter)(), progress)); |
683 } | 683 } |
684 | 684 |
685 protected: | 685 protected: |
686 void (FillLayer::*m_setter)(PassRefPtr<T>); | 686 void (FillLayer::*m_setter)(PassRefPtr<T>); |
687 }; | 687 }; |
688 | 688 |
689 class FillLayerStyleImagePropertyWrapper : public FillLayerRefCountedPropertyWra
pper<StyleImage> { | 689 class FillLayerStyleImagePropertyWrapper FINAL : public FillLayerRefCountedPrope
rtyWrapper<StyleImage> { |
690 public: | 690 public: |
691 FillLayerStyleImagePropertyWrapper(StyleImage* (FillLayer::*getter)() const,
void (FillLayer::*setter)(PassRefPtr<StyleImage>)) | 691 FillLayerStyleImagePropertyWrapper(StyleImage* (FillLayer::*getter)() const,
void (FillLayer::*setter)(PassRefPtr<StyleImage>)) |
692 : FillLayerRefCountedPropertyWrapper<StyleImage>(getter, setter) | 692 : FillLayerRefCountedPropertyWrapper<StyleImage>(getter, setter) |
693 { | 693 { |
694 } | 694 } |
695 | 695 |
696 virtual bool equals(const FillLayer* a, const FillLayer* b) const | 696 virtual bool equals(const FillLayer* a, const FillLayer* b) const OVERRIDE |
697 { | 697 { |
698 // If the style pointers are the same, don't bother doing the test. | 698 // If the style pointers are the same, don't bother doing the test. |
699 // If either is null, return false. If both are null, return true. | 699 // If either is null, return false. If both are null, return true. |
700 if (a == b) | 700 if (a == b) |
701 return true; | 701 return true; |
702 if (!a || !b) | 702 if (!a || !b) |
703 return false; | 703 return false; |
704 | 704 |
705 StyleImage* imageA = (a->*m_getter)(); | 705 StyleImage* imageA = (a->*m_getter)(); |
706 StyleImage* imageB = (b->*m_getter)(); | 706 StyleImage* imageB = (b->*m_getter)(); |
707 return StyleImage::imagesEquivalent(imageA, imageB); | 707 return StyleImage::imagesEquivalent(imageA, imageB); |
708 } | 708 } |
709 }; | 709 }; |
710 | 710 |
711 | 711 |
712 class FillLayersPropertyWrapper : public AnimationPropertyWrapperBase { | 712 class FillLayersPropertyWrapper FINAL : public AnimationPropertyWrapperBase { |
713 public: | 713 public: |
714 typedef const FillLayer* (RenderStyle::*LayersGetter)() const; | 714 typedef const FillLayer* (RenderStyle::*LayersGetter)() const; |
715 typedef FillLayer* (RenderStyle::*LayersAccessor)(); | 715 typedef FillLayer* (RenderStyle::*LayersAccessor)(); |
716 | 716 |
717 FillLayersPropertyWrapper(CSSPropertyID prop, LayersGetter getter, LayersAcc
essor accessor) | 717 FillLayersPropertyWrapper(CSSPropertyID prop, LayersGetter getter, LayersAcc
essor accessor) |
718 : AnimationPropertyWrapperBase(prop) | 718 : AnimationPropertyWrapperBase(prop) |
719 , m_layersGetter(getter) | 719 , m_layersGetter(getter) |
720 , m_layersAccessor(accessor) | 720 , m_layersAccessor(accessor) |
721 { | 721 { |
722 switch (prop) { | 722 switch (prop) { |
(...skipping 11 matching lines...) Expand all Loading... |
734 m_fillLayerPropertyWrapper = new FillLayerPropertyWrapper<LengthSize
>(&FillLayer::sizeLength, &FillLayer::setSizeLength); | 734 m_fillLayerPropertyWrapper = new FillLayerPropertyWrapper<LengthSize
>(&FillLayer::sizeLength, &FillLayer::setSizeLength); |
735 break; | 735 break; |
736 case CSSPropertyBackgroundImage: | 736 case CSSPropertyBackgroundImage: |
737 m_fillLayerPropertyWrapper = new FillLayerStyleImagePropertyWrapper(
&FillLayer::image, &FillLayer::setImage); | 737 m_fillLayerPropertyWrapper = new FillLayerStyleImagePropertyWrapper(
&FillLayer::image, &FillLayer::setImage); |
738 break; | 738 break; |
739 default: | 739 default: |
740 break; | 740 break; |
741 } | 741 } |
742 } | 742 } |
743 | 743 |
744 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const | 744 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const OVERRI
DE |
745 { | 745 { |
746 const FillLayer* fromLayer = (a->*m_layersGetter)(); | 746 const FillLayer* fromLayer = (a->*m_layersGetter)(); |
747 const FillLayer* toLayer = (b->*m_layersGetter)(); | 747 const FillLayer* toLayer = (b->*m_layersGetter)(); |
748 | 748 |
749 while (fromLayer && toLayer) { | 749 while (fromLayer && toLayer) { |
750 if (!m_fillLayerPropertyWrapper->equals(fromLayer, toLayer)) | 750 if (!m_fillLayerPropertyWrapper->equals(fromLayer, toLayer)) |
751 return false; | 751 return false; |
752 | 752 |
753 fromLayer = fromLayer->next(); | 753 fromLayer = fromLayer->next(); |
754 toLayer = toLayer->next(); | 754 toLayer = toLayer->next(); |
755 } | 755 } |
756 | 756 |
757 return true; | 757 return true; |
758 } | 758 } |
759 | 759 |
760 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 760 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const OVERRIDE |
761 { | 761 { |
762 const FillLayer* aLayer = (a->*m_layersGetter)(); | 762 const FillLayer* aLayer = (a->*m_layersGetter)(); |
763 const FillLayer* bLayer = (b->*m_layersGetter)(); | 763 const FillLayer* bLayer = (b->*m_layersGetter)(); |
764 FillLayer* dstLayer = (dst->*m_layersAccessor)(); | 764 FillLayer* dstLayer = (dst->*m_layersAccessor)(); |
765 | 765 |
766 while (aLayer && bLayer && dstLayer) { | 766 while (aLayer && bLayer && dstLayer) { |
767 m_fillLayerPropertyWrapper->blend(anim, dstLayer, aLayer, bLayer, pr
ogress); | 767 m_fillLayerPropertyWrapper->blend(anim, dstLayer, aLayer, bLayer, pr
ogress); |
768 aLayer = aLayer->next(); | 768 aLayer = aLayer->next(); |
769 bLayer = bLayer->next(); | 769 bLayer = bLayer->next(); |
770 dstLayer = dstLayer->next(); | 770 dstLayer = dstLayer->next(); |
771 } | 771 } |
772 } | 772 } |
773 | 773 |
774 private: | 774 private: |
775 FillLayerAnimationPropertyWrapperBase* m_fillLayerPropertyWrapper; | 775 FillLayerAnimationPropertyWrapperBase* m_fillLayerPropertyWrapper; |
776 | 776 |
777 LayersGetter m_layersGetter; | 777 LayersGetter m_layersGetter; |
778 LayersAccessor m_layersAccessor; | 778 LayersAccessor m_layersAccessor; |
779 }; | 779 }; |
780 | 780 |
781 class ShorthandPropertyWrapper : public AnimationPropertyWrapperBase { | 781 class ShorthandPropertyWrapper FINAL : public AnimationPropertyWrapperBase { |
782 public: | 782 public: |
783 ShorthandPropertyWrapper(CSSPropertyID property, const StylePropertyShorthan
d& shorthand) | 783 ShorthandPropertyWrapper(CSSPropertyID property, const StylePropertyShorthan
d& shorthand) |
784 : AnimationPropertyWrapperBase(property) | 784 : AnimationPropertyWrapperBase(property) |
785 { | 785 { |
786 for (unsigned i = 0; i < shorthand.length(); ++i) { | 786 for (unsigned i = 0; i < shorthand.length(); ++i) { |
787 AnimationPropertyWrapperBase* wrapper = wrapperForProperty(shorthand
.properties()[i]); | 787 AnimationPropertyWrapperBase* wrapper = wrapperForProperty(shorthand
.properties()[i]); |
788 if (wrapper) | 788 if (wrapper) |
789 m_propertyWrappers.append(wrapper); | 789 m_propertyWrappers.append(wrapper); |
790 } | 790 } |
791 } | 791 } |
792 | 792 |
793 virtual bool isShorthandWrapper() const { return true; } | 793 virtual bool isShorthandWrapper() const OVERRIDE { return true; } |
794 | 794 |
795 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const | 795 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const OVERRI
DE |
796 { | 796 { |
797 Vector<AnimationPropertyWrapperBase*>::const_iterator end = m_propertyWr
appers.end(); | 797 Vector<AnimationPropertyWrapperBase*>::const_iterator end = m_propertyWr
appers.end(); |
798 for (Vector<AnimationPropertyWrapperBase*>::const_iterator it = m_proper
tyWrappers.begin(); it != end; ++it) { | 798 for (Vector<AnimationPropertyWrapperBase*>::const_iterator it = m_proper
tyWrappers.begin(); it != end; ++it) { |
799 if (!(*it)->equals(a, b)) | 799 if (!(*it)->equals(a, b)) |
800 return false; | 800 return false; |
801 } | 801 } |
802 return true; | 802 return true; |
803 } | 803 } |
804 | 804 |
805 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 805 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const OVERRIDE |
806 { | 806 { |
807 Vector<AnimationPropertyWrapperBase*>::const_iterator end = m_propertyWr
appers.end(); | 807 Vector<AnimationPropertyWrapperBase*>::const_iterator end = m_propertyWr
appers.end(); |
808 for (Vector<AnimationPropertyWrapperBase*>::const_iterator it = m_proper
tyWrappers.begin(); it != end; ++it) | 808 for (Vector<AnimationPropertyWrapperBase*>::const_iterator it = m_proper
tyWrappers.begin(); it != end; ++it) |
809 (*it)->blend(anim, dst, a, b, progress); | 809 (*it)->blend(anim, dst, a, b, progress); |
810 } | 810 } |
811 | 811 |
812 const Vector<AnimationPropertyWrapperBase*> propertyWrappers() const { retur
n m_propertyWrappers; } | 812 const Vector<AnimationPropertyWrapperBase*> propertyWrappers() const { retur
n m_propertyWrappers; } |
813 | 813 |
814 private: | 814 private: |
815 Vector<AnimationPropertyWrapperBase*> m_propertyWrappers; | 815 Vector<AnimationPropertyWrapperBase*> m_propertyWrappers; |
816 }; | 816 }; |
817 | 817 |
818 class PropertyWrapperFlex : public AnimationPropertyWrapperBase { | 818 class PropertyWrapperFlex FINAL : public AnimationPropertyWrapperBase { |
819 public: | 819 public: |
820 PropertyWrapperFlex() | 820 PropertyWrapperFlex() |
821 : AnimationPropertyWrapperBase(CSSPropertyFlex) | 821 : AnimationPropertyWrapperBase(CSSPropertyFlex) |
822 { | 822 { |
823 } | 823 } |
824 | 824 |
825 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const | 825 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const OVERRI
DE |
826 { | 826 { |
827 // If the style pointers are the same, don't bother doing the test. | 827 // If the style pointers are the same, don't bother doing the test. |
828 // If either is null, return false. If both are null, return true. | 828 // If either is null, return false. If both are null, return true. |
829 if ((!a && !b) || a == b) | 829 if ((!a && !b) || a == b) |
830 return true; | 830 return true; |
831 if (!a || !b) | 831 if (!a || !b) |
832 return false; | 832 return false; |
833 | 833 |
834 return a->flexBasis() == b->flexBasis() && a->flexGrow() == b->flexGrow(
) && a->flexShrink() == b->flexShrink(); | 834 return a->flexBasis() == b->flexBasis() && a->flexGrow() == b->flexGrow(
) && a->flexShrink() == b->flexShrink(); |
835 } | 835 } |
836 | 836 |
837 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 837 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const OVERRIDE |
838 { | 838 { |
839 dst->setFlexBasis(blendFunc(anim, a->flexBasis(), b->flexBasis(), progre
ss)); | 839 dst->setFlexBasis(blendFunc(anim, a->flexBasis(), b->flexBasis(), progre
ss)); |
840 dst->setFlexGrow(blendFunc(anim, a->flexGrow(), b->flexGrow(), progress)
); | 840 dst->setFlexGrow(blendFunc(anim, a->flexGrow(), b->flexGrow(), progress)
); |
841 dst->setFlexShrink(blendFunc(anim, a->flexShrink(), b->flexShrink(), pro
gress)); | 841 dst->setFlexShrink(blendFunc(anim, a->flexShrink(), b->flexShrink(), pro
gress)); |
842 } | 842 } |
843 }; | 843 }; |
844 | 844 |
845 class PropertyWrapperSVGPaint : public AnimationPropertyWrapperBase { | 845 class PropertyWrapperSVGPaint FINAL : public AnimationPropertyWrapperBase { |
846 public: | 846 public: |
847 PropertyWrapperSVGPaint(CSSPropertyID prop, const SVGPaint::SVGPaintType& (R
enderStyle::*paintTypeGetter)() const, Color (RenderStyle::*getter)() const, voi
d (RenderStyle::*setter)(const Color&)) | 847 PropertyWrapperSVGPaint(CSSPropertyID prop, const SVGPaint::SVGPaintType& (R
enderStyle::*paintTypeGetter)() const, Color (RenderStyle::*getter)() const, voi
d (RenderStyle::*setter)(const Color&)) |
848 : AnimationPropertyWrapperBase(prop) | 848 : AnimationPropertyWrapperBase(prop) |
849 , m_paintTypeGetter(paintTypeGetter) | 849 , m_paintTypeGetter(paintTypeGetter) |
850 , m_getter(getter) | 850 , m_getter(getter) |
851 , m_setter(setter) | 851 , m_setter(setter) |
852 { | 852 { |
853 } | 853 } |
854 | 854 |
855 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const | 855 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const OVERRI
DE |
856 { | 856 { |
857 if ((a->*m_paintTypeGetter)() != (b->*m_paintTypeGetter)()) | 857 if ((a->*m_paintTypeGetter)() != (b->*m_paintTypeGetter)()) |
858 return false; | 858 return false; |
859 | 859 |
860 // We only support animations between SVGPaints that are pure Color valu
es. | 860 // We only support animations between SVGPaints that are pure Color valu
es. |
861 // For everything else we must return true for this method, otherwise | 861 // For everything else we must return true for this method, otherwise |
862 // we will try to animate between values forever. | 862 // we will try to animate between values forever. |
863 if ((a->*m_paintTypeGetter)() == SVGPaint::SVG_PAINTTYPE_RGBCOLOR) { | 863 if ((a->*m_paintTypeGetter)() == SVGPaint::SVG_PAINTTYPE_RGBCOLOR) { |
864 Color fromColor = (a->*m_getter)(); | 864 Color fromColor = (a->*m_getter)(); |
865 Color toColor = (b->*m_getter)(); | 865 Color toColor = (b->*m_getter)(); |
866 | 866 |
867 if (!fromColor.isValid() && !toColor.isValid()) | 867 if (!fromColor.isValid() && !toColor.isValid()) |
868 return true; | 868 return true; |
869 | 869 |
870 if (!fromColor.isValid()) | 870 if (!fromColor.isValid()) |
871 fromColor = Color(); | 871 fromColor = Color(); |
872 if (!toColor.isValid()) | 872 if (!toColor.isValid()) |
873 toColor = Color(); | 873 toColor = Color(); |
874 | 874 |
875 return fromColor == toColor; | 875 return fromColor == toColor; |
876 } | 876 } |
877 return true; | 877 return true; |
878 } | 878 } |
879 | 879 |
880 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const | 880 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const OVERRIDE |
881 { | 881 { |
882 if ((a->*m_paintTypeGetter)() != SVGPaint::SVG_PAINTTYPE_RGBCOLOR | 882 if ((a->*m_paintTypeGetter)() != SVGPaint::SVG_PAINTTYPE_RGBCOLOR |
883 || (b->*m_paintTypeGetter)() != SVGPaint::SVG_PAINTTYPE_RGBCOLOR) | 883 || (b->*m_paintTypeGetter)() != SVGPaint::SVG_PAINTTYPE_RGBCOLOR) |
884 return; | 884 return; |
885 | 885 |
886 Color fromColor = (a->*m_getter)(); | 886 Color fromColor = (a->*m_getter)(); |
887 Color toColor = (b->*m_getter)(); | 887 Color toColor = (b->*m_getter)(); |
888 | 888 |
889 if (!fromColor.isValid() && !toColor.isValid()) | 889 if (!fromColor.isValid() && !toColor.isValid()) |
890 return; | 890 return; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 } | 1197 } |
1198 | 1198 |
1199 int CSSPropertyAnimation::getNumProperties() | 1199 int CSSPropertyAnimation::getNumProperties() |
1200 { | 1200 { |
1201 ensurePropertyMap(); | 1201 ensurePropertyMap(); |
1202 | 1202 |
1203 return gPropertyWrappers->size(); | 1203 return gPropertyWrappers->size(); |
1204 } | 1204 } |
1205 | 1205 |
1206 } | 1206 } |
OLD | NEW |