OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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 import 'dart:html'; | 5 import 'dart:html'; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:observatory/models.dart' as M; | 7 import 'package:observatory/models.dart' as M; |
8 import 'package:observatory/src/elements/function_ref.dart'; | 8 import 'package:observatory/src/elements/function_ref.dart'; |
9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
10 import 'package:observatory/src/elements/helpers/tag.dart'; | 10 import 'package:observatory/src/elements/helpers/tag.dart'; |
11 import 'package:observatory/src/elements/source_link.dart'; | 11 import 'package:observatory/src/elements/source_link.dart'; |
12 | 12 |
13 class IsolateLocationElement extends HtmlElement implements Renderable { | 13 class IsolateLocationElement extends HtmlElement implements Renderable { |
14 static const tag = const Tag<IsolateLocationElement>('isolate-location', | 14 static const tag = const Tag<IsolateLocationElement>('isolate-location', |
15 dependencies: const [ | 15 dependencies: const [FunctionRefElement.tag, SourceLinkElement.tag]); |
16 FunctionRefElement.tag, | |
17 SourceLinkElement.tag | |
18 ]); | |
19 | 16 |
20 RenderingScheduler<IsolateLocationElement> _r; | 17 RenderingScheduler<IsolateLocationElement> _r; |
21 | 18 |
22 Stream<RenderedEvent<IsolateLocationElement>> get onRendered => | 19 Stream<RenderedEvent<IsolateLocationElement>> get onRendered => _r.onRendered; |
23 _r.onRendered; | |
24 | 20 |
25 M.Isolate _isolate; | 21 M.Isolate _isolate; |
26 M.EventRepository _events; | 22 M.EventRepository _events; |
27 M.ScriptRepository _scripts; | 23 M.ScriptRepository _scripts; |
28 StreamSubscription _debugSubscription; | 24 StreamSubscription _debugSubscription; |
29 StreamSubscription _isolateSubscription; | 25 StreamSubscription _isolateSubscription; |
30 | 26 |
31 factory IsolateLocationElement(M.Isolate isolate, | 27 factory IsolateLocationElement( |
32 M.EventRepository events, | 28 M.Isolate isolate, M.EventRepository events, M.ScriptRepository scripts, |
33 M.ScriptRepository scripts, | 29 {RenderingQueue queue}) { |
34 {RenderingQueue queue}) { | |
35 assert(isolate != null); | 30 assert(isolate != null); |
36 assert(events != null); | 31 assert(events != null); |
37 assert(scripts != null); | 32 assert(scripts != null); |
38 IsolateLocationElement e = document.createElement(tag.name); | 33 IsolateLocationElement e = document.createElement(tag.name); |
39 e._r = new RenderingScheduler(e, queue: queue); | 34 e._r = new RenderingScheduler(e, queue: queue); |
40 e._isolate = isolate; | 35 e._isolate = isolate; |
41 e._events = events; | 36 e._events = events; |
42 e._scripts = scripts; | 37 e._scripts = scripts; |
43 return e; | 38 return e; |
44 } | 39 } |
(...skipping 18 matching lines...) Expand all Loading... |
63 } | 58 } |
64 | 59 |
65 void render() { | 60 void render() { |
66 switch (_isolate.status) { | 61 switch (_isolate.status) { |
67 case M.IsolateStatus.loading: | 62 case M.IsolateStatus.loading: |
68 children = [new SpanElement()..text = 'not yet runnable']; | 63 children = [new SpanElement()..text = 'not yet runnable']; |
69 break; | 64 break; |
70 case M.IsolateStatus.running: | 65 case M.IsolateStatus.running: |
71 children = [ | 66 children = [ |
72 new SpanElement()..text = 'at ', | 67 new SpanElement()..text = 'at ', |
73 new FunctionRefElement(_isolate, | 68 new FunctionRefElement( |
74 M.topFrame(_isolate.pauseEvent).function, | 69 _isolate, M.topFrame(_isolate.pauseEvent).function, |
75 queue: _r.queue), | 70 queue: _r.queue), |
76 new SpanElement()..text = ' (', | 71 new SpanElement()..text = ' (', |
77 new SourceLinkElement(_isolate, | 72 new SourceLinkElement( |
78 M.topFrame(_isolate.pauseEvent).location, | 73 _isolate, M.topFrame(_isolate.pauseEvent).location, _scripts, |
79 _scripts, | 74 queue: _r.queue), |
80 queue: _r.queue), | |
81 new SpanElement()..text = ') ' | 75 new SpanElement()..text = ') ' |
82 ]; | 76 ]; |
83 break; | 77 break; |
84 case M.IsolateStatus.paused: | 78 case M.IsolateStatus.paused: |
85 if (_isolate.pauseEvent is M.PauseStartEvent) { | 79 if (_isolate.pauseEvent is M.PauseStartEvent) { |
86 children = [new SpanElement()..text = 'at isolate start']; | 80 children = [new SpanElement()..text = 'at isolate start']; |
87 } else if (_isolate.pauseEvent is M.PauseExitEvent) { | 81 } else if (_isolate.pauseEvent is M.PauseExitEvent) { |
88 children = [new SpanElement()..text = 'at isolate exit']; | 82 children = [new SpanElement()..text = 'at isolate exit']; |
89 } else if (_isolate.pauseEvent is M.NoneEvent) { | 83 } else if (_isolate.pauseEvent is M.NoneEvent) { |
90 children = [new SpanElement()..text = 'not yet runnable']; | 84 children = [new SpanElement()..text = 'not yet runnable']; |
91 } else { | 85 } else { |
92 final content = <Element>[]; | 86 final content = <Element>[]; |
93 if (_isolate.pauseEvent is M.PauseBreakpointEvent) { | 87 if (_isolate.pauseEvent is M.PauseBreakpointEvent) { |
94 content.add(new SpanElement()..text = 'by breakpoint'); | 88 content.add(new SpanElement()..text = 'by breakpoint'); |
95 } else if (_isolate.pauseEvent is M.PauseExceptionEvent) { | 89 } else if (_isolate.pauseEvent is M.PauseExceptionEvent) { |
96 content.add(new SpanElement()..text = 'by exception'); | 90 content.add(new SpanElement()..text = 'by exception'); |
97 } | 91 } |
98 if (M.topFrame(_isolate.pauseEvent) != null) { | 92 if (M.topFrame(_isolate.pauseEvent) != null) { |
99 content.addAll([ | 93 content.addAll([ |
100 new SpanElement()..text = ' at ', | 94 new SpanElement()..text = ' at ', |
101 new FunctionRefElement(_isolate, | 95 new FunctionRefElement( |
102 M.topFrame(_isolate.pauseEvent).function, | 96 _isolate, M.topFrame(_isolate.pauseEvent).function, |
103 queue: _r.queue), | 97 queue: _r.queue), |
104 new SpanElement()..text = ' (', | 98 new SpanElement()..text = ' (', |
105 new SourceLinkElement(_isolate, | 99 new SourceLinkElement( |
106 M.topFrame(_isolate.pauseEvent).location, | 100 _isolate, M.topFrame(_isolate.pauseEvent).location, _scripts, |
107 _scripts, | 101 queue: _r.queue), |
108 queue: _r.queue), | |
109 new SpanElement()..text = ') ' | 102 new SpanElement()..text = ') ' |
110 ]); | 103 ]); |
111 } | 104 } |
112 children = content; | 105 children = content; |
113 } | 106 } |
114 break; | 107 break; |
115 default: | 108 default: |
116 children = const []; | 109 children = const []; |
117 } | 110 } |
118 } | 111 } |
119 | 112 |
120 void _eventListener(e) { | 113 void _eventListener(e) { |
121 if (e.isolate.id == _isolate.id) { | 114 if (e.isolate.id == _isolate.id) { |
122 _r.dirty(); | 115 _r.dirty(); |
123 } | 116 } |
124 } | 117 } |
125 } | 118 } |
OLD | NEW |