зеркало из https://github.com/mozilla/gecko-dev.git
NOT PART OF BUILD. Fire events to nsIScriptEventManager targets. Add some #ifdefs around some code to fix breakage in other configurations. Comment out a debug macro. b=174404 sr=rpotts@netscape.com
This commit is contained in:
Родитель
2a7ed19e4e
Коммит
f623bad311
|
@ -596,6 +596,7 @@ NPError NewControl(const char *pluginType,
|
||||||
return NPERR_GENERIC_ERROR;
|
return NPERR_GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef XPC_IDISPATCH_SUPPORT
|
||||||
nsEventSinkInstance *pSink = NULL;
|
nsEventSinkInstance *pSink = NULL;
|
||||||
nsEventSinkInstance::CreateInstance(&pSink);
|
nsEventSinkInstance::CreateInstance(&pSink);
|
||||||
if (pSink)
|
if (pSink)
|
||||||
|
@ -606,10 +607,10 @@ NPError NewControl(const char *pluginType,
|
||||||
pSite->GetControlUnknown(&control);
|
pSite->GetControlUnknown(&control);
|
||||||
pSink->SubscribeToEvents(control);
|
pSink->SubscribeToEvents(control);
|
||||||
}
|
}
|
||||||
|
pData->pControlEventSink = pSink;
|
||||||
|
#endif
|
||||||
pData->nType = itControl;
|
pData->nType = itControl;
|
||||||
pData->pControlSite = pSite;
|
pData->pControlSite = pSite;
|
||||||
pData->pControlEventSink = pSink;
|
|
||||||
|
|
||||||
return NPERR_NO_ERROR;
|
return NPERR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -708,11 +709,13 @@ NPP_Destroy(NPP instance, NPSavedData** save)
|
||||||
pSite->Detach();
|
pSite->Detach();
|
||||||
pSite->Release();
|
pSite->Release();
|
||||||
}
|
}
|
||||||
|
#ifdef XPC_IDISPATCH_SUPPORT
|
||||||
if (pData->pControlEventSink)
|
if (pData->pControlEventSink)
|
||||||
{
|
{
|
||||||
pData->pControlEventSink->UnsubscribeFromEvents();
|
pData->pControlEventSink->UnsubscribeFromEvents();
|
||||||
pData->pControlEventSink->Release();
|
pData->pControlEventSink->Release();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#ifdef MOZ_ACTIVEX_PLUGIN_XPCONNECT
|
#ifdef MOZ_ACTIVEX_PLUGIN_XPCONNECT
|
||||||
if (pData->pScriptingPeer)
|
if (pData->pScriptingPeer)
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,7 +63,9 @@ struct PluginInstanceData {
|
||||||
CActiveScriptSiteInstance *pScriptSite;
|
CActiveScriptSiteInstance *pScriptSite;
|
||||||
struct {
|
struct {
|
||||||
CControlSiteInstance *pControlSite;
|
CControlSiteInstance *pControlSite;
|
||||||
|
#ifdef XPC_IDISPATCH_SUPPORT
|
||||||
nsEventSinkInstance *pControlEventSink;
|
nsEventSinkInstance *pControlEventSink;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
char *szUrl;
|
char *szUrl;
|
||||||
|
|
|
@ -48,8 +48,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,0,0,3
|
FILEVERSION 1,0,0,4
|
||||||
PRODUCTVERSION 1,0,0,3
|
PRODUCTVERSION 1,0,0,4
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -69,7 +69,7 @@ BEGIN
|
||||||
VALUE "FileDescription", "Mozilla ActiveX control and plugin module\0"
|
VALUE "FileDescription", "Mozilla ActiveX control and plugin module\0"
|
||||||
VALUE "FileExtents", "*.ocx|*.ocx|*.axs\0"
|
VALUE "FileExtents", "*.ocx|*.ocx|*.axs\0"
|
||||||
VALUE "FileOpenName", "ActiveX (*.ocx)|ActiveX (*.ocx)|ActiveScript(*.axs)\0"
|
VALUE "FileOpenName", "ActiveX (*.ocx)|ActiveX (*.ocx)|ActiveScript(*.axs)\0"
|
||||||
VALUE "FileVersion", "1, 0, 0, 3\0"
|
VALUE "FileVersion", "1, 0, 0, 4\0"
|
||||||
VALUE "InternalName", "NPMOZAX\0"
|
VALUE "InternalName", "NPMOZAX\0"
|
||||||
VALUE "LegalCopyright", "Copyright 1999\0"
|
VALUE "LegalCopyright", "Copyright 1999\0"
|
||||||
VALUE "LegalTrademarks", "\0"
|
VALUE "LegalTrademarks", "\0"
|
||||||
|
@ -77,7 +77,7 @@ BEGIN
|
||||||
VALUE "OriginalFilename", "NPMOZAX.DLL\0"
|
VALUE "OriginalFilename", "NPMOZAX.DLL\0"
|
||||||
VALUE "PrivateBuild", "\0"
|
VALUE "PrivateBuild", "\0"
|
||||||
VALUE "ProductName", "Mozilla ActiveX control and plugin support\0"
|
VALUE "ProductName", "Mozilla ActiveX control and plugin support\0"
|
||||||
VALUE "ProductVersion", "1, 0, 0, 3\0"
|
VALUE "ProductVersion", "1, 0, 0, 4\0"
|
||||||
VALUE "SpecialBuild", "\0"
|
VALUE "SpecialBuild", "\0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
|
@ -56,8 +56,10 @@
|
||||||
|
|
||||||
#define USE_PLUGIN
|
#define USE_PLUGIN
|
||||||
|
|
||||||
|
// Uncomment if you want to say what is QI'ing for what
|
||||||
|
//#define _ATL_DEBUG_QI
|
||||||
|
|
||||||
// ATL headers
|
// ATL headers
|
||||||
#define _ATL_DEBUG_QI
|
|
||||||
#include <atlbase.h>
|
#include <atlbase.h>
|
||||||
//You may derive a class from CComModule and use it if you want to override
|
//You may derive a class from CComModule and use it if you want to override
|
||||||
//something, but do not change the name of _Module
|
//something, but do not change the name of _Module
|
||||||
|
|
|
@ -56,13 +56,17 @@
|
||||||
#include "nsIDOMNodeList.h"
|
#include "nsIDOMNodeList.h"
|
||||||
#include "nsIDOMElement.h"
|
#include "nsIDOMElement.h"
|
||||||
#include "nsIDOMEventReceiver.h"
|
#include "nsIDOMEventReceiver.h"
|
||||||
|
#include "nsIDOMWindow.h"
|
||||||
|
|
||||||
|
#include "nsIInterfaceRequestorUtils.h"
|
||||||
#include "nsIEventListenerManager.h"
|
#include "nsIEventListenerManager.h"
|
||||||
#include "nsGUIEvent.h"
|
#include "nsGUIEvent.h"
|
||||||
|
|
||||||
#include "nsIScriptEventHandler.h"
|
#include "nsIScriptEventManager.h"
|
||||||
#include "jsapi.h"
|
#include "jsapi.h"
|
||||||
|
#ifdef XPC_IDISPATCH_SUPPORT
|
||||||
#include "nsIDispatchSupport.h"
|
#include "nsIDispatchSupport.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "LegacyPlugin.h"
|
#include "LegacyPlugin.h"
|
||||||
#include "XPConnect.h"
|
#include "XPConnect.h"
|
||||||
|
@ -631,6 +635,7 @@ nsScriptablePeer::SetProperty(const char *propertyName, nsIVariant *propertyValu
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef XPC_IDISPATCH_SUPPORT
|
||||||
HRESULT
|
HRESULT
|
||||||
nsEventSink::InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
nsEventSink::InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
||||||
{
|
{
|
||||||
|
@ -735,6 +740,8 @@ nsEventSink::InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wF
|
||||||
ATLTRACE(_T(");\n"));
|
ATLTRACE(_T(");\n"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
m_spEventSinkTypeInfo->ReleaseFuncDesc(pFuncDesc);
|
||||||
|
pFuncDesc = NULL;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMElement> element;
|
nsCOMPtr<nsIDOMElement> element;
|
||||||
NPN_GetValue(mPlugin->pPluginInstance, NPNVDOMElement, (void *) &element);
|
NPN_GetValue(mPlugin->pPluginInstance, NPNVDOMElement, (void *) &element);
|
||||||
|
@ -751,102 +758,69 @@ nsEventSink::InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wF
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAutoString eventName(bstrName.m_str);
|
nsDependentString eventName(bstrName.m_str);
|
||||||
|
|
||||||
// TODO Turn VARIANT args into js objects
|
|
||||||
#if 0
|
|
||||||
// Fire event to DOM 2 event listeners
|
|
||||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver = do_QueryInterface(element);
|
|
||||||
if (eventReceiver)
|
|
||||||
{
|
|
||||||
// Get the event manager
|
|
||||||
nsCOMPtr<nsIEventListenerManager> eventManager;
|
|
||||||
eventReceiver->GetListenerManager(getter_AddRefs(eventManager));
|
|
||||||
if (eventManager)
|
|
||||||
{
|
|
||||||
nsStringKey key(eventName);
|
|
||||||
nsEvent event;
|
|
||||||
event.message = NS_USER_DEFINED_EVENT;
|
|
||||||
event.userType = &key;
|
|
||||||
|
|
||||||
// Fire the event!
|
|
||||||
nsCOMPtr<nsIDOMEvent> domEvent;
|
|
||||||
nsEventStatus eventStatus;
|
|
||||||
nsresult rv = eventManager->HandleEvent(nsnull, &event, getter_AddRefs(domEvent),
|
|
||||||
eventReceiver, NS_EVENT_FLAG_INIT, &eventStatus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||||
nsCOMPtr<nsIDOMNodeList> scriptElements;
|
nsCOMPtr<nsIDOMNodeList> scriptElements;
|
||||||
|
|
||||||
// This outer loop is used for error handling...
|
// Fire the script event handler...
|
||||||
do {
|
nsCOMPtr<nsIDOMWindow> window;
|
||||||
// Get a list of all SCRIPT elements in the document.
|
NPN_GetValue(mPlugin->pPluginInstance, NPNVDOMWindow, (void *)&window);
|
||||||
rv = element->GetOwnerDocument(getter_AddRefs(domdoc));
|
|
||||||
if (NS_FAILED(rv)) break;
|
|
||||||
|
|
||||||
rv = domdoc->GetElementsByTagName(NS_LITERAL_STRING("script"),
|
nsCOMPtr<nsIScriptEventManager> eventManager(do_GetInterface(window));
|
||||||
getter_AddRefs(scriptElements));
|
if (!eventManager) return S_OK;
|
||||||
if (NS_FAILED(rv)) break;
|
|
||||||
|
|
||||||
// Get the number of script elements in the current document...
|
nsCOMPtr<nsISupports> handler;
|
||||||
PRUint32 count = 0;
|
|
||||||
rv = scriptElements->GetLength(&count);
|
|
||||||
if (NS_FAILED(rv)) break;
|
|
||||||
|
|
||||||
//
|
eventManager->FindEventHandler(id, eventName, pDispParams->cArgs, getter_AddRefs(handler));
|
||||||
// Iterate over all of the SCRIPT elements looking for a handler.
|
if (!handler)
|
||||||
//
|
|
||||||
// Walk the list backwards in order to pick up the most recently
|
|
||||||
// defined script handler (if more than one is present)...
|
|
||||||
//
|
|
||||||
nsDependentString eventName(bstrName.m_str);
|
|
||||||
nsCOMPtr<nsIDOMNode> node;
|
|
||||||
nsCOMPtr<nsIScriptEventHandler> handler;
|
|
||||||
|
|
||||||
while (count--)
|
|
||||||
{
|
{
|
||||||
rv = scriptElements->Item(count, getter_AddRefs(node));
|
return S_OK;
|
||||||
if (NS_FAILED(rv)) break;
|
}
|
||||||
|
|
||||||
handler = do_QueryInterface(node, &rv);
|
// Create a list of arguments to pass along
|
||||||
if (NS_FAILED(rv)) continue;
|
//
|
||||||
|
// This array is created on the stack if the number of arguments
|
||||||
|
// less than kMaxArgsOnStack. Otherwise, the array is heap
|
||||||
|
// allocated.
|
||||||
|
//
|
||||||
|
const int kMaxArgsOnStack = 10;
|
||||||
|
|
||||||
PRBool bFound;
|
PRUint32 argc = pDispParams->cArgs;
|
||||||
rv = handler->IsSameEvent(id, eventName, pDispParams->cArgs, &bFound);
|
|
||||||
if (NS_FAILED(rv)) break;
|
|
||||||
|
|
||||||
if (bFound)
|
|
||||||
{
|
|
||||||
// Create a list of arguments to pass along.
|
|
||||||
jsval *args = nsnull;
|
jsval *args = nsnull;
|
||||||
if (pDispParams->cArgs > 0)
|
jsval stackArgs[kMaxArgsOnStack];
|
||||||
|
|
||||||
|
// Heap allocate the jsval array if it is too big to fit on
|
||||||
|
// the stack (ie. more than kMaxArgsOnStack arguments)
|
||||||
|
if (argc > kMaxArgsOnStack)
|
||||||
|
{
|
||||||
|
args = new jsval[argc];
|
||||||
|
if (!args) return S_OK;
|
||||||
|
}
|
||||||
|
else if (argc)
|
||||||
|
{
|
||||||
|
// Use the jsval array on the stack...
|
||||||
|
args = stackArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc)
|
||||||
{
|
{
|
||||||
args = new jsval[pDispParams->cArgs];
|
|
||||||
if (!args) break;
|
|
||||||
nsCOMPtr<nsIDispatchSupport> disp(do_GetService("@mozilla.org/nsdispatchsupport;1"));
|
nsCOMPtr<nsIDispatchSupport> disp(do_GetService("@mozilla.org/nsdispatchsupport;1"));
|
||||||
for (UINT i = 0; i < pDispParams->cArgs; i++)
|
for (UINT i = 0; i < argc; i++)
|
||||||
{
|
{
|
||||||
// For some bizarre reason, arguments are listed backwards
|
disp->COMVariant2JSVal(&pDispParams->rgvarg[i], &args[i]);
|
||||||
disp->COMVariant2JSVal(&pDispParams->rgvarg[pDispParams->cArgs - 1 - i], &args[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fire the Event.
|
// Fire the Event.
|
||||||
handler->Invoke(element, args, pDispParams->cArgs);
|
eventManager->InvokeEventHandler(handler, element, args, argc);
|
||||||
if (args)
|
|
||||||
|
// Free the jsvals if they were heap allocated...
|
||||||
|
if (args != stackArgs)
|
||||||
{
|
{
|
||||||
// TODO cleanup jsval or are these things garbage collected somehow?
|
delete [] args;
|
||||||
delete[]args;
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (0);
|
|
||||||
// Errors just fall of the end of the do..while
|
|
||||||
|
|
||||||
// TODO Turn js objects for out params back into VARIANTS
|
// TODO Turn js objects for out params back into VARIANTS
|
||||||
|
|
||||||
|
@ -859,10 +833,9 @@ nsEventSink::InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wF
|
||||||
pExcepInfo->wCode = 0;
|
pExcepInfo->wCode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_spEventSinkTypeInfo->ReleaseFuncDesc(pFuncDesc);
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -121,6 +121,7 @@ public:
|
||||||
virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS __RPC_FAR *pDispParams, VARIANT __RPC_FAR *pVarResult, EXCEPINFO __RPC_FAR *pExcepInfo, UINT __RPC_FAR *puArgErr);
|
virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS __RPC_FAR *pDispParams, VARIANT __RPC_FAR *pVarResult, EXCEPINFO __RPC_FAR *pExcepInfo, UINT __RPC_FAR *puArgErr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef XPC_IDISPATCH_SUPPORT
|
||||||
class nsEventSink : public CControlEventSink
|
class nsEventSink : public CControlEventSink
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -130,6 +131,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef CComObject<nsEventSink> nsEventSinkInstance;
|
typedef CComObject<nsEventSink> nsEventSinkInstance;
|
||||||
|
#endif
|
||||||
|
|
||||||
extern void xpc_AddRef();
|
extern void xpc_AddRef();
|
||||||
extern void xpc_Release();
|
extern void xpc_Release();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче