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

Side by Side Diff: dart/site/try/src/run.dart

Issue 349683003: Improve running in iframes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r37602. Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « dart/site/try/src/interaction_manager.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.run; 5 library trydart.run;
6 6
7 import 'dart:html' show 7 import 'dart:html' show
8 Blob, 8 Blob,
9 IFrameElement, 9 IFrameElement,
10 Url; 10 Url;
(...skipping 17 matching lines...) Expand all
28 ..src = Url.createObjectUrl(new Blob([outputHtml], "text/html")) 28 ..src = Url.createObjectUrl(new Blob([outputHtml], "text/html"))
29 ..style.width = '100%' 29 ..style.width = '100%'
30 ..style.height = '0px'; 30 ..style.height = '0px';
31 } 31 }
32 32
33 final String outputHelper = 33 final String outputHelper =
34 Url.createObjectUrl(new Blob([OUTPUT_HELPER], 'application/javascript')); 34 Url.createObjectUrl(new Blob([OUTPUT_HELPER], 'application/javascript'));
35 35
36 const String OUTPUT_HELPER = r''' 36 const String OUTPUT_HELPER = r'''
37 function dartPrint(msg) { 37 function dartPrint(msg) {
38 // Send a message to the main Try Dart window.
38 window.parent.postMessage(String(msg), "*"); 39 window.parent.postMessage(String(msg), "*");
39 } 40 }
40 41
41 function dartMainRunner(main) { 42 function dartMainRunner(main) {
43 // Store the current height (of an empty document). This implies that the
44 // main Try Dart application is only notified if the document is actually
45 // changed.
46 var previousScrollHeight = document.documentElement.scrollHeight;
47
48 function postScrollHeight(mutations, observer) {
49 var scrollHeight = document.documentElement.scrollHeight;
50 if (scrollHeight !== previousScrollHeight) {
51 previousScrollHeight = scrollHeight;
52 window.parent.postMessage(["scrollHeight", scrollHeight], "*");
53 }
54 }
55
56 var MutationObserver =
57 window.MutationObserver ||
58 window.WebKitMutationObserver ||
59 window.MozMutationObserver;
60
61 // Listen to any changes to the DOM.
62 new MutationObserver(postScrollHeight).observe(
63 document.documentElement,
64 { attributes: true,
65 childList: true,
66 characterData: true,
67 subtree: true });
68
42 main(); 69 main();
43 } 70 }
44
45 window.onerror = function (message, url, lineNumber) {
46 window.parent.postMessage(
47 ["error", {message: message, url: url, lineNumber: lineNumber}], "*");
48 };
49
50 (function () {
51
52 function postScrollHeight() {
53 window.parent.postMessage(
54 ["scrollHeight", document.documentElement.scrollHeight], "*");
55 }
56
57 var observer = new (window.MutationObserver ||
58 window.WebKitMutationObserver ||
59 window.MozMutationObserver)(function(mutations) {
60 postScrollHeight()
61 window.setTimeout(postScrollHeight, 500);
62 });
63
64 observer.observe(
65 document.body,
66 { attributes: true,
67 childList: true,
68 characterData: true,
69 subtree: true });
70 })();
71 '''; 71 ''';
OLDNEW
« no previous file with comments | « dart/site/try/src/interaction_manager.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698