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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/async_patch.dart

Issue 550843003: Add support for setImmediate on IE. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update test. Created 6 years, 3 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 | tests/lib/lib.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Patch file for the dart:async library. 5 // Patch file for the dart:async library.
6 6
7 import 'dart:_js_helper' show 7 import 'dart:_js_helper' show
8 patch, 8 patch,
9 Primitives, 9 Primitives,
10 convertDartClosureToJS, 10 convertDartClosureToJS,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return (void callback()) { 56 return (void callback()) {
57 assert(storedCallback == null); 57 assert(storedCallback == null);
58 enterJsAsync(); 58 enterJsAsync();
59 storedCallback = callback; 59 storedCallback = callback;
60 // Because of a broken shadow-dom polyfill we have to change the 60 // Because of a broken shadow-dom polyfill we have to change the
61 // children instead a cheap property. 61 // children instead a cheap property.
62 // See https://github.com/Polymer/ShadowDOM/issues/468 62 // See https://github.com/Polymer/ShadowDOM/issues/468
63 JS('', '#.firstChild ? #.removeChild(#): #.appendChild(#)', 63 JS('', '#.firstChild ? #.removeChild(#): #.appendChild(#)',
64 div, div, span, div, span); 64 div, div, span, div, span);
65 }; 65 };
66 66 } else if (JS('', 'self.setImmediate') != null) {
67 return _scheduleImmediateWithSetImmediate;
67 } 68 }
68 // TODO(9002): don't use the Timer to enqueue the immediate callback.
69 // Also check for other JS options like setImmediate.
70 // TODO(20055): We should use DOM promises when available. 69 // TODO(20055): We should use DOM promises when available.
71 return _scheduleImmediateWithTimer; 70 return _scheduleImmediateWithTimer;
72 } 71 }
73 72
74 static void _scheduleImmediateJsOverride(void callback()) { 73 static void _scheduleImmediateJsOverride(void callback()) {
75 internalCallback() { 74 internalCallback() {
76 leaveJsAsync(); 75 leaveJsAsync();
77 callback(); 76 callback();
78 }; 77 };
79 enterJsAsync(); 78 enterJsAsync();
80 JS('void', 'self.scheduleImmediate(#)', 79 JS('void', 'self.scheduleImmediate(#)',
81 convertDartClosureToJS(internalCallback, 0)); 80 convertDartClosureToJS(internalCallback, 0));
82 } 81 }
83 82
83 static void _scheduleImmediateWithSetImmediate(void callback()) {
84 internalCallback() {
85 leaveJsAsync();
86 callback();
87 };
88 enterJsAsync();
89 JS('void', 'self.setImmediate(#)',
90 convertDartClosureToJS(internalCallback, 0));
91 }
92
84 static void _scheduleImmediateWithTimer(void callback()) { 93 static void _scheduleImmediateWithTimer(void callback()) {
85 Timer._createTimer(Duration.ZERO, callback); 94 Timer._createTimer(Duration.ZERO, callback);
86 } 95 }
87 } 96 }
88 97
89 @patch 98 @patch
90 class DeferredLibrary { 99 class DeferredLibrary {
91 @patch 100 @patch
92 Future<Null> load() { 101 Future<Null> load() {
93 throw 'DeferredLibrary not supported. ' 102 throw 'DeferredLibrary not supported. '
(...skipping 13 matching lines...) Expand all
107 @patch 116 @patch
108 static Timer _createPeriodicTimer(Duration duration, 117 static Timer _createPeriodicTimer(Duration duration,
109 void callback(Timer timer)) { 118 void callback(Timer timer)) {
110 int milliseconds = duration.inMilliseconds; 119 int milliseconds = duration.inMilliseconds;
111 if (milliseconds < 0) milliseconds = 0; 120 if (milliseconds < 0) milliseconds = 0;
112 return new TimerImpl.periodic(milliseconds, callback); 121 return new TimerImpl.periodic(milliseconds, callback);
113 } 122 }
114 } 123 }
115 124
116 bool get _hasDocument => JS('String', 'typeof document') == 'object'; 125 bool get _hasDocument => JS('String', 'typeof document') == 'object';
OLDNEW
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698