Title: [204617] trunk/Source
Revision
204617
Author
[email protected]
Date
2016-08-18 17:12:27 -0700 (Thu, 18 Aug 2016)

Log Message

Move an NPAPI-only function from WebCore to WebKit
https://bugs.webkit.org/show_bug.cgi?id=160967

Reviewed by Sam Weinig.

Source/WebCore:

* WebCore.xcodeproj/project.pbxproj:
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::createScriptObjectForPluginElement): Deleted.
* bindings/js/ScriptController.h:
* bridge/NP_jsobject.h:

Source/WebKit/mac:

* Plugins/WebNetscapePluginView.h:
* Plugins/WebNetscapePluginView.mm:
(-[WebNetscapePluginView getVariable:value:]):
(-[WebNetscapePluginView _destroyPlugin]):

Source/WebKit/win:

* Plugins/PluginView.cpp:
(WebCore::PluginView::~PluginView):
(WebCore::PluginView::PluginView):
(WebCore::PluginView::getValue):
* Plugins/PluginView.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (204616 => 204617)


--- trunk/Source/WebCore/ChangeLog	2016-08-18 23:21:50 UTC (rev 204616)
+++ trunk/Source/WebCore/ChangeLog	2016-08-19 00:12:27 UTC (rev 204617)
@@ -1,3 +1,16 @@
+2016-08-18  Anders Carlsson  <[email protected]>
+
+        Move an NPAPI-only function from WebCore to WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=160967
+
+        Reviewed by Sam Weinig.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::createScriptObjectForPluginElement): Deleted.
+        * bindings/js/ScriptController.h:
+        * bridge/NP_jsobject.h:
+
 2016-08-18  Ryosuke Niwa  <[email protected]>
 
         Building test fix after r204611.

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (204616 => 204617)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-08-18 23:21:50 UTC (rev 204616)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-08-19 00:12:27 UTC (rev 204617)
@@ -737,7 +737,7 @@
 		1A569CFD0D7E2B82007C3983 /* c_utility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CCC0D7E2B82007C3983 /* c_utility.cpp */; };
 		1A569CFE0D7E2B82007C3983 /* c_utility.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CCD0D7E2B82007C3983 /* c_utility.h */; };
 		1A569D0A0D7E2B82007C3983 /* NP_jsobject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CDA0D7E2B82007C3983 /* NP_jsobject.cpp */; };
-		1A569D0B0D7E2B82007C3983 /* NP_jsobject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CDB0D7E2B82007C3983 /* NP_jsobject.h */; };
+		1A569D0B0D7E2B82007C3983 /* NP_jsobject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CDB0D7E2B82007C3983 /* NP_jsobject.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1A569D0D0D7E2B82007C3983 /* npruntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CDD0D7E2B82007C3983 /* npruntime.cpp */; };
 		1A569D0F0D7E2B82007C3983 /* npruntime_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CDF0D7E2B82007C3983 /* npruntime_impl.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1A569D100D7E2B82007C3983 /* npruntime_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CE00D7E2B82007C3983 /* npruntime_internal.h */; settings = {ATTRIBUTES = (Private, ); }; };

Modified: trunk/Source/WebCore/bindings/js/ScriptController.cpp (204616 => 204617)


--- trunk/Source/WebCore/bindings/js/ScriptController.cpp	2016-08-18 23:21:50 UTC (rev 204616)
+++ trunk/Source/WebCore/bindings/js/ScriptController.cpp	2016-08-19 00:12:27 UTC (rev 204617)
@@ -384,7 +384,6 @@
 }
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
-
 NPObject* ScriptController::windowScriptNPObject()
 {
     if (!m_windowScriptNPObject) {
@@ -405,17 +404,6 @@
 
     return m_windowScriptNPObject;
 }
-
-NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement* plugin)
-{
-    JSObject* object = jsObjectForPluginElement(plugin);
-    if (!object)
-        return _NPN_CreateNoScriptObject();
-
-    // Wrap the JSObject in an NPObject
-    return _NPN_CreateScriptObject(0, object, bindingRootObject());
-}
-
 #endif
 
 #if !PLATFORM(COCOA)

Modified: trunk/Source/WebCore/bindings/js/ScriptController.h (204616 => 204617)


--- trunk/Source/WebCore/bindings/js/ScriptController.h	2016-08-18 23:21:50 UTC (rev 204616)
+++ trunk/Source/WebCore/bindings/js/ScriptController.h	2016-08-19 00:12:27 UTC (rev 204617)
@@ -147,7 +147,7 @@
     void updatePlatformScriptObjects();
 
     RefPtr<JSC::Bindings::Instance>  createScriptInstanceForWidget(Widget*);
