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

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: Reues both dummy-element and MutationObserver. 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 | « no previous file | 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 get _timerFactoryClosure => 519 get _timerFactoryClosure =>
520 (int milliSeconds, void callback(Timer timer), bool repeating) { 520 (int milliSeconds, void callback(Timer timer), bool repeating) {
521 return new _Timer(milliSeconds, callback, repeating); 521 return new _Timer(milliSeconds, callback, repeating);
522 }; 522 };
523 523
524 get _pureIsolateTimerFactoryClosure => 524 get _pureIsolateTimerFactoryClosure =>
525 ((int milliSeconds, void callback(Timer time), bool repeating) => 525 ((int milliSeconds, void callback(Timer time), bool repeating) =>
526 throw new UnimplementedError("Timers on background isolates " 526 throw new UnimplementedError("Timers on background isolates "
527 "are not supported in the browser")); 527 "are not supported in the browser"));
528 528
529 class _EnqueueImmediateScheduler {
530 MutationObserver _observer;
531 final Element _dummy = new DivElement();
floitsch 2013/10/10 16:02:18 s/_dummy/_div
Anders Johnsen 2013/10/15 17:21:17 Done.
532 Function _callback;
533
534 _EnqueueImmediateScheduler() {
535 // Mutation events get fired as soon as the current event stack is unwound
536 // so we just make a dummy event and listen for that.
537 _observer = new MutationObserver(_handleMutation);
538 _observer.observe(_dummy, attributes: true);
539 }
540
541 void _schedule(callback) {
542 if (_callback != null) {
543 throw new StateError(
544 'Only one immediate callback can be scheduled at once');
545 }
546 _callback = callback;
547 // Toggle it to trigger the mutation event.
548 _dummy.hidden = !_dummy.hidden;
549 }
550
551 _handleMutation(List<MutationRecord> mutations, MutationObserver observer) {
552 var tmp = _callback;
553 _callback = null;
554 tmp();
555 }
556 }
557
558 final _EnqueueImmediateScheduler _enqueueImmediateScheduler =
559 new _EnqueueImmediateScheduler();
560
561 get _enqueueImmediateFactoryClosure => (void callback()) {
562 _enqueueImmediateScheduler._schedule(callback);
563 };
564
565 get _pureIsolateEnqueueImmediateFactoryClosure => ((void callback()) =>
566 throw new UnimplementedError("runAsync in background isolates "
567 "are not supported in the browser"));
568
529 void _initializeCustomElement(Element e) { 569 void _initializeCustomElement(Element e) {
530 _Utils.initializeCustomElement(e); 570 _Utils.initializeCustomElement(e);
531 } 571 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698