Chromium Code Reviews| 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 if (targetClass) { |
|
Anton Muhin
2012/09/12 14:50:54
Please, to keep the cases as similar as they can b
Mads Ager (google)
2012/09/13 07:17:42
Done.
| |
| 78 ASSERT(!Dart_IsError(cls)); | 78 Dart_Handle cls = Dart_GetClass(library, Dart_NewString(targetClass)); |
| 79 | 79 ASSERT(!Dart_IsError(cls)); |
| 80 Dart_SetField(cls, Dart_NewString(targetField), value); | 80 Dart_SetField(cls, Dart_NewString(targetField), value); |
|
Anton Muhin
2012/09/12 14:50:54
nit: 4 spaces for indent.
Mads Ager (google)
2012/09/13 07:17:42
Thanks. Code is now gone.
| |
| 81 } else { | |
| 82 Dart_SetField(library, Dart_NewString(targetField), value); | |
| 83 } | |
| 81 } | 84 } |
| 82 | 85 |
| 83 static void initDOMIsolate() | 86 static void initDOMIsolate() |
| 84 { | 87 { |
| 85 // Fix the html library. | 88 // Fix the html library. |
| 86 Dart_Handle html = Dart_LookupLibrary(Dart_NewString(DartUtilities::htmlLibr aryName)); | 89 Dart_Handle html = Dart_LookupLibrary(Dart_NewString(DartUtilities::htmlLibr aryName)); |
| 87 ASSERT(!Dart_IsError(html)); | 90 ASSERT(!Dart_IsError(html)); |
| 88 | 91 |
| 89 Dart_SetNativeResolver(html, domResolver); | 92 Dart_SetNativeResolver(html, domResolver); |
| 90 | 93 |
| 91 // Import html library into core to make it all available to the user direct ly. | 94 // 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")); | 95 Dart_Handle core = Dart_LookupLibrary(Dart_NewString("dart:core")); |
| 93 Dart_LibraryImportLibrary(core, html, Dart_Null()); | 96 Dart_LibraryImportLibrary(core, html, Dart_Null()); |
| 94 | 97 |
| 95 // Setup configuration closures | 98 // Setup configuration closures |
| 96 copyValue(html, "_printClosure", "dart:coreimpl", "PrintImplementation", "_p rintClosure"); | 99 copyValue(html, "_printClosure", "dart:core", 0, "_printClosure"); |
|
Anton Muhin
2012/09/12 14:50:54
cannot we unify this stuff and use class for print
Mads Ager (google)
2012/09/13 07:17:42
We could but I don't think we want to put that req
Anton Muhin
2012/09/13 07:25:33
That'd be cool.
On 2012/09/13 07:17:42, Mads Ager
| |
| 97 copyValue(html, "_timerFactoryClosure", "dart:isolate", "_TimerFactory", "_f actory"); | 100 copyValue(html, "_timerFactoryClosure", "dart:isolate", "_TimerFactory", "_f actory"); |
| 98 } | 101 } |
| 99 | 102 |
| 100 static void messageNotifyCallback(Dart_Isolate); | 103 static void messageNotifyCallback(Dart_Isolate); |
| 101 | 104 |
| 102 PassRefPtr<DartIsolate> DartController::createDOMIsolate(Document* document, Pas sRefPtr<DartApplicationLoader> applicationLoader) | 105 PassRefPtr<DartIsolate> DartController::createDOMIsolate(Document* document, Pas sRefPtr<DartApplicationLoader> applicationLoader) |
| 103 { | 106 { |
| 104 RefPtr<DartIsolate> isolate = DartIsolate::create(document, applicationLoade r); | 107 RefPtr<DartIsolate> isolate = DartIsolate::create(document, applicationLoade r); |
| 105 | 108 |
| 106 DartApiScope apiScope; | 109 DartApiScope apiScope; |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 } | 605 } |
| 603 | 606 |
| 604 DartController* DartController::retrieve(ScriptExecutionContext* context) | 607 DartController* DartController::retrieve(ScriptExecutionContext* context) |
| 605 { | 608 { |
| 606 if (!context || !context->isDocument()) | 609 if (!context || !context->isDocument()) |
| 607 return 0; | 610 return 0; |
| 608 return retrieve(static_cast<Document*>(context)->frame()); | 611 return retrieve(static_cast<Document*>(context)->frame()); |
| 609 } | 612 } |
| 610 | 613 |
| 611 } | 614 } |
| OLD | NEW |