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" |
34 | 35 |
35 namespace blink { | 36 namespace blink { |
36 | 37 |
37 static const double animationFrameDelay = 0.025; | 38 static const double animationFrameDelay = 0.025; |
38 | 39 |
39 SVGImageChromeClient::SVGImageChromeClient(SVGImage* image) | 40 SVGImageChromeClient::SVGImageChromeClient(SVGImage* image) |
40 : m_image(image) | 41 : m_image(image) |
41 , m_animationTimer( | 42 , m_animationTimer( |
42 adoptPtr(new Timer<SVGImageChromeClient>( | 43 wrapUnique(new Timer<SVGImageChromeClient>( |
43 this, &SVGImageChromeClient::animationTimerFired))) | 44 this, &SVGImageChromeClient::animationTimerFired))) |
44 , m_timelineState(Running) | 45 , m_timelineState(Running) |
45 { | 46 { |
46 } | 47 } |
47 | 48 |
48 SVGImageChromeClient* SVGImageChromeClient::create(SVGImage* image) | 49 SVGImageChromeClient* SVGImageChromeClient::create(SVGImage* image) |
49 { | 50 { |
50 return new SVGImageChromeClient(image); | 51 return new SVGImageChromeClient(image); |
51 } | 52 } |
52 | 53 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 if (m_image->hasAnimations()) { | 107 if (m_image->hasAnimations()) { |
107 if (m_timelineState >= Suspended) | 108 if (m_timelineState >= Suspended) |
108 return; | 109 return; |
109 fireTime = animationFrameDelay; | 110 fireTime = animationFrameDelay; |
110 } | 111 } |
111 m_animationTimer->startOneShot(fireTime, BLINK_FROM_HERE); | 112 m_animationTimer->startOneShot(fireTime, BLINK_FROM_HERE); |
112 } | 113 } |
113 | 114 |
114 void SVGImageChromeClient::setTimer(Timer<SVGImageChromeClient>* timer) | 115 void SVGImageChromeClient::setTimer(Timer<SVGImageChromeClient>* timer) |
115 { | 116 { |
116 m_animationTimer = adoptPtr(timer); | 117 m_animationTimer = wrapUnique(timer); |
117 } | 118 } |
118 | 119 |
119 void SVGImageChromeClient::animationTimerFired(Timer<SVGImageChromeClient>*) | 120 void SVGImageChromeClient::animationTimerFired(Timer<SVGImageChromeClient>*) |
120 { | 121 { |
121 if (!m_image) | 122 if (!m_image) |
122 return; | 123 return; |
123 | 124 |
124 // The SVGImageChromeClient object's lifetime is dependent on | 125 // The SVGImageChromeClient object's lifetime is dependent on |
125 // the ImageObserver (an ImageResource) of its image. Should it | 126 // the ImageObserver (an ImageResource) of its image. Should it |
126 // be dead and about to be lazily swept out, do not proceed. | 127 // be dead and about to be lazily swept out, do not proceed. |
127 // | 128 // |
128 // TODO(Oilpan): move (SVG)Image to the Oilpan heap, and avoid | 129 // TODO(Oilpan): move (SVG)Image to the Oilpan heap, and avoid |
129 // this explicit lifetime check. | 130 // this explicit lifetime check. |
130 if (ThreadHeap::willObjectBeLazilySwept(m_image->getImageObserver())) | 131 if (ThreadHeap::willObjectBeLazilySwept(m_image->getImageObserver())) |
131 return; | 132 return; |
132 | 133 |
133 m_image->serviceAnimations(monotonicallyIncreasingTime()); | 134 m_image->serviceAnimations(monotonicallyIncreasingTime()); |
134 } | 135 } |
135 | 136 |
136 } // namespace blink | 137 } // namespace blink |
OLD | NEW |