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

Side by Side Diff: tests/compiler/dart2js/sourcemaps/sourcemap_html_templates.dart

Issue 1196433002: Create and test source mapping for invocations. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Update comments. Created 5 years, 5 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) 2015, 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 /// Templates used for the HTML visualization of source map information.
6
7 library sourcemap.html.templates;
8
9 import 'dart:io';
10
11 /// Outputs JavaScript/Dart source mapping traces into [uri].
12 void outputJsDartTrace(
13 Uri uri,
14 String jsCodeHtml,
15 String dartCodeHtml,
16 String jsTraceHtml) {
17 String html = '''
18 <div class="js-buffer">
19 ${jsCodeHtml}
20 </div>
21 ${dartCodeHtml}
22 ${jsTraceHtml}
23 ''';
24 String css = '''
25 .js-buffer {
26 left:0%;
27 width:50%;
28 top:0%;
29 height:50%;
30 }
31 .dart-buffer {
32 right:0%;
33 width:50%;
34 top:0%;
35 height:50%;
36 }
37 .js-trace-buffer {
38 left:0%;
39 width:100%;
40 top:50%;
41 height:50%;
42 }
43 ''';
44 outputInTemplate(uri, html, css);
45 }
46
47 /// Outputs [html] with customized [css] in [uri].
48 void outputInTemplate(Uri uri,
49 String html,
50 String css) {
51 output(uri, '''
52 <html>
53 <head>
54 <style>
55 a, a:hover {
56 text-decoration: none;
57 color: #000;
58 }
59 h3 {
60 cursor: pointer;
61 }
62 .lineNumber {
63 font-size: smaller;
64 color: #888;
65 }
66 .buffer, .js-buffer, .dart-buffer, .js-trace-buffer {
67 position:fixed;
68 top:0px;
69 height:100%;
70 overflow:auto;
71 }
72 $css,
73 .code {
74 font-family: monospace;
75 }
76 </style>
77 </head>
78 <body>
79 <script>
80 function setAll(name, property, value) {
81 var elements = document.getElementsByName(name);
82 for (var i = 0; i < elements.length; i++) {
83 elements[i].style[property] = value;
84 }
85 }
86
87 var shownName;
88 function show(name) {
89 if (shownName != name) {
90 if (shownName) {
91 setAll(shownName, 'display', 'none');
92 }
93 shownName = name;
94 if (shownName) {
95 setAll(shownName, 'display', 'block');
96 }
97 }
98 }
99 var highlightNames = [];
100 function highlight(names) {
101 var property = 'text-decoration';
102 var onValue = 'underline';
103 var offValue = 'none';
104 if (highlightNames != names) {
105 if (highlightNames && highlightNames.length > 0) {
106 for (var index in highlightNames) {
107 var highlightName = highlightNames[index];
108 setAll(highlightName, property, offValue);
109 setAll('js' + highlightName, property, offValue);
110 setAll('trace' + highlightName, property, offValue);
111 }
112 }
113 highlightNames = names;
114 if (highlightNames && highlightNames.length > 0) {
115 for (var index in highlightNames) {
116 var highlightName = highlightNames[index];
117 setAll(highlightName, property, onValue);
118 setAll('js' + highlightName, property, onValue);
119 setAll('trace' + highlightName, property, onValue);
120 }
121 }
122 }
123 }
124 </script>
125 $html
126 </body>
127 </html>
128 ''');
129 }
130
131 /// Outputs [html] in [uri].
132 void output(Uri uri,
133 String html) {
134 File outputFile = new File.fromUri(uri);
135 outputFile.writeAsStringSync(html);
136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698