Commit d239de21 authored by darin@chromium.org's avatar darin@chromium.org

2008-11-25 Darin Fisher <darin@chromium.org>

        Reviewed by Geoffrey Garen.

        https://bugs.webkit.org/show_bug.cgi?id=22493
        Abstract away JSC:: usage in WebCore/html

        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/JSPluginElementFunctions.cpp:
        (WebCore::pluginInstance):
        * bindings/js/ScriptController.h:
        * bindings/js/ScriptControllerMac.mm:
        (WebCore::ScriptController::createScriptInstanceForWidget):
        * bindings/js/ScriptInstance.h: Added.
        * html/HTMLPlugInElement.cpp:
        (WebCore::HTMLPlugInElement::~HTMLPlugInElement):
        (WebCore::HTMLPlugInElement::getInstance):
        * html/HTMLPlugInElement.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@38774 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ae5e975a
2008-11-25 Darin Fisher <darin@chromium.org>
Reviewed by Geoffrey Garen.
https://bugs.webkit.org/show_bug.cgi?id=22493
Abstract away JSC:: usage in WebCore/html
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSPluginElementFunctions.cpp:
(WebCore::pluginInstance):
* bindings/js/ScriptController.h:
* bindings/js/ScriptControllerMac.mm:
(WebCore::ScriptController::createScriptInstanceForWidget):
* bindings/js/ScriptInstance.h: Added.
* html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::~HTMLPlugInElement):
(WebCore::HTMLPlugInElement::getInstance):
* html/HTMLPlugInElement.h:
2008-11-24 Nikolas Zimmermann <nikolas.zimmermann@torchmobile.com>
Reviewed by Sam Weinig.
......@@ -13884,6 +13884,10 @@
RelativePath="..\bindings\js\ScriptControllerWin.cpp"
>
</File>
<File
RelativePath="..\bindings\js\ScriptInstance.h"
>
</File>
<File
RelativePath="..\bindings\js\ScriptSourceCode.h"
>
......
......@@ -203,7 +203,7 @@
1A569D1A0D7E2B82007C3983 /* objc_utility.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CEB0D7E2B82007C3983 /* objc_utility.mm */; };
1A569D1B0D7E2B82007C3983 /* WebScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CEC0D7E2B82007C3983 /* WebScriptObject.h */; };
1A569D1C0D7E2B82007C3983 /* runtime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CED0D7E2B82007C3983 /* runtime.cpp */; };
1A569D1D0D7E2B82007C3983 /* runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CEE0D7E2B82007C3983 /* runtime.h */; };
1A569D1D0D7E2B82007C3983 /* runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CEE0D7E2B82007C3983 /* runtime.h */; settings = {ATTRIBUTES = (Private, ); }; };
1A569D1E0D7E2B82007C3983 /* runtime_array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CEF0D7E2B82007C3983 /* runtime_array.cpp */; };
1A569D1F0D7E2B82007C3983 /* runtime_array.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CF00D7E2B82007C3983 /* runtime_array.h */; };
1A569D200D7E2B82007C3983 /* runtime_method.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CF10D7E2B82007C3983 /* runtime_method.cpp */; };
......@@ -1808,6 +1808,7 @@
934CC0E10ED39D6F00A658F2 /* ScriptValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 934CC0DF0ED39D6F00A658F2 /* ScriptValue.cpp */; };
934CC0E20ED39D6F00A658F2 /* ScriptValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 934CC0E00ED39D6F00A658F2 /* ScriptValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
934CC10A0EDB223900A658F2 /* ScriptSourceCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 934CC1090EDB223900A658F2 /* ScriptSourceCode.h */; };
934CC1170EDCAC7300A658F2 /* ScriptInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = 934CC1160EDCAC7300A658F2 /* ScriptInstance.h */; settings = {ATTRIBUTES = (Private, ); }; };
934D9BA50B8C116B007B42A9 /* WebCoreNSStringExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 934D9BA40B8C116B007B42A9 /* WebCoreNSStringExtras.mm */; };
934D9BA70B8C1175007B42A9 /* WebCoreNSStringExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 934D9BA60B8C1175007B42A9 /* WebCoreNSStringExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
934F71380D5A6EFF00018D69 /* AuthenticationChallengeBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 934F71370D5A6EFF00018D69 /* AuthenticationChallengeBase.cpp */; };
......@@ -6598,6 +6599,7 @@
934CC0DF0ED39D6F00A658F2 /* ScriptValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptValue.cpp; sourceTree = "<group>"; };
934CC0E00ED39D6F00A658F2 /* ScriptValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptValue.h; sourceTree = "<group>"; };
934CC1090EDB223900A658F2 /* ScriptSourceCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptSourceCode.h; sourceTree = "<group>"; };
934CC1160EDCAC7300A658F2 /* ScriptInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptInstance.h; sourceTree = "<group>"; };
934D9BA40B8C116B007B42A9 /* WebCoreNSStringExtras.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSStringExtras.mm; sourceTree = "<group>"; };
934D9BA60B8C1175007B42A9 /* WebCoreNSStringExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreNSStringExtras.h; sourceTree = "<group>"; };
934F71370D5A6EFF00018D69 /* AuthenticationChallengeBase.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticationChallengeBase.cpp; sourceTree = "<group>"; };
......@@ -13092,6 +13094,7 @@
93B70D5309EB0C7C009D8468 /* ScriptController.cpp */,
93B70D5409EB0C7C009D8468 /* ScriptController.h */,
A83E1C720E49042B00140B9C /* ScriptControllerMac.mm */,
934CC1160EDCAC7300A658F2 /* ScriptInstance.h */,
934CC1090EDB223900A658F2 /* ScriptSourceCode.h */,
416F45EF0ED7B311008215B6 /* ScriptString.h */,
934CC0DF0ED39D6F00A658F2 /* ScriptValue.cpp */,
......@@ -16418,6 +16421,7 @@
080AEC840ED8708B00DF4CCE /* WMLIntrinsicEventHandler.h in Headers */,
08203AA00ED8C35300B8B61A /* WMLAccessElement.h in Headers */,
934CC10A0EDB223900A658F2 /* ScriptSourceCode.h in Headers */,
934CC1170EDCAC7300A658F2 /* ScriptInstance.h in Headers */,
08744BAE0EDB7D92004C9E63 /* WMLOnEventElement.h in Headers */,
0818AEE30EDB86BC00647B66 /* WMLEventHandlingElement.h in Headers */,
);
......@@ -46,7 +46,8 @@ static Instance* pluginInstance(Node* node)
if (!(node->hasTagName(objectTag) || node->hasTagName(embedTag) || node->hasTagName(appletTag)))
return 0;
HTMLPlugInElement* plugInElement = static_cast<HTMLPlugInElement*>(node);
Instance* instance = plugInElement->getInstance();
// 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;
......
......@@ -23,6 +23,7 @@
#define ScriptController_h
#include "JSDOMWindowShell.h"
#include "ScriptInstance.h"
#include <runtime/Protect.h>
#include <wtf/RefPtr.h>
......@@ -42,7 +43,6 @@ namespace JSC {
class JSGlobalObject;
namespace Bindings {
class Instance;
class RootObject;
}
}
......@@ -109,7 +109,7 @@ public:
void clearScriptObjects();
void cleanupScriptObjectsForPlugin(void*);
PassRefPtr<JSC::Bindings::Instance> createScriptInstanceForWidget(Widget*);
PassScriptInstance createScriptInstanceForWidget(Widget*);
JSC::Bindings::RootObject* bindingRootObject();
PassRefPtr<JSC::Bindings::RootObject> createRootObject(void* nativeHandle);
......
......@@ -63,7 +63,7 @@ using namespace JSC::Bindings;
namespace WebCore {
PassRefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWidget(Widget* widget)
PassScriptInstance ScriptController::createScriptInstanceForWidget(Widget* widget)
{
NSView* widgetView = widget->platformWidget();
if (!widgetView)
......
/*
* Copyright (c) 2008, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ScriptInstance_h
#define ScriptInstance_h
#include <wtf/RefPtr.h>
#include "runtime.h"
namespace WebCore {
typedef RefPtr<JSC::Bindings::Instance> ScriptInstance;
typedef PassRefPtr<JSC::Bindings::Instance> PassScriptInstance;
} // namespace WebCore
#endif // ScriptInstance_h
......@@ -32,19 +32,12 @@
#include "HTMLNames.h"
#include "Page.h"
#include "RenderWidget.h"
#include "ScriptController.h"
#include "Settings.h"
#include "Widget.h"
#include "ScriptController.h"
#if USE(JSC)
#include "runtime.h"
#endif
#if ENABLE(NETSCAPE_PLUGIN_API)
#include "JSNode.h"
#include "NP_jsobject.h"
#include "npruntime_impl.h"
#include "runtime_root.h"
#endif
namespace WebCore {
......@@ -61,9 +54,7 @@ HTMLPlugInElement::HTMLPlugInElement(const QualifiedName& tagName, Document* doc
HTMLPlugInElement::~HTMLPlugInElement()
{
#if USE(JSC)
ASSERT(!m_instance); // cleared in detach()
#endif
#if ENABLE(NETSCAPE_PLUGIN_API)
if (m_NPObject) {
......@@ -73,14 +64,13 @@ HTMLPlugInElement::~HTMLPlugInElement()
#endif
}
#if USE(JSC)
void HTMLPlugInElement::detach()
{
m_instance.clear();
HTMLFrameOwnerElement::detach();
}
JSC::Bindings::Instance* HTMLPlugInElement::getInstance() const
PassScriptInstance HTMLPlugInElement::getInstance() const
{
Frame* frame = document()->frame();
if (!frame)
......@@ -89,15 +79,14 @@ JSC::Bindings::Instance* HTMLPlugInElement::getInstance() const
// If the host dynamically turns off JavaScript (or Java) we will still return
// the cached allocated Bindings::Instance. Not supporting this edge-case is OK.
if (m_instance)
return m_instance.get();
return m_instance;
RenderWidget* renderWidget = renderWidgetForJSBindings();
if (renderWidget && renderWidget->widget())
m_instance = frame->script()->createScriptInstanceForWidget(renderWidget->widget());
return m_instance.get();
return m_instance;
}
#endif
String HTMLPlugInElement::align() const
{
......
......@@ -24,14 +24,7 @@
#define HTMLPlugInElement_h
#include "HTMLFrameOwnerElement.h"
#if USE(JSC)
namespace JSC {
namespace Bindings {
class Instance;
}
}
#endif
#include "ScriptInstance.h"
#if ENABLE(NETSCAPE_PLUGIN_API)
struct NPObject;
......@@ -69,10 +62,8 @@ public:
virtual void defaultEventHandler(Event*);
virtual RenderWidget* renderWidgetForJSBindings() const = 0;
#if USE(JSC)
virtual void detach();
JSC::Bindings::Instance* getInstance() const;
#endif
PassScriptInstance getInstance() const;
#if ENABLE(NETSCAPE_PLUGIN_API)
virtual NPObject* getNPObject();
......@@ -82,9 +73,7 @@ protected:
static void updateWidgetCallback(Node*);
AtomicString m_name;
#if USE(JSC)
mutable RefPtr<JSC::Bindings::Instance> m_instance;
#endif
mutable ScriptInstance m_instance;
#if ENABLE(NETSCAPE_PLUGIN_API)
NPObject* m_NPObject;
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment