OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. |
3 * Copyright (C) 2007, 2008, 2009 Google, Inc. All rights reserved. | 3 * Copyright (C) 2007, 2008, 2009 Google, Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "bindings/v8/ScriptController.h" | 31 #include "bindings/v8/ScriptController.h" |
32 #include "bindings/v8/ScriptSourceCode.h" | 32 #include "bindings/v8/ScriptSourceCode.h" |
33 #include "bindings/v8/V8Binding.h" | 33 #include "bindings/v8/V8Binding.h" |
34 #include "bindings/v8/V8GCController.h" | 34 #include "bindings/v8/V8GCController.h" |
35 #include "bindings/v8/V8NPUtils.h" | 35 #include "bindings/v8/V8NPUtils.h" |
36 #include "bindings/v8/V8ObjectConstructor.h" | 36 #include "bindings/v8/V8ObjectConstructor.h" |
37 #include "bindings/v8/V8ScriptRunner.h" | 37 #include "bindings/v8/V8ScriptRunner.h" |
38 #include "bindings/v8/WrapperTypeInfo.h" | 38 #include "bindings/v8/WrapperTypeInfo.h" |
39 #include "bindings/v8/npruntime_impl.h" | 39 #include "bindings/v8/npruntime_impl.h" |
40 #include "bindings/v8/npruntime_priv.h" | 40 #include "bindings/v8/npruntime_priv.h" |
41 #include "core/frame/DOMWindow.h" | 41 #include "core/frame/LocalDOMWindow.h" |
42 #include "core/frame/LocalFrame.h" | 42 #include "core/frame/LocalFrame.h" |
43 #include "platform/UserGestureIndicator.h" | 43 #include "platform/UserGestureIndicator.h" |
44 #include "wtf/OwnPtr.h" | 44 #include "wtf/OwnPtr.h" |
45 | 45 |
46 #include <stdio.h> | 46 #include <stdio.h> |
47 #include "wtf/StringExtras.h" | 47 #include "wtf/StringExtras.h" |
48 #include "wtf/text/WTFString.h" | 48 #include "wtf/text/WTFString.h" |
49 | 49 |
50 using namespace WebCore; | 50 using namespace WebCore; |
51 | 51 |
(...skipping 22 matching lines...) Expand all Loading... |
74 NP_CLASS_STRUCT_VERSION, | 74 NP_CLASS_STRUCT_VERSION, |
75 allocV8NPObject, | 75 allocV8NPObject, |
76 freeV8NPObject, | 76 freeV8NPObject, |
77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | 77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
78 }; | 78 }; |
79 | 79 |
80 static ScriptState* mainWorldScriptState(v8::Isolate* isolate, NPP npp, NPObject
* npObject) | 80 static ScriptState* mainWorldScriptState(v8::Isolate* isolate, NPP npp, NPObject
* npObject) |
81 { | 81 { |
82 ASSERT(npObject->_class == &V8NPObjectClass); | 82 ASSERT(npObject->_class == &V8NPObjectClass); |
83 V8NPObject* object = reinterpret_cast<V8NPObject*>(npObject); | 83 V8NPObject* object = reinterpret_cast<V8NPObject*>(npObject); |
84 DOMWindow* window = object->rootObject; | 84 LocalDOMWindow* window = object->rootObject; |
85 if (!window || !window->isCurrentlyDisplayedInFrame()) | 85 if (!window || !window->isCurrentlyDisplayedInFrame()) |
86 return 0; | 86 return 0; |
87 v8::HandleScope handleScope(isolate); | 87 v8::HandleScope handleScope(isolate); |
88 v8::Handle<v8::Context> context = toV8Context(object->rootObject->frame(), D
OMWrapperWorld::mainWorld()); | 88 v8::Handle<v8::Context> context = toV8Context(object->rootObject->frame(), D
OMWrapperWorld::mainWorld()); |
89 return ScriptState::from(context); | 89 return ScriptState::from(context); |
90 } | 90 } |
91 | 91 |
92 static PassOwnPtr<v8::Handle<v8::Value>[]> createValueListFromVariantArgs(const
NPVariant* arguments, uint32_t argumentCount, NPObject* owner, v8::Isolate* isol
ate) | 92 static PassOwnPtr<v8::Handle<v8::Value>[]> createValueListFromVariantArgs(const
NPVariant* arguments, uint32_t argumentCount, NPObject* owner, v8::Isolate* isol
ate) |
93 { | 93 { |
94 OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Valu
e>[argumentCount]); | 94 OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Valu
e>[argumentCount]); |
(...skipping 14 matching lines...) Expand all Loading... |
109 char buffer[32]; | 109 char buffer[32]; |
110 snprintf(buffer, sizeof(buffer), "%d", identifier->value.number); | 110 snprintf(buffer, sizeof(buffer), "%d", identifier->value.number); |
111 return v8AtomicString(isolate, buffer); | 111 return v8AtomicString(isolate, buffer); |
112 } | 112 } |
113 | 113 |
114 NPObject* v8ObjectToNPObject(v8::Handle<v8::Object> object) | 114 NPObject* v8ObjectToNPObject(v8::Handle<v8::Object> object) |
115 { | 115 { |
116 return reinterpret_cast<NPObject*>(object->GetAlignedPointerFromInternalFiel
d(v8DOMWrapperObjectIndex)); | 116 return reinterpret_cast<NPObject*>(object->GetAlignedPointerFromInternalFiel
d(v8DOMWrapperObjectIndex)); |
117 } | 117 } |
118 | 118 |
119 NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object> object, DOMWind
ow* root, v8::Isolate* isolate) | 119 NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object> object, LocalDO
MWindow* root, v8::Isolate* isolate) |
120 { | 120 { |
121 // Check to see if this object is already wrapped. | 121 // Check to see if this object is already wrapped. |
122 if (object->InternalFieldCount() == npObjectInternalFieldCount) { | 122 if (object->InternalFieldCount() == npObjectInternalFieldCount) { |
123 const WrapperTypeInfo* typeInfo = static_cast<const WrapperTypeInfo*>(ob
ject->GetAlignedPointerFromInternalField(v8DOMWrapperTypeIndex)); | 123 const WrapperTypeInfo* typeInfo = static_cast<const WrapperTypeInfo*>(ob
ject->GetAlignedPointerFromInternalField(v8DOMWrapperTypeIndex)); |
124 if (typeInfo == npObjectTypeInfo()) { | 124 if (typeInfo == npObjectTypeInfo()) { |
125 NPObject* returnValue = v8ObjectToNPObject(object); | 125 NPObject* returnValue = v8ObjectToNPObject(object); |
126 _NPN_RetainObject(returnValue); | 126 _NPN_RetainObject(returnValue); |
127 return returnValue; | 127 return returnValue; |
128 } | 128 } |
129 } | 129 } |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 | 596 |
597 convertV8ObjectToNPVariant(resultObject, npObject, result, isolate); | 597 convertV8ObjectToNPVariant(resultObject, npObject, result, isolate); |
598 return true; | 598 return true; |
599 } | 599 } |
600 | 600 |
601 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class->
construct) | 601 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class->
construct) |
602 return npObject->_class->construct(npObject, arguments, argumentCount, r
esult); | 602 return npObject->_class->construct(npObject, arguments, argumentCount, r
esult); |
603 | 603 |
604 return false; | 604 return false; |
605 } | 605 } |
OLD | NEW |