| 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 25 matching lines...) Expand all Loading... |
| 36 #include "DartNode.h" | 36 #include "DartNode.h" |
| 37 #include "bindings/dart/DartUtilities.h" | 37 #include "bindings/dart/DartUtilities.h" |
| 38 #include "core/html/HTMLFormControlElement.h" | 38 #include "core/html/HTMLFormControlElement.h" |
| 39 #include "core/html/LabelableElement.h" | 39 #include "core/html/LabelableElement.h" |
| 40 | 40 |
| 41 #include <stdio.h> | 41 #include <stdio.h> |
| 42 #include <wtf/text/WTFString.h> | 42 #include <wtf/text/WTFString.h> |
| 43 | 43 |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 Dart_Handle DartDOMWrapper::instantiateWrapper(const char* className, const char
* libraryName) | 46 Dart_Handle DartDOMWrapper::dartClass(const char* className, const char* library
Name, intptr_t index) |
| 47 { | 47 { |
| 48 Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryName); | 48 ASSERT(index < NumWebkitClassIds); |
| 49 ASSERT(!Dart_IsError(library)); | |
| 50 | 49 |
| 51 Dart_Handle type = Dart_GetType(library, Dart_NewStringFromCString(className
), 0, 0); | 50 ClassTable* table = DartDOMData::current()->classHandleCache(); |
| 52 ASSERT(!Dart_IsError(type)); | |
| 53 | 51 |
| 54 Dart_Handle instance = Dart_Allocate(type); | 52 Dart_Handle type; |
| 55 ASSERT(!Dart_IsError(instance)); | 53 Dart_PersistentHandle persistentType = (*table)[index]; |
| 56 | 54 |
| 57 return instance; | 55 if (persistentType) { |
| 58 } | 56 type = Dart_HandleFromPersistent(persistentType); |
| 57 } else { |
| 58 Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryNam
e); |
| 59 ASSERT(!Dart_IsError(library)); |
| 59 | 60 |
| 60 bool DartDOMWrapper::instanceOf(const char* className, const char* libraryName,
Dart_Handle wrapper) | 61 type = Dart_GetType(library, Dart_NewStringFromCString(className), 0, 0)
; |
| 61 { | 62 ASSERT(!Dart_IsError(type)); |
| 62 // FIXME(rmacnak): Cache classes in the corresponding bindings class. Requir
es persistent handles. | |
| 63 Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryName); | |
| 64 ASSERT(!Dart_IsError(library)); | |
| 65 | 63 |
| 66 Dart_Handle type = Dart_GetType(library, Dart_NewStringFromCString(className
), 0, 0); | 64 persistentType = Dart_NewPersistentHandle(type); |
| 67 ASSERT(!Dart_IsError(type)); | 65 (*table)[index] = persistentType; |
| 68 if (Dart_IsError(type)) | 66 } |
| 69 return false; | |
| 70 | 67 |
| 71 bool isInstanceOf = false; | 68 return type; |
| 72 Dart_Handle result = Dart_ObjectIsType(wrapper, type, &isInstanceOf); | |
| 73 ASSERT(!Dart_IsError(result)); | |
| 74 if (Dart_IsError(result)) | |
| 75 return false; | |
| 76 return isInstanceOf; | |
| 77 } | 69 } |
| 78 | 70 |
| 79 Dart_Handle DartDOMWrapper::exceptionCodeToDartException(ExceptionCode exception
Code) | 71 Dart_Handle DartDOMWrapper::exceptionCodeToDartException(ExceptionCode exception
Code) |
| 80 { | 72 { |
| 81 ASSERT(exceptionCode > 0); | 73 ASSERT(exceptionCode > 0); |
| 82 | 74 |
| 83 // FIXME: Get a better exception message here. | 75 // FIXME: Get a better exception message here. |
| 84 RefPtr<DOMException> domException = DOMException::create(exceptionCode, "Int
ernal Dartium Exception"); | 76 RefPtr<DOMException> domException = DOMException::create(exceptionCode, "Int
ernal Dartium Exception"); |
| 85 | 77 |
| 86 return DartDOMException::toDart(domException); | 78 return DartDOMException::toDart(domException); |
| 87 } | 79 } |
| 88 | 80 |
| 89 Dart_Handle DartDOMWrapper::exceptionCodeToDartException(DartExceptionState& exc
eptionState) | 81 Dart_Handle DartDOMWrapper::exceptionCodeToDartException(DartExceptionState& exc
eptionState) |
| 90 { | 82 { |
| 91 return exceptionCodeToDartException(exceptionState.code()); | 83 return exceptionCodeToDartException(exceptionState.code()); |
| 92 } | 84 } |
| 93 | 85 |
| 94 } | 86 } |
| OLD | NEW |