| 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 script_inset_element; | 5 library script_inset_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'observatory_element.dart'; | 9 import 'observatory_element.dart'; |
| 10 import 'service_ref.dart'; |
| 10 import 'package:observatory/service.dart'; | 11 import 'package:observatory/service.dart'; |
| 11 import 'package:polymer/polymer.dart'; | 12 import 'package:polymer/polymer.dart'; |
| 12 | 13 |
| 13 const nbsp = "\u00A0"; | 14 const nbsp = "\u00A0"; |
| 14 | 15 |
| 16 void addInfoBox(content, infoBox) { |
| 17 infoBox.style.position = 'absolute'; |
| 18 infoBox.style.padding = '1em'; |
| 19 infoBox.style.border = 'solid black 2px'; |
| 20 infoBox.style.zIndex = '10'; |
| 21 infoBox.style.backgroundColor = 'white'; |
| 22 |
| 23 infoBox.style.display = 'none'; // Initially hidden. |
| 24 |
| 25 var show = false; |
| 26 content.onClick.listen((event) { |
| 27 show = !show; |
| 28 infoBox.style.display = show ? 'block' : 'none'; |
| 29 }); |
| 30 |
| 31 // Causes infoBox to be positioned relative to the bottom-left of content. |
| 32 content.style.display = 'inline-block'; |
| 33 content.append(infoBox); |
| 34 } |
| 35 |
| 15 abstract class Annotation { | 36 abstract class Annotation { |
| 16 int line; | 37 int line; |
| 17 int columnStart; | 38 int columnStart; |
| 18 int columnStop; | 39 int columnStop; |
| 19 | 40 |
| 20 void applyStyleTo(element); | 41 void applyStyleTo(element); |
| 21 } | 42 } |
| 22 | 43 |
| 23 class CurrentExecutionAnnotation extends Annotation { | 44 class CurrentExecutionAnnotation extends Annotation { |
| 24 void applyStyleTo(element) { | 45 void applyStyleTo(element) { |
| 25 if (element == null) { | 46 if (element == null) { |
| 26 return; // TODO(rmacnak): Handling overlapping annotations. | 47 return; // TODO(rmacnak): Handling overlapping annotations. |
| 27 } | 48 } |
| 28 element.classes.add("currentCol"); | 49 element.classes.add("currentCol"); |
| 29 element.title = "Current execution"; | 50 element.title = "Current execution"; |
| 30 } | 51 } |
| 31 } | 52 } |
| 32 | 53 |
| 33 class CallSiteAnnotation extends Annotation { | 54 class CallSiteAnnotation extends Annotation { |
| 34 CallSite callSite; | 55 CallSite callSite; |
| 35 | 56 |
| 57 Element row() { |
| 58 var e = new DivElement(); |
| 59 e.style.display = "table-row"; |
| 60 return e; |
| 61 } |
| 62 |
| 63 Element cell(content) { |
| 64 var e = new DivElement(); |
| 65 e.style.display = "table-cell"; |
| 66 e.style.padding = "3px"; |
| 67 if (content is String) e.text = content; |
| 68 if (content is Element) e.children.add(content); |
| 69 return e; |
| 70 } |
| 71 |
| 72 Element serviceRef(object) { |
| 73 AnyServiceRefElement e = new Element.tag("any-service-ref"); |
| 74 e.ref = object; |
| 75 return e; |
| 76 } |
| 77 |
| 78 Element entriesTable() { |
| 79 var e = new DivElement(); |
| 80 e.style.display = "table"; |
| 81 e.style.color = "#333"; |
| 82 e.style.font = "400 14px 'Montserrat', sans-serif"; |
| 83 |
| 84 var r = row(); |
| 85 r.append(cell("Container")); |
| 86 r.append(cell("Count")); |
| 87 r.append(cell("Target")); |
| 88 e.append(r); |
| 89 |
| 90 for (var entry in callSite.entries) { |
| 91 var r = row(); |
| 92 r.append(cell(serviceRef(entry.receiverContainer))); |
| 93 r.append(cell(entry.count.toString())); |
| 94 r.append(cell(serviceRef(entry.target))); |
| 95 e.append(r); |
| 96 } |
| 97 |
| 98 return e; |
| 99 } |
| 100 |
| 36 void applyStyleTo(element) { | 101 void applyStyleTo(element) { |
| 37 if (element == null) { | 102 if (element == null) { |
| 38 return; // TODO(rmacnak): Handling overlapping annotations. | 103 return; // TODO(rmacnak): Handling overlapping annotations. |
| 39 } | 104 } |
| 40 element.style.textDecoration = "underline"; | 105 element.style.fontWeight = "bold"; |
| 41 element.style.color = "blue"; | 106 element.title = "Call site: ${callSite.name}"; |
| 42 | 107 |
| 43 StringBuffer sb = new StringBuffer(); | 108 addInfoBox(element, entriesTable()); |
| 44 sb.write("Call site: "); | |
| 45 sb.write(callSite.name); | |
| 46 sb.write("\n"); | |
| 47 for (var entry in callSite.entries) { | |
| 48 sb.write("Class: "); | |
| 49 // TODO(rmacnak): Make this a link. | |
| 50 sb.write(entry.receiverContainer.name); | |
| 51 sb.write(" Count: "); | |
| 52 sb.write(entry.count); | |
| 53 sb.write("\n"); | |
| 54 } | |
| 55 element.title = sb.toString(); | |
| 56 } | 109 } |
| 57 } | 110 } |
| 58 | 111 |
| 59 /// Box with script source code in it. | 112 /// Box with script source code in it. |
| 60 @CustomTag('script-inset') | 113 @CustomTag('script-inset') |
| 61 class ScriptInsetElement extends ObservatoryElement { | 114 class ScriptInsetElement extends ObservatoryElement { |
| 62 @published Script script; | 115 @published Script script; |
| 63 | 116 |
| 64 /// Set the height to make the script inset scroll. Otherwise it | 117 /// Set the height to make the script inset scroll. Otherwise it |
| 65 /// will show from startPos to endPos. | 118 /// will show from startPos to endPos. |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 pending.add(line.script.isolate.removeBreakpoint(bpt)); | 400 pending.add(line.script.isolate.removeBreakpoint(bpt)); |
| 348 } | 401 } |
| 349 Future.wait(pending).then((_) { | 402 Future.wait(pending).then((_) { |
| 350 busy = false; | 403 busy = false; |
| 351 }); | 404 }); |
| 352 } | 405 } |
| 353 } | 406 } |
| 354 | 407 |
| 355 BreakpointToggleElement.created() : super.created(); | 408 BreakpointToggleElement.created() : super.created(); |
| 356 } | 409 } |
| OLD | NEW |