| OLD | NEW |
| 1 // Copyright (c) 2009, Google Inc. | 1 // Copyright (c) 2009, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 static void copyValue(Dart_Handle source, const char* fieldName, | 68 static void copyValue(Dart_Handle source, const char* fieldName, |
| 69 const char* targetLibrary, const char* targetClass, const char* targetField) | 69 const char* targetLibrary, const char* targetClass, const char* targetField) |
| 70 { | 70 { |
| 71 Dart_Handle value = Dart_GetField(source, Dart_NewString(fieldName)); | 71 Dart_Handle value = Dart_GetField(source, Dart_NewString(fieldName)); |
| 72 ASSERT(!Dart_IsError(value)); | 72 ASSERT(!Dart_IsError(value)); |
| 73 | 73 |
| 74 Dart_Handle library = Dart_LookupLibrary(Dart_NewString(targetLibrary)); | 74 Dart_Handle library = Dart_LookupLibrary(Dart_NewString(targetLibrary)); |
| 75 ASSERT(!Dart_IsError(library)); | 75 ASSERT(!Dart_IsError(library)); |
| 76 | 76 |
| 77 Dart_Handle cls = Dart_GetClass(library, Dart_NewString(targetClass)); | 77 Dart_Handle target = targetClass ? Dart_GetClass(library, Dart_NewString(tar
getClass)) : library; |
| 78 ASSERT(!Dart_IsError(cls)); | 78 ASSERT(!Dart_IsError(target)); |
| 79 | 79 |
| 80 Dart_SetField(cls, Dart_NewString(targetField), value); | 80 Dart_SetField(target, Dart_NewString(targetField), value); |
| 81 } | 81 } |
| 82 | 82 |
| 83 static void initDOMIsolate() | 83 static void initDOMIsolate() |
| 84 { | 84 { |
| 85 // Fix the html library. | 85 // Fix the html library. |
| 86 Dart_Handle html = Dart_LookupLibrary(Dart_NewString(DartUtilities::htmlLibr
aryName)); | 86 Dart_Handle html = Dart_LookupLibrary(Dart_NewString(DartUtilities::htmlLibr
aryName)); |
| 87 ASSERT(!Dart_IsError(html)); | 87 ASSERT(!Dart_IsError(html)); |
| 88 | 88 |
| 89 Dart_SetNativeResolver(html, domResolver); | 89 Dart_SetNativeResolver(html, domResolver); |
| 90 | 90 |
| 91 // Import html library into core to make it all available to the user direct
ly. | 91 // Import html library into core to make it all available to the user direct
ly. |
| 92 Dart_Handle core = Dart_LookupLibrary(Dart_NewString("dart:core")); | 92 Dart_Handle core = Dart_LookupLibrary(Dart_NewString("dart:core")); |
| 93 Dart_LibraryImportLibrary(core, html, Dart_Null()); | 93 Dart_LibraryImportLibrary(core, html, Dart_Null()); |
| 94 | 94 |
| 95 // Setup configuration closures | 95 // Setup configuration closures |
| 96 copyValue(html, "_printClosure", "dart:coreimpl", "PrintImplementation", "_p
rintClosure"); | 96 copyValue(html, "_printClosure", "dart:core", 0, "_printClosure"); |
| 97 copyValue(html, "_timerFactoryClosure", "dart:isolate", "_TimerFactory", "_f
actory"); | 97 copyValue(html, "_timerFactoryClosure", "dart:isolate", "_TimerFactory", "_f
actory"); |
| 98 } | 98 } |
| 99 | 99 |
| 100 static void messageNotifyCallback(Dart_Isolate); | 100 static void messageNotifyCallback(Dart_Isolate); |
| 101 | 101 |
| 102 PassRefPtr<DartIsolate> DartController::createDOMIsolate(Document* document, Pas
sRefPtr<DartApplicationLoader> applicationLoader) | 102 PassRefPtr<DartIsolate> DartController::createDOMIsolate(Document* document, Pas
sRefPtr<DartApplicationLoader> applicationLoader) |
| 103 { | 103 { |
| 104 RefPtr<DartIsolate> isolate = DartIsolate::create(document, applicationLoade
r); | 104 RefPtr<DartIsolate> isolate = DartIsolate::create(document, applicationLoade
r); |
| 105 | 105 |
| 106 DartApiScope apiScope; | 106 DartApiScope apiScope; |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 } | 602 } |
| 603 | 603 |
| 604 DartController* DartController::retrieve(ScriptExecutionContext* context) | 604 DartController* DartController::retrieve(ScriptExecutionContext* context) |
| 605 { | 605 { |
| 606 if (!context || !context->isDocument()) | 606 if (!context || !context->isDocument()) |
| 607 return 0; | 607 return 0; |
| 608 return retrieve(static_cast<Document*>(context)->frame()); | 608 return retrieve(static_cast<Document*>(context)->frame()); |
| 609 } | 609 } |
| 610 | 610 |
| 611 } | 611 } |
| OLD | NEW |