| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "core/svg/graphics/SVGImageChromeClient.h" | 29 #include "core/svg/graphics/SVGImageChromeClient.h" |
| 30 | 30 |
| 31 #include "core/svg/graphics/SVGImage.h" | 31 #include "core/svg/graphics/SVGImage.h" |
| 32 #include "platform/graphics/ImageObserver.h" | 32 #include "platform/graphics/ImageObserver.h" |
| 33 #include "wtf/CurrentTime.h" | 33 #include "wtf/CurrentTime.h" |
| 34 #include "wtf/PtrUtil.h" | |
| 35 | 34 |
| 36 namespace blink { | 35 namespace blink { |
| 37 | 36 |
| 38 static const double animationFrameDelay = 0.025; | 37 static const double animationFrameDelay = 0.025; |
| 39 | 38 |
| 40 SVGImageChromeClient::SVGImageChromeClient(SVGImage* image) | 39 SVGImageChromeClient::SVGImageChromeClient(SVGImage* image) |
| 41 : m_image(image) | 40 : m_image(image) |
| 42 , m_animationTimer( | 41 , m_animationTimer( |
| 43 wrapUnique(new Timer<SVGImageChromeClient>( | 42 wrapUnique(new Timer<SVGImageChromeClient>( |
| 44 this, &SVGImageChromeClient::animationTimerFired))) | 43 this, &SVGImageChromeClient::animationTimerFired))) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // stringent. | 104 // stringent. |
| 106 double fireTime = 0; | 105 double fireTime = 0; |
| 107 if (m_image->hasAnimations()) { | 106 if (m_image->hasAnimations()) { |
| 108 if (m_timelineState >= Suspended) | 107 if (m_timelineState >= Suspended) |
| 109 return; | 108 return; |
| 110 fireTime = animationFrameDelay; | 109 fireTime = animationFrameDelay; |
| 111 } | 110 } |
| 112 m_animationTimer->startOneShot(fireTime, BLINK_FROM_HERE); | 111 m_animationTimer->startOneShot(fireTime, BLINK_FROM_HERE); |
| 113 } | 112 } |
| 114 | 113 |
| 115 void SVGImageChromeClient::setTimer(Timer<SVGImageChromeClient>* timer) | 114 void SVGImageChromeClient::setTimer(std::unique_ptr<TimerBase> timer) |
| 116 { | 115 { |
| 117 m_animationTimer = wrapUnique(timer); | 116 m_animationTimer = std::move(timer); |
| 118 } | 117 } |
| 119 | 118 |
| 120 void SVGImageChromeClient::animationTimerFired(Timer<SVGImageChromeClient>*) | 119 void SVGImageChromeClient::animationTimerFired(TimerBase*) |
| 121 { | 120 { |
| 122 if (!m_image) | 121 if (!m_image) |
| 123 return; | 122 return; |
| 124 | 123 |
| 125 // The SVGImageChromeClient object's lifetime is dependent on | 124 // The SVGImageChromeClient object's lifetime is dependent on |
| 126 // the ImageObserver (an ImageResource) of its image. Should it | 125 // the ImageObserver (an ImageResource) of its image. Should it |
| 127 // be dead and about to be lazily swept out, do not proceed. | 126 // be dead and about to be lazily swept out, do not proceed. |
| 128 // | 127 // |
| 129 // TODO(Oilpan): move (SVG)Image to the Oilpan heap, and avoid | 128 // TODO(Oilpan): move (SVG)Image to the Oilpan heap, and avoid |
| 130 // this explicit lifetime check. | 129 // this explicit lifetime check. |
| 131 if (ThreadHeap::willObjectBeLazilySwept(m_image->getImageObserver())) | 130 if (ThreadHeap::willObjectBeLazilySwept(m_image->getImageObserver())) |
| 132 return; | 131 return; |
| 133 | 132 |
| 134 m_image->serviceAnimations(monotonicallyIncreasingTime()); | 133 m_image->serviceAnimations(monotonicallyIncreasingTime()); |
| 135 } | 134 } |
| 136 | 135 |
| 137 } // namespace blink | 136 } // namespace blink |
| OLD | NEW |