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

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/patch/async_patch.dart

Issue 2752163002: Format all dart dev compiler files (Closed)
Patch Set: Created 3 years, 9 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 // 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 patch, Primitives;
8 patch, 8 import 'dart:_isolate_helper'
9 Primitives; 9 show
10 import 'dart:_isolate_helper' show 10 IsolateNatives,
11 IsolateNatives, 11 TimerImpl,
12 TimerImpl, 12 global,
13 global, 13 leaveJsAsync,
14 leaveJsAsync, 14 enterJsAsync,
15 enterJsAsync, 15 isWorker;
16 isWorker;
17 16
18 import 'dart:_foreign_helper' show JS; 17 import 'dart:_foreign_helper' show JS;
19 18
20 typedef void _Callback(); 19 typedef void _Callback();
21 typedef void _TakeCallback(_Callback callback); 20 typedef void _TakeCallback(_Callback callback);
22 21
23 @patch 22 @patch
24 class _AsyncRun { 23 class _AsyncRun {
25 @patch 24 @patch
26 static void _scheduleImmediate(void callback()) { 25 static void _scheduleImmediate(void callback()) {
(...skipping 15 matching lines...) Expand all
42 // Use mutationObservers. 41 // Use mutationObservers.
43 var div = JS('', '#.document.createElement("div")', global); 42 var div = JS('', '#.document.createElement("div")', global);
44 var span = JS('', '#.document.createElement("span")', global); 43 var span = JS('', '#.document.createElement("span")', global);
45 _Callback storedCallback; 44 _Callback storedCallback;
46 45
47 internalCallback(_) { 46 internalCallback(_) {
48 leaveJsAsync(); 47 leaveJsAsync();
49 var f = storedCallback; 48 var f = storedCallback;
50 storedCallback = null; 49 storedCallback = null;
51 f(); 50 f();
52 }; 51 }
53 52
54 var observer = JS('', 'new #.MutationObserver(#)', global, internalCallbac k); 53 ;
55 JS('', '#.observe(#, { childList: true })', 54
56 observer, div); 55 var observer =
56 JS('', 'new #.MutationObserver(#)', global, internalCallback);
57 JS('', '#.observe(#, { childList: true })', observer, div);
57 58
58 return (void callback()) { 59 return (void callback()) {
59 assert(storedCallback == null); 60 assert(storedCallback == null);
60 enterJsAsync(); 61 enterJsAsync();
61 storedCallback = callback; 62 storedCallback = callback;
62 // Because of a broken shadow-dom polyfill we have to change the 63 // Because of a broken shadow-dom polyfill we have to change the
63 // children instead a cheap property. 64 // children instead a cheap property.
64 // See https://github.com/Polymer/ShadowDOM/issues/468 65 // See https://github.com/Polymer/ShadowDOM/issues/468
65 JS('', '#.firstChild ? #.removeChild(#): #.appendChild(#)', 66 JS('', '#.firstChild ? #.removeChild(#): #.appendChild(#)', div, div,
66 div, div, span, div, span); 67 span, div, span);
67 }; 68 };
68 } else if (JS('', '#.setImmediate', global) != null) { 69 } else if (JS('', '#.setImmediate', global) != null) {
69 return _scheduleImmediateWithSetImmediate; 70 return _scheduleImmediateWithSetImmediate;
70 } 71 }
71 // TODO(20055): We should use DOM promises when available. 72 // TODO(20055): We should use DOM promises when available.
72 return _scheduleImmediateWithTimer; 73 return _scheduleImmediateWithTimer;
73 } 74 }
74 75
75 static void _scheduleImmediateJsOverride(void callback()) { 76 static void _scheduleImmediateJsOverride(void callback()) {
76 internalCallback() { 77 internalCallback() {
77 leaveJsAsync(); 78 leaveJsAsync();
78 callback(); 79 callback();
79 }; 80 }
81
82 ;
80 enterJsAsync(); 83 enterJsAsync();
81 JS('void', '#.scheduleImmediate(#)', global, internalCallback); 84 JS('void', '#.scheduleImmediate(#)', global, internalCallback);
82 } 85 }
83 86
84 static void _scheduleImmediateWithSetImmediate(void callback()) { 87 static void _scheduleImmediateWithSetImmediate(void callback()) {
85 internalCallback() { 88 internalCallback() {
86 leaveJsAsync(); 89 leaveJsAsync();
87 callback(); 90 callback();
88 }; 91 }
92
93 ;
89 enterJsAsync(); 94 enterJsAsync();
90 JS('void', '#.setImmediate(#)', global, internalCallback); 95 JS('void', '#.setImmediate(#)', global, internalCallback);
91 } 96 }
92 97
93 static void _scheduleImmediateWithTimer(void callback()) { 98 static void _scheduleImmediateWithTimer(void callback()) {
94 Timer._createTimer(Duration.ZERO, callback); 99 Timer._createTimer(Duration.ZERO, callback);
95 } 100 }
96 } 101 }
97 102
98 @patch 103 @patch
99 class DeferredLibrary { 104 class DeferredLibrary {
100 @patch 105 @patch
101 Future<Null> load() { 106 Future<Null> load() {
102 throw 'DeferredLibrary not supported. ' 107 throw 'DeferredLibrary not supported. '
103 'please use the `import "lib.dart" deferred as lib` syntax.'; 108 'please use the `import "lib.dart" deferred as lib` syntax.';
104 } 109 }
105 } 110 }
106 111
107 @patch 112 @patch
108 class Timer { 113 class Timer {
109 @patch 114 @patch
110 static Timer _createTimer(Duration duration, void callback()) { 115 static Timer _createTimer(Duration duration, void callback()) {
111 int milliseconds = duration.inMilliseconds; 116 int milliseconds = duration.inMilliseconds;
112 if (milliseconds < 0) milliseconds = 0; 117 if (milliseconds < 0) milliseconds = 0;
113 return new TimerImpl(milliseconds, callback); 118 return new TimerImpl(milliseconds, callback);
114 } 119 }
115 120
116 @patch 121 @patch
117 static Timer _createPeriodicTimer(Duration duration, 122 static Timer _createPeriodicTimer(
118 void callback(Timer timer)) { 123 Duration duration, void callback(Timer timer)) {
119 int milliseconds = duration.inMilliseconds; 124 int milliseconds = duration.inMilliseconds;
120 if (milliseconds < 0) milliseconds = 0; 125 if (milliseconds < 0) milliseconds = 0;
121 return new TimerImpl.periodic(milliseconds, callback); 126 return new TimerImpl.periodic(milliseconds, callback);
122 } 127 }
123 } 128 }
124 129
125 @patch 130 @patch
126 void _rethrow(Object error, StackTrace stackTrace) { 131 void _rethrow(Object error, StackTrace stackTrace) {
127 // TODO(rnystrom): Not needed by dev_compiler. 132 // TODO(rnystrom): Not needed by dev_compiler.
128 // error = wrapException(error); 133 // error = wrapException(error);
129 JS("void", "#.stack = #", error, stackTrace.toString()); 134 JS("void", "#.stack = #", error, stackTrace.toString());
130 JS("void", "throw #", error); 135 JS("void", "throw #", error);
131 } 136 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/tool/input_sdk/libraries.dart ('k') | pkg/dev_compiler/tool/input_sdk/patch/collection_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698