| 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 11 matching lines...) Expand all Loading... |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "bindings/v8/V8NPUtils.h" | 32 #include "bindings/core/v8/V8NPUtils.h" |
| 33 | 33 |
| 34 #include "bindings/v8/NPV8Object.h" | 34 #include "bindings/core/v8/NPV8Object.h" |
| 35 #include "bindings/v8/V8Binding.h" | 35 #include "bindings/core/v8/V8Binding.h" |
| 36 #include "bindings/v8/V8NPObject.h" | 36 #include "bindings/core/v8/V8NPObject.h" |
| 37 #include "bindings/v8/npruntime_impl.h" | 37 #include "bindings/core/v8/npruntime_impl.h" |
| 38 #include "bindings/v8/npruntime_priv.h" | 38 #include "bindings/core/v8/npruntime_priv.h" |
| 39 #include "core/frame/LocalDOMWindow.h" | 39 #include "core/frame/LocalDOMWindow.h" |
| 40 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
| 41 | 41 |
| 42 #include <stdlib.h> | 42 #include <stdlib.h> |
| 43 | 43 |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject* owner, NP
Variant* result, v8::Isolate* isolate) | 46 void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject* owner, NP
Variant* result, v8::Isolate* isolate) |
| 47 { | 47 { |
| 48 VOID_TO_NPVARIANT(*result); | 48 VOID_TO_NPVARIANT(*result); |
| 49 | 49 |
| 50 // It is really the caller's responsibility to deal with the empty handle ca
se because there could be different actions to | 50 // It is really the caller's responsibility to deal with the empty handle ca
se because there could be different actions to |
| 51 // take in different contexts. | 51 // take in different contexts. |
| 52 ASSERT(!object.IsEmpty()); | 52 ASSERT(!object.IsEmpty()); |
| 53 | 53 |
| 54 if (object.IsEmpty()) | 54 if (object.IsEmpty()) |
| 55 return; | 55 return; |
| 56 | 56 |
| 57 if (object->IsNumber()) | 57 if (object->IsNumber()) { |
| 58 DOUBLE_TO_NPVARIANT(object->NumberValue(), *result); | 58 DOUBLE_TO_NPVARIANT(object->NumberValue(), *result); |
| 59 else if (object->IsBoolean()) | 59 } else if (object->IsBoolean()) { |
| 60 BOOLEAN_TO_NPVARIANT(object->BooleanValue(), *result); | 60 BOOLEAN_TO_NPVARIANT(object->BooleanValue(), *result); |
| 61 else if (object->IsNull()) | 61 } else if (object->IsNull()) { |
| 62 NULL_TO_NPVARIANT(*result); | 62 NULL_TO_NPVARIANT(*result); |
| 63 else if (object->IsUndefined()) | 63 } else if (object->IsUndefined()) { |
| 64 VOID_TO_NPVARIANT(*result); | 64 VOID_TO_NPVARIANT(*result); |
| 65 else if (object->IsString()) { | 65 } else if (object->IsString()) { |
| 66 v8::Handle<v8::String> str = object.As<v8::String>(); | 66 v8::Handle<v8::String> str = object.As<v8::String>(); |
| 67 int length = str->Utf8Length() + 1; | 67 int length = str->Utf8Length() + 1; |
| 68 char* utf8Chars = reinterpret_cast<char*>(malloc(length)); | 68 char* utf8Chars = reinterpret_cast<char*>(malloc(length)); |
| 69 str->WriteUtf8(utf8Chars, length, 0, v8::String::HINT_MANY_WRITES_EXPECT
ED); | 69 str->WriteUtf8(utf8Chars, length, 0, v8::String::HINT_MANY_WRITES_EXPECT
ED); |
| 70 STRINGN_TO_NPVARIANT(utf8Chars, length-1, *result); | 70 STRINGN_TO_NPVARIANT(utf8Chars, length-1, *result); |
| 71 } else if (object->IsObject()) { | 71 } else if (object->IsObject()) { |
| 72 LocalDOMWindow* window = currentDOMWindow(isolate); | 72 LocalDOMWindow* window = currentDOMWindow(isolate); |
| 73 NPObject* npobject = npCreateV8ScriptObject(0, v8::Handle<v8::Object>::C
ast(object), window, isolate); | 73 NPObject* npobject = npCreateV8ScriptObject(0, v8::Handle<v8::Object>::C
ast(object), window, isolate); |
| 74 if (npobject) | 74 if (npobject) |
| 75 _NPN_RegisterObject(npobject, owner); | 75 _NPN_RegisterObject(npobject, owner); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 ExceptionCatcher::~ExceptionCatcher() | 162 ExceptionCatcher::~ExceptionCatcher() |
| 163 { | 163 { |
| 164 if (!m_tryCatch.HasCaught()) | 164 if (!m_tryCatch.HasCaught()) |
| 165 return; | 165 return; |
| 166 | 166 |
| 167 if (topHandler) | 167 if (topHandler) |
| 168 topHandler->handler(topHandler->data, *v8::String::Utf8Value(m_tryCatch.
Exception())); | 168 topHandler->handler(topHandler->data, *v8::String::Utf8Value(m_tryCatch.
Exception())); |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace WebCore | 171 } // namespace WebCore |
| OLD | NEW |