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

Side by Side Diff: Source/core/wawwa/MockAnimationPlayer.cpp

Issue 491053004: Expose Web Animations API to Web Workers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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
(Empty)
1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES{
25
26 } LOSS OF USE,
27 * DATA, OR PROFITS{
28
29 } OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include "config.h"
36 #include "core/wawwa/MockAnimationPlayer.h"
37
38 #include "core/page/Page.h"
39 #include "core/wawwa/ListOfElements.h"
40
41 namespace blink {
42
43 MockAnimationPlayer::MockAnimationPlayer(String inputID, PassRefPtr<DedicatedWor kerGlobalScope> workerGlobalScope, const Vector<ProxyKeyframe> keyframes, const Timing timingInputDictionary)
44 : m_workerGlobalScope(workerGlobalScope)
45 {
46 m_id = inputID;
47 startTime = std::numeric_limits<double>::quiet_NaN();
48 for (size_t i = 0; i < keyframes.size(); i++) {
49 m_keyframes.append(keyframes[i]);
50 }
51 m_timingInputDictionary = timingInputDictionary;
52 String temp = m_id.isolatedCopy();
53 Document* doc = static_cast<Document*>(m_workerGlobalScope->thread()->worker ObjectProxy().context());
54 Page* page = doc->page();
55 m_workerGlobalScope->thread()->workerObjectProxy().postTaskToMainExecutionCo ntext(createCrossThreadTask(&ListOfElements::addtoMapMockAnimationPlayer, AllowC rossThreadAccess(page->m_listOfElements.get()), temp, this));
56 }
57
58 PassRefPtrWillBeRawPtr<MockAnimationPlayer> MockAnimationPlayer::create(String i nputID, PassRefPtr<DedicatedWorkerGlobalScope> workerGlobalScope, const Vector<P roxyKeyframe> keyframes, const Timing timingInputDictionary)
59 {
60 return adoptRef(new MockAnimationPlayer(inputID, workerGlobalScope, keyframe s, timingInputDictionary));
61 }
62
63 void MockAnimationPlayer::pause(ExceptionState & es)
64 {
65 String temp = m_id.isolatedCopy();
66 String action = "pause_element";
67 action = action.isolatedCopy();
68 if (!temp.isSafeToSendToAnotherThread() || !action.isSafeToSendToAnotherThre ad()) {
69 exit(42);
70 }
shans 2014/08/25 11:53:58 ASSERT(....);
71 Document* doc = static_cast<Document*>(m_workerGlobalScope->thread()->worker ObjectProxy().context());
72 Page* page = doc->page();
73 m_workerGlobalScope->thread()->workerObjectProxy().postTaskToMainExecutionCo ntext(createCrossThreadTask(&ListOfElements::execute, AllowCrossThreadAccess(pag e->m_listOfElements.get()), action, temp, m_keyframes, m_timingInputDictionary)) ;
74 }
75
76 void MockAnimationPlayer::play(ExceptionState & es)
77 {
78 String temp = m_id.isolatedCopy();
79 String action = "play_element";
80 action = action.isolatedCopy();
81 if (!temp.isSafeToSendToAnotherThread() || !action.isSafeToSendToAnotherThre ad()) {
82 exit(42);
83 }
shans 2014/08/25 11:53:58 ASSERT(....);
84 Document* doc = static_cast<Document*>(m_workerGlobalScope->thread()->worker ObjectProxy().context());
85 Page* page = doc->page();
86 m_workerGlobalScope->thread()->workerObjectProxy().postTaskToMainExecutionCo ntext(createCrossThreadTask(&ListOfElements::execute, AllowCrossThreadAccess(pag e->m_listOfElements.get()), action, temp, m_keyframes, m_timingInputDictionary)) ;
87 }
88
89 void MockAnimationPlayer::cancel(ExceptionState & es)
90 {
91 String temp = m_id.isolatedCopy();
92 String action = "cancel_element";
93 action = action.isolatedCopy();
94 if (!temp.isSafeToSendToAnotherThread() || !action.isSafeToSendToAnotherThre ad()) {
95 exit(42);
96 }
97 Document* doc = static_cast<Document*>(m_workerGlobalScope->thread()->worker ObjectProxy().context());
98 Page* page = doc->page();
99 m_workerGlobalScope->thread()->workerObjectProxy().postTaskToMainExecutionCo ntext(createCrossThreadTask(&ListOfElements::execute, AllowCrossThreadAccess(pag e->m_listOfElements.get()), action, temp, m_keyframes, m_timingInputDictionary)) ;
100 }
101
102 void MockAnimationPlayer::finish(ExceptionState & es)
103 {
104 String temp = m_id.isolatedCopy();
105 String action = "finish_element";
shans 2014/08/25 11:53:58 In C++, I think we can use an enum instead of Stri
106 action = action.isolatedCopy();
107 if (!temp.isSafeToSendToAnotherThread() || !action.isSafeToSendToAnotherThre ad()) {
108 exit(42);
109 }
110 Document* doc = static_cast<Document*>(m_workerGlobalScope->thread()->worker ObjectProxy().context());
111 Page* page = doc->page();
112 m_workerGlobalScope->thread()->workerObjectProxy().postTaskToMainExecutionCo ntext(createCrossThreadTask(&ListOfElements::execute, AllowCrossThreadAccess(pag e->m_listOfElements.get()), action, temp, m_keyframes, m_timingInputDictionary)) ;
113 }
114
115 void MockAnimationPlayer::reverse(ExceptionState & es)
116 {
117 String temp = m_id.isolatedCopy();
118 String action = "reverse_element";
119 action = action.isolatedCopy();
120 if (!temp.isSafeToSendToAnotherThread() || !action.isSafeToSendToAnotherThre ad()) {
121 exit(42);
122 }
123 Document* doc = static_cast<Document*>(m_workerGlobalScope->thread()->worker ObjectProxy().context());
124 Page* page = doc->page();
125 m_workerGlobalScope->thread()->workerObjectProxy().postTaskToMainExecutionCo ntext(createCrossThreadTask(&ListOfElements::execute, AllowCrossThreadAccess(pag e->m_listOfElements.get()), action, temp, m_keyframes, m_timingInputDictionary)) ;
126 }
127
128 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698