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

Side by Side Diff: runtime/observatory/lib/src/elements/helpers/rendering_queue.dart

Issue 2119733003: Wrapping leaf nodes in non polymer elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Converted vm-connect Created 4 years, 5 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
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'dart:html';
6 import 'dart:collection';
7 import 'dart:async';
8
9 abstract class RenderingTask {
10 void render();
11 }
12
13 abstract class RenderingBarrier {
14 Future<num> get next;
15 }
16
17 class NextAnimationFrameBarrier implements RenderingBarrier {
18 Future<num> get next => window.animationFrame;
19 }
20
21 class RenderingQueue {
22 final RenderingBarrier _barrier;
23 final Queue<RenderingTask> _queue = new Queue<RenderingTask>();
24
25 bool get isEmpty => _queue.isEmpty;
26 bool get isNotEmpty => _queue.isNotEmpty;
27
28 RenderingQueue() : this.fromBarrier(new NextAnimationFrameBarrier());
29
30 RenderingQueue.fromBarrier(this._barrier);
31
32 void enqueue(RenderingTask r) {
33 assert(r != null);
34 if (isEmpty) _render();
35 _queue.addLast(r);
36 }
37
38 Future _render() async {
39 await _barrier.next;
40 while (_queue.isNotEmpty) {
41 _queue.removeFirst().render();
42 }
43 }
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698