Chromium Code Reviews| Index: Source/bindings/dart/DartUtilities.cpp |
| diff --git a/Source/bindings/dart/DartUtilities.cpp b/Source/bindings/dart/DartUtilities.cpp |
| index 04eadb97724e6c11a5924d0486bf0671123335f9..d05656dfe0f29a8846aa2622479cda608cbbae5f 100644 |
| --- a/Source/bindings/dart/DartUtilities.cpp |
| +++ b/Source/bindings/dart/DartUtilities.cpp |
| @@ -30,6 +30,9 @@ |
| #include "config.h" |
| #include "bindings/dart/DartUtilities.h" |
| +#include "DartBlob.h" |
| +#include "DartIDBKeyRange.h" |
| +#include "DartImageData.h" |
| #include "DartMessagePort.h" |
| #include "bindings/dart/DartDOMData.h" |
| #include "bindings/dart/DartHandleProxy.h" |
| @@ -65,6 +68,7 @@ namespace WebCore { |
| const char* DartUtilities::htmlLibraryName = "dart:html"; |
| const char* DartUtilities::indexedDBLibraryName = "dart:indexed_db"; |
| +const char* DartUtilities::svgLibraryName = "dart:svg"; |
| static void stringFinalizer(void* peer) |
| { |
| @@ -345,17 +349,28 @@ bool DartUtilities::isDateTime(Dart_Handle handle) |
| bool DartUtilities::isBlob(Dart_Handle handle) |
| { |
| - return objectIsType(handle, htmlLibraryName, "Blob"); |
| + return objectIsClass(handle, DartDOMWrapper::dartClass<DartBlob>()); |
| } |
| bool DartUtilities::isImageData(Dart_Handle handle) |
| { |
| - return objectIsType(handle, htmlLibraryName, "ImageData"); |
| + return objectIsClass(handle, DartDOMWrapper::dartClass<DartImageData>()); |
| } |
| bool DartUtilities::isIDBKeyRange(Dart_Handle handle) |
| { |
| - return objectIsType(handle, indexedDBLibraryName, "KeyRange"); |
| + return objectIsClass(handle, DartDOMWrapper::dartClass<DartIDBKeyRange>()); |
| +} |
| + |
| +bool DartUtilities::objectIsClass(Dart_Handle handle, Dart_Handle cls) |
|
vsm
2013/09/25 22:39:10
I'd call this objectIsType for clarity.
blois
2013/09/25 22:50:18
Done.
|
| +{ |
| + bool isType = false; |
| + Dart_Handle result = Dart_ObjectIsType(handle, cls, &isType); |
| + ASSERT(!Dart_IsError(result)); |
| + if (Dart_IsError(result)) |
| + return false; |
| + |
| + return isType; |
| } |
| bool DartUtilities::objectIsType(Dart_Handle handle, const char* libraryName, const char* typeName) |
| @@ -376,6 +391,27 @@ bool DartUtilities::objectIsType(Dart_Handle handle, const char* libraryName, co |
| return isType; |
| } |
| +bool DartUtilities::isTypeSubclassOf(Dart_Handle type, const char* libraryName, const char* typeName) |
| +{ |
| + Dart_Handle library = libraryForCurrentIsolate(libraryName); |
| + ASSERT(!Dart_IsError(library)); |
| + |
| + Dart_Handle other = Dart_GetType(library, Dart_NewStringFromCString(typeName), 0, 0); |
| + ASSERT(!Dart_IsError(other)); |
| + |
| + Dart_Handle args[2] = { type, other }; |
| + Dart_Handle result = DartUtilities::invokeUtilsMethod("isTypeSubclassOf", 2, args); |
| + ASSERT(!Dart_IsError(result)); |
| + if (Dart_IsError(result)) |
| + return false; |
| + |
| + Dart_Handle exception = 0; |
| + bool boolResult = dartToBool(result, exception); |
| + if (exception) |
| + return false; |
| + return boolResult; |
| +} |
| + |
| bool DartUtilities::isTypedData(Dart_Handle handle) |
| { |
| return Dart_GetTypeOfTypedData(handle) != Dart_TypedData_kInvalid || Dart_GetTypeOfExternalTypedData(handle) != Dart_TypedData_kInvalid; |