| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 library trydart.compilation; | 5 library trydart.compilation; |
| 6 | 6 |
| 7 import 'dart:html' show | 7 import 'dart:html' show |
| 8 Blob, | 8 Blob, |
| 9 Element, | 9 Element, |
| 10 ErrorEvent, | 10 ErrorEvent, |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 var url = | 190 var url = |
| 191 Url.createObjectUrl( | 191 Url.createObjectUrl( |
| 192 new Blob([codeWithPrint], 'application/javascript')); | 192 new Blob([codeWithPrint], 'application/javascript')); |
| 193 objectUrls.add(url); | 193 objectUrls.add(url); |
| 194 | 194 |
| 195 run(url, makeIframe); | 195 run(url, makeIframe); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void run(String url, IFrameElement makeIframe()) { | 198 void run(String url, IFrameElement makeIframe()) { |
| 199 void retryInIframe() { | 199 void retryInIframe() { |
| 200 interaction.aboutToRun(); |
| 200 var frame = makeIframe(); | 201 var frame = makeIframe(); |
| 201 frame.style | 202 frame.style |
| 202 ..visibility = 'hidden' | 203 ..visibility = 'hidden' |
| 203 ..position = 'absolute'; | 204 ..position = 'absolute'; |
| 204 outputFrame.parent.insertBefore(frame, outputFrame); | 205 outputFrame.parent.insertBefore(frame, outputFrame); |
| 205 outputFrame = frame; | 206 outputFrame = frame; |
| 206 errorStream(frame).listen(interaction.onIframeError); | 207 errorStream(frame).listen(interaction.onIframeError); |
| 207 } | 208 } |
| 208 void onError(String errorMessage) { | 209 void onError(String errorMessage) { |
| 210 interaction.consolePrintLine(errorMessage); |
| 209 console | 211 console |
| 210 ..appendText(errorMessage) | |
| 211 ..appendText(' ') | |
| 212 ..append(buildButton('Try in iframe', (_) => retryInIframe())) | 212 ..append(buildButton('Try in iframe', (_) => retryInIframe())) |
| 213 ..appendText('\n'); | 213 ..appendText('\n'); |
| 214 } | 214 } |
| 215 interaction.aboutToRun(); | 215 interaction.aboutToRun(); |
| 216 if (usesDartHtml && !alwaysRunInWorker) { | 216 if (usesDartHtml && !alwaysRunInWorker) { |
| 217 retryInIframe(); | 217 retryInIframe(); |
| 218 } else { | 218 } else { |
| 219 runInWorker(url, onError); | 219 runInWorker(url, onError); |
| 220 } | 220 } |
| 221 } | 221 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 251 if (seenMessages.add('$begin:$end: [$kind] $message')) { | 251 if (seenMessages.add('$begin:$end: [$kind] $message')) { |
| 252 // Guard against duplicated messages. | 252 // Guard against duplicated messages. |
| 253 addDiagnostic(kind, message, begin, end); | 253 addDiagnostic(kind, message, begin, end); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 | 256 |
| 257 onCrash(data) { | 257 onCrash(data) { |
| 258 interaction.onCompilerCrash(data); | 258 interaction.onCompilerCrash(data); |
| 259 } | 259 } |
| 260 } | 260 } |
| OLD | NEW |