| 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 14 matching lines...) Expand all Loading... |
| 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 "config.h" | 29 #include "config.h" |
| 30 #include "core/svg/graphics/SVGImageChromeClient.h" | 30 #include "core/svg/graphics/SVGImageChromeClient.h" |
| 31 | 31 |
| 32 #include "core/frame/FrameView.h" | 32 #include "core/frame/FrameView.h" |
| 33 #include "core/svg/graphics/SVGImage.h" | 33 #include "core/svg/graphics/SVGImage.h" |
| 34 #include "platform/graphics/ImageObserver.h" | 34 #include "platform/graphics/ImageObserver.h" |
| 35 #include "wtf/CurrentTime.h" | |
| 36 | 35 |
| 37 namespace WebCore { | 36 namespace WebCore { |
| 38 | 37 |
| 39 static const double animationFrameDelay = 0.025; | |
| 40 | |
| 41 SVGImageChromeClient::SVGImageChromeClient(SVGImage* image) | 38 SVGImageChromeClient::SVGImageChromeClient(SVGImage* image) |
| 42 : m_image(image) | 39 : m_image(image) |
| 43 , m_animationTimer(this, &SVGImageChromeClient::animationTimerFired) | 40 , m_animationTimer(this, &SVGImageChromeClient::animationTimerFired) |
| 44 { | 41 { |
| 45 } | 42 } |
| 46 | 43 |
| 47 bool SVGImageChromeClient::isSVGImageChromeClient() const | 44 bool SVGImageChromeClient::isSVGImageChromeClient() const |
| 48 { | 45 { |
| 49 return true; | 46 return true; |
| 50 } | 47 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 63 | 60 |
| 64 void SVGImageChromeClient::scheduleAnimation() | 61 void SVGImageChromeClient::scheduleAnimation() |
| 65 { | 62 { |
| 66 // Because a single SVGImage can be shared by multiple pages, we can't key | 63 // Because a single SVGImage can be shared by multiple pages, we can't key |
| 67 // our svg image layout on the page's real animation frame. Therefore, we | 64 // our svg image layout on the page's real animation frame. Therefore, we |
| 68 // run this fake animation timer to trigger layout in SVGImages. The name, | 65 // run this fake animation timer to trigger layout in SVGImages. The name, |
| 69 // "animationTimer", is to match the new requestAnimationFrame-based layout | 66 // "animationTimer", is to match the new requestAnimationFrame-based layout |
| 70 // approach. | 67 // approach. |
| 71 if (m_animationTimer.isActive()) | 68 if (m_animationTimer.isActive()) |
| 72 return; | 69 return; |
| 73 // Schedule the 'animation' ASAP if the image does not contain any | 70 m_animationTimer.startOneShot(0); |
| 74 // animations, but prefer a fixed, jittery, frame-delay if there're any | |
| 75 // animations. Checking for pending/active animations could be more | |
| 76 // stringent. | |
| 77 double fireTime = m_image->hasAnimations() ? animationFrameDelay : 0; | |
| 78 m_animationTimer.startOneShot(fireTime); | |
| 79 } | 71 } |
| 80 | 72 |
| 81 void SVGImageChromeClient::animationTimerFired(Timer<SVGImageChromeClient>*) | 73 void SVGImageChromeClient::animationTimerFired(Timer<SVGImageChromeClient>*) |
| 82 { | 74 { |
| 83 // In principle, we should call requestAnimationFrame callbacks here, but | 75 // In principle, we should call requestAnimationFrame callbacks here, but |
| 84 // we know there aren't any because script is forbidden inside SVGImages. | 76 // we know there aren't any because script is forbidden inside SVGImages. |
| 85 if (m_image) { | 77 if (m_image) { |
| 86 m_image->frameView()->page()->animator().serviceScriptedAnimations(curre
ntTime()); | 78 m_image->frameView()->page()->animator().serviceScriptedAnimations(0); |
| 87 m_image->frameView()->updateLayoutAndStyleIfNeededRecursive(); | 79 m_image->frameView()->updateLayoutAndStyleIfNeededRecursive(); |
| 88 } | 80 } |
| 89 } | 81 } |
| 90 | 82 |
| 91 } | 83 } |
| OLD | NEW |