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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/site/try/src/interaction_manager.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/site/try/src/run.dart
diff --git a/dart/site/try/src/run.dart b/dart/site/try/src/run.dart
index 3eae69811d5db7a582956d5c1ba39618edca0376..e453a7015bccf9bdeb3f965dd7cb4299f0932392 100644
--- a/dart/site/try/src/run.dart
+++ b/dart/site/try/src/run.dart
@@ -35,37 +35,37 @@ final String outputHelper =
const String OUTPUT_HELPER = r'''
function dartPrint(msg) {
+ // Send a message to the main Try Dart window.
window.parent.postMessage(String(msg), "*");
}
function dartMainRunner(main) {
- main();
-}
-
-window.onerror = function (message, url, lineNumber) {
- window.parent.postMessage(
- ["error", {message: message, url: url, lineNumber: lineNumber}], "*");
-};
+ // Store the current height (of an empty document). This implies that the
+ // main Try Dart application is only notified if the document is actually
+ // changed.
+ var previousScrollHeight = document.documentElement.scrollHeight;
-(function () {
+ function postScrollHeight(mutations, observer) {
+ var scrollHeight = document.documentElement.scrollHeight;
+ if (scrollHeight !== previousScrollHeight) {
+ previousScrollHeight = scrollHeight;
+ window.parent.postMessage(["scrollHeight", scrollHeight], "*");
+ }
+ }
-function postScrollHeight() {
- window.parent.postMessage(
- ["scrollHeight", document.documentElement.scrollHeight], "*");
-}
+ var MutationObserver =
+ window.MutationObserver ||
+ window.WebKitMutationObserver ||
+ window.MozMutationObserver;
-var observer = new (window.MutationObserver ||
- window.WebKitMutationObserver ||
- window.MozMutationObserver)(function(mutations) {
- postScrollHeight()
- window.setTimeout(postScrollHeight, 500);
-});
+ // Listen to any changes to the DOM.
+ new MutationObserver(postScrollHeight).observe(
+ document.documentElement,
+ { attributes: true,
+ childList: true,
+ characterData: true,
+ subtree: true });
-observer.observe(
- document.body,
- { attributes: true,
- childList: true,
- characterData: true,
- subtree: true });
-})();
+ main();
+}
''';
« 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