summaryrefslogtreecommitdiff
path: root/Source/WebCore/bindings/js/JSPluginElementFunctions.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/bindings/js/JSPluginElementFunctions.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/bindings/js/JSPluginElementFunctions.cpp')
-rw-r--r--Source/WebCore/bindings/js/JSPluginElementFunctions.cpp84
1 files changed, 40 insertions, 44 deletions
diff --git a/Source/WebCore/bindings/js/JSPluginElementFunctions.cpp b/Source/WebCore/bindings/js/JSPluginElementFunctions.cpp
index 7f62aa2a7..88b5b123a 100644
--- a/Source/WebCore/bindings/js/JSPluginElementFunctions.cpp
+++ b/Source/WebCore/bindings/js/JSPluginElementFunctions.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -35,77 +35,73 @@ using namespace HTMLNames;
// JavaScript access to plug-in-exported properties for JSHTMLAppletElement, JSHTMLEmbedElement and JSHTMLObjectElement.
-static inline bool isPluginElement(HTMLElement& element)
-{
- return element.hasTagName(objectTag) || element.hasTagName(embedTag) || element.hasTagName(appletTag);
-}
-
Instance* pluginInstance(HTMLElement& element)
{
// The plugin element holds an owning reference, so we don't have to.
- if (!isPluginElement(element))
- return 0;
- Instance* instance = toHTMLPlugInElement(element).getInstance().get();
+ if (!is<HTMLPlugInElement>(element))
+ return nullptr;
+ auto* instance = downcast<HTMLPlugInElement>(element).bindingsInstance();
if (!instance || !instance->rootObject())
- return 0;
+ return nullptr;
return instance;
}
static JSObject* pluginScriptObjectFromPluginViewBase(HTMLPlugInElement& pluginElement, JSGlobalObject* globalObject)
{
Widget* pluginWidget = pluginElement.pluginWidget();
- if (!pluginWidget)
- return 0;
-
- if (!pluginWidget->isPluginViewBase())
- return 0;
+ if (!is<PluginViewBase>(pluginWidget))
+ return nullptr;
- PluginViewBase* pluginViewBase = toPluginViewBase(pluginWidget);
- return pluginViewBase->scriptObject(globalObject);
+ return downcast<PluginViewBase>(*pluginWidget).scriptObject(globalObject);
}
static JSObject* pluginScriptObjectFromPluginViewBase(JSHTMLElement* jsHTMLElement)
{
- HTMLElement& element = jsHTMLElement->impl();
- if (!isPluginElement(element))
- return 0;
+ HTMLElement& element = jsHTMLElement->wrapped();
+ if (!is<HTMLPlugInElement>(element))
+ return nullptr;
- HTMLPlugInElement& pluginElement = toHTMLPlugInElement(element);
+ HTMLPlugInElement& pluginElement = downcast<HTMLPlugInElement>(element);
return pluginScriptObjectFromPluginViewBase(pluginElement, jsHTMLElement->globalObject());
}
JSObject* pluginScriptObject(ExecState* exec, JSHTMLElement* jsHTMLElement)
{
- HTMLElement& element = jsHTMLElement->impl();
- if (!isPluginElement(element))
- return 0;
+ HTMLElement& element = jsHTMLElement->wrapped();
+ if (!is<HTMLPlugInElement>(element))
+ return nullptr;
+
+ auto& pluginElement = downcast<HTMLPlugInElement>(element);
- HTMLPlugInElement& pluginElement = toHTMLPlugInElement(element);
+ // Choke point for script/plugin interaction; notify DOMTimer of the event.
+ DOMTimer::scriptDidInteractWithPlugin(pluginElement);
// First, see if the element has a plug-in replacement with a script.
- if (JSObject* scriptObject = pluginElement.scriptObjectForPluginReplacement())
+ if (auto* scriptObject = pluginElement.scriptObjectForPluginReplacement())
return scriptObject;
// Next, see if we can ask the plug-in view for its script object.
- if (JSObject* scriptObject = pluginScriptObjectFromPluginViewBase(pluginElement, jsHTMLElement->globalObject()))
+ if (auto* 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();
+ auto* instance = pluginElement.bindingsInstance();
if (!instance || !instance->rootObject())
- return 0;
+ return nullptr;
return instance->createRuntimeObject(exec);
}
-EncodedJSValue pluginElementPropertyGetter(ExecState* exec, EncodedJSValue, EncodedJSValue thisValue, PropertyName propertyName)
+EncodedJSValue pluginElementPropertyGetter(ExecState* exec, EncodedJSValue thisValue, PropertyName propertyName)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
- JSHTMLElement* thisObject = jsDynamicCast<JSHTMLElement*>(JSValue::decode(thisValue));
+ JSHTMLElement* thisObject = jsDynamicDowncast<JSHTMLElement*>(vm, JSValue::decode(thisValue));
if (!thisObject)
- return throwVMTypeError(exec);
+ return throwVMTypeError(exec, scope);
JSObject* scriptObject = pluginScriptObject(exec, thisObject);
if (!scriptObject)
return JSValue::encode(jsUndefined());
@@ -125,20 +121,20 @@ bool pluginElementCustomGetOwnPropertySlot(ExecState* exec, PropertyName propert
return true;
}
-bool pluginElementCustomPut(ExecState* exec, PropertyName propertyName, JSValue value, JSHTMLElement* element, PutPropertySlot& slot)
+bool pluginElementCustomPut(ExecState* exec, PropertyName propertyName, JSValue value, JSHTMLElement* element, PutPropertySlot& slot, bool& putResult)
{
JSObject* scriptObject = pluginScriptObject(exec, element);
if (!scriptObject)
- return 0;
+ return false;
if (!scriptObject->hasProperty(exec, propertyName))
return false;
- scriptObject->methodTable()->put(scriptObject, exec, propertyName, value, slot);
+ putResult = scriptObject->methodTable()->put(scriptObject, exec, propertyName, value, slot);
return true;
}
static EncodedJSValue JSC_HOST_CALL callPlugin(ExecState* exec)
{
- JSHTMLElement* element = jsCast<JSHTMLElement*>(exec->callee());
+ JSHTMLElement* element = jsCast<JSHTMLElement*>(exec->jsCallee());
// Get the plug-in script object.
JSObject* scriptObject = pluginScriptObject(exec, element);
@@ -151,10 +147,10 @@ static EncodedJSValue JSC_HOST_CALL callPlugin(ExecState* exec)
CallData callData;
CallType callType = getCallData(scriptObject, callData);
- ASSERT(callType == CallTypeHost);
+ ASSERT(callType == CallType::Host);
// Call the object.
- JSValue result = call(exec, scriptObject, callType, callData, exec->hostThisValue(), argumentList);
+ JSValue result = call(exec, scriptObject, callType, callData, exec->thisValue(), argumentList);
return JSValue::encode(result);
}
@@ -164,18 +160,18 @@ CallType pluginElementGetCallData(JSHTMLElement* element, CallData& callData)
if (JSObject* scriptObject = pluginScriptObjectFromPluginViewBase(element)) {
CallData scriptObjectCallData;
- if (scriptObject->methodTable()->getCallData(scriptObject, scriptObjectCallData) == CallTypeNone)
- return CallTypeNone;
+ if (scriptObject->methodTable()->getCallData(scriptObject, scriptObjectCallData) == CallType::None)
+ return CallType::None;
callData.native.function = callPlugin;
- return CallTypeHost;
+ return CallType::Host;
}
- Instance* instance = pluginInstance(element->impl());
+ Instance* instance = pluginInstance(element->wrapped());
if (!instance || !instance->supportsInvokeDefaultMethod())
- return CallTypeNone;
+ return CallType::None;
callData.native.function = callPlugin;
- return CallTypeHost;
+ return CallType::Host;
}
} // namespace WebCore