Changeset 64312 in webkit
- Timestamp:
- Jul 29, 2010 3:21:43 PM (14 years ago)
- Location:
- trunk/WebKit2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r64306 r64312 1 2010-07-29 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 Implement NPN_Enumerate 6 https://bugs.webkit.org/show_bug.cgi?id=43215 7 8 * WebProcess/Plugins/JSNPObject.cpp: 9 (WebKit::npIdentifierFromIdentifier): 10 Get the UTF-8 string representation instead of the lossy ASCII representation. 11 12 (WebKit::JSNPObject::getOwnPropertyNames): 13 Implement by calling the NPClass::enumerate function. 14 15 * WebProcess/Plugins/JSNPObject.h: 16 * WebProcess/Plugins/NPJSObject.cpp: 17 (WebKit::NPJSObject::enumerate): 18 Implement by calling JSObject::getPropertyNames. 19 20 (WebKit::NPJSObject::npClass): 21 (WebKit::NPJSObject::NP_Enumerate): 22 Call NPJSObject::enumerate. 23 24 * WebProcess/Plugins/NPJSObject.h: 25 * WebProcess/Plugins/NPRuntimeUtilities.cpp: 26 (WebKit::createNPObject): 27 Fix a comment. 28 29 * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp: 30 (WebKit::NPN_Enumerate): 31 Call the NPClass::enumerate function. 32 1 33 2010-07-29 John Sullivan <sullivan@apple.com> 2 34 -
trunk/WebKit2/WebProcess/Plugins/JSNPObject.cpp
r64300 r64312 34 34 #include <JavaScriptCore/JSLock.h> 35 35 #include <WebCore/IdentifierRep.h> 36 #include <WebCore/PlatformString.h> 36 37 37 38 using namespace WebCore; … … 42 43 static NPIdentifier npIdentifierFromIdentifier(const Identifier& identifier) 43 44 { 44 return static_cast<NPIdentifier>(IdentifierRep::get(identifier. ascii()));45 return static_cast<NPIdentifier>(IdentifierRep::get(identifier.ustring().UTF8String().data())); 45 46 } 46 47 … … 228 229 } 229 230 231 void JSNPObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNameArray, EnumerationMode mode) 232 { 233 if (!m_npObject) { 234 throwInvalidAccessError(exec); 235 return; 236 } 237 238 if (!NP_CLASS_STRUCT_VERSION_HAS_ENUM(m_npObject->_class) || !m_npObject->_class->enumerate) 239 return; 240 241 NPIdentifier* identifiers = 0; 242 uint32_t identifierCount = 0; 243 244 { 245 JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly); 246 247 // FIXME: Handle enumerate setting an exception. 248 // FIXME: Find out what happens if calling enumerate causes the plug-in to go away. 249 // FIXME: Should we throw an exception if enumerate returns false? 250 if (!m_npObject->_class->enumerate(m_npObject, &identifiers, &identifierCount)) 251 return; 252 } 253 254 for (uint32_t i = 0; i < identifierCount; ++i) { 255 IdentifierRep* identifierRep = static_cast<IdentifierRep*>(identifiers[i]); 256 257 Identifier identifier; 258 if (identifierRep->isString()) { 259 const char* string = identifierRep->string(); 260 int length = strlen(string); 261 262 identifier = Identifier(exec, String::fromUTF8WithLatin1Fallback(string, length).impl()); 263 } else 264 identifier = Identifier::from(exec, identifierRep->number()); 265 266 propertyNameArray.add(identifier); 267 } 268 269 // This should use NPN_MemFree, but we know that it uses free under the hood. 270 free(identifiers); 271 } 272 230 273 JSValue JSNPObject::propertyGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) 231 274 { -
trunk/WebKit2/WebProcess/Plugins/JSNPObject.h
r64300 r64312 62 62 virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); 63 63 64 virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties); 65 64 66 static JSC::JSValue propertyGetter(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); 65 67 static JSC::JSValue methodGetter(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); -
trunk/WebKit2/WebProcess/Plugins/NPJSObject.cpp
r64300 r64312 172 172 } 173 173 174 bool NPJSObject::enumerate(NPIdentifier** identifiers, uint32_t* identifierCount) 175 { 176 ExecState* exec = m_objectMap->globalExec(); 177 if (!exec) 178 return false; 179 180 JSLock lock(SilenceAssertionsOnly); 181 182 PropertyNameArray propertyNames(exec); 183 m_jsObject->getPropertyNames(exec, propertyNames); 184 185 // This should use NPN_MemAlloc, but we know that it uses malloc under the hood. 186 NPIdentifier* nameIdentifiers = static_cast<NPIdentifier*>(malloc(sizeof(NPIdentifier) * propertyNames.size())); 187 188 for (size_t i = 0; i < propertyNames.size(); ++i) 189 nameIdentifiers[i] = static_cast<NPIdentifier>(IdentifierRep::get(propertyNames[i].ustring().UTF8String().data())); 190 191 *identifiers = nameIdentifiers; 192 *identifierCount = propertyNames.size(); 193 194 return true; 195 } 196 174 197 bool NPJSObject::construct(const NPVariant *arguments, uint32_t argumentCount, NPVariant *result) 175 198 { … … 238 261 NP_SetProperty, 239 262 0, 240 0,263 NP_Enumerate, 241 264 NP_Construct 242 265 }; … … 289 312 } 290 313 314 bool NPJSObject::NP_Enumerate(NPObject* npObject, NPIdentifier** identifiers, uint32_t* identifierCount) 315 { 316 return toNPJSObject(npObject)->enumerate(identifiers, identifierCount); 317 } 318 291 319 bool NPJSObject::NP_Construct(NPObject* npObject, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result) 292 320 { -
trunk/WebKit2/WebProcess/Plugins/NPJSObject.h
r64300 r64312 66 66 bool hasProperty(NPIdentifier propertyName); 67 67 bool getProperty(NPIdentifier propertyName, NPVariant* result); 68 bool enumerate(NPIdentifier** identifiers, uint32_t* identifierCount); 68 69 bool construct(const NPVariant* arguments, uint32_t argumentCount, NPVariant* result); 69 70 … … 79 80 static bool NP_GetProperty(NPObject*, NPIdentifier propertyName, NPVariant* result); 80 81 static bool NP_SetProperty(NPObject*, NPIdentifier propertyName, const NPVariant* value); 82 static bool NP_Enumerate(NPObject*, NPIdentifier** identifiers, uint32_t* identifierCount); 81 83 static bool NP_Construct(NPObject*, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result); 82 84 -
trunk/WebKit2/WebProcess/Plugins/NPRuntimeUtilities.cpp
r63636 r64312 36 36 npObject = npClass->allocate(npp, npClass); 37 37 else { 38 // This should really call NPN_MemAlloc, but we know that it uses malloc 39 // under the hood so it's fine. 38 // This should use NPN_MemAlloc, but we know that it uses malloc under the hood. 40 39 npObject = static_cast<NPObject*>(malloc(sizeof(NPObject))); 41 40 } -
trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
r64304 r64312 632 632 } 633 633 634 static bool NPN_Enumerate(NPP npp, NPObject* npobj, NPIdentifier** identifier, uint32_t* count) 635 { 636 notImplemented(); 634 static bool NPN_Enumerate(NPP, NPObject* npObject, NPIdentifier** identifiers, uint32_t* identifierCount) 635 { 636 if (NP_CLASS_STRUCT_VERSION_HAS_ENUM(npObject->_class) && npObject->_class->enumerate) 637 return npObject->_class->enumerate(npObject, identifiers, identifierCount); 638 637 639 return false; 638 640 }
Note: See TracChangeset
for help on using the changeset viewer.