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

Side by Side Diff: Source/WebCore/bindings/v8/NPObjectWrapper.cpp

Issue 8293008: Merge 97429 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/874/
Patch Set: Created 9 years, 2 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
« no previous file with comments | « Source/WebCore/bindings/v8/NPObjectWrapper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 NPObjectWrapper::NPInvokeDefault, 48 NPObjectWrapper::NPInvokeDefault,
49 NPObjectWrapper::NPHasProperty, 49 NPObjectWrapper::NPHasProperty,
50 NPObjectWrapper::NPGetProperty, 50 NPObjectWrapper::NPGetProperty,
51 NPObjectWrapper::NPSetProperty, 51 NPObjectWrapper::NPSetProperty,
52 NPObjectWrapper::NPRemoveProperty, 52 NPObjectWrapper::NPRemoveProperty,
53 NPObjectWrapper::NPNEnumerate, 53 NPObjectWrapper::NPNEnumerate,
54 NPObjectWrapper::NPNConstruct 54 NPObjectWrapper::NPNConstruct
55 }; 55 };
56 56
57 NPObjectWrapper::NPObjectWrapper(NPObject* obj) 57 NPObjectWrapper::NPObjectWrapper(NPObject* obj)
58 : m_wrappedNPObject(obj) { 58 : m_wrappedNPObject(obj)
59 {
59 } 60 }
60 61
61 NPObject* NPObjectWrapper::create(NPObject* object) { 62 NPObject* NPObjectWrapper::create(NPObject* object)
63 {
62 ASSERT(object); 64 ASSERT(object);
63 NPProxyObject* proxyObject = reinterpret_cast<NPProxyObject*>(_NPN_CreateObj ect(0, &m_npClassWrapper)); 65 NPProxyObject* proxyObject = reinterpret_cast<NPProxyObject*>(_NPN_CreateObj ect(0, &m_npClassWrapper));
64 proxyObject->wrapper = new NPObjectWrapper(object); 66 proxyObject->wrapper = new NPObjectWrapper(object);
65 return reinterpret_cast<NPObject*>(proxyObject); 67 return reinterpret_cast<NPObject*>(proxyObject);
66 } 68 }
67 69
68 void NPObjectWrapper::clear() { 70 void NPObjectWrapper::clear()
71 {
69 m_wrappedNPObject = 0; 72 m_wrappedNPObject = 0;
70 } 73 }
71 74
72 NPObjectWrapper* NPObjectWrapper::getWrapper(NPObject* obj) { 75 NPObjectWrapper* NPObjectWrapper::getWrapper(NPObject* obj)
76 {
73 if (&m_npClassWrapper == obj->_class) { 77 if (&m_npClassWrapper == obj->_class) {
74 NPProxyObject* proxyObject = reinterpret_cast<NPProxyObject*>(obj); 78 NPProxyObject* proxyObject = reinterpret_cast<NPProxyObject*>(obj);
75 return proxyObject->wrapper; 79 return proxyObject->wrapper;
76 } 80 }
77 return 0; 81 return 0;
78 } 82 }
79 83
80 NPObject* NPObjectWrapper::getUnderlyingNPObject(NPObject* obj) { 84 NPObject* NPObjectWrapper::getUnderlyingNPObject(NPObject* obj)
85 {
81 NPObjectWrapper* wrapper = getWrapper(obj); 86 NPObjectWrapper* wrapper = getWrapper(obj);
82 return wrapper ? wrapper->m_wrappedNPObject : 0; 87 return wrapper ? wrapper->m_wrappedNPObject : 0;
83 } 88 }
84 89
85 NPObject* NPObjectWrapper::getObjectForCall(NPObject* obj) { 90 NPObject* NPObjectWrapper::getObjectForCall(NPObject* obj)
86 NPObject* actualObject = getUnderlyingNPObject(obj); 91 {
87 return actualObject ? actualObject : obj; 92 NPObject* actualObject = getUnderlyingNPObject(obj);
93 return actualObject ? actualObject : 0;
88 } 94 }
89 95
90 NPObject* NPObjectWrapper::NPAllocate(NPP, NPClass*) { 96 NPObject* NPObjectWrapper::NPAllocate(NPP, NPClass*)
91 return reinterpret_cast<NPObject*>(new NPObjectWrapper(0)); 97 {
98 return reinterpret_cast<NPObject*>(new NPProxyObject);
92 } 99 }
93 100
94 void NPObjectWrapper::NPDeallocate(NPObject* obj) { 101 void NPObjectWrapper::NPDeallocate(NPObject* obj)
102 {
95 NPProxyObject* proxyObject = reinterpret_cast<NPProxyObject*>(obj); 103 NPProxyObject* proxyObject = reinterpret_cast<NPProxyObject*>(obj);
96 delete proxyObject->wrapper; 104 delete proxyObject->wrapper;
97 delete proxyObject; 105 delete proxyObject;
98 } 106 }
99 107
100 void NPObjectWrapper::NPPInvalidate(NPObject* obj) { 108 void NPObjectWrapper::NPPInvalidate(NPObject* obj)
109 {
101 NPObject* actualObject = getObjectForCall(obj); 110 NPObject* actualObject = getObjectForCall(obj);
102 if (actualObject && actualObject->_class->invalidate) 111 if (actualObject && actualObject->_class->invalidate)
103 actualObject->_class->invalidate(actualObject); 112 actualObject->_class->invalidate(actualObject);
104 } 113 }
105 114
106 bool NPObjectWrapper::NPHasMethod(NPObject* obj, NPIdentifier name) { 115 bool NPObjectWrapper::NPHasMethod(NPObject* obj, NPIdentifier name)
116 {
107 NPObject* actualObject = getObjectForCall(obj); 117 NPObject* actualObject = getObjectForCall(obj);
108 return actualObject ? _NPN_HasMethod(0, actualObject, name) : false; 118 return actualObject ? _NPN_HasMethod(0, actualObject, name) : false;
109 } 119 }
110 120
111 bool NPObjectWrapper::NPInvoke(NPObject* obj, NPIdentifier name, const NPVariant * args, uint32_t argCount, NPVariant* result) { 121 bool NPObjectWrapper::NPInvoke(NPObject* obj, NPIdentifier name, const NPVariant * args, uint32_t argCount, NPVariant* result)
122 {
112 NPObject* actualObject = getObjectForCall(obj); 123 NPObject* actualObject = getObjectForCall(obj);
113 return actualObject ? _NPN_Invoke(0, actualObject, name, args, argCount, res ult) : false; 124 return actualObject ? _NPN_Invoke(0, actualObject, name, args, argCount, res ult) : false;
114 } 125 }
115 126
116 bool NPObjectWrapper::NPInvokeDefault(NPObject* obj, const NPVariant* args, uint 32_t argCount, NPVariant* result) { 127 bool NPObjectWrapper::NPInvokeDefault(NPObject* obj, const NPVariant* args, uint 32_t argCount, NPVariant* result)
128 {
117 NPObject* actualObject = getObjectForCall(obj); 129 NPObject* actualObject = getObjectForCall(obj);
118 return actualObject ? _NPN_InvokeDefault(0, actualObject, args, argCount, re sult) : false; 130 return actualObject ? _NPN_InvokeDefault(0, actualObject, args, argCount, re sult) : false;
119 } 131 }
120 132
121 bool NPObjectWrapper::NPHasProperty(NPObject* obj, NPIdentifier name) { 133 bool NPObjectWrapper::NPHasProperty(NPObject* obj, NPIdentifier name)
134 {
122 NPObject* actualObject = getObjectForCall(obj); 135 NPObject* actualObject = getObjectForCall(obj);
123 return actualObject ? _NPN_HasProperty(0, actualObject, name) : false; 136 return actualObject ? _NPN_HasProperty(0, actualObject, name) : false;
124 } 137 }
125 138
126 bool NPObjectWrapper::NPGetProperty(NPObject* obj, NPIdentifier name, NPVariant* result) { 139 bool NPObjectWrapper::NPGetProperty(NPObject* obj, NPIdentifier name, NPVariant* result)
140 {
127 NPObject* actualObject = getObjectForCall(obj); 141 NPObject* actualObject = getObjectForCall(obj);
128 return actualObject ? _NPN_GetProperty(0, actualObject, name, result) : fals e; 142 return actualObject ? _NPN_GetProperty(0, actualObject, name, result) : fals e;
129 } 143 }
130 144
131 bool NPObjectWrapper::NPSetProperty(NPObject* obj, NPIdentifier name, const NPVa riant* value) { 145 bool NPObjectWrapper::NPSetProperty(NPObject* obj, NPIdentifier name, const NPVa riant* value)
146 {
132 NPObject* actualObject = getObjectForCall(obj); 147 NPObject* actualObject = getObjectForCall(obj);
133 return actualObject ? _NPN_SetProperty(0, actualObject, name, value) : false ; 148 return actualObject ? _NPN_SetProperty(0, actualObject, name, value) : false ;
134 } 149 }
135 150
136 bool NPObjectWrapper::NPRemoveProperty(NPObject* obj, NPIdentifier name) { 151 bool NPObjectWrapper::NPRemoveProperty(NPObject* obj, NPIdentifier name) {
137 NPObject* actualObject = getObjectForCall(obj); 152 NPObject* actualObject = getObjectForCall(obj);
138 return actualObject ? _NPN_RemoveProperty(0, actualObject, name) : false; 153 return actualObject ? _NPN_RemoveProperty(0, actualObject, name) : false;
139 } 154 }
140 155
141 bool NPObjectWrapper::NPNEnumerate(NPObject* obj, NPIdentifier** value, uint32_t * count) { 156 bool NPObjectWrapper::NPNEnumerate(NPObject* obj, NPIdentifier** value, uint32_t * count)
157 {
142 NPObject* actualObject = getObjectForCall(obj); 158 NPObject* actualObject = getObjectForCall(obj);
143 return actualObject ? _NPN_Enumerate(0, actualObject, value, count) : false; 159 return actualObject ? _NPN_Enumerate(0, actualObject, value, count) : false;
144 } 160 }
145 161
146 bool NPObjectWrapper::NPNConstruct(NPObject* obj, const NPVariant* args, uint32_ t argCount, NPVariant* result) { 162 bool NPObjectWrapper::NPNConstruct(NPObject* obj, const NPVariant* args, uint32_ t argCount, NPVariant* result)
163 {
147 NPObject* actualObject = getObjectForCall(obj); 164 NPObject* actualObject = getObjectForCall(obj);
148 return actualObject ? _NPN_Construct(0, actualObject, args, argCount, result ) : false; 165 return actualObject ? _NPN_Construct(0, actualObject, args, argCount, result ) : false;
149 } 166 }
150 167
151 bool NPObjectWrapper::NPInvokePrivate(NPP npp, NPObject* obj, bool isDefault, NP Identifier name, const NPVariant* args, uint32_t argCount, NPVariant* result) { 168 bool NPObjectWrapper::NPInvokePrivate(NPP npp, NPObject* obj, bool isDefault, NP Identifier name, const NPVariant* args, uint32_t argCount, NPVariant* result)
169 {
152 NPObject* actualObject = getObjectForCall(obj); 170 NPObject* actualObject = getObjectForCall(obj);
153 if (!actualObject) 171 if (!actualObject)
154 return false; 172 return false;
155 173
156 if (isDefault) { 174 if (isDefault) {
157 return _NPN_InvokeDefault(0, actualObject, args, argCount, result); 175 return _NPN_InvokeDefault(0, actualObject, args, argCount, result);
158 } else { 176 } else {
159 return _NPN_Invoke(0, actualObject, name, args, argCount, result); 177 return _NPN_Invoke(0, actualObject, name, args, argCount, result);
160 } 178 }
161 } 179 }
162 180
163 } // namespace WebCore 181 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/bindings/v8/NPObjectWrapper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698