OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library source_inset_element; | 5 library source_inset_element; |
6 | 6 |
7 import 'dart:html'; | 7 import 'dart:html'; |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'package:observatory/models.dart' as M; | 9 import 'package:observatory/models.dart' as M; |
10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
11 import 'package:observatory/src/elements/helpers/tag.dart'; | 11 import 'package:observatory/src/elements/helpers/tag.dart'; |
12 import 'package:observatory/src/elements/script_inset.dart'; | 12 import 'package:observatory/src/elements/script_inset.dart'; |
13 | 13 |
14 class SourceInsetElement extends HtmlElement implements Renderable { | 14 class SourceInsetElement extends HtmlElement implements Renderable { |
15 static const tag = const Tag<SourceInsetElement>('source-inset'); | 15 static const tag = const Tag<SourceInsetElement>('source-inset'); |
16 | 16 |
17 RenderingScheduler _r; | 17 RenderingScheduler _r; |
18 | 18 |
19 Stream<RenderedEvent<SourceInsetElement>> get onRendered => _r.onRendered; | 19 Stream<RenderedEvent<SourceInsetElement>> get onRendered => _r.onRendered; |
20 | 20 |
21 M.IsolateRef _isolate; | 21 M.IsolateRef _isolate; |
22 M.SourceLocation _location; | 22 M.SourceLocation _location; |
23 M.ScriptRepository _scripts; | 23 M.ScriptRepository _scripts; |
24 M.InstanceRepository _instances; | 24 M.ObjectRepository _objects; |
25 M.EventRepository _events; | 25 M.EventRepository _events; |
26 int _currentPos; | 26 int _currentPos; |
27 bool _inDebuggerContext; | 27 bool _inDebuggerContext; |
28 Iterable _variables; | 28 Iterable _variables; |
29 | 29 |
30 M.IsolateRef get isolate => _isolate; | 30 M.IsolateRef get isolate => _isolate; |
31 M.SourceLocation get location => _location; | 31 M.SourceLocation get location => _location; |
32 | 32 |
33 factory SourceInsetElement( | 33 factory SourceInsetElement( |
34 M.IsolateRef isolate, | 34 M.IsolateRef isolate, |
35 M.SourceLocation location, | 35 M.SourceLocation location, |
36 M.ScriptRepository scripts, | 36 M.ScriptRepository scripts, |
37 M.InstanceRepository instances, | 37 M.ObjectRepository objects, |
38 M.EventRepository events, | 38 M.EventRepository events, |
39 {int currentPos, | 39 {int currentPos, |
40 bool inDebuggerContext: false, | 40 bool inDebuggerContext: false, |
41 Iterable variables: const [], | 41 Iterable variables: const [], |
42 RenderingQueue queue}) { | 42 RenderingQueue queue}) { |
43 assert(isolate != null); | 43 assert(isolate != null); |
44 assert(location != null); | 44 assert(location != null); |
45 assert(scripts != null); | 45 assert(scripts != null); |
46 assert(instances != null); | 46 assert(objects != null); |
47 assert(events != null); | 47 assert(events != null); |
48 assert(inDebuggerContext != null); | 48 assert(inDebuggerContext != null); |
49 assert(variables != null); | 49 assert(variables != null); |
50 SourceInsetElement e = document.createElement(tag.name); | 50 SourceInsetElement e = document.createElement(tag.name); |
51 e._r = new RenderingScheduler(e, queue: queue); | 51 e._r = new RenderingScheduler(e, queue: queue); |
52 e._isolate = isolate; | 52 e._isolate = isolate; |
53 e._location = location; | 53 e._location = location; |
54 e._scripts = scripts; | 54 e._scripts = scripts; |
55 e._instances = instances; | 55 e._objects = objects; |
56 e._events = events; | 56 e._events = events; |
57 e._currentPos = currentPos; | 57 e._currentPos = currentPos; |
58 e._inDebuggerContext = inDebuggerContext; | 58 e._inDebuggerContext = inDebuggerContext; |
59 e._variables = variables; | 59 e._variables = variables; |
60 return e; | 60 return e; |
61 } | 61 } |
62 | 62 |
63 SourceInsetElement.created() : super.created(); | 63 SourceInsetElement.created() : super.created(); |
64 | 64 |
65 @override | 65 @override |
66 void attached() { | 66 void attached() { |
67 super.attached(); | 67 super.attached(); |
68 _r.enable(); | 68 _r.enable(); |
69 } | 69 } |
70 | 70 |
71 @override | 71 @override |
72 void detached() { | 72 void detached() { |
73 super.detached(); | 73 super.detached(); |
74 children = []; | 74 children = []; |
75 _r.disable(notify: true); | 75 _r.disable(notify: true); |
76 } | 76 } |
77 | 77 |
78 void render() { | 78 void render() { |
79 children = [ | 79 children = [ |
80 new ScriptInsetElement( | 80 new ScriptInsetElement( |
81 _isolate, _location.script, _scripts, _instances, _events, | 81 _isolate, _location.script, _scripts, _objects, _events, |
82 startPos: _location.tokenPos, | 82 startPos: _location.tokenPos, |
83 endPos: _location.endTokenPos, | 83 endPos: _location.endTokenPos, |
84 currentPos: _currentPos, | 84 currentPos: _currentPos, |
85 inDebuggerContext: _inDebuggerContext, | 85 inDebuggerContext: _inDebuggerContext, |
86 variables: _variables, | 86 variables: _variables, |
87 queue: _r.queue) | 87 queue: _r.queue) |
88 ]; | 88 ]; |
89 } | 89 } |
90 } | 90 } |
OLD | NEW |