Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: runtime/observatory/lib/src/elements/error_ref_wrapper.dart

Issue 2202943002: Converted Observatory error-ref element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016, 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
7 import 'package:observatory/app.dart';
8 import 'package:observatory/mocks.dart' show ErrorRefMock;
9 import 'package:observatory/service_html.dart' show ServiceMap, DartError;
10 import 'package:observatory/src/elements/error_ref.dart';
11 import 'package:observatory/src/elements/helpers/tag.dart';
12 import 'package:observatory/src/elements/shims/binding.dart';
13
14 class ErrorRefElementWrapper extends HtmlElement {
15
16 static const binder = const Binder<ErrorRefElementWrapper>(const {
17 'ref': #ref
18 });
19
20 static const tag = const Tag<ErrorRefElementWrapper>('error-ref');
21
22 ServiceMap _error;
23 ServiceMap get ref => _error;
24 void set ref(ServiceMap ref) { _error = ref; render(); }
25
26 ErrorRefElementWrapper.created() : super.created() {
27 binder.registerCallback(this);
28 createShadowRoot();
29 render();
30 }
31
32 @override
33 void attached() {
34 super.attached();
35 render();
36 }
37
38 void render() {
39 shadowRoot.children = [];
40 if (_error == null) return;
41
42 if (ref is Map) {
43 shadowRoot.children = [
44 new StyleElement()
45 ..text = '''
46 error-ref-wrapped > pre {
47 background-color: #f5f5f5;
48 border: 1px solid #ccc;
49 padding: 10px;
50 font-family: consolas, courier, monospace;
51 font-size: 1em;
52 line-height: 1.2em;
53 white-space: pre;
54 }
55 ''',
56 new ErrorRefElement(new ErrorRefMock(message: ref['message']))
57 ];
58 } else {
59 shadowRoot.children = [
60 new StyleElement()
61 ..text = '''
62 error-ref-wrapped > pre {
63 background-color: #f5f5f5;
64 border: 1px solid #ccc;
65 padding: 10px;
66 font-family: consolas, courier, monospace;
67 font-size: 1em;
68 line-height: 1.2em;
69 white-space: pre;
70 }
71 ''',
72 new ErrorRefElement(
73 new ErrorRefMock(message: (ref as DartError).message),
74 queue: ObservatoryApplication.app.queue)
75 ];
76 }
77 }
78 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/error_ref.html ('k') | runtime/observatory/lib/src/elements/eval_box.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698