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