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

Side by Side Diff: tools/dom/src/native_DOMImplementation.dart

Issue 25722010: Add support for micro-tasks in Dartium. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename stuff. Created 7 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 | « tests/lib/lib.status ('k') | no next file » | 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 part of html; 5 part of html;
6 6
7 class _ConsoleVariables { 7 class _ConsoleVariables {
8 Map<String, Object> _data = new Map<String, Object>(); 8 Map<String, Object> _data = new Map<String, Object>();
9 9
10 /** 10 /**
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 get _timerFactoryClosure => 524 get _timerFactoryClosure =>
525 (int milliSeconds, void callback(Timer timer), bool repeating) { 525 (int milliSeconds, void callback(Timer timer), bool repeating) {
526 return new _Timer(milliSeconds, callback, repeating); 526 return new _Timer(milliSeconds, callback, repeating);
527 }; 527 };
528 528
529 get _pureIsolateTimerFactoryClosure => 529 get _pureIsolateTimerFactoryClosure =>
530 ((int milliSeconds, void callback(Timer time), bool repeating) => 530 ((int milliSeconds, void callback(Timer time), bool repeating) =>
531 throw new UnimplementedError("Timers on background isolates " 531 throw new UnimplementedError("Timers on background isolates "
532 "are not supported in the browser")); 532 "are not supported in the browser"));
533 533
534 class _ScheduleImmediateHelper {
535 MutationObserver _observer;
536 final DivElement _div = new DivElement();
537 Function _callback;
538
539 _ScheduleImmediateHelper() {
540 // Mutation events get fired as soon as the current event stack is unwound
541 // so we just make a dummy event and listen for that.
542 _observer = new MutationObserver(_handleMutation);
543 _observer.observe(_div, attributes: true);
544 }
545
546 void _schedule(callback) {
547 if (_callback != null) {
548 throw new StateError(
549 'Only one immediate callback can be scheduled at once');
550 }
551 _callback = callback;
552 // Toggle it to trigger the mutation event.
553 _div.hidden = !_div.hidden;
554 }
555
556 _handleMutation(List<MutationRecord> mutations, MutationObserver observer) {
557 var tmp = _callback;
558 _callback = null;
559 tmp();
560 }
561 }
562
563 final _ScheduleImmediateHelper _scheduleImmediateHelper =
564 new _ScheduleImmediateHelper();
565
566 get _scheduleImmediateClosure => (void callback()) {
567 _scheduleImmediateHelper._schedule(callback);
568 };
569
570 get _pureIsolateScheduleImmediateClosure => ((void callback()) =>
571 throw new UnimplementedError("scheduleMicrotask in background isolates "
572 "are not supported in the browser"));
573
534 void _initializeCustomElement(Element e) { 574 void _initializeCustomElement(Element e) {
535 _Utils.initializeCustomElement(e); 575 _Utils.initializeCustomElement(e);
536 } 576 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698