-    JSC::Bindings::RootObject* bindingRootObject();
+    WEBCORE_EXPORT JSC::Bindings::RootObject* bindingRootObject();
     JSC::Bindings::RootObject* cacheableBindingRootObject();
 
     WEBCORE_EXPORT RefPtr<JSC::Bindings::RootObject> createRootObject(void* nativeHandle);
@@ -162,7 +162,6 @@
     WEBCORE_EXPORT JSC::JSObject* jsObjectForPluginElement(HTMLPlugInElement*);
     
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    NPObject* createScriptObjectForPluginElement(HTMLPlugInElement*);
     WEBCORE_EXPORT NPObject* windowScriptNPObject();
 #endif
 

Modified: trunk/Source/WebCore/bridge/NP_jsobject.h (204616 => 204617)


--- trunk/Source/WebCore/bridge/NP_jsobject.h	2016-08-18 23:21:50 UTC (rev 204616)
+++ trunk/Source/WebCore/bridge/NP_jsobject.h	2016-08-19 00:12:27 UTC (rev 204617)
@@ -47,8 +47,8 @@
     JSC::Bindings::RootObject* rootObject;
 };
 
-NPObject* _NPN_CreateScriptObject(NPP, JSC::JSObject*, RefPtr<JSC::Bindings::RootObject>&&);
-NPObject* _NPN_CreateNoScriptObject(void);
+WEBCORE_EXPORT NPObject* _NPN_CreateScriptObject(NPP, JSC::JSObject*, RefPtr<JSC::Bindings::RootObject>&&);
+WEBCORE_EXPORT NPObject* _NPN_CreateNoScriptObject(void);
 
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 

Modified: trunk/Source/WebCore/html/HTMLPlugInElement.cpp (204616 => 204617)


--- trunk/Source/WebCore/html/HTMLPlugInElement.cpp	2016-08-18 23:21:50 UTC (rev 204616)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.cpp	2016-08-19 00:12:27 UTC (rev 204617)
@@ -67,9 +67,6 @@
     : HTMLFrameOwnerElement(tagName, document)
     , m_inBeforeLoadEventHandler(false)
     , m_swapRendererTimer(*this, &HTMLPlugInElement::swapRendererTimerFired)
-#if ENABLE(NETSCAPE_PLUGIN_API)
-    , m_NPObject(0)
-#endif
     , m_isCapturingMouseEvents(false)
     , m_displayState(Playing)
 {
@@ -79,13 +76,6 @@
 HTMLPlugInElement::~HTMLPlugInElement()
 {
     ASSERT(!m_instance); // cleared in detach()
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-    if (m_NPObject) {
-        _NPN_ReleaseObject(m_NPObject);
-        m_NPObject = 0;
-    }
-#endif
 }
 
 bool HTMLPlugInElement::canProcessDrag() const
@@ -111,13 +101,6 @@
             frame->eventHandler().setCapturingMouseEventsElement(nullptr);
         m_isCapturingMouseEvents = false;
     }
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-    if (m_NPObject) {
-        _NPN_ReleaseObject(m_NPObject);
-        m_NPObject = 0;
-    }
-#endif
 }
 
 void HTMLPlugInElement::resetInstance()
@@ -282,18 +265,6 @@
     return !downcast<RenderEmbeddedObject>(*renderer()).isPluginUnavailable();
 }
 
