Chromium Code Reviews| Index: runtime/bin/vmservice/client/lib/src/elements/script_inset.dart |
| diff --git a/runtime/bin/vmservice/client/lib/src/elements/script_inset.dart b/runtime/bin/vmservice/client/lib/src/elements/script_inset.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..336a40ac2a73c05b55ca10db375b816316489bdb |
| --- /dev/null |
| +++ b/runtime/bin/vmservice/client/lib/src/elements/script_inset.dart |
| @@ -0,0 +1,49 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library script_inset_element; |
| + |
| +import 'observatory_element.dart'; |
| +import 'package:observatory/service.dart'; |
| +import 'package:polymer/polymer.dart'; |
| + |
| +/// Displays an Error response. |
| +@CustomTag('script-inset') |
| +class ScriptInsetElement extends ObservatoryElement { |
| + @published Script script; |
| + @published int pos; |
| + bool loadStarted = false; |
| + |
| + @observable List<ScriptLine> lines = toObservable([]); |
| + |
| + void scriptChanged(oldValue) { |
| + loadStarted = false; |
|
Cutch
2014/03/28 20:22:32
Maybe add a TODO to move this load state tracking
|
| + _updateProperties(); |
| + } |
| + |
| + void posChanged(oldValue) { |
| + loadStarted = false; |
| + _updateProperties(); |
| + } |
| + |
| + void _updateProperties() { |
| + if (!script.loaded) { |
| + if (!loadStarted) { |
| + loadStarted = true; |
| + script.load().then((_) { |
| + if (script.loaded) { |
| + _updateProperties(); |
| + } |
| + }); |
| + } |
| + return; |
| + } |
| + notifyPropertyChange(#lines, 0, 1); |
| + var lineNumber = script.tokenToLine(pos); |
| + lines.clear(); |
| + lines.add(script.lines[lineNumber-1]); |
| + } |
| + |
| + ScriptInsetElement.created() : super.created(); |
| +} |