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

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

Issue 2211603002: Centralized event streams (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged with master 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
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 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 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 import 'dart:html'; 5 import 'dart:html';
6 6
7 import 'package:observatory/app.dart'; 7 import 'package:observatory/app.dart';
8 import 'package:observatory/mocks.dart' show ErrorRefMock; 8 import 'package:observatory/service.dart';
9 import 'package:observatory/service_html.dart' show ServiceMap, DartError;
10 import 'package:observatory/src/elements/error_ref.dart'; 9 import 'package:observatory/src/elements/error_ref.dart';
11 import 'package:observatory/src/elements/helpers/tag.dart'; 10 import 'package:observatory/src/elements/helpers/tag.dart';
12 import 'package:observatory/src/elements/shims/binding.dart'; 11 import 'package:observatory/src/elements/shims/binding.dart';
13 12
14 class ErrorRefElementWrapper extends HtmlElement { 13 class ErrorRefElementWrapper extends HtmlElement {
15 14
16 static const binder = const Binder<ErrorRefElementWrapper>(const { 15 static const binder = const Binder<ErrorRefElementWrapper>(const {
17 'ref': #ref 16 'ref': #ref
18 }); 17 });
19 18
20 static const tag = const Tag<ErrorRefElementWrapper>('error-ref'); 19 static const tag = const Tag<ErrorRefElementWrapper>('error-ref');
21 20
22 ServiceMap _error; 21 DartError _error;
23 ServiceMap get ref => _error; 22
24 void set ref(ServiceMap ref) { _error = ref; render(); } 23 DartError get ref => _error;
24
25 void set ref(DartError value) {
26 _error = value;
27 render();
28 }
25 29
26 ErrorRefElementWrapper.created() : super.created() { 30 ErrorRefElementWrapper.created() : super.created() {
27 binder.registerCallback(this); 31 binder.registerCallback(this);
28 createShadowRoot(); 32 createShadowRoot();
29 render(); 33 render();
30 } 34 }
31 35
32 @override 36 @override
33 void attached() { 37 void attached() {
34 super.attached(); 38 super.attached();
35 render(); 39 render();
36 } 40 }
37 41
38 void render() { 42 void render() {
39 shadowRoot.children = []; 43 shadowRoot.children = [];
40 if (_error == null) return; 44 if (_error == null) {
45 return;
46 }
41 47
42 if (ref is Map) { 48 shadowRoot.children = [
43 shadowRoot.children = [ 49 new StyleElement()
44 new StyleElement() 50 ..text = '''
45 ..text = ''' 51 error-ref-wrapped > pre {
46 error-ref-wrapped > pre { 52 background-color: #f5f5f5;
47 background-color: #f5f5f5; 53 border: 1px solid #ccc;
48 border: 1px solid #ccc; 54 padding: 10px;
49 padding: 10px; 55 font-family: consolas, courier, monospace;
50 font-family: consolas, courier, monospace; 56 font-size: 1em;
51 font-size: 1em; 57 line-height: 1.2em;
52 line-height: 1.2em; 58 white-space: pre;
53 white-space: pre; 59 }
54 } 60 ''',
55 ''', 61 new ErrorRefElement(_error, queue: ObservatoryApplication.app.queue)
56 new ErrorRefElement(new ErrorRefMock(message: ref['message'])) 62 ];
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 } 63 }
78 } 64 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/error_ref.dart ('k') | runtime/observatory/lib/src/elements/flag_list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698