Bug 292326. Make events coming from the repeating timer in nsAutoButtonBoxFrame be trusted if the original mouse click was trusted. r+sr=jst,a=asa

This commit is contained in:
roc+%cs.cmu.edu 2005-05-05 00:07:59 +00:00
parent 7004daecc0
commit 6dd1089550
3 changed files with 21 additions and 29 deletions

View File

@ -150,7 +150,7 @@ nsButtonBoxFrame::HandleEvent(nsPresContext* aPresContext,
} }
void void
nsButtonBoxFrame::MouseClicked(nsPresContext* aPresContext, nsGUIEvent* aEvent) nsButtonBoxFrame::DoMouseClick(nsGUIEvent* aEvent, PRBool aTrustEvent)
{ {
// Don't execute if we're disabled. // Don't execute if we're disabled.
nsAutoString disabled; nsAutoString disabled;
@ -160,7 +160,7 @@ nsButtonBoxFrame::MouseClicked(nsPresContext* aPresContext, nsGUIEvent* aEvent)
// Execute the oncommand event handler. // Execute the oncommand event handler.
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(aEvent ? NS_IS_TRUSTED_EVENT(aEvent) : PR_FALSE, nsMouseEvent event(aEvent ? NS_IS_TRUSTED_EVENT(aEvent) : aTrustEvent,
NS_XUL_COMMAND, nsnull, nsMouseEvent::eReal); NS_XUL_COMMAND, nsnull, nsMouseEvent::eReal);
if(aEvent) { if(aEvent) {
event.isShift = ((nsInputEvent*)(aEvent))->isShift; event.isShift = ((nsInputEvent*)(aEvent))->isShift;
@ -170,7 +170,7 @@ nsButtonBoxFrame::MouseClicked(nsPresContext* aPresContext, nsGUIEvent* aEvent)
} }
// Have the content handle the event, propagating it according to normal DOM rules. // Have the content handle the event, propagating it according to normal DOM rules.
nsIPresShell *shell = aPresContext->GetPresShell(); nsIPresShell *shell = GetPresContext()->GetPresShell();
if (shell) { if (shell) {
shell->HandleDOMEventWithTarget(mContent, &event, &status); shell->HandleDOMEventWithTarget(mContent, &event, &status);
// shell may no longer be alive, don't use it here unless you keep a ref // shell may no longer be alive, don't use it here unless you keep a ref

View File

@ -57,9 +57,14 @@ public:
NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough); NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough);
virtual void MouseClicked (nsPresContext* aPresContext, nsGUIEvent* aEvent); virtual void MouseClicked (nsPresContext* aPresContext, nsGUIEvent* aEvent)
{ DoMouseClick(aEvent, PR_FALSE); }
/**
* Our implementation of MouseClicked.
* @param aTrustEvent if PR_TRUE and aEvent as null, then assume the event was trusted
*/
void DoMouseClick(nsGUIEvent* aEvent, PRBool aTrustEvent);
}; // class nsButtonBoxFrame }; // class nsButtonBoxFrame
#endif /* nsButtonBoxFrame_h___ */ #endif /* nsButtonBoxFrame_h___ */

View File

@ -75,15 +75,10 @@ public:
nsGUIEvent* aEvent, nsGUIEvent* aEvent,
nsEventStatus* aEventStatus); nsEventStatus* aEventStatus);
NS_IMETHOD Init(nsPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsStyleContext* aContext,
nsIFrame* aPrevInFlow);
NS_DECL_NSITIMERCALLBACK NS_DECL_NSITIMERCALLBACK
nsPresContext* mPresContext;
protected:
PRPackedBool mTrustedEvent;
}; };
nsresult nsresult
@ -108,17 +103,6 @@ nsAutoRepeatBoxFrame::nsAutoRepeatBoxFrame(nsIPresShell* aPresShell)
{ {
} }
NS_IMETHODIMP
nsAutoRepeatBoxFrame::Init(nsPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
mPresContext = aPresContext;
return nsButtonBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
}
NS_INTERFACE_MAP_BEGIN(nsAutoRepeatBoxFrame) NS_INTERFACE_MAP_BEGIN(nsAutoRepeatBoxFrame)
NS_INTERFACE_MAP_ENTRY(nsITimerCallback) NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
NS_INTERFACE_MAP_END_INHERITING(nsButtonBoxFrame) NS_INTERFACE_MAP_END_INHERITING(nsButtonBoxFrame)
@ -135,13 +119,16 @@ nsAutoRepeatBoxFrame::HandleEvent(nsPresContext* aPresContext,
{ {
case NS_MOUSE_ENTER: case NS_MOUSE_ENTER:
case NS_MOUSE_ENTER_SYNTH: case NS_MOUSE_ENTER_SYNTH:
nsRepeatService::GetInstance()->Start(this); nsRepeatService::GetInstance()->Start(this);
break; mTrustedEvent = NS_IS_TRUSTED_EVENT(aEvent);
break;
case NS_MOUSE_EXIT: case NS_MOUSE_EXIT:
case NS_MOUSE_EXIT_SYNTH: case NS_MOUSE_EXIT_SYNTH:
nsRepeatService::GetInstance()->Stop(); nsRepeatService::GetInstance()->Stop();
break; // Not really necessary but do this to be safe
mTrustedEvent = PR_FALSE;
break;
} }
return nsButtonBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus); return nsButtonBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
@ -150,7 +137,7 @@ nsAutoRepeatBoxFrame::HandleEvent(nsPresContext* aPresContext,
NS_IMETHODIMP NS_IMETHODIMP
nsAutoRepeatBoxFrame::Notify(nsITimer *timer) nsAutoRepeatBoxFrame::Notify(nsITimer *timer)
{ {
MouseClicked(mPresContext, nsnull); DoMouseClick(nsnull, mTrustedEvent);
return NS_OK; return NS_OK;
} }