Bug 496567 - Remove nsXULCommandEvent and nsIDOMXULListener, r=neil, sr=sicking
This commit is contained in:
Родитель
c758b3107e
Коммит
b0b08b2779
|
@ -51,7 +51,6 @@
|
|||
#include "nsIDocument.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsIDOMFormListener.h"
|
||||
#include "nsIDOMXULListener.h"
|
||||
#include "nsITimer.h"
|
||||
|
||||
#define NS_ROOTACCESSIBLE_IMPL_CID \
|
||||
|
|
|
@ -106,6 +106,7 @@ class nsIWidget;
|
|||
class nsIDragSession;
|
||||
class nsPIDOMWindow;
|
||||
class nsPIDOMEventTarget;
|
||||
class nsIPresShell;
|
||||
#ifdef MOZ_XTF
|
||||
class nsIXTFService;
|
||||
#endif
|
||||
|
@ -1401,6 +1402,21 @@ public:
|
|||
nsString& aOrigin);
|
||||
static nsresult GetUTFOrigin(nsIURI* aURI, nsString& aOrigin);
|
||||
|
||||
/**
|
||||
* This method creates and dispatches "command" event, which implements
|
||||
* nsIDOMXULCommandEvent.
|
||||
* If aShell is not null, dispatching goes via
|
||||
* nsIPresShell::HandleDOMEventWithTarget.
|
||||
*/
|
||||
static nsresult DispatchXULCommand(nsIContent* aTarget,
|
||||
PRBool aTrusted,
|
||||
nsIDOMEvent* aSourceEvent = nsnull,
|
||||
nsIPresShell* aShell = nsnull,
|
||||
PRBool aCtrl = PR_FALSE,
|
||||
PRBool aAlt = PR_FALSE,
|
||||
PRBool aShift = PR_FALSE,
|
||||
PRBool aMeta = PR_FALSE);
|
||||
|
||||
/**
|
||||
* Gets the nsIDocument given the script context. Will return nsnull on failure.
|
||||
*
|
||||
|
|
|
@ -162,6 +162,8 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
|||
#include "nsCPrefetchService.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIMIMEHeaderParam.h"
|
||||
#include "nsIDOMXULCommandEvent.h"
|
||||
#include "nsIDOMAbstractView.h"
|
||||
#include "nsIDOMDragEvent.h"
|
||||
#include "nsDOMDataTransfer.h"
|
||||
#include "nsHtml5Module.h"
|
||||
|
@ -5044,3 +5046,42 @@ nsContentUtils::CanAccessNativeAnon()
|
|||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
nsContentUtils::DispatchXULCommand(nsIContent* aTarget,
|
||||
PRBool aTrusted,
|
||||
nsIDOMEvent* aSourceEvent,
|
||||
nsIPresShell* aShell,
|
||||
PRBool aCtrl,
|
||||
PRBool aAlt,
|
||||
PRBool aShift,
|
||||
PRBool aMeta)
|
||||
{
|
||||
NS_ENSURE_STATE(aTarget);
|
||||
nsIDocument* doc = aTarget->GetOwnerDoc();
|
||||
nsCOMPtr<nsIDOMDocumentEvent> docEvent = do_QueryInterface(doc);
|
||||
NS_ENSURE_STATE(docEvent);
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
docEvent->CreateEvent(NS_LITERAL_STRING("xulcommandevent"),
|
||||
getter_AddRefs(event));
|
||||
nsCOMPtr<nsIDOMXULCommandEvent> xulCommand = do_QueryInterface(event);
|
||||
nsCOMPtr<nsIPrivateDOMEvent> pEvent = do_QueryInterface(xulCommand);
|
||||
NS_ENSURE_STATE(pEvent);
|
||||
nsCOMPtr<nsIDOMAbstractView> view = do_QueryInterface(doc->GetWindow());
|
||||
nsresult rv = xulCommand->InitCommandEvent(NS_LITERAL_STRING("command"),
|
||||
PR_TRUE, PR_TRUE, view,
|
||||
0, aCtrl, aAlt, aShift, aMeta,
|
||||
aSourceEvent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aShell) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsCOMPtr<nsIPresShell> kungFuDeathGrip = aShell;
|
||||
return aShell->HandleDOMEventWithTarget(aTarget, event, &status);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(aTarget);
|
||||
NS_ENSURE_STATE(target);
|
||||
PRBool dummy;
|
||||
return target->DispatchEvent(event, &dummy);
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ nsresult
|
|||
NS_NewDOMSVGZoomEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsGUIEvent* aEvent);
|
||||
#endif // MOZ_SVG
|
||||
nsresult
|
||||
NS_NewDOMXULCommandEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsXULCommandEvent* aEvent);
|
||||
NS_NewDOMXULCommandEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsInputEvent* aEvent);
|
||||
nsresult
|
||||
NS_NewDOMCommandEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsCommandEvent* aEvent);
|
||||
nsresult
|
||||
|
|
|
@ -184,9 +184,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMEvent)
|
|||
static_cast<nsDragEvent*>(tmp->mEvent)->dataTransfer = nsnull;
|
||||
static_cast<nsMouseEvent_base*>(tmp->mEvent)->relatedTarget = nsnull;
|
||||
break;
|
||||
case NS_XUL_COMMAND_EVENT:
|
||||
static_cast<nsXULCommandEvent*>(tmp->mEvent)->sourceEvent = nsnull;
|
||||
break;
|
||||
case NS_MUTATION_EVENT:
|
||||
static_cast<nsMutationEvent*>(tmp->mEvent)->mRelatedNode = nsnull;
|
||||
break;
|
||||
|
@ -220,11 +217,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEvent)
|
|||
cb.NoteXPCOMChild(
|
||||
static_cast<nsMouseEvent_base*>(tmp->mEvent)->relatedTarget);
|
||||
break;
|
||||
case NS_XUL_COMMAND_EVENT:
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->sourceEvent");
|
||||
cb.NoteXPCOMChild(
|
||||
static_cast<nsXULCommandEvent*>(tmp->mEvent)->sourceEvent);
|
||||
break;
|
||||
case NS_MUTATION_EVENT:
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->mRelatedNode");
|
||||
cb.NoteXPCOMChild(
|
||||
|
@ -588,7 +580,7 @@ nsDOMEvent::SetEventType(const nsAString& aEventTypeArg)
|
|||
mEvent->message = NS_UI_FOCUSOUT;
|
||||
else if (atom == nsGkAtoms::oninput)
|
||||
mEvent->message = NS_FORM_INPUT;
|
||||
} else if (mEvent->eventStructType == NS_XUL_COMMAND_EVENT) {
|
||||
} else if (mEvent->eventStructType == NS_INPUT_EVENT) {
|
||||
if (atom == nsGkAtoms::oncommand)
|
||||
mEvent->message = NS_XUL_COMMAND;
|
||||
}
|
||||
|
@ -958,16 +950,6 @@ NS_METHOD nsDOMEvent::DuplicatePrivateData()
|
|||
break;
|
||||
}
|
||||
#endif // MOZ_SVG
|
||||
case NS_XUL_COMMAND_EVENT:
|
||||
{
|
||||
newEvent = new nsXULCommandEvent(PR_FALSE, msg, nsnull);
|
||||
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
||||
isInputEvent = PR_TRUE;
|
||||
newEvent->eventStructType = NS_XUL_COMMAND_EVENT;
|
||||
static_cast<nsXULCommandEvent*>(newEvent)->sourceEvent =
|
||||
static_cast<nsXULCommandEvent*>(mEvent)->sourceEvent;
|
||||
break;
|
||||
}
|
||||
case NS_SIMPLE_GESTURE_EVENT:
|
||||
{
|
||||
nsSimpleGestureEvent* oldSimpleGestureEvent = static_cast<nsSimpleGestureEvent*>(mEvent);
|
||||
|
@ -1130,6 +1112,9 @@ nsDOMEvent::GetEventPopupControlState(nsEvent *aEvent)
|
|||
if (::PopupAllowedForEvent("change"))
|
||||
abuse = openControlled;
|
||||
break;
|
||||
case NS_XUL_COMMAND:
|
||||
abuse = openControlled;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1211,10 +1196,6 @@ nsDOMEvent::GetEventPopupControlState(nsEvent *aEvent)
|
|||
}
|
||||
}
|
||||
break;
|
||||
case NS_XUL_COMMAND_EVENT :
|
||||
if (nsEventStateManager::IsHandlingUserInput()) {
|
||||
abuse = openControlled;
|
||||
}
|
||||
}
|
||||
|
||||
return abuse;
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
#include "nsContentUtils.h"
|
||||
|
||||
nsDOMXULCommandEvent::nsDOMXULCommandEvent(nsPresContext* aPresContext,
|
||||
nsXULCommandEvent* aEvent)
|
||||
nsInputEvent* aEvent)
|
||||
: nsDOMUIEvent(aPresContext,
|
||||
aEvent ? aEvent : new nsXULCommandEvent(PR_FALSE, 0, nsnull))
|
||||
aEvent ? aEvent : new nsInputEvent(PR_FALSE, 0, nsnull))
|
||||
{
|
||||
if (aEvent) {
|
||||
mEventIsInternal = PR_FALSE;
|
||||
|
@ -53,19 +53,22 @@ nsDOMXULCommandEvent::nsDOMXULCommandEvent(nsPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
nsDOMXULCommandEvent::~nsDOMXULCommandEvent()
|
||||
{
|
||||
if (mEventIsInternal) {
|
||||
nsXULCommandEvent* command = static_cast<nsXULCommandEvent*>(mEvent);
|
||||
delete command;
|
||||
mEvent = nsnull;
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMXULCommandEvent)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMXULCommandEvent)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMXULCommandEvent,
|
||||
nsDOMUIEvent)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mSourceEvent)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMXULCommandEvent,
|
||||
nsDOMUIEvent)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSourceEvent)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMXULCommandEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMXULCommandEvent)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(XULCommandEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
|
||||
|
@ -106,7 +109,7 @@ NS_IMETHODIMP
|
|||
nsDOMXULCommandEvent::GetSourceEvent(nsIDOMEvent** aSourceEvent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSourceEvent);
|
||||
NS_IF_ADDREF(*aSourceEvent = Event()->sourceEvent);
|
||||
NS_IF_ADDREF(*aSourceEvent = mSourceEvent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -123,12 +126,12 @@ nsDOMXULCommandEvent::InitCommandEvent(const nsAString& aType,
|
|||
aView, aDetail);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXULCommandEvent *event = Event();
|
||||
nsInputEvent *event = Event();
|
||||
event->isControl = aCtrlKey;
|
||||
event->isAlt = aAltKey;
|
||||
event->isShift = aShiftKey;
|
||||
event->isMeta = aMetaKey;
|
||||
event->sourceEvent = aSourceEvent;
|
||||
mSourceEvent = aSourceEvent;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -136,7 +139,7 @@ nsDOMXULCommandEvent::InitCommandEvent(const nsAString& aType,
|
|||
|
||||
nsresult NS_NewDOMXULCommandEvent(nsIDOMEvent** aInstancePtrResult,
|
||||
nsPresContext* aPresContext,
|
||||
nsXULCommandEvent *aEvent)
|
||||
nsInputEvent *aEvent)
|
||||
{
|
||||
nsDOMXULCommandEvent* it = new nsDOMXULCommandEvent(aPresContext, aEvent);
|
||||
if (nsnull == it) {
|
||||
|
|
|
@ -48,20 +48,22 @@ class nsDOMXULCommandEvent : public nsDOMUIEvent,
|
|||
public nsIDOMXULCommandEvent
|
||||
{
|
||||
public:
|
||||
nsDOMXULCommandEvent(nsPresContext* aPresContext, nsXULCommandEvent* aEvent);
|
||||
virtual ~nsDOMXULCommandEvent();
|
||||
nsDOMXULCommandEvent(nsPresContext* aPresContext, nsInputEvent* aEvent);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent)
|
||||
NS_DECL_NSIDOMXULCOMMANDEVENT
|
||||
|
||||
// Forward our inherited virtual methods to the base class
|
||||
NS_FORWARD_TO_NSDOMUIEVENT
|
||||
|
||||
private:
|
||||
protected:
|
||||
// Convenience accessor for the event
|
||||
nsXULCommandEvent* Event() {
|
||||
return static_cast<nsXULCommandEvent*>(mEvent);
|
||||
nsInputEvent* Event() {
|
||||
return static_cast<nsInputEvent*>(mEvent);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> mSourceEvent;
|
||||
};
|
||||
|
||||
#endif // nsDOMXULCommandEvent_h_
|
||||
|
|
|
@ -650,10 +650,6 @@ nsEventDispatcher::CreateEvent(nsPresContext* aPresContext,
|
|||
static_cast<nsGUIEvent*>(aEvent));
|
||||
#endif // MOZ_SVG
|
||||
|
||||
case NS_XUL_COMMAND_EVENT:
|
||||
return NS_NewDOMXULCommandEvent(aDOMEvent, aPresContext,
|
||||
static_cast<nsXULCommandEvent*>
|
||||
(aEvent));
|
||||
case NS_COMMAND_EVENT:
|
||||
return NS_NewDOMCommandEvent(aDOMEvent, aPresContext,
|
||||
static_cast<nsCommandEvent*>(aEvent));
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include "nsIDOMLoadListener.h"
|
||||
#include "nsIDOMTextListener.h"
|
||||
#include "nsIDOMCompositionListener.h"
|
||||
#include "nsIDOMXULListener.h"
|
||||
#include "nsIDOMUIListener.h"
|
||||
#include "nsITextControlFrame.h"
|
||||
#ifdef MOZ_SVG
|
||||
|
@ -244,17 +243,6 @@ static const EventDispatchData sLoadEvents[] = {
|
|||
{ NS_BEFORE_PAGE_UNLOAD, HANDLER(&nsIDOMLoadListener::BeforeUnload) }
|
||||
};
|
||||
|
||||
static const EventDispatchData sXULEvents[] = {
|
||||
{ NS_XUL_POPUP_SHOWING, HANDLER(&nsIDOMXULListener::PopupShowing) },
|
||||
{ NS_XUL_POPUP_SHOWN, HANDLER(&nsIDOMXULListener::PopupShown) },
|
||||
{ NS_XUL_POPUP_HIDING, HANDLER(&nsIDOMXULListener::PopupHiding) },
|
||||
{ NS_XUL_POPUP_HIDDEN, HANDLER(&nsIDOMXULListener::PopupHidden) },
|
||||
{ NS_XUL_CLOSE, HANDLER(&nsIDOMXULListener::Close) },
|
||||
{ NS_XUL_COMMAND, HANDLER(&nsIDOMXULListener::Command) },
|
||||
{ NS_XUL_BROADCAST, HANDLER(&nsIDOMXULListener::Broadcast) },
|
||||
{ NS_XUL_COMMAND_UPDATE, HANDLER(&nsIDOMXULListener::CommandUpdate) }
|
||||
};
|
||||
|
||||
static const EventDispatchData sUIEvents[] = {
|
||||
{ NS_UI_ACTIVATE, HANDLER(&nsIDOMUIListener::Activate) },
|
||||
{ NS_UI_FOCUSIN, HANDLER(&nsIDOMUIListener::FocusIn) },
|
||||
|
@ -280,7 +268,6 @@ static const EventTypeData sEventTypes[] = {
|
|||
IMPL_EVENTTYPEDATA(Form),
|
||||
IMPL_EVENTTYPEDATA(Text),
|
||||
IMPL_EVENTTYPEDATA(Composition),
|
||||
IMPL_EVENTTYPEDATA(XUL),
|
||||
IMPL_EVENTTYPEDATA(UI)
|
||||
};
|
||||
|
||||
|
|
|
@ -79,7 +79,6 @@
|
|||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMFormListener.h"
|
||||
#include "nsIDOMXULListener.h"
|
||||
#include "nsIDOMContextMenuListener.h"
|
||||
#include "nsIDOMEventGroup.h"
|
||||
#include "nsAttrName.h"
|
||||
|
|
|
@ -528,9 +528,6 @@ nsXBLPrototypeHandler::DispatchXULKeyCommand(nsIDOMEvent* aEvent)
|
|||
|
||||
aEvent->PreventDefault();
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsXULCommandEvent event(PR_TRUE, NS_XUL_COMMAND, nsnull);
|
||||
|
||||
// Copy the modifiers from the key event.
|
||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent);
|
||||
if (!keyEvent) {
|
||||
|
@ -538,21 +535,18 @@ nsXBLPrototypeHandler::DispatchXULKeyCommand(nsIDOMEvent* aEvent)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
keyEvent->GetAltKey(&event.isAlt);
|
||||
keyEvent->GetCtrlKey(&event.isControl);
|
||||
keyEvent->GetShiftKey(&event.isShift);
|
||||
keyEvent->GetMetaKey(&event.isMeta);
|
||||
PRBool isAlt = PR_FALSE;
|
||||
PRBool isControl = PR_FALSE;
|
||||
PRBool isShift = PR_FALSE;
|
||||
PRBool isMeta = PR_FALSE;
|
||||
keyEvent->GetAltKey(&isAlt);
|
||||
keyEvent->GetCtrlKey(&isControl);
|
||||
keyEvent->GetShiftKey(&isShift);
|
||||
keyEvent->GetMetaKey(&isMeta);
|
||||
|
||||
nsPresContext *pc = nsnull;
|
||||
nsIDocument *doc = handlerElement->GetCurrentDoc();
|
||||
if (doc) {
|
||||
nsIPresShell *shell = doc->GetPrimaryShell();
|
||||
if (shell) {
|
||||
pc = shell->GetPresContext();
|
||||
}
|
||||
}
|
||||
|
||||
nsEventDispatcher::Dispatch(handlerElement, pc, &event, nsnull, &status);
|
||||
nsContentUtils::DispatchXULCommand(handlerElement, PR_TRUE,
|
||||
nsnull, nsnull,
|
||||
isControl, isAlt, isShift, isMeta);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@
|
|||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMFormListener.h"
|
||||
#include "nsIDOMXULListener.h"
|
||||
#include "nsIDOMContextMenuListener.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
|
@ -1576,13 +1575,18 @@ nsXULElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
|||
return NS_OK;
|
||||
}
|
||||
if (aVisitor.mEvent->message == NS_XUL_COMMAND &&
|
||||
aVisitor.mEvent->eventStructType == NS_INPUT_EVENT &&
|
||||
aVisitor.mEvent->originalTarget == static_cast<nsIContent*>(this) &&
|
||||
tag != nsGkAtoms::command) {
|
||||
// Check that we really have an xul command event. That will be handled
|
||||
// in a special way.
|
||||
nsCOMPtr<nsIDOMXULCommandEvent> xulEvent =
|
||||
do_QueryInterface(aVisitor.mDOMEvent);
|
||||
// See if we have a command elt. If so, we execute on the command
|
||||
// instead of on our content element.
|
||||
nsAutoString command;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::command, command);
|
||||
if (!command.IsEmpty()) {
|
||||
if (xulEvent && GetAttr(kNameSpaceID_None, nsGkAtoms::command, command) &&
|
||||
!command.IsEmpty()) {
|
||||
// Stop building the event target chain for the original event.
|
||||
// We don't want it to propagate to any DOM nodes.
|
||||
aVisitor.mCanHandle = PR_FALSE;
|
||||
|
@ -1598,29 +1602,6 @@ nsXULElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
|||
// pointed to by the command attribute. The new event's
|
||||
// sourceEvent will be the original command event that we're
|
||||
// handling.
|
||||
|
||||
nsXULCommandEvent event(NS_IS_TRUSTED_EVENT(aVisitor.mEvent),
|
||||
NS_XUL_COMMAND, nsnull);
|
||||
if (aVisitor.mEvent->eventStructType == NS_XUL_COMMAND_EVENT) {
|
||||
nsXULCommandEvent *orig =
|
||||
static_cast<nsXULCommandEvent*>(aVisitor.mEvent);
|
||||
|
||||
event.isShift = orig->isShift;
|
||||
event.isControl = orig->isControl;
|
||||
event.isAlt = orig->isAlt;
|
||||
event.isMeta = orig->isMeta;
|
||||
} else {
|
||||
NS_WARNING("Incorrect eventStructType for command event");
|
||||
}
|
||||
|
||||
if (!aVisitor.mDOMEvent) {
|
||||
// We need to create a new DOMEvent for the original event
|
||||
nsEventDispatcher::CreateEvent(aVisitor.mPresContext,
|
||||
aVisitor.mEvent,
|
||||
EmptyString(),
|
||||
&aVisitor.mDOMEvent);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent =
|
||||
do_QueryInterface(aVisitor.mDOMEvent);
|
||||
while (nsevent) {
|
||||
|
@ -1636,12 +1617,17 @@ nsXULElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
|||
nsevent = do_QueryInterface(tmp);
|
||||
}
|
||||
|
||||
event.sourceEvent = aVisitor.mDOMEvent;
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEventDispatcher::Dispatch(commandContent,
|
||||
aVisitor.mPresContext,
|
||||
&event, nsnull, &status);
|
||||
nsInputEvent* orig =
|
||||
static_cast<nsInputEvent*>(aVisitor.mEvent);
|
||||
nsContentUtils::DispatchXULCommand(
|
||||
commandContent,
|
||||
NS_IS_TRUSTED_EVENT(aVisitor.mEvent),
|
||||
aVisitor.mDOMEvent,
|
||||
nsnull,
|
||||
orig->isControl,
|
||||
orig->isAlt,
|
||||
orig->isShift,
|
||||
orig->isMeta);
|
||||
} else {
|
||||
NS_WARNING("A XUL element is attached to a command that doesn't exist!\n");
|
||||
}
|
||||
|
@ -2132,15 +2118,7 @@ nsXULElement::DoCommand()
|
|||
{
|
||||
nsCOMPtr<nsIDocument> doc = GetCurrentDoc(); // strong just in case
|
||||
if (doc) {
|
||||
nsPresShellIterator iter(doc);
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
while ((shell = iter.GetNextShell())) {
|
||||
nsCOMPtr<nsPresContext> context = shell->GetPresContext();
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsXULCommandEvent event(PR_TRUE, NS_XUL_COMMAND, nsnull);
|
||||
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this),
|
||||
context, &event, nsnull, &status);
|
||||
}
|
||||
nsContentUtils::DispatchXULCommand(this, PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -53,7 +53,6 @@ EXPORTS = \
|
|||
nsIDOMMouseMotionListener.h \
|
||||
nsIDOMTextListener.h \
|
||||
nsIDOMCompositionListener.h \
|
||||
nsIDOMXULListener.h \
|
||||
nsIDOMContextMenuListener.h \
|
||||
nsIDOMUIListener.h \
|
||||
$(NULL)
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#ifndef nsIDOMXULListener_h__
|
||||
#define nsIDOMXULListener_h__
|
||||
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
|
||||
// {0730C841-42F3-11d3-97FA-00400553EEF0}
|
||||
#define NS_IDOMXULLISTENER_IID \
|
||||
{ 0x730c841, 0x42f3, 0x11d3, { 0x97, 0xfa, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
|
||||
|
||||
class nsIDOMXULListener : public nsIDOMEventListener {
|
||||
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMXULLISTENER_IID)
|
||||
|
||||
NS_IMETHOD PopupShowing(nsIDOMEvent* aEvent) = 0;
|
||||
NS_IMETHOD PopupShown(nsIDOMEvent* aEvent) = 0;
|
||||
NS_IMETHOD PopupHiding(nsIDOMEvent* aEvent) = 0;
|
||||
NS_IMETHOD PopupHidden(nsIDOMEvent* aEvent) = 0;
|
||||
|
||||
NS_IMETHOD Close(nsIDOMEvent* aEvent) = 0;
|
||||
NS_IMETHOD Command(nsIDOMEvent* aEvent) = 0;
|
||||
NS_IMETHOD Broadcast(nsIDOMEvent* aEvent) = 0;
|
||||
NS_IMETHOD CommandUpdate(nsIDOMEvent* aEvent) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMXULListener, NS_IDOMXULLISTENER_IID)
|
||||
|
||||
#endif // nsIDOMXULListener_h__
|
|
@ -97,14 +97,15 @@ class nsIScrollableFrame;
|
|||
class gfxASurface;
|
||||
class gfxContext;
|
||||
class nsPIDOMEventTarget;
|
||||
class nsIDOMEvent;
|
||||
|
||||
typedef short SelectionType;
|
||||
typedef PRUint32 nsFrameState;
|
||||
|
||||
// 41FE90F8-88DF-476E-A3B0-60916234F791
|
||||
// 189d234b-3823-4e8f-bbd2-63c0282b9fac
|
||||
#define NS_IPRESSHELL_IID \
|
||||
{ 0x41fe90f8, 0x88df, 0x476e, \
|
||||
{ 0xa3, 0xb0, 0x60, 0x91, 0x62, 0x34, 0xf7, 0x91 } }
|
||||
{ 0x189d234b, 0x3823, 0x4e8f, \
|
||||
{ 0xbb, 0xd2, 0x63, 0xc0, 0x28, 0x2b, 0x9f, 0xac } }
|
||||
|
||||
// Constants for ScrollContentIntoView() function
|
||||
#define NS_PRESSHELL_SCROLL_TOP 0
|
||||
|
@ -574,6 +575,14 @@ public:
|
|||
nsEvent* aEvent,
|
||||
nsEventStatus* aStatus) = 0;
|
||||
|
||||
/**
|
||||
* Dispatch event to content only (NOT full processing)
|
||||
* @note The caller must have a strong reference to the PresShell.
|
||||
*/
|
||||
NS_IMETHOD HandleDOMEventWithTarget(nsIContent* aTargetContent,
|
||||
nsIDOMEvent* aEvent,
|
||||
nsEventStatus* aStatus) = 0;
|
||||
|
||||
/**
|
||||
* Gets the current target event frame from the PresShell
|
||||
*/
|
||||
|
|
|
@ -919,6 +919,9 @@ public:
|
|||
NS_IMETHOD HandleDOMEventWithTarget(nsIContent* aTargetContent,
|
||||
nsEvent* aEvent,
|
||||
nsEventStatus* aStatus);
|
||||
NS_IMETHOD HandleDOMEventWithTarget(nsIContent* aTargetContent,
|
||||
nsIDOMEvent* aEvent,
|
||||
nsEventStatus* aStatus);
|
||||
NS_IMETHOD ResizeReflow(nsIView *aView, nscoord aWidth, nscoord aHeight);
|
||||
NS_IMETHOD_(PRBool) IsVisible();
|
||||
NS_IMETHOD_(void) WillPaint();
|
||||
|
@ -6381,6 +6384,23 @@ PresShell::HandleDOMEventWithTarget(nsIContent* aTargetContent, nsEvent* aEvent,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// See the method above.
|
||||
NS_IMETHODIMP
|
||||
PresShell::HandleDOMEventWithTarget(nsIContent* aTargetContent,
|
||||
nsIDOMEvent* aEvent,
|
||||
nsEventStatus* aStatus)
|
||||
{
|
||||
PushCurrentEventInfo(nsnull, aTargetContent);
|
||||
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
|
||||
if (container) {
|
||||
nsEventDispatcher::DispatchDOMEvent(aTargetContent, nsnull, aEvent,
|
||||
mPresContext, aStatus);
|
||||
}
|
||||
|
||||
PopCurrentEventInfo();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
PresShell::AdjustContextMenuKeyEvent(nsMouseEvent* aEvent)
|
||||
{
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsIEventStateManager.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
//
|
||||
// NS_NewXULButtonFrame
|
||||
|
@ -149,19 +150,24 @@ nsButtonBoxFrame::DoMouseClick(nsGUIEvent* aEvent, PRBool aTrustEvent)
|
|||
return;
|
||||
|
||||
// Execute the oncommand event handler.
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsXULCommandEvent event(aEvent ? NS_IS_TRUSTED_EVENT(aEvent) : aTrustEvent,
|
||||
NS_XUL_COMMAND, nsnull);
|
||||
PRBool isShift = PR_FALSE;
|
||||
PRBool isControl = PR_FALSE;
|
||||
PRBool isAlt = PR_FALSE;
|
||||
PRBool isMeta = PR_FALSE;
|
||||
if(aEvent) {
|
||||
event.isShift = ((nsInputEvent*)(aEvent))->isShift;
|
||||
event.isControl = ((nsInputEvent*)(aEvent))->isControl;
|
||||
event.isAlt = ((nsInputEvent*)(aEvent))->isAlt;
|
||||
event.isMeta = ((nsInputEvent*)(aEvent))->isMeta;
|
||||
isShift = ((nsInputEvent*)(aEvent))->isShift;
|
||||
isControl = ((nsInputEvent*)(aEvent))->isControl;
|
||||
isAlt = ((nsInputEvent*)(aEvent))->isAlt;
|
||||
isMeta = ((nsInputEvent*)(aEvent))->isMeta;
|
||||
}
|
||||
|
||||
// Have the content handle the event, propagating it according to normal DOM rules.
|
||||
nsCOMPtr<nsIPresShell> shell = PresContext()->GetPresShell();
|
||||
if (shell) {
|
||||
shell->HandleDOMEventWithTarget(mContent, &event, &status);
|
||||
nsContentUtils::DispatchXULCommand(mContent,
|
||||
aEvent ?
|
||||
NS_IS_TRUSTED_EVENT(aEvent) : aTrustEvent,
|
||||
nsnull, shell,
|
||||
isControl, isAlt, isShift, isMeta);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsPIDOMWindow.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
//
|
||||
// NS_NewResizerFrame
|
||||
|
@ -259,10 +260,7 @@ void
|
|||
nsResizerFrame::MouseClicked(nsPresContext* aPresContext, nsGUIEvent *aEvent)
|
||||
{
|
||||
// Execute the oncommand event handler.
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
|
||||
nsXULCommandEvent event(aEvent ? NS_IS_TRUSTED_EVENT(aEvent) : PR_FALSE,
|
||||
NS_XUL_COMMAND, nsnull);
|
||||
|
||||
nsEventDispatcher::Dispatch(mContent, aPresContext, &event, nsnull, &status);
|
||||
nsContentUtils::DispatchXULCommand(mContent,
|
||||
aEvent ?
|
||||
NS_IS_TRUSTED_EVENT(aEvent) : PR_FALSE);
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "nsGUIEvent.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
//
|
||||
// NS_NewTitleBarFrame
|
||||
|
@ -242,10 +243,7 @@ void
|
|||
nsTitleBarFrame::MouseClicked(nsPresContext* aPresContext, nsGUIEvent* aEvent)
|
||||
{
|
||||
// Execute the oncommand event handler.
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
|
||||
nsXULCommandEvent event(aEvent ? NS_IS_TRUSTED_EVENT(aEvent) : PR_FALSE,
|
||||
NS_XUL_COMMAND, nsnull);
|
||||
|
||||
nsEventDispatcher::Dispatch(mContent, aPresContext, &event, nsnull, &status);
|
||||
nsContentUtils::DispatchXULCommand(mContent,
|
||||
aEvent ?
|
||||
NS_IS_TRUSTED_EVENT(aEvent) : PR_FALSE);
|
||||
}
|
||||
|
|
|
@ -2091,14 +2091,8 @@ nsXULMenuCommandEvent::Run()
|
|||
menuFrame->SelectMenu(PR_FALSE);
|
||||
|
||||
nsAutoHandlingUserInputStatePusher userInpStatePusher(mUserInput);
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsXULCommandEvent commandEvent(mIsTrusted, NS_XUL_COMMAND, nsnull);
|
||||
commandEvent.isShift = mShift;
|
||||
commandEvent.isControl = mControl;
|
||||
commandEvent.isAlt = mAlt;
|
||||
commandEvent.isMeta = mMeta;
|
||||
shell->HandleDOMEventWithTarget(mMenu, &commandEvent, &status);
|
||||
nsContentUtils::DispatchXULCommand(mMenu, mIsTrusted, nsnull, shell,
|
||||
mControl, mAlt, mShift, mMeta);
|
||||
}
|
||||
|
||||
if (popup && mCloseMenuMode != CloseMenuMode_None)
|
||||
|
|
|
@ -107,7 +107,6 @@ NS_INTERFACE_MAP_BEGIN(nsXULTooltipListener)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseMotionListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMXULListener)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMMouseListener)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMouseMotionListener)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
@ -312,6 +311,9 @@ nsXULTooltipListener::HandleEvent(nsIDOMEvent* aEvent)
|
|||
aEvent->GetType(type);
|
||||
if (type.EqualsLiteral("DOMMouseScroll") || type.EqualsLiteral("dragstart"))
|
||||
HideTooltip();
|
||||
else if (type.EqualsLiteral("popuphiding"))
|
||||
DestroyTooltip();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -329,13 +331,6 @@ nsXULTooltipListener::ToolbarTipsPrefChanged(const char *aPref,
|
|||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULTooltipListener::PopupHiding(nsIDOMEvent* aEvent)
|
||||
{
|
||||
DestroyTooltip();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// nsXULTooltipListener
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include "nsIDOMMouseMotionListener.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIDOMXULListener.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsITimer.h"
|
||||
|
@ -56,8 +55,7 @@
|
|||
|
||||
class nsXULTooltipListener : public nsIDOMMouseListener,
|
||||
public nsIDOMMouseMotionListener,
|
||||
public nsIDOMKeyListener,
|
||||
public nsIDOMXULListener
|
||||
public nsIDOMKeyListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -79,16 +77,6 @@ public:
|
|||
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent) { return NS_OK; }
|
||||
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent) { return NS_OK; }
|
||||
|
||||
// nsIDOMXULListener
|
||||
NS_IMETHOD PopupShowing(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD PopupShown(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD PopupHiding(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PopupHidden(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD Close(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD Command(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD Broadcast(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD CommandUpdate(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
// nsIDOMEventListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ class nsIMenuItem;
|
|||
class nsIAccessible;
|
||||
class nsIContent;
|
||||
class nsIURI;
|
||||
class nsIDOMEvent;
|
||||
class nsHashKey;
|
||||
|
||||
/**
|
||||
|
@ -96,7 +95,7 @@ class nsHashKey;
|
|||
#define NS_SVG_EVENT 30
|
||||
#define NS_SVGZOOM_EVENT 31
|
||||
#endif // MOZ_SVG
|
||||
#define NS_XUL_COMMAND_EVENT 32
|
||||
|
||||
#define NS_QUERY_CONTENT_EVENT 33
|
||||
#ifdef MOZ_MEDIA
|
||||
#define NS_MEDIA_EVENT 34
|
||||
|
@ -1208,20 +1207,6 @@ public:
|
|||
PRInt32 detail;
|
||||
};
|
||||
|
||||
/**
|
||||
* XUL command event
|
||||
*/
|
||||
class nsXULCommandEvent : public nsInputEvent
|
||||
{
|
||||
public:
|
||||
nsXULCommandEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
|
||||
: nsInputEvent(isTrusted, msg, w, NS_XUL_COMMAND_EVENT)
|
||||
{
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> sourceEvent;
|
||||
};
|
||||
|
||||
/**
|
||||
* Simple gesture event
|
||||
*/
|
||||
|
|
|
@ -218,10 +218,7 @@ void nsMenuItemX::DoCommand()
|
|||
/* the AttributeChanged code will update all the internal state */
|
||||
}
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsXULCommandEvent event(PR_TRUE, NS_XUL_COMMAND, nsnull);
|
||||
|
||||
mContent->DispatchDOMEvent(&event, nsnull, nsnull, &status);
|
||||
nsMenuUtilsX::DispatchCommandTo(mContent);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ extern "C" MenuRef _NSGetCarbonMenu(NSMenu* aMenu);
|
|||
// Namespace containing utility functions used in our native menu implementation.
|
||||
namespace nsMenuUtilsX
|
||||
{
|
||||
nsEventStatus DispatchCommandTo(nsIContent* aTargetContent);
|
||||
void DispatchCommandTo(nsIContent* aTargetContent);
|
||||
NSString* GetTruncatedCocoaLabel(const nsString& itemLabel);
|
||||
PRUint8 GeckoModifiersForNodeAttribute(const nsString& modifiersAttribute);
|
||||
unsigned int MacModifiersForGeckoModifiers(PRUint8 geckoModifiers);
|
||||
|
|
|
@ -44,19 +44,41 @@
|
|||
#include "nsCocoaUtils.h"
|
||||
#include "nsCocoaWindow.h"
|
||||
#include "nsWidgetAtoms.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMXULCommandEvent.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDOMAbstractView.h"
|
||||
|
||||
nsEventStatus nsMenuUtilsX::DispatchCommandTo(nsIContent* aTargetContent)
|
||||
void nsMenuUtilsX::DispatchCommandTo(nsIContent* aTargetContent)
|
||||
{
|
||||
NS_PRECONDITION(aTargetContent, "null ptr");
|
||||
|
||||
nsEventStatus status = nsEventStatus_eConsumeNoDefault;
|
||||
nsXULCommandEvent event(PR_TRUE, NS_XUL_COMMAND, nsnull);
|
||||
nsIDocument* doc = aTargetContent->GetOwnerDoc();
|
||||
nsCOMPtr<nsIDOMDocumentEvent> docEvent = do_QueryInterface(doc);
|
||||
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(aTargetContent);
|
||||
if (docEvent && target) {
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
docEvent->CreateEvent(NS_LITERAL_STRING("xulcommandevent"),
|
||||
getter_AddRefs(event));
|
||||
nsCOMPtr<nsIDOMXULCommandEvent> command = do_QueryInterface(event);
|
||||
nsCOMPtr<nsIPrivateDOMEvent> pEvent = do_QueryInterface(command);
|
||||
nsCOMPtr<nsIDOMAbstractView> view = do_QueryInterface(doc->GetWindow());
|
||||
|
||||
// FIXME: Should probably figure out how to init this with the actual
|
||||
// pressed keys, but this is a big old edge case anyway. -dwh
|
||||
|
||||
aTargetContent->DispatchDOMEvent(&event, nsnull, nsnull, &status);
|
||||
return status;
|
||||
// FIXME: Should probably figure out how to init this with the actual
|
||||
// pressed keys, but this is a big old edge case anyway. -dwh
|
||||
if (pEvent &&
|
||||
NS_SUCCEEDED(command->InitCommandEvent(NS_LITERAL_STRING("command"),
|
||||
PR_TRUE, PR_TRUE, view, 0,
|
||||
PR_FALSE, PR_FALSE, PR_FALSE,
|
||||
PR_FALSE, nsnull))) {
|
||||
pEvent->SetTrusted(PR_TRUE);
|
||||
PRBool dummy;
|
||||
target->DispatchEvent(event, &dummy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче