| OLD | NEW |
| 1 // Copyright 2011, Google Inc. | 1 // Copyright 2011, 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 28 matching lines...) Expand all Loading... |
| 39 #include "HTMLFormControlElement.h" | 39 #include "HTMLFormControlElement.h" |
| 40 #include "LabelableElement.h" | 40 #include "LabelableElement.h" |
| 41 | 41 |
| 42 #include <stdio.h> | 42 #include <stdio.h> |
| 43 #include <wtf/text/WTFString.h> | 43 #include <wtf/text/WTFString.h> |
| 44 | 44 |
| 45 namespace WebCore { | 45 namespace WebCore { |
| 46 | 46 |
| 47 Dart_Handle DartDOMWrapper::instantiateWrapper(const char* className) | 47 Dart_Handle DartDOMWrapper::instantiateWrapper(const char* className) |
| 48 { | 48 { |
| 49 // FIXME: this all is very ugly, but we're blocked by API here. | |
| 50 // In this case we need an API to invoke ctor, or even better, | |
| 51 // create an instance without exposing constructor at all. | |
| 52 String factoryMethodName = String("_create") + className; | |
| 53 Dart_Handle html = DartUtilities::htmlLibraryForCurrentIsolate(); | 49 Dart_Handle html = DartUtilities::htmlLibraryForCurrentIsolate(); |
| 54 ASSERT(!Dart_IsError(html)); | 50 ASSERT(!Dart_IsError(html)); |
| 55 | 51 |
| 56 Dart_Handle cls = Dart_GetClass(html, Dart_NewString(className)); | 52 Dart_Handle cls = Dart_GetClass(html, Dart_NewString(className)); |
| 57 ASSERT(!Dart_IsError(cls)); | 53 ASSERT(!Dart_IsError(cls)); |
| 58 | 54 |
| 59 Dart_Handle instance = Dart_Invoke(cls, DartUtilities::stringToDartString(fa
ctoryMethodName), 0, 0); | 55 Dart_Handle instance = Dart_New(cls, Dart_Null(), 0, 0); |
| 60 ASSERT(!Dart_IsError(instance)); | 56 ASSERT(!Dart_IsError(instance)); |
| 57 |
| 61 return instance; | 58 return instance; |
| 62 } | 59 } |
| 63 | 60 |
| 64 bool DartDOMWrapper::instanceOf(const char* className, Dart_Handle wrapper) | 61 bool DartDOMWrapper::instanceOf(const char* className, Dart_Handle wrapper) |
| 65 { | 62 { |
| 66 // FIXME: Cache classes in the corresponding bindings class. Requires persis
tent handles. | 63 // FIXME: Cache classes in the corresponding bindings class. Requires persis
tent handles. |
| 67 Dart_Handle html = DartUtilities::htmlLibraryForCurrentIsolate(); | 64 Dart_Handle html = DartUtilities::htmlLibraryForCurrentIsolate(); |
| 68 ASSERT(!Dart_IsError(html)); | 65 ASSERT(!Dart_IsError(html)); |
| 69 | 66 |
| 70 Dart_Handle cls = Dart_GetClass(html, Dart_NewString(className)); | 67 Dart_Handle cls = Dart_GetClass(html, Dart_NewString(className)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 96 DOM_EXCEPTION_INTERFACES_FOR_EACH(TRY_TO_CREATE_EXCEPTION) | 93 DOM_EXCEPTION_INTERFACES_FOR_EACH(TRY_TO_CREATE_EXCEPTION) |
| 97 } | 94 } |
| 98 | 95 |
| 99 ASSERT_NOT_REACHED(); | 96 ASSERT_NOT_REACHED(); |
| 100 return Dart_NewString("Unknown WebCore exception"); | 97 return Dart_NewString("Unknown WebCore exception"); |
| 101 } | 98 } |
| 102 | 99 |
| 103 #undef TRY_TO_CREATE_EXCEPTION | 100 #undef TRY_TO_CREATE_EXCEPTION |
| 104 | 101 |
| 105 } | 102 } |
| OLD | NEW |