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

Side by Side Diff: lib/compiler/implementation/emitter.dart

Issue 9918014: Fix issue http://dartbug.com/2342 by checking document.readyState (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | « frog/minfrog ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 5 /**
6 * A function element that represents a closure call. The signature is copied 6 * A function element that represents a closure call. The signature is copied
7 * from the given element. 7 * from the given element.
8 */ 8 */
9 class ClosureInvocationElement extends FunctionElement { 9 class ClosureInvocationElement extends FunctionElement {
10 ClosureInvocationElement(SourceString name, 10 ClosureInvocationElement(SourceString name,
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 Element main = compiler.mainApp.find(Compiler.MAIN); 702 Element main = compiler.mainApp.find(Compiler.MAIN);
703 String mainCall = null; 703 String mainCall = null;
704 if (compiler.isolateLibrary != null) { 704 if (compiler.isolateLibrary != null) {
705 Element isolateMain = 705 Element isolateMain =
706 compiler.isolateLibrary.find(Compiler.START_ROOT_ISOLATE); 706 compiler.isolateLibrary.find(Compiler.START_ROOT_ISOLATE);
707 mainCall = buildIsolateSetup(buffer, main, isolateMain); 707 mainCall = buildIsolateSetup(buffer, main, isolateMain);
708 } else { 708 } else {
709 mainCall = '${namer.isolateAccess(main)}()'; 709 mainCall = '${namer.isolateAccess(main)}()';
710 } 710 }
711 buffer.add(""" 711 buffer.add("""
712 if (typeof window != 'undefined' && window.addEventListener) { 712 if (typeof window != 'undefined' && typeof document != 'undefined' &&
713 window.addEventListener && document.readyState == 'loading') {
713 window.addEventListener('DOMContentLoaded', function(e) { 714 window.addEventListener('DOMContentLoaded', function(e) {
714 ${mainCall}; 715 ${mainCall};
715 }); 716 });
716 } else { 717 } else {
717 ${mainCall}; 718 ${mainCall};
718 } 719 }
719 """); 720 """);
720 } 721 }
721 722
722 String assembleProgram() { 723 String assembleProgram() {
723 measure(() { 724 measure(() {
724 mainBuffer.add('function ${namer.ISOLATE}() {'); 725 mainBuffer.add('function ${namer.ISOLATE}() {');
725 emitStaticNonFinalFieldInitializations(mainBuffer); 726 emitStaticNonFinalFieldInitializations(mainBuffer);
726 mainBuffer.add('}\n\n'); 727 mainBuffer.add('}\n\n');
727 emitClasses(mainBuffer); 728 emitClasses(mainBuffer);
728 emitStaticFunctions(mainBuffer); 729 emitStaticFunctions(mainBuffer);
729 emitStaticFunctionGetters(mainBuffer); 730 emitStaticFunctionGetters(mainBuffer);
730 emitCompileTimeConstants(mainBuffer); 731 emitCompileTimeConstants(mainBuffer);
731 emitStaticFinalFieldInitializations(mainBuffer); 732 emitStaticFinalFieldInitializations(mainBuffer);
732 nativeEmitter.emitDynamicDispatchMetadata(); 733 nativeEmitter.emitDynamicDispatchMetadata();
733 mainBuffer.add( 734 mainBuffer.add(
734 'var ${namer.CURRENT_ISOLATE} = new ${namer.ISOLATE}();\n'); 735 'var ${namer.CURRENT_ISOLATE} = new ${namer.ISOLATE}();\n');
735 nativeEmitter.assembleCode(mainBuffer); 736 nativeEmitter.assembleCode(mainBuffer);
736 emitMain(mainBuffer); 737 emitMain(mainBuffer);
737 compiler.assembledCode = mainBuffer.toString(); 738 compiler.assembledCode = mainBuffer.toString();
738 }); 739 });
739 return compiler.assembledCode; 740 return compiler.assembledCode;
740 } 741 }
741 } 742 }
OLDNEW
« no previous file with comments | « frog/minfrog ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698