| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'dart:html'; |
| 6 import 'dart:async'; |
| 7 |
| 8 import 'package:observatory/app.dart'; |
| 9 import 'package:observatory/repositories.dart'; |
| 10 import 'package:observatory/service_html.dart' show SourceLocation; |
| 11 import 'package:observatory/src/elements/script_inset.dart'; |
| 12 import 'package:observatory/src/elements/helpers/tag.dart'; |
| 13 import 'package:observatory/src/elements/shims/binding.dart'; |
| 14 |
| 15 @bindable |
| 16 class SourceInsetElementWrapper extends HtmlElement { |
| 17 static const binder = const Binder<SourceInsetElementWrapper>(const { |
| 18 'location': #location, 'currentpos': #currentPos, |
| 19 'indebuggercontext': #inDebuggerContext, 'variables': #variables |
| 20 }); |
| 21 |
| 22 static const tag = const Tag<SourceInsetElementWrapper>('source-inset'); |
| 23 |
| 24 SourceLocation _location; |
| 25 int _currentPos; |
| 26 bool _inDebuggerContext; |
| 27 Iterable _variables; |
| 28 |
| 29 SourceLocation get location => _location; |
| 30 int get currentPos => _currentPos; |
| 31 bool get inDebuggerContext => _inDebuggerContext; |
| 32 Iterable get variables => _variables; |
| 33 |
| 34 set location(SourceLocation value) { |
| 35 _location = value; |
| 36 render(); |
| 37 } |
| 38 set currentPos(int value) { |
| 39 _currentPos = value; |
| 40 render(); |
| 41 } |
| 42 set inDebuggerContext(bool value) { |
| 43 _inDebuggerContext = value; |
| 44 render(); |
| 45 } |
| 46 set variables(Iterable value) { |
| 47 _variables = value; |
| 48 render(); |
| 49 } |
| 50 |
| 51 SourceInsetElementWrapper.created() : super.created() { |
| 52 binder.registerCallback(this); |
| 53 createShadowRoot(); |
| 54 render(); |
| 55 } |
| 56 |
| 57 @override |
| 58 void attached() { |
| 59 super.attached(); |
| 60 render(); |
| 61 } |
| 62 |
| 63 Future render() async { |
| 64 shadowRoot.children = []; |
| 65 if (_location == null) { |
| 66 return; |
| 67 } |
| 68 |
| 69 shadowRoot.children = [ |
| 70 new StyleElement() |
| 71 ..text = ''' |
| 72 script-inset-wrapped { |
| 73 position: relative; |
| 74 } |
| 75 script-inset-wrapped button.refresh, |
| 76 script-inset-wrapped button.toggle-profile { |
| 77 background-color: transparent; |
| 78 padding: 0; |
| 79 margin: 0; |
| 80 border: none; |
| 81 position: absolute; |
| 82 display: inline-block; |
| 83 top: 5px; |
| 84 color: #888888; |
| 85 line-height: 30px; |
| 86 } |
| 87 script-inset-wrapped button.refresh { |
| 88 right: 5px; |
| 89 font-size: 25px; |
| 90 } |
| 91 script-inset-wrapped button.toggle-profile { |
| 92 right: 30px; |
| 93 font-size: 20px; |
| 94 } |
| 95 script-inset-wrapped button.toggle-profile.enabled { |
| 96 color: #BB3322; |
| 97 } |
| 98 script-inset-wrapped a { |
| 99 color: #0489c3; |
| 100 text-decoration: none; |
| 101 } |
| 102 script-inset-wrapped a:hover { |
| 103 text-decoration: underline; |
| 104 } |
| 105 script-inset-wrapped .sourceInset { |
| 106 } |
| 107 script-inset-wrapped .sourceTable { |
| 108 position: relative; |
| 109 background-color: #f5f5f5; |
| 110 border: 1px solid #ccc; |
| 111 padding: 10px; |
| 112 width: 100%; |
| 113 box-sizing: border-box; |
| 114 overflow-x: scroll; |
| 115 } |
| 116 script-inset-wrapped .sourceRow { |
| 117 display: flex; |
| 118 flex-direction: row; |
| 119 width: 100%; |
| 120 } |
| 121 script-inset-wrapped .sourceItem, .sourceItemCurrent { |
| 122 vertical-align: top; |
| 123 font: 400 14px consolas, courier, monospace; |
| 124 line-height: 125%; |
| 125 white-space: pre; |
| 126 max-width: 0; |
| 127 } |
| 128 script-inset-wrapped .currentLine { |
| 129 background-color: #fff; |
| 130 } |
| 131 script-inset-wrapped .currentCol { |
| 132 background-color: #6cf; |
| 133 } |
| 134 script-inset-wrapped .hitsCurrent, |
| 135 script-inset-wrapped .hitsNone, |
| 136 script-inset-wrapped .hitsNotExecuted, |
| 137 script-inset-wrapped .hitsExecuted, |
| 138 script-inset-wrapped .hitsCompiled, |
| 139 script-inset-wrapped .hitsNotCompiled { |
| 140 display: table-cell; |
| 141 vertical-align: top; |
| 142 font: 400 14px consolas, courier, monospace; |
| 143 margin-left: 5px; |
| 144 margin-right: 5px; |
| 145 text-align: right; |
| 146 color: #a8a8a8; |
| 147 } |
| 148 script-inset-wrapped .hitsCurrent { |
| 149 background-color: #6cf; |
| 150 color: black; |
| 151 } |
| 152 script-inset-wrapped .hitsNotExecuted { |
| 153 background-color: #faa; |
| 154 } |
| 155 script-inset-wrapped .hitsExecuted { |
| 156 background-color: #aea; |
| 157 } |
| 158 script-inset-wrapped .hitsCompiled { |
| 159 background-color: #e0e0e0; |
| 160 } |
| 161 script-inset-wrapped .hitsNotCompiled { |
| 162 background-color: #f0c5c5; |
| 163 } |
| 164 script-inset-wrapped .noCopy {} |
| 165 script-inset-wrapped .emptyBreakpoint, |
| 166 script-inset-wrapped .possibleBreakpoint, |
| 167 script-inset-wrapped .busyBreakpoint, |
| 168 script-inset-wrapped .unresolvedBreakpoint, |
| 169 script-inset-wrapped .resolvedBreakpoint { |
| 170 display: table-cell; |
| 171 vertical-align: top; |
| 172 font: 400 14px consolas, courier, monospace; |
| 173 width: 1em; |
| 174 text-align: center; |
| 175 cursor: pointer; |
| 176 } |
| 177 script-inset-wrapped .possibleBreakpoint { |
| 178 color: #e0e0e0; |
| 179 } |
| 180 script-inset-wrapped .possibleBreakpoint:hover { |
| 181 color: white; |
| 182 background-color: #777; |
| 183 } |
| 184 script-inset-wrapped .busyBreakpoint { |
| 185 color: white; |
| 186 background-color: black; |
| 187 cursor: wait; |
| 188 } |
| 189 script-inset-wrapped .unresolvedBreakpoint { |
| 190 color: white; |
| 191 background-color: #cac; |
| 192 } |
| 193 script-inset-wrapped .resolvedBreakpoint { |
| 194 color: white; |
| 195 background-color: #e66; |
| 196 } |
| 197 script-inset-wrapped .unresolvedBreakAnnotation { |
| 198 color: white; |
| 199 background-color: #cac; |
| 200 } |
| 201 script-inset-wrapped .resolvedBreakAnnotation { |
| 202 color: white; |
| 203 background-color: #e66; |
| 204 } |
| 205 script-inset-wrapped .notSourceProfile, |
| 206 script-inset-wrapped .noProfile, |
| 207 script-inset-wrapped .coldProfile, |
| 208 script-inset-wrapped .mediumProfile, |
| 209 script-inset-wrapped .hotProfile { |
| 210 display: table-cell; |
| 211 vertical-align: top; |
| 212 font: 400 14px consolas, courier, monospace; |
| 213 width: 4em; |
| 214 text-align: right; |
| 215 cursor: pointer; |
| 216 margin-left: 5px; |
| 217 margin-right: 5px; |
| 218 } |
| 219 script-inset-wrapped .notSourceProfile { |
| 220 } |
| 221 script-inset-wrapped .noProfile { |
| 222 background-color: #e0e0e0; |
| 223 } |
| 224 script-inset-wrapped .coldProfile { |
| 225 background-color: #aea; |
| 226 } |
| 227 script-inset-wrapped .mediumProfile { |
| 228 background-color: #fe9; |
| 229 } |
| 230 script-inset-wrapped .hotProfile { |
| 231 background-color: #faa; |
| 232 }''', |
| 233 new ScriptInsetElement(_location.script.isolate, _location.script, |
| 234 new ScriptRepository(), |
| 235 new InstanceRepository(), |
| 236 ObservatoryApplication.app.events, |
| 237 startPos: _location.tokenPos, |
| 238 endPos: _location.endTokenPos, |
| 239 currentPos: _currentPos, |
| 240 inDebuggerContext: _inDebuggerContext ?? false, |
| 241 variables: _variables ?? const [], |
| 242 queue: ObservatoryApplication.app.queue) |
| 243 ]; |
| 244 } |
| 245 } |
| OLD | NEW |