本文整理汇总了C++中HTMLPlugInElement::getInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLPlugInElement::getInstance方法的具体用法?C++ HTMLPlugInElement::getInstance怎么用?C++ HTMLPlugInElement::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLPlugInElement
的用法示例。
在下文中一共展示了HTMLPlugInElement::getInstance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pluginInstance
static Instance* pluginInstance(Node* node)
{
if (!node)
return 0;
if (!(node->hasTagName(objectTag) || node->hasTagName(embedTag) || node->hasTagName(appletTag)))
return 0;
HTMLPlugInElement* plugInElement = static_cast<HTMLPlugInElement*>(node);
// The plugin element holds an owning reference, so we don't have to.
Instance* instance = plugInElement->getInstance().get();
if (!instance || !instance->rootObject())
return 0;
return instance;
}
示例2: npObjectSetNamedProperty
static v8::Handle<v8::Value> npObjectNamedSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
HTMLPlugInElement* imp = C::toNative(info.Holder());
ScriptInstance scriptInstance = imp->getInstance();
if (!scriptInstance)
return v8Undefined();
v8::Local<v8::Object> instance = v8::Local<v8::Object>::New(scriptInstance->instance());
if (instance.IsEmpty())
return v8Undefined();
return npObjectSetNamedProperty(instance, name, value, info);
}
示例3: npObjectGetIndexedProperty
v8::Handle<v8::Value> npObjectIndexedGetter(uint32_t index, const v8::AccessorInfo& info)
{
HTMLPlugInElement* imp = C::toNative(info.Holder());
ScriptInstance scriptInstance = imp->getInstance();
if (!scriptInstance)
return v8Undefined();
v8::Local<v8::Object> instance = v8::Local<v8::Object>::New(scriptInstance->instance());
if (instance.IsEmpty())
return v8Undefined();
return npObjectGetIndexedProperty(instance, index, info);
}
示例4: npObjectNamedSetter
static void npObjectNamedSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
HTMLPlugInElement* imp = C::toNative(info.Holder());
ScriptInstance scriptInstance = imp->getInstance();
if (!scriptInstance)
return;
v8::Local<v8::Object> instance = scriptInstance->newLocal(v8::Isolate::GetCurrent());
if (instance.IsEmpty())
return;
npObjectSetNamedProperty(instance, name, value, info);
}
示例5: npObjectIndexedGetter
void npObjectIndexedGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
{
HTMLPlugInElement* imp = C::toNative(info.Holder());
ScriptInstance scriptInstance = imp->getInstance();
if (!scriptInstance)
return;
v8::Local<v8::Object> instance = scriptInstance->newLocal(v8::Isolate::GetCurrent());
if (instance.IsEmpty())
return;
npObjectGetIndexedProperty(instance, index, info);
}
示例6: pluginInstance
Instance* pluginInstance(Node* node)
{
if (!node)
return 0;
if (!isPluginElement(node))
return 0;
HTMLPlugInElement* plugInElement = static_cast<HTMLPlugInElement*>(node);
// The plugin element holds an owning reference, so we don't have to.
Instance* instance = plugInElement->getInstance().get();
if (!instance || !instance->rootObject())
return 0;
return instance;
}
示例7: pluginScriptObject
JSObject* pluginScriptObject(ExecState* exec, JSHTMLElement* jsHTMLElement)
{
HTMLElement* element = jsHTMLElement->impl();
if (!isPluginElement(element))
return 0;
HTMLPlugInElement* pluginElement = static_cast<HTMLPlugInElement*>(element);
// First, see if we can ask the plug-in view for its script object.
if (JSObject* scriptObject = pluginScriptObjectFromPluginViewBase(pluginElement, jsHTMLElement->globalObject()))
return scriptObject;
// Otherwise, fall back to getting the object from the instance.
// The plugin element holds an owning reference, so we don't have to.
Instance* instance = pluginElement->getInstance().get();
if (!instance || !instance->rootObject())
return 0;
return instance->createRuntimeObject(exec);
}
示例8: throwError
// FIXME: need comments.
// Params: holder could be HTMLEmbedElement or NPObject
static v8::Handle<v8::Value> npObjectInvokeImpl(const v8::Arguments& args, InvokeFunctionType functionId)
{
NPObject* npObject;
// These three types are subtypes of HTMLPlugInElement.
if (V8HTMLAppletElement::HasInstance(args.Holder()) || V8HTMLEmbedElement::HasInstance(args.Holder())
|| V8HTMLObjectElement::HasInstance(args.Holder())) {
// The holder object is a subtype of HTMLPlugInElement.
HTMLPlugInElement* element = V8DOMWrapper::convertDOMWrapperToNode<HTMLPlugInElement>(args.Holder());
ScriptInstance scriptInstance = element->getInstance();
if (scriptInstance)
npObject = V8DOMWrapper::convertToNativeObject<NPObject>(V8ClassIndex::NPOBJECT, scriptInstance->instance());
else
npObject = 0;
} else {
// The holder object is not a subtype of HTMLPlugInElement, it must be an NPObject which has three
// internal fields.
if (args.Holder()->InternalFieldCount() != V8Custom::kNPObjectInternalFieldCount)
return throwError("NPMethod called on non-NPObject", V8Proxy::ReferenceError);
npObject = V8DOMWrapper::convertToNativeObject<NPObject>(V8ClassIndex::NPOBJECT, args.Holder());
}
// Verify that our wrapper wasn't using a NPObject which has already been deleted.
if (!npObject || !_NPN_IsAlive(npObject))
return throwError("NPObject deleted", V8Proxy::ReferenceError);
// Wrap up parameters.
int numArgs = args.Length();
OwnArrayPtr<NPVariant> npArgs(new NPVariant[numArgs]);
for (int i = 0; i < numArgs; i++)
convertV8ObjectToNPVariant(args[i], npObject, &npArgs[i]);
NPVariant result;
VOID_TO_NPVARIANT(result);
switch (functionId) {
case InvokeMethod:
if (npObject->_class->invoke) {
v8::Handle<v8::String> functionName(v8::String::Cast(*args.Data()));
NPIdentifier identifier = getStringIdentifier(functionName);
npObject->_class->invoke(npObject, identifier, npArgs.get(), numArgs, &result);
}
break;
case InvokeConstruct:
if (npObject->_class->construct)
npObject->_class->construct(npObject, npArgs.get(), numArgs, &result);
break;
case InvokeDefault:
if (npObject->_class->invokeDefault)
npObject->_class->invokeDefault(npObject, npArgs.get(), numArgs, &result);
break;
default:
break;
}
for (int i=0; i < numArgs; i++)
_NPN_ReleaseVariantValue(&npArgs[i]);
// Unwrap return values.
v8::Handle<v8::Value> returnValue = convertNPVariantToV8Object(&result, npObject);
_NPN_ReleaseVariantValue(&result);
return returnValue;
}
示例9: npObjectInvokeImpl
// FIXME: need comments.
// Params: holder could be HTMLEmbedElement or NPObject
static void npObjectInvokeImpl(const v8::FunctionCallbackInfo<v8::Value>& args, InvokeFunctionType functionId)
{
NPObject* npObject;
WrapperWorldType currentWorldType = worldType(args.GetIsolate());
// These three types are subtypes of HTMLPlugInElement.
if (V8HTMLAppletElement::HasInstance(args.Holder(), args.GetIsolate(), currentWorldType) || V8HTMLEmbedElement::HasInstance(args.Holder(), args.GetIsolate(), currentWorldType)
|| V8HTMLObjectElement::HasInstance(args.Holder(), args.GetIsolate(), currentWorldType)) {
// The holder object is a subtype of HTMLPlugInElement.
HTMLPlugInElement* element;
if (V8HTMLAppletElement::HasInstance(args.Holder(), args.GetIsolate(), currentWorldType))
element = V8HTMLAppletElement::toNative(args.Holder());
else if (V8HTMLEmbedElement::HasInstance(args.Holder(), args.GetIsolate(), currentWorldType))
element = V8HTMLEmbedElement::toNative(args.Holder());
else
element = V8HTMLObjectElement::toNative(args.Holder());
ScriptInstance scriptInstance = element->getInstance();
if (scriptInstance) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handleScope(isolate);
npObject = v8ObjectToNPObject(scriptInstance->newLocal(isolate));
} else
npObject = 0;
} else {
// The holder object is not a subtype of HTMLPlugInElement, it must be an NPObject which has three
// internal fields.
if (args.Holder()->InternalFieldCount() != npObjectInternalFieldCount) {
throwError(v8ReferenceError, "NPMethod called on non-NPObject", args.GetIsolate());
return;
}
npObject = v8ObjectToNPObject(args.Holder());
}
// Verify that our wrapper wasn't using a NPObject which has already been deleted.
if (!npObject || !_NPN_IsAlive(npObject)) {
throwError(v8ReferenceError, "NPObject deleted", args.GetIsolate());
return;
}
// Wrap up parameters.
int numArgs = args.Length();
OwnArrayPtr<NPVariant> npArgs = adoptArrayPtr(new NPVariant[numArgs]);
for (int i = 0; i < numArgs; i++)
convertV8ObjectToNPVariant(args[i], npObject, &npArgs[i]);
NPVariant result;
VOID_TO_NPVARIANT(result);
bool retval = true;
switch (functionId) {
case InvokeMethod:
if (npObject->_class->invoke) {
v8::Handle<v8::String> functionName = v8::Handle<v8::String>::Cast(args.Data());
NPIdentifier identifier = getStringIdentifier(functionName);
retval = npObject->_class->invoke(npObject, identifier, npArgs.get(), numArgs, &result);
}
break;
case InvokeConstruct:
if (npObject->_class->construct)
retval = npObject->_class->construct(npObject, npArgs.get(), numArgs, &result);
break;
case InvokeDefault:
if (npObject->_class->invokeDefault)
retval = npObject->_class->invokeDefault(npObject, npArgs.get(), numArgs, &result);
break;
default:
break;
}
if (!retval)
throwError(v8GeneralError, "Error calling method on NPObject.", args.GetIsolate());
for (int i = 0; i < numArgs; i++)
_NPN_ReleaseVariantValue(&npArgs[i]);
// Unwrap return values.
v8::Handle<v8::Value> returnValue;
if (_NPN_IsAlive(npObject))
returnValue = convertNPVariantToV8Object(&result, npObject, args.GetIsolate());
_NPN_ReleaseVariantValue(&result);
v8SetReturnValue(args, returnValue);
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:87,代码来源:V8NPObject.cpp