Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Side by Side Diff: third_party/WebKit/Source/core/svg/graphics/SVGImageChromeClient.h

Issue 2000483003: Rework timeline/frame scheduling logic for SVGImage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unittest Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 11 matching lines...) Expand all
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
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 #ifndef SVGImageChromeClient_h 29 #ifndef SVGImageChromeClient_h
30 #define SVGImageChromeClient_h 30 #define SVGImageChromeClient_h
31 31
32 #include "base/gtest_prod_util.h"
33 #include "core/CoreExport.h"
32 #include "core/loader/EmptyClients.h" 34 #include "core/loader/EmptyClients.h"
33 #include "platform/Timer.h" 35 #include "platform/Timer.h"
34 36
35 namespace blink { 37 namespace blink {
36 38
37 class SVGImage; 39 class SVGImage;
38 40
39 class SVGImageChromeClient final : public EmptyChromeClient { 41 class CORE_EXPORT SVGImageChromeClient final : public EmptyChromeClient {
40 public: 42 public:
41 static SVGImageChromeClient* create(SVGImage*); 43 static SVGImageChromeClient* create(SVGImage*);
42 44
43 bool isSVGImageChromeClient() const override; 45 bool isSVGImageChromeClient() const override;
44 46
45 SVGImage* image() const { return m_image; } 47 SVGImage* image() const { return m_image; }
46 48
49 void suspendAnimation();
50 void resumeAnimation();
51 bool isSuspended() const { return m_timelineState >= Suspended; }
52
47 private: 53 private:
48 explicit SVGImageChromeClient(SVGImage*); 54 explicit SVGImageChromeClient(SVGImage*);
49 55
50 void chromeDestroyed() override; 56 void chromeDestroyed() override;
51 void invalidateRect(const IntRect&) override; 57 void invalidateRect(const IntRect&) override;
52 void scheduleAnimation(Widget*) override; 58 void scheduleAnimation(Widget*) override;
53 59
60 void setTimer(Timer<SVGImageChromeClient>*);
54 void animationTimerFired(Timer<SVGImageChromeClient>*); 61 void animationTimerFired(Timer<SVGImageChromeClient>*);
55 62
56 SVGImage* m_image; 63 SVGImage* m_image;
57 Timer<SVGImageChromeClient> m_animationTimer; 64 OwnPtr<Timer<SVGImageChromeClient>> m_animationTimer;
65 enum {
66 Running,
67 Suspended,
68 SuspendedWithAnimationPending,
69 } m_timelineState;
70
71 FRIEND_TEST_ALL_PREFIXES(SVGImageTest, TimelineSuspendAndResume);
72 FRIEND_TEST_ALL_PREFIXES(SVGImageTest, ResetAnimation);
58 }; 73 };
59 74
60 DEFINE_TYPE_CASTS(SVGImageChromeClient, ChromeClient, client, client->isSVGImage ChromeClient(), client.isSVGImageChromeClient()); 75 DEFINE_TYPE_CASTS(SVGImageChromeClient, ChromeClient, client, client->isSVGImage ChromeClient(), client.isSVGImageChromeClient());
61 76
62 } // namespace blink 77 } // namespace blink
63 78
64 #endif // SVGImageChromeClient_h 79 #endif // SVGImageChromeClient_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698