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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 void SVGImageChromeClient::invalidateRect(const IntRect& r) { | 58 void SVGImageChromeClient::invalidateRect(const IntRect& r) { |
59 // If m_image->m_page is null, we're being destructed, don't fire | 59 // If m_image->m_page is null, we're being destructed, don't fire |
60 // changedInRect() in that case. | 60 // changedInRect() in that case. |
61 if (m_image && m_image->getImageObserver() && m_image->m_page) | 61 if (m_image && m_image->getImageObserver() && m_image->m_page) |
62 m_image->getImageObserver()->changedInRect(m_image, r); | 62 m_image->getImageObserver()->changedInRect(m_image, r); |
63 } | 63 } |
64 | 64 |
65 void SVGImageChromeClient::suspendAnimation() { | 65 void SVGImageChromeClient::suspendAnimation() { |
66 if (m_image->hasAnimations()) { | 66 if (m_image->maybeAnimated()) { |
67 m_timelineState = SuspendedWithAnimationPending; | 67 m_timelineState = SuspendedWithAnimationPending; |
68 } else { | 68 } else { |
69 // Preserve SuspendedWithAnimationPending if set. | 69 // Preserve SuspendedWithAnimationPending if set. |
70 m_timelineState = std::max(m_timelineState, Suspended); | 70 m_timelineState = std::max(m_timelineState, Suspended); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 void SVGImageChromeClient::resumeAnimation() { | 74 void SVGImageChromeClient::resumeAnimation() { |
75 bool havePendingAnimation = m_timelineState == SuspendedWithAnimationPending; | 75 bool havePendingAnimation = m_timelineState == SuspendedWithAnimationPending; |
76 m_timelineState = Running; | 76 m_timelineState = Running; |
(...skipping 11 matching lines...) Expand all Loading... |
88 // run this fake animation timer to trigger layout in SVGImages. The name, | 88 // run this fake animation timer to trigger layout in SVGImages. The name, |
89 // "animationTimer", is to match the new requestAnimationFrame-based layout | 89 // "animationTimer", is to match the new requestAnimationFrame-based layout |
90 // approach. | 90 // approach. |
91 if (m_animationTimer->isActive()) | 91 if (m_animationTimer->isActive()) |
92 return; | 92 return; |
93 // Schedule the 'animation' ASAP if the image does not contain any | 93 // Schedule the 'animation' ASAP if the image does not contain any |
94 // animations, but prefer a fixed, jittery, frame-delay if there're any | 94 // animations, but prefer a fixed, jittery, frame-delay if there're any |
95 // animations. Checking for pending/active animations could be more | 95 // animations. Checking for pending/active animations could be more |
96 // stringent. | 96 // stringent. |
97 double fireTime = 0; | 97 double fireTime = 0; |
98 if (m_image->hasAnimations()) { | 98 if (m_image->maybeAnimated()) { |
99 if (m_timelineState >= Suspended) | 99 if (m_timelineState >= Suspended) |
100 return; | 100 return; |
101 fireTime = animationFrameDelay; | 101 fireTime = animationFrameDelay; |
102 } | 102 } |
103 m_animationTimer->startOneShot(fireTime, BLINK_FROM_HERE); | 103 m_animationTimer->startOneShot(fireTime, BLINK_FROM_HERE); |
104 } | 104 } |
105 | 105 |
106 void SVGImageChromeClient::setTimer(std::unique_ptr<TimerBase> timer) { | 106 void SVGImageChromeClient::setTimer(std::unique_ptr<TimerBase> timer) { |
107 m_animationTimer = std::move(timer); | 107 m_animationTimer = std::move(timer); |
108 } | 108 } |
109 | 109 |
110 void SVGImageChromeClient::animationTimerFired(TimerBase*) { | 110 void SVGImageChromeClient::animationTimerFired(TimerBase*) { |
111 if (!m_image) | 111 if (!m_image) |
112 return; | 112 return; |
113 | 113 |
114 // The SVGImageChromeClient object's lifetime is dependent on | 114 // The SVGImageChromeClient object's lifetime is dependent on |
115 // the ImageObserver (an ImageResourceContent) of its image. Should it | 115 // the ImageObserver (an ImageResourceContent) of its image. Should it |
116 // be dead and about to be lazily swept out, do not proceed. | 116 // be dead and about to be lazily swept out, do not proceed. |
117 // | 117 // |
118 // TODO(Oilpan): move (SVG)Image to the Oilpan heap, and avoid | 118 // TODO(Oilpan): move (SVG)Image to the Oilpan heap, and avoid |
119 // this explicit lifetime check. | 119 // this explicit lifetime check. |
120 if (ThreadHeap::willObjectBeLazilySwept(m_image->getImageObserver())) | 120 if (ThreadHeap::willObjectBeLazilySwept(m_image->getImageObserver())) |
121 return; | 121 return; |
122 | 122 |
123 m_image->serviceAnimations(monotonicallyIncreasingTime()); | 123 m_image->serviceAnimations(monotonicallyIncreasingTime()); |
124 } | 124 } |
125 | 125 |
126 } // namespace blink | 126 } // namespace blink |
OLD | NEW |