| 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 const int navbarHeight = 56; |
| 25 const int splitterHeight = 12; |
| 26 const int cmdHeight = 22; |
| 27 |
| 28 var stack = $['stack']; |
| 29 int windowHeight = window.innerHeight; |
| 30 int available = windowHeight - (navbarHeight + splitterHeight); |
| 31 int stackHeight = available ~/ 1.3; |
| 32 if (showConsole) { |
| 33 stack.style.setProperty('height', '${stackHeight}px'); |
| 34 } else { |
| 35 stack.style.setProperty('height', '${available}px'); |
| 36 } |
| 37 } |
| 38 } |
| 39 |
| 40 @CustomTag('debugger-stack') |
| 41 class DebuggerStackElement extends ObservatoryElement { |
| 42 @published Isolate isolate; |
| 43 @published ServiceMap stack; |
| 44 @published int activeFrame = 0; |
| 45 |
| 46 isolateChanged(oldValue) { |
| 47 isolate.get('stacktrace').then((result) { |
| 48 stack = result; |
| 49 }); |
| 50 } |
| 51 |
| 52 DebuggerStackElement.created() : super.created(); |
| 53 } |
| 54 |
| 55 @CustomTag('debugger-frame') |
| 56 class DebuggerFrameElement extends ObservatoryElement { |
| 57 @published ObservableMap frame; |
| 58 @published bool expand = false; // Expand by default |
| 59 @observable String scriptHeight; |
| 60 @observable bool expanded = false; |
| 61 @observable bool busy = false; |
| 62 |
| 63 DebuggerFrameElement.created() : super.created(); |
| 64 |
| 65 @override |
| 66 void attached() { |
| 67 super.attached(); |
| 68 int windowHeight = window.innerHeight; |
| 69 scriptHeight = '${windowHeight ~/ 1.6}px'; |
| 70 } |
| 71 |
| 72 void expandChanged(oldValue) { |
| 73 if (expand != expanded) { |
| 74 toggleExpand(null, null, null); |
| 75 } |
| 76 } |
| 77 |
| 78 void toggleExpand(var a, var b, var c) { |
| 79 if (busy) { |
| 80 return; |
| 81 } |
| 82 busy = true; |
| 83 frame['function'].load().then((func) { |
| 84 expanded = !expanded; |
| 85 busy = false; |
| 86 }); |
| 87 } |
| 88 } |
| 89 |
| 90 @CustomTag('debugger-console') |
| 91 class DebuggerConsoleElement extends ObservatoryElement { |
| 92 @published Isolate isolate; |
| 93 |
| 94 DebuggerConsoleElement.created() : super.created(); |
| 95 } |
| 96 |
| 97 @CustomTag('debugger-input') |
| 98 class DebuggerInputElement extends ObservatoryElement { |
| 99 @published Isolate isolate; |
| 100 @published String text = ''; |
| 101 |
| 102 @override |
| 103 void ready() { |
| 104 super.ready(); |
| 105 var textBox = $['textBox']; |
| 106 textBox.select(); |
| 107 textBox.onKeyDown.listen((KeyboardEvent e) { |
| 108 switch (e.keyCode) { |
| 109 case KeyCode.TAB: |
| 110 e.preventDefault(); |
| 111 textBox.setRangeText('TAB'); |
| 112 textBox.setSelectionRange(textBox.selectionStart + 3, |
| 113 textBox.selectionStart + 3); |
| 114 break; |
| 115 case KeyCode.ENTER: |
| 116 print('Debugger command (not implemented): $text'); |
| 117 text = ''; |
| 118 break; |
| 119 } |
| 120 }); |
| 121 } |
| 122 |
| 123 DebuggerInputElement.created() : super.created(); |
| 124 } |
| 125 |
| OLD | NEW |