OLD | NEW |
| (Empty) |
1 // Copyright (c) 2014, 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 library debugger_page_element; | |
6 | |
7 import 'dart:html'; | |
8 import 'observatory_element.dart'; | |
9 import 'package:observatory/service.dart'; | |
10 import 'package:polymer/polymer.dart'; | |
11 | |
12 @CustomTag('debugger-page') | |
13 class DebuggerPageElement extends ObservatoryElement { | |
14 @published Isolate isolate; | |
15 @published bool showConsole = false; | |
16 | |
17 DebuggerPageElement.created() : super.created(); | |
18 | |
19 @override | |
20 void attached() { | |
21 super.attached(); | |
22 | |
23 // TODO(turnidge): Get these values from the DOM. | |
24 // TODO(turnidge): splitterHeight is 0 until I implement it. | |
25 const int navbarHeight = 56; | |
26 const int splitterHeight = 0; | |
27 const int cmdHeight = 22; | |
28 | |
29 var stack = $['stack']; | |
30 int windowHeight = window.innerHeight; | |
31 int available = windowHeight - (navbarHeight + splitterHeight); | |
32 int stackHeight = available ~/ 1.3; | |
33 if (showConsole) { | |
34 stack.style.setProperty('height', '${stackHeight}px'); | |
35 } else { | |
36 stack.style.setProperty('height', '${available}px'); | |
37 } | |
38 } | |
39 } | |
40 | |
41 @CustomTag('debugger-stack') | |
42 class DebuggerStackElement extends ObservatoryElement { | |
43 @published Isolate isolate; | |
44 @published ServiceMap stack; | |
45 @published int activeFrame = 0; | |
46 | |
47 isolateChanged(oldValue) { | |
48 isolate.get('stacktrace').then((result) { | |
49 stack = result; | |
50 }); | |
51 } | |
52 | |
53 DebuggerStackElement.created() : super.created(); | |
54 } | |
55 | |
56 @CustomTag('debugger-frame') | |
57 class DebuggerFrameElement extends ObservatoryElement { | |
58 @published ObservableMap frame; | |
59 | |
60 // When true, the frame will start out expanded. | |
61 @published bool expand = false; | |
62 | |
63 @observable String scriptHeight; | |
64 @observable bool expanded = false; | |
65 @observable bool busy = false; | |
66 | |
67 DebuggerFrameElement.created() : super.created(); | |
68 | |
69 @override | |
70 void attached() { | |
71 super.attached(); | |
72 int windowHeight = window.innerHeight; | |
73 scriptHeight = '${windowHeight ~/ 1.6}px'; | |
74 } | |
75 | |
76 void expandChanged(oldValue) { | |
77 if (expand != expanded) { | |
78 toggleExpand(null, null, null); | |
79 } | |
80 } | |
81 | |
82 void toggleExpand(var a, var b, var c) { | |
83 if (busy) { | |
84 return; | |
85 } | |
86 busy = true; | |
87 frame['function'].load().then((func) { | |
88 expanded = !expanded; | |
89 var frameOuter = $['frameOuter']; | |
90 if (expanded) { | |
91 frameOuter.classes.add('shadow'); | |
92 } else { | |
93 frameOuter.classes.remove('shadow'); | |
94 } | |
95 busy = false; | |
96 }); | |
97 } | |
98 } | |
99 | |
100 @CustomTag('debugger-console') | |
101 class DebuggerConsoleElement extends ObservatoryElement { | |
102 @published Isolate isolate; | |
103 | |
104 DebuggerConsoleElement.created() : super.created(); | |
105 } | |
106 | |
107 @CustomTag('debugger-input') | |
108 class DebuggerInputElement extends ObservatoryElement { | |
109 @published Isolate isolate; | |
110 @published String text = ''; | |
111 | |
112 @override | |
113 void ready() { | |
114 super.ready(); | |
115 var textBox = $['textBox']; | |
116 textBox.select(); | |
117 textBox.onKeyDown.listen((KeyboardEvent e) { | |
118 switch (e.keyCode) { | |
119 case KeyCode.TAB: | |
120 e.preventDefault(); | |
121 textBox.setRangeText('TAB'); | |
122 textBox.setSelectionRange(textBox.selectionStart + 3, | |
123 textBox.selectionStart + 3); | |
124 break; | |
125 case KeyCode.ENTER: | |
126 print('Debugger command (not implemented): $text'); | |
127 text = ''; | |
128 break; | |
129 } | |
130 }); | |
131 } | |
132 | |
133 DebuggerInputElement.created() : super.created(); | |
134 } | |
135 | |
OLD | NEW |