| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Google Inc. 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 23 matching lines...) Expand all Loading... |
| 34 #include "bindings/v8/NPV8Object.h" | 34 #include "bindings/v8/NPV8Object.h" |
| 35 #include "bindings/v8/V8Binding.h" | 35 #include "bindings/v8/V8Binding.h" |
| 36 #include "bindings/v8/V8NPObject.h" | 36 #include "bindings/v8/V8NPObject.h" |
| 37 #include "bindings/v8/npruntime_impl.h" | 37 #include "bindings/v8/npruntime_impl.h" |
| 38 #include "bindings/v8/npruntime_priv.h" | 38 #include "bindings/v8/npruntime_priv.h" |
| 39 #include "core/page/DOMWindow.h" | 39 #include "core/page/DOMWindow.h" |
| 40 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject* owner, NP
Variant* result) | 44 void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject* owner, NP
Variant* result, v8::Isolate* isolate) |
| 45 { | 45 { |
| 46 VOID_TO_NPVARIANT(*result); | 46 VOID_TO_NPVARIANT(*result); |
| 47 | 47 |
| 48 // It is really the caller's responsibility to deal with the empty handle ca
se because there could be different actions to | 48 // It is really the caller's responsibility to deal with the empty handle ca
se because there could be different actions to |
| 49 // take in different contexts. | 49 // take in different contexts. |
| 50 ASSERT(!object.IsEmpty()); | 50 ASSERT(!object.IsEmpty()); |
| 51 | 51 |
| 52 if (object.IsEmpty()) | 52 if (object.IsEmpty()) |
| 53 return; | 53 return; |
| 54 | 54 |
| 55 if (object->IsNumber()) | 55 if (object->IsNumber()) |
| 56 DOUBLE_TO_NPVARIANT(object->NumberValue(), *result); | 56 DOUBLE_TO_NPVARIANT(object->NumberValue(), *result); |
| 57 else if (object->IsBoolean()) | 57 else if (object->IsBoolean()) |
| 58 BOOLEAN_TO_NPVARIANT(object->BooleanValue(), *result); | 58 BOOLEAN_TO_NPVARIANT(object->BooleanValue(), *result); |
| 59 else if (object->IsNull()) | 59 else if (object->IsNull()) |
| 60 NULL_TO_NPVARIANT(*result); | 60 NULL_TO_NPVARIANT(*result); |
| 61 else if (object->IsUndefined()) | 61 else if (object->IsUndefined()) |
| 62 VOID_TO_NPVARIANT(*result); | 62 VOID_TO_NPVARIANT(*result); |
| 63 else if (object->IsString()) { | 63 else if (object->IsString()) { |
| 64 v8::Handle<v8::String> str = object.As<v8::String>(); | 64 v8::Handle<v8::String> str = object.As<v8::String>(); |
| 65 int length = str->Utf8Length() + 1; | 65 int length = str->Utf8Length() + 1; |
| 66 char* utf8Chars = reinterpret_cast<char*>(malloc(length)); | 66 char* utf8Chars = reinterpret_cast<char*>(malloc(length)); |
| 67 str->WriteUtf8(utf8Chars, length, 0, v8::String::HINT_MANY_WRITES_EXPECT
ED); | 67 str->WriteUtf8(utf8Chars, length, 0, v8::String::HINT_MANY_WRITES_EXPECT
ED); |
| 68 STRINGN_TO_NPVARIANT(utf8Chars, length-1, *result); | 68 STRINGN_TO_NPVARIANT(utf8Chars, length-1, *result); |
| 69 } else if (object->IsObject()) { | 69 } else if (object->IsObject()) { |
| 70 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent()); | 70 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent()); |
| 71 NPObject* npobject = npCreateV8ScriptObject(0, v8::Handle<v8::Object>::C
ast(object), window); | 71 NPObject* npobject = npCreateV8ScriptObject(0, v8::Handle<v8::Object>::C
ast(object), window, isolate); |
| 72 if (npobject) | 72 if (npobject) |
| 73 _NPN_RegisterObject(npobject, owner); | 73 _NPN_RegisterObject(npobject, owner); |
| 74 OBJECT_TO_NPVARIANT(npobject, *result); | 74 OBJECT_TO_NPVARIANT(npobject, *result); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 v8::Handle<v8::Value> convertNPVariantToV8Object(const NPVariant* variant, NPObj
ect* owner, v8::Isolate* isolate) | 78 v8::Handle<v8::Value> convertNPVariantToV8Object(const NPVariant* variant, NPObj
ect* owner, v8::Isolate* isolate) |
| 79 { | 79 { |
| 80 NPVariantType type = variant->type; | 80 NPVariantType type = variant->type; |
| 81 | 81 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 ExceptionCatcher::~ExceptionCatcher() | 160 ExceptionCatcher::~ExceptionCatcher() |
| 161 { | 161 { |
| 162 if (!m_tryCatch.HasCaught()) | 162 if (!m_tryCatch.HasCaught()) |
| 163 return; | 163 return; |
| 164 | 164 |
| 165 if (topHandler) | 165 if (topHandler) |
| 166 topHandler->handler(topHandler->data, *v8::String::Utf8Value(m_tryCatch.
Exception())); | 166 topHandler->handler(topHandler->data, *v8::String::Utf8Value(m_tryCatch.
Exception())); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace WebCore | 169 } // namespace WebCore |
| OLD | NEW |