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

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

Issue 27543002: Fix scheduleImmediate in Dartium. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 { 534 class _ScheduleImmediateHelper {
535 MutationObserver _observer; 535 MutationObserver _observer;
536 final DivElement _div = new DivElement(); 536 final DivElement _div = new DivElement();
537 Function _callback; 537 Function _callback;
538 538
539 _ScheduleImmediateHelper() { 539 _ScheduleImmediateHelper() {
540 // Mutation events get fired as soon as the current event stack is unwound 540 // Run in the root-zone as the DOM callback would otherwise execute in the
541 // so we just make a dummy event and listen for that. 541 // current zone.
542 _observer = new MutationObserver(_handleMutation); 542 Zone.ROOT.run(() {
543 _observer.observe(_div, attributes: true); 543 // Mutation events get fired as soon as the current event stack is unwound
544 // so we just make a dummy event and listen for that.
545 _observer = new MutationObserver(_handleMutation);
546 _observer.observe(_div, attributes: true);
547 });
544 } 548 }
545 549
546 void _schedule(callback) { 550 void _schedule(callback) {
547 if (_callback != null) { 551 if (_callback != null) {
548 throw new StateError( 552 throw new StateError(
549 'Only one immediate callback can be scheduled at once'); 553 'Only one immediate callback can be scheduled at once');
550 } 554 }
551 _callback = callback; 555 _callback = callback;
552 // Toggle it to trigger the mutation event. 556 // Toggle it to trigger the mutation event.
553 _div.hidden = !_div.hidden; 557 _div.hidden = !_div.hidden;
(...skipping 13 matching lines...) Expand all
567 _scheduleImmediateHelper._schedule(callback); 571 _scheduleImmediateHelper._schedule(callback);
568 }; 572 };
569 573
570 get _pureIsolateScheduleImmediateClosure => ((void callback()) => 574 get _pureIsolateScheduleImmediateClosure => ((void callback()) =>
571 throw new UnimplementedError("scheduleMicrotask in background isolates " 575 throw new UnimplementedError("scheduleMicrotask in background isolates "
572 "are not supported in the browser")); 576 "are not supported in the browser"));
573 577
574 void _initializeCustomElement(Element e) { 578 void _initializeCustomElement(Element e) {
575 _Utils.initializeCustomElement(e); 579 _Utils.initializeCustomElement(e);
576 } 580 }
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