-#if ENABLE(NETSCAPE_PLUGIN_API)
-
-NPObject* HTMLPlugInElement::getNPObject()
-{
-    ASSERT(document().frame());
-    if (!m_NPObject)
-        m_NPObject = document().frame()->script().createScriptObjectForPluginElement(this);
-    return m_NPObject;
-}
-
-#endif /* ENABLE(NETSCAPE_PLUGIN_API) */
-
 RenderPtr<RenderElement> HTMLPlugInElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition& insertionPosition)
 {
     if (m_pluginReplacement && m_pluginReplacement->willCreateRenderer())

Modified: trunk/Source/WebCore/html/HTMLPlugInElement.h (204616 => 204617)


--- trunk/Source/WebCore/html/HTMLPlugInElement.h	2016-08-18 23:21:50 UTC (rev 204616)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.h	2016-08-19 00:12:27 UTC (rev 204617)
@@ -26,10 +26,6 @@
 #include "HTMLFrameOwnerElement.h"
 #include "Image.h"
 
-#if ENABLE(NETSCAPE_PLUGIN_API)
-struct NPObject;
-#endif
-
 namespace JSC {
 namespace Bindings {
 class Instance;
@@ -71,10 +67,6 @@
 
     JSC::JSObject* scriptObjectForPluginReplacement();
 
-#if ENABLE(NETSCAPE_PLUGIN_API)
-    WEBCORE_EXPORT NPObject* getNPObject();
-#endif
-
     bool isCapturingMouseEvents() const { return m_isCapturingMouseEvents; }
     void setIsCapturingMouseEvents(bool capturing) { m_isCapturingMouseEvents = capturing; }
 
@@ -128,9 +120,6 @@
     RefPtr<JSC::Bindings::Instance> m_instance;
     Timer m_swapRendererTimer;
     RefPtr<PluginReplacement> m_pluginReplacement;
-#if ENABLE(NETSCAPE_PLUGIN_API)
-    NPObject* m_NPObject;
-#endif
     bool m_isCapturingMouseEvents;
 
     DisplayState m_displayState;

Modified: trunk/Source/WebKit/mac/ChangeLog (204616 => 204617)


--- trunk/Source/WebKit/mac/ChangeLog	2016-08-18 23:21:50 UTC (rev 204616)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-08-19 00:12:27 UTC (rev 204617)
@@ -1,3 +1,15 @@
+2016-08-18  Anders Carlsson  <[email protected]>
+
+        Move an NPAPI-only function from WebCore to WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=160967
+
+        Reviewed by Sam Weinig.
+
+        * Plugins/WebNetscapePluginView.h:
+        * Plugins/WebNetscapePluginView.mm:
+        (-[WebNetscapePluginView getVariable:value:]):
+        (-[WebNetscapePluginView _destroyPlugin]):
+
 2016-08-18  Rawinder Singh  <[email protected]>
 
         [web-animations] Add Animatable, AnimationEffect, KeyframeEffect and Animation interface

Modified: trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.h (204616 => 204617)


--- trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.h	2016-08-18 23:21:50 UTC (rev 204616)
+++ trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.h	2016-08-19 00:12:27 UTC (rev 204617)
@@ -59,7 +59,9 @@
     RetainPtr<CALayer> _pluginLayer;
     unsigned _dataLengthReceived;
     RetainPtr<NSError> _error;
-        
+
+    NPObject* _elementNPObject;
+
     unsigned argsCount;
     char **cAttributes;
     char **cValues;

Modified: trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm (204616 => 204617)


--- trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm	2016-08-18 23:21:50 UTC (rev 204616)
+++ trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm	2016-08-19 00:12:27 UTC (rev 204617)
@@ -61,7 +61,8 @@
 #import <WebCore/FrameTree.h>
 #import <WebCore/FrameView.h>
 #import <WebCore/HTMLPlugInElement.h>
-#import <WebCore/Page.h> 
+#import <WebCore/NP_jsobject.h>
+#import <WebCore/Page.h>
 #import <WebCore/ProxyServer.h>
 #import <WebCore/ScriptController.h>
 #import <WebCore/SecurityOrigin.h>
@@ -70,6 +71,7 @@
 #import <WebCore/WebCoreObjCExtras.h>
 #import <WebCore/WebCoreURLResponse.h>
 #import <WebCore/npruntime_impl.h>
+#import <WebCore/runtime_root.h>
 #import <WebKitLegacy/DOMPrivate.h>
 #import <WebKitLegacy/WebUIDelegate.h>
 #import <objc/runtime.h>
@@ -1922,17 +1924,26 @@
 
         case NPNVPluginElementNPObject:
         {
-            if (!_element)
-                return NPERR_GENERIC_ERROR;
-            
-            NPObject *plugInScriptObject = _element->getNPObject();
+            if (!_elementNPObject) {
+                if (!_element)
+                    return NPERR_GENERIC_ERROR;
 
+                Frame* frame = core(self.webFrame);
+                if (!frame)
+                    return NPERR_GENERIC_ERROR;
+
+                JSC::JSObject* object = frame->script().jsObjectForPluginElement(_element.get());
+                if (!object)
+                    _elementNPObject = _NPN_CreateNoScriptObject();
+                else
+                    _elementNPObject = _NPN_CreateScriptObject(0, object, frame->script().bindingRootObject());
+            }
+
             // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess>
-            if (plugInScriptObject)
-                _NPN_RetainObject(plugInScriptObject);
+            if (_elementNPObject)
+                _NPN_RetainObject(_elementNPObject);
 
-            void **v = (void **)value;
-            *v = plugInScriptObject;
+            *(void **)value = _elementNPObject;
 
             return NPERR_NO_ERROR;
         }
@@ -2280,7 +2291,10 @@
     NPError npErr;
     npErr = ![_pluginPackage.get() pluginFuncs]->destroy(plugin, NULL);
     LOG(Plugins, "NPP_Destroy: %d", npErr);
-    
+
+    if (_elementNPObject)
+        _NPN_ReleaseObject(_elementNPObject);
+
     if (Frame* frame = core([self webFrame]))
         frame->script().cleanupScriptObjectsForPlugin(self);
         

Modified: trunk/Source/WebKit/win/ChangeLog (204616 => 204617)


--- trunk/Source/WebKit/win/ChangeLog	2016-08-18 23:21:50 UTC (rev 204616)
+++ trunk/Source/WebKit/win/ChangeLog	2016-08-19 00:12:27 UTC (rev 204617)
@@ -1,3 +1,16 @@
+2016-08-18  Anders Carlsson  <[email protected]>
+
+        Move an NPAPI-only function from WebCore to WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=160967
+
+        Reviewed by Sam Weinig.
+
+        * Plugins/PluginView.cpp:
+        (WebCore::PluginView::~PluginView):
+        (WebCore::PluginView::PluginView):
+        (WebCore::PluginView::getValue):
+        * Plugins/PluginView.h:
+
 2016-08-15  Joseph Pecoraro  <[email protected]>
 
         Remove unused includes of wtf headers

Modified: trunk/Source/WebKit/win/Plugins/PluginView.cpp (204616 => 204617)


--- trunk/Source/WebKit/win/Plugins/PluginView.cpp	2016-08-18 23:21:50 UTC (rev 204616)
+++ trunk/Source/WebKit/win/Plugins/PluginView.cpp	2016-08-19 00:12:27 UTC (rev 204617)
@@ -55,6 +55,7 @@
 #include <WebCore/KeyboardEvent.h>
 #include <WebCore/MIMETypeRegistry.h>
 #include <WebCore/MouseEvent.h>
+#include <WebCore/NP_jsobject.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/Page.h>
 #include <WebCore/PlatformMouseEvent.h>
@@ -292,6 +293,9 @@
 
     stop();
 
+    if (m_elementNPObject)
+        _NPN_ReleaseObject(m_elementNPObject);
+    
     freeStringArray(m_paramNames, m_paramCount);
     freeStringArray(m_paramValues, m_paramCount);
 
@@ -749,6 +753,7 @@
     , m_paramValues(0)
     , m_mimeType(mimeType)
     , m_instance(0)
+    , m_elementNPObject(nullptr)
     , m_isWindowed(true)
     , m_isTransparent(false)
     , m_haveInitialized(false)
@@ -1192,6 +1197,14 @@
     return NPERR_GENERIC_ERROR;
 }
 
+static Frame* getFrame(Frame* parentFrame, Element* element)
+{
+    if (parentFrame)
+        return parentFrame;
+    
+    return element->document().frame();
+}
+
 NPError PluginView::getValue(NPNVariable variable, void* value)
 {
     LOG(Plugins, "PluginView::getValue(%s)", prettyNameForNPNVariable(variable).data());
@@ -1224,18 +1237,23 @@
         if (m_isJavaScriptPaused)
             return NPERR_GENERIC_ERROR;
 
-        NPObject* pluginScriptObject = 0;
+        if (!m_elementNPObject) {
+            Frame* frame = getFrame(parentFrame(), m_element);
+            if (!frame)
+                return NPERR_GENERIC_ERROR;
 
-        if (m_element->hasTagName(appletTag) || m_element->hasTagName(embedTag) || m_element->hasTagName(objectTag))
-            pluginScriptObject = m_element->getNPObject();
+            JSC::JSObject* object = frame->script().jsObjectForPluginElement(m_element);
+            if (!object)
+                m_elementNPObject = _NPN_CreateNoScriptObject();
+            else
+                m_elementNPObject = _NPN_CreateScriptObject(0, object, frame->script().bindingRootObject());
+        }
 
-        // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
-        if (pluginScriptObject)
-            _NPN_RetainObject(pluginScriptObject);
+        // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess>
+        if (m_elementNPObject)
+            _NPN_RetainObject(m_elementNPObject);
 
-        void** v = (void**)value;
-        *v = pluginScriptObject;
-
+        *(void **)value = m_elementNPObject;
         return NPERR_NO_ERROR;
     }
 
@@ -1252,14 +1270,6 @@
     }
 }
 
-static Frame* getFrame(Frame* parentFrame, Element* element)
-{
-    if (parentFrame)
-        return parentFrame;
-    
-    return element->document().frame();
-}
-
 NPError PluginView::getValueForURL(NPNURLVariable variable, const char* url, char** value, uint32_t* len)
 {
     LOG(Plugins, "PluginView::getValueForURL(%s)", prettyNameForNPNURLVariable(variable).data());

Modified: trunk/Source/WebKit/win/Plugins/PluginView.h (204616 => 204617)


--- trunk/Source/WebKit/win/Plugins/PluginView.h	2016-08-18 23:21:50 UTC (rev 204616)
+++ trunk/Source/WebKit/win/Plugins/PluginView.h	2016-08-19 00:12:27 UTC (rev 204617)
@@ -310,6 +310,8 @@
         NPWindow m_npWindow;
 #endif
 
+        NPObject* m_elementNPObject;
+
         Vector<bool, 4> m_popupStateStack;
 
         HashSet<RefPtr<PluginStream> > m_streams;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to