[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
andersca at apple.com
andersca at apple.com
Wed Dec 22 11:28:53 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 52af08a24d9a66656ba810e9616e34b9fab4d828
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jul 27 00:09:07 2010 +0000
Plug-in views should be able to return JSObjects directly
https://bugs.webkit.org/show_bug.cgi?id=43019
Reviewed by Sam Weinig.
* bindings/js/JSHTMLAppletElementCustom.cpp:
(WebCore::JSHTMLAppletElement::putDelegate):
(WebCore::JSHTMLAppletElement::getCallData):
* bindings/js/JSHTMLEmbedElementCustom.cpp:
(WebCore::JSHTMLEmbedElement::putDelegate):
(WebCore::JSHTMLEmbedElement::getCallData):
* bindings/js/JSHTMLObjectElementCustom.cpp:
(WebCore::JSHTMLObjectElement::putDelegate):
(WebCore::JSHTMLObjectElement::getCallData):
runtimeObjectCustomPut and runtimeObjectGetCallData now take a JSHTMLElement instead of a HTMLElement.
* bindings/js/JSPluginElementFunctions.cpp:
(WebCore::pluginScriptObject):
First, ask the PluginViewBase for a JSObject and fall back to getting the JSObject from the instance.
(WebCore::runtimeObjectPropertyGetter):
(WebCore::runtimeObjectCustomGetOwnPropertySlot):
(WebCore::runtimeObjectCustomGetOwnPropertyDescriptor):
Call pluginScriptObject.
(WebCore::runtimeObjectCustomPut):
Change to take a JSHTMLElement. Call pluginScriptObject.
(WebCore::runtimeObjectGetCallData):
Change to take a JSHTMLElement.
* bridge/jsc/BridgeJSC.cpp:
* bridge/jsc/BridgeJSC.h:
(JSC::Bindings::Instance::createRuntimeObject):
Change this to return a JSObject.
* html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::getInstance):
Call pluginWidget.
(WebCore::HTMLPlugInElement::pluginWidget):
Return the plug-in widget for this element.
* html/HTMLPlugInElement.h:
* plugins/PluginViewBase.h:
(WebCore::PluginViewBase::scriptObject):
Add default implementation of scriptObject.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64093 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7160376..dc2e18b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,53 @@
+2010-07-26 Anders Carlsson <andersca at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Plug-in views should be able to return JSObjects directly
+ https://bugs.webkit.org/show_bug.cgi?id=43019
+
+ * bindings/js/JSHTMLAppletElementCustom.cpp:
+ (WebCore::JSHTMLAppletElement::putDelegate):
+ (WebCore::JSHTMLAppletElement::getCallData):
+ * bindings/js/JSHTMLEmbedElementCustom.cpp:
+ (WebCore::JSHTMLEmbedElement::putDelegate):
+ (WebCore::JSHTMLEmbedElement::getCallData):
+ * bindings/js/JSHTMLObjectElementCustom.cpp:
+ (WebCore::JSHTMLObjectElement::putDelegate):
+ (WebCore::JSHTMLObjectElement::getCallData):
+ runtimeObjectCustomPut and runtimeObjectGetCallData now take a JSHTMLElement instead of a HTMLElement.
+
+ * bindings/js/JSPluginElementFunctions.cpp:
+ (WebCore::pluginScriptObject):
+ First, ask the PluginViewBase for a JSObject and fall back to getting the JSObject from the instance.
+
+ (WebCore::runtimeObjectPropertyGetter):
+ (WebCore::runtimeObjectCustomGetOwnPropertySlot):
+ (WebCore::runtimeObjectCustomGetOwnPropertyDescriptor):
+ Call pluginScriptObject.
+
+ (WebCore::runtimeObjectCustomPut):
+ Change to take a JSHTMLElement. Call pluginScriptObject.
+
+ (WebCore::runtimeObjectGetCallData):
+ Change to take a JSHTMLElement.
+
+ * bridge/jsc/BridgeJSC.cpp:
+ * bridge/jsc/BridgeJSC.h:
+ (JSC::Bindings::Instance::createRuntimeObject):
+ Change this to return a JSObject.
+
+ * html/HTMLPlugInElement.cpp:
+ (WebCore::HTMLPlugInElement::getInstance):
+ Call pluginWidget.
+
+ (WebCore::HTMLPlugInElement::pluginWidget):
+ Return the plug-in widget for this element.
+
+ * html/HTMLPlugInElement.h:
+ * plugins/PluginViewBase.h:
+ (WebCore::PluginViewBase::scriptObject):
+ Add default implementation of scriptObject.
+
2010-07-26 Chris Fleizach <cfleizach at apple.com>
Reviewed by Darin Adler.
diff --git a/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp b/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp
index 40d20cf..2bff01a 100644
--- a/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp
@@ -45,12 +45,12 @@ bool JSHTMLAppletElement::getOwnPropertyDescriptorDelegate(ExecState* exec, cons
bool JSHTMLAppletElement::putDelegate(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
- return runtimeObjectCustomPut(exec, propertyName, value, impl(), slot);
+ return runtimeObjectCustomPut(exec, propertyName, value, this, slot);
}
CallType JSHTMLAppletElement::getCallData(CallData& callData)
{
- return runtimeObjectGetCallData(impl(), callData);
+ return runtimeObjectGetCallData(this, callData);
}
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp b/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp
index b9f8c12..72e695b 100644
--- a/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp
@@ -45,12 +45,12 @@ bool JSHTMLEmbedElement::getOwnPropertyDescriptorDelegate(ExecState* exec, const
bool JSHTMLEmbedElement::putDelegate(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
- return runtimeObjectCustomPut(exec, propertyName, value, impl(), slot);
+ return runtimeObjectCustomPut(exec, propertyName, value, this, slot);
}
CallType JSHTMLEmbedElement::getCallData(CallData& callData)
{
- return runtimeObjectGetCallData(impl(), callData);
+ return runtimeObjectGetCallData(this, callData);
}
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp b/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp
index 68c9e59..c87b932 100644
--- a/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp
@@ -45,12 +45,12 @@ bool JSHTMLObjectElement::getOwnPropertyDescriptorDelegate(ExecState* exec, cons
bool JSHTMLObjectElement::putDelegate(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
- return runtimeObjectCustomPut(exec, propertyName, value, impl(), slot);
+ return runtimeObjectCustomPut(exec, propertyName, value, this, slot);
}
CallType JSHTMLObjectElement::getCallData(CallData& callData)
{
- return runtimeObjectGetCallData(impl(), callData);
+ return runtimeObjectGetCallData(this, callData);
}
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSPluginElementFunctions.cpp b/WebCore/bindings/js/JSPluginElementFunctions.cpp
index 7cc2e65..6bdc440 100644
--- a/WebCore/bindings/js/JSPluginElementFunctions.cpp
+++ b/WebCore/bindings/js/JSPluginElementFunctions.cpp
@@ -24,7 +24,7 @@
#include "HTMLNames.h"
#include "HTMLPlugInElement.h"
#include "JSHTMLElement.h"
-#include "runtime_object.h"
+#include "PluginViewBase.h"
using namespace JSC;
@@ -49,30 +49,50 @@ Instance* pluginInstance(Node* node)
return instance;
}
-static RuntimeObject* getRuntimeObject(ExecState* exec, Node* node)
+static JSObject* pluginScriptObject(ExecState* exec, JSHTMLElement* jsHTMLElement)
{
- Instance* instance = pluginInstance(node);
- if (!instance)
+ HTMLElement* element = jsHTMLElement->impl();
+ if (!(element->hasTagName(objectTag) || element->hasTagName(embedTag) || element->hasTagName(appletTag)))
return 0;
+
+ HTMLPlugInElement* pluginElement = static_cast<HTMLPlugInElement*>(element);
+
+ // First, see if we can ask the plug-in view for its script object.
+ if (Widget* pluginWidget = pluginElement->pluginWidget()) {
+ if (pluginWidget->isPluginViewBase()) {
+ PluginViewBase* pluginViewBase = static_cast<PluginViewBase*>(pluginWidget);
+ if (JSObject* scriptObject = pluginViewBase->scriptObject(exec, 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);
}
-
+
JSValue runtimeObjectPropertyGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName)
{
- JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(asObject(slotBase));
- HTMLElement* element = static_cast<HTMLElement*>(thisObj->impl());
- RuntimeObject* runtimeObject = getRuntimeObject(exec, element);
- if (!runtimeObject)
+ JSHTMLElement* element = static_cast<JSHTMLElement*>(asObject(slotBase));
+ JSObject* scriptObject = pluginScriptObject(exec, element);
+ if (!scriptObject)
return jsUndefined();
- return runtimeObject->get(exec, propertyName);
+
+ return scriptObject->get(exec, propertyName);
}
bool runtimeObjectCustomGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot, JSHTMLElement* element)
{
- RuntimeObject* runtimeObject = getRuntimeObject(exec, element->impl());
- if (!runtimeObject)
+ JSObject* scriptObject = pluginScriptObject(exec, element);
+ if (!scriptObject)
return false;
- if (!runtimeObject->hasProperty(exec, propertyName))
+
+ if (!scriptObject->hasProperty(exec, propertyName))
return false;
slot.setCustom(element, runtimeObjectPropertyGetter);
return true;
@@ -80,10 +100,10 @@ bool runtimeObjectCustomGetOwnPropertySlot(ExecState* exec, const Identifier& pr
bool runtimeObjectCustomGetOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, JSHTMLElement* element)
{
- RuntimeObject* runtimeObject = getRuntimeObject(exec, element->impl());
- if (!runtimeObject)
+ JSObject* scriptObject = pluginScriptObject(exec, element);
+ if (!scriptObject)
return false;
- if (!runtimeObject->hasProperty(exec, propertyName))
+ if (!scriptObject->hasProperty(exec, propertyName))
return false;
PropertySlot slot;
slot.setCustom(element, runtimeObjectPropertyGetter);
@@ -94,14 +114,14 @@ bool runtimeObjectCustomGetOwnPropertyDescriptor(ExecState* exec, const Identifi
return true;
}
-bool runtimeObjectCustomPut(ExecState* exec, const Identifier& propertyName, JSValue value, HTMLElement* element, PutPropertySlot& slot)
+bool runtimeObjectCustomPut(ExecState* exec, const Identifier& propertyName, JSValue value, JSHTMLElement* element, PutPropertySlot& slot)
{
- RuntimeObject* runtimeObject = getRuntimeObject(exec, element);
- if (!runtimeObject)
+ JSObject* scriptObject = pluginScriptObject(exec, element);
+ if (!scriptObject)
return 0;
- if (!runtimeObject->hasProperty(exec, propertyName))
+ if (!scriptObject->hasProperty(exec, propertyName))
return false;
- runtimeObject->put(exec, propertyName, value, slot);
+ scriptObject->put(exec, propertyName, value, slot);
return true;
}
@@ -114,9 +134,9 @@ static EncodedJSValue JSC_HOST_CALL callPlugin(ExecState* exec)
return JSValue::encode(result);
}
-CallType runtimeObjectGetCallData(HTMLElement* element, CallData& callData)
+CallType runtimeObjectGetCallData(JSHTMLElement* element, CallData& callData)
{
- Instance* instance = pluginInstance(element);
+ Instance* instance = pluginInstance(element->impl());
if (!instance || !instance->supportsInvokeDefaultMethod())
return CallTypeNone;
callData.native.function = callPlugin;
diff --git a/WebCore/bindings/js/JSPluginElementFunctions.h b/WebCore/bindings/js/JSPluginElementFunctions.h
index 736ace9..acd4965 100644
--- a/WebCore/bindings/js/JSPluginElementFunctions.h
+++ b/WebCore/bindings/js/JSPluginElementFunctions.h
@@ -40,8 +40,8 @@ namespace WebCore {
JSC::JSValue runtimeObjectPropertyGetter(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
bool runtimeObjectCustomGetOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&, JSHTMLElement*);
bool runtimeObjectCustomGetOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&, JSHTMLElement*);
- bool runtimeObjectCustomPut(JSC::ExecState*, const JSC::Identifier&, JSC::JSValue, HTMLElement*, JSC::PutPropertySlot&);
- JSC::CallType runtimeObjectGetCallData(HTMLElement*, JSC::CallData&);
+ bool runtimeObjectCustomPut(JSC::ExecState*, const JSC::Identifier&, JSC::JSValue, JSHTMLElement*, JSC::PutPropertySlot&);
+ JSC::CallType runtimeObjectGetCallData(JSHTMLElement*, JSC::CallData&);
} // namespace WebCore
diff --git a/WebCore/bridge/jsc/BridgeJSC.cpp b/WebCore/bridge/jsc/BridgeJSC.cpp
index d44cdb5..9b3af25 100644
--- a/WebCore/bridge/jsc/BridgeJSC.cpp
+++ b/WebCore/bridge/jsc/BridgeJSC.cpp
@@ -83,7 +83,7 @@ void Instance::end()
virtualEnd();
}
-RuntimeObject* Instance::createRuntimeObject(ExecState* exec)
+JSObject* Instance::createRuntimeObject(ExecState* exec)
{
ASSERT(m_rootObject);
ASSERT(m_rootObject->isValid());
diff --git a/WebCore/bridge/jsc/BridgeJSC.h b/WebCore/bridge/jsc/BridgeJSC.h
index ee7deb6..44ce4d1 100644
--- a/WebCore/bridge/jsc/BridgeJSC.h
+++ b/WebCore/bridge/jsc/BridgeJSC.h
@@ -84,7 +84,7 @@ public:
void end();
virtual Class* getClass() const = 0;
- RuntimeObject* createRuntimeObject(ExecState*);
+ JSObject* createRuntimeObject(ExecState*);
void willInvalidateRuntimeObject();
void willDestroyRuntimeObject();
diff --git a/WebCore/html/HTMLPlugInElement.cpp b/WebCore/html/HTMLPlugInElement.cpp
index 4193546..6b11961 100644
--- a/WebCore/html/HTMLPlugInElement.cpp
+++ b/WebCore/html/HTMLPlugInElement.cpp
@@ -92,13 +92,21 @@ PassScriptInstance HTMLPlugInElement::getInstance() const
if (m_instance)
return m_instance;
- RenderWidget* renderWidget = renderWidgetForJSBindings();
- if (renderWidget && renderWidget->widget())
- m_instance = frame->script()->createScriptInstanceForWidget(renderWidget->widget());
+ if (Widget* widget = pluginWidget())
+ m_instance = frame->script()->createScriptInstanceForWidget(widget);
return m_instance;
}
+Widget* HTMLPlugInElement::pluginWidget() const
+{
+ RenderWidget* renderWidget = renderWidgetForJSBindings();
+ if (!renderWidget)
+ return 0;
+
+ return renderWidget->widget();
+}
+
bool HTMLPlugInElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
{
if (attrName == widthAttr ||
diff --git a/WebCore/html/HTMLPlugInElement.h b/WebCore/html/HTMLPlugInElement.h
index 8b902d9..afa74fc 100644
--- a/WebCore/html/HTMLPlugInElement.h
+++ b/WebCore/html/HTMLPlugInElement.h
@@ -33,6 +33,7 @@ struct NPObject;
namespace WebCore {
class RenderWidget;
+class Widget;
class HTMLPlugInElement : public HTMLFrameOwnerElement {
public:
@@ -40,6 +41,8 @@ public:
PassScriptInstance getInstance() const;
+ Widget* pluginWidget() const;
+
#if ENABLE(NETSCAPE_PLUGIN_API)
NPObject* getNPObject();
#endif
diff --git a/WebCore/plugins/PluginViewBase.h b/WebCore/plugins/PluginViewBase.h
index 9d3f463..34b808f 100644
--- a/WebCore/plugins/PluginViewBase.h
+++ b/WebCore/plugins/PluginViewBase.h
@@ -28,6 +28,12 @@
#include "Widget.h"
#include "GraphicsLayer.h"
+namespace JSC {
+ class ExecState;
+ class JSGlobalObject;
+ class JSObject;
+}
+
namespace WebCore {
// PluginViewBase is a widget that all plug-in views inherit from, both in Webkit and WebKit2.
@@ -38,6 +44,8 @@ public:
virtual PlatformLayer* platformLayer() const { return 0; }
#endif
+ JSC::JSObject* scriptObject(JSC::ExecState*, JSC::JSGlobalObject*) { return 0; }
+
protected:
PluginViewBase(PlatformWidget widget) : Widget(widget) { }
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list