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

Side by Side Diff: client/base/AnimationScheduler.dart

Issue 8360025: Move the individual property definitions from client/base/Css to CSSStyleDeclaration. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | client/base/Css.dart » ('j') | client/base/scripts/css_code_generator.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 typedef void AnimationCallback(num currentTime); 5 typedef void AnimationCallback(num currentTime);
6 6
7 class CallbackData { 7 class CallbackData {
8 final AnimationCallback callback; 8 final AnimationCallback callback;
9 final num minTime; 9 final num minTime;
10 int id; 10 int id;
(...skipping 23 matching lines...) Expand all
34 // 60fps for the current browser. 34 // 60fps for the current browser.
35 class AnimationScheduler { 35 class AnimationScheduler {
36 static final FRAMES_PER_SECOND = 60; 36 static final FRAMES_PER_SECOND = 60;
37 static final MS_PER_FRAME = 1000 ~/ FRAMES_PER_SECOND; 37 static final MS_PER_FRAME = 1000 ~/ FRAMES_PER_SECOND;
38 static final USE_INTERVALS = false; 38 static final USE_INTERVALS = false;
39 39
40 /** List of callbacks to be executed next animation frame. */ 40 /** List of callbacks to be executed next animation frame. */
41 List<CallbackData> _callbacks; 41 List<CallbackData> _callbacks;
42 int _intervalId; 42 int _intervalId;
43 bool _isMobileSafari = false; 43 bool _isMobileSafari = false;
44 Css _safariHackCss; 44 CSSStyleDeclaration _safariHackStyle;
45 int _frameCount = 0; 45 int _frameCount = 0;
46 bool _webkitAnimationFrameMaybeAvailable = true; 46 bool _webkitAnimationFrameMaybeAvailable = true;
47 47
48 AnimationScheduler() 48 AnimationScheduler()
49 : _callbacks = new List<CallbackData>() { 49 : _callbacks = new List<CallbackData>() {
50 if (_isMobileSafari) { 50 if (_isMobileSafari) {
51 // TODO(jacobr): find a better workaround for the issue that 3d transforms 51 // TODO(jacobr): find a better workaround for the issue that 3d transforms
52 // sometimes don't render on iOS without forcing a layout. 52 // sometimes don't render on iOS without forcing a layout.
53 final element = new Element.tag('div'); 53 final element = new Element.tag('div');
54 document.body.nodes.add(element); 54 document.body.nodes.add(element);
55 _safariHackCss = new Css(element.style); 55 _safariHackStyle = element.style;
56 _safariHackCss.position = 'absolute'; 56 _safariHackStyle.position = 'absolute';
57 } 57 }
58 } 58 }
59 59
60 /** 60 /**
61 * Cancel the pending callback matching the specified [id]. 61 * Cancel the pending callback matching the specified [id].
62 * This is not heavily optimized as typically users don't cancel animation 62 * This is not heavily optimized as typically users don't cancel animation
63 * frames. 63 * frames.
64 */ 64 */
65 void cancelRequestAnimationFrame(int id) { 65 void cancelRequestAnimationFrame(int id) {
66 _callbacks = _callbacks.filter((CallbackData e) => e.id != id); 66 _callbacks = _callbacks.filter((CallbackData e) => e.id != id);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 _callbacks.add(callbackData); 153 _callbacks.add(callbackData);
154 } 154 }
155 } 155 }
156 156
157 _frameCount++; 157 _frameCount++;
158 if (_isMobileSafari) { 158 if (_isMobileSafari) {
159 // Hack to work around an iOS bug where sometimes animations do not 159 // Hack to work around an iOS bug where sometimes animations do not
160 // render if only webkit transforms were modified. 160 // render if only webkit transforms were modified.
161 // TODO(jacobr): find a cleaner workaround. 161 // TODO(jacobr): find a cleaner workaround.
162 int offset = _frameCount % 2; 162 int offset = _frameCount % 2;
163 _safariHackCss.left = '${offset}px'; 163 _safariHackStyle.left = '${offset}px';
164 } 164 }
165 } 165 }
166 } 166 }
OLDNEW
« no previous file with comments | « no previous file | client/base/Css.dart » ('j') | client/base/scripts/css_code_generator.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698