Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: Source/bindings/dart/DartUtilities.cpp

Issue 24294002: Dartium changes for custom element lifecycle events. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include <wtf/Uint8Array.h> 58 #include <wtf/Uint8Array.h>
59 #include <wtf/Uint8ClampedArray.h> 59 #include <wtf/Uint8ClampedArray.h>
60 #include <wtf/text/AtomicString.h> 60 #include <wtf/text/AtomicString.h>
61 #include <wtf/text/CString.h> 61 #include <wtf/text/CString.h>
62 #include <wtf/text/WTFString.h> 62 #include <wtf/text/WTFString.h>
63 63
64 namespace WebCore { 64 namespace WebCore {
65 65
66 const char* DartUtilities::htmlLibraryName = "dart:html"; 66 const char* DartUtilities::htmlLibraryName = "dart:html";
67 const char* DartUtilities::indexedDBLibraryName = "dart:indexed_db"; 67 const char* DartUtilities::indexedDBLibraryName = "dart:indexed_db";
68 const char* DartUtilities::svgLibraryName = "dart:svg";
68 69
69 static void stringFinalizer(void* peer) 70 static void stringFinalizer(void* peer)
70 { 71 {
71 reinterpret_cast<StringImpl*>(peer)->deref(); 72 reinterpret_cast<StringImpl*>(peer)->deref();
72 } 73 }
73 74
74 template <typename T> PassRefPtr<StringImpl> convertAndExternalize(Dart_Handle s tring, intptr_t length) 75 template <typename T> PassRefPtr<StringImpl> convertAndExternalize(Dart_Handle s tring, intptr_t length)
75 { 76 {
76 if (!length) 77 if (!length)
77 return StringImpl::empty(); 78 return StringImpl::empty();
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 370
370 bool isType = false; 371 bool isType = false;
371 Dart_Handle result = Dart_ObjectIsType(handle, cls, &isType); 372 Dart_Handle result = Dart_ObjectIsType(handle, cls, &isType);
372 ASSERT(!Dart_IsError(result)); 373 ASSERT(!Dart_IsError(result));
373 if (Dart_IsError(result)) 374 if (Dart_IsError(result))
374 return false; 375 return false;
375 376
376 return isType; 377 return isType;
377 } 378 }
378 379
380 bool DartUtilities::isTypeSubclassOf(Dart_Handle type, const char* libraryName, const char* typeName)
381 {
382 Dart_Handle library = libraryForCurrentIsolate(libraryName);
383 ASSERT(!Dart_IsError(library));
384
385 Dart_Handle other = Dart_GetType(library, Dart_NewStringFromCString(typeName ), 0, 0);
386 ASSERT(!Dart_IsError(other));
siva 2013/09/20 20:57:37 Is this typeName one of the predefined 5000 types?
387
388 Dart_Handle args[2] = { type, other };
389 Dart_Handle result = DartUtilities::invokeUtilsMethod("isTypeSubclassOf", 2, args);
390 ASSERT(!Dart_IsError(result));
391 if (Dart_IsError(result))
392 return false;
393
394 Dart_Handle exception = 0;
395 bool boolResult = dartToBool(result, exception);
396 if (exception)
397 return false;
398 return boolResult;
399 }
400
379 bool DartUtilities::isTypedData(Dart_Handle handle) 401 bool DartUtilities::isTypedData(Dart_Handle handle)
380 { 402 {
381 return Dart_GetTypeOfTypedData(handle) != Dart_TypedData_kInvalid || Dart_Ge tTypeOfExternalTypedData(handle) != Dart_TypedData_kInvalid; 403 return Dart_GetTypeOfTypedData(handle) != Dart_TypedData_kInvalid || Dart_Ge tTypeOfExternalTypedData(handle) != Dart_TypedData_kInvalid;
382 } 404 }
383 405
384 static Dart_TypedData_Type typedDataTypeFromViewType(ArrayBufferView::ViewType t ype) 406 static Dart_TypedData_Type typedDataTypeFromViewType(ArrayBufferView::ViewType t ype)
385 { 407 {
386 switch (type) { 408 switch (type) {
387 case ArrayBufferView::TypeInt8: 409 case ArrayBufferView::TypeInt8:
388 return Dart_TypedData_kInt8; 410 return Dart_TypedData_kInt8;
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 Dart_Handle library = htmlLibraryForCurrentIsolate(); 1048 Dart_Handle library = htmlLibraryForCurrentIsolate();
1027 ASSERT(!Dart_IsError(library)); 1049 ASSERT(!Dart_IsError(library));
1028 1050
1029 Dart_Handle utilsClass = Dart_GetType(library, Dart_NewStringFromCString("_U tils"), 0, 0); 1051 Dart_Handle utilsClass = Dart_GetType(library, Dart_NewStringFromCString("_U tils"), 0, 0);
1030 ASSERT(!Dart_IsError(utilsClass)); 1052 ASSERT(!Dart_IsError(utilsClass));
1031 1053
1032 return Dart_Invoke(utilsClass, Dart_NewStringFromCString(methodName), argCou nt, args); 1054 return Dart_Invoke(utilsClass, Dart_NewStringFromCString(methodName), argCou nt, args);
1033 } 1055 }
1034 1056
1035 } 1057 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698