Bug 282438. Fire menupopupend for context menus and autocomplete. r=bryner, sr=neil

This commit is contained in:
aaronleventhal%moonset.net 2005-02-18 14:28:36 +00:00
Родитель aa07ce39b3
Коммит b390d6bd1c
4 изменённых файлов: 16 добавлений и 7 удалений

Просмотреть файл

@ -2565,19 +2565,20 @@ nsBoxFrame::RegUnregAccessKey(nsPresContext* aPresContext, PRBool aDoReg)
void void
nsBoxFrame::FireDOMEvent(const nsAString& aDOMEventName) nsBoxFrame::FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent)
{ {
if (mContent && mPresContext) { nsIContent *content = aContent ? aContent : mContent;
// Fire a DOM event for the title change. if (content && mPresContext) {
// Fire a DOM event
nsCOMPtr<nsIDOMEvent> event; nsCOMPtr<nsIDOMEvent> event;
nsCOMPtr<nsIEventListenerManager> manager; nsCOMPtr<nsIEventListenerManager> manager;
mContent->GetListenerManager(getter_AddRefs(manager)); content->GetListenerManager(getter_AddRefs(manager));
if (manager && NS_SUCCEEDED(manager->CreateEvent(mPresContext, nsnull, if (manager && NS_SUCCEEDED(manager->CreateEvent(mPresContext, nsnull,
NS_LITERAL_STRING("Events"), NS_LITERAL_STRING("Events"),
getter_AddRefs(event)))) { getter_AddRefs(event)))) {
event->InitEvent(aDOMEventName, PR_TRUE, PR_TRUE); event->InitEvent(aDOMEventName, PR_TRUE, PR_TRUE);
PRBool noDefault; PRBool noDefault;
mPresContext->EventStateManager()->DispatchNewEvent(mContent, event, mPresContext->EventStateManager()->DispatchNewEvent(content, event,
&noDefault); &noDefault);
} }
} }

Просмотреть файл

@ -204,7 +204,8 @@ public:
static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect); static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect);
void FireDOMEvent(const nsAString& aDOMEventName); // Fire DOM event. If no aContent argument use frame's mContent.
void FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent = nsnull);
protected: protected:
#ifdef DEBUG_LAYOUT #ifdef DEBUG_LAYOUT

Просмотреть файл

@ -77,6 +77,7 @@ nsPopupFrameList::nsPopupFrameList(nsIContent* aPopupContent, nsPopupFrameList*
mPopupContent(aPopupContent), mPopupContent(aPopupContent),
mElementContent(nsnull), mElementContent(nsnull),
mCreateHandlerSucceeded(PR_FALSE), mCreateHandlerSucceeded(PR_FALSE),
mIsOpen(PR_FALSE),
mLastPref(-1,-1) mLastPref(-1,-1)
{ {
} }
@ -377,6 +378,7 @@ nsPopupSetFrame::ShowPopup(nsIContent* aElementContent, nsIContent* aPopupConten
// Generate the popup. // Generate the popup.
entry->mCreateHandlerSucceeded = PR_TRUE; entry->mCreateHandlerSucceeded = PR_TRUE;
entry->mIsOpen = PR_TRUE;
MarkAsGenerated(aPopupContent); MarkAsGenerated(aPopupContent);
// determine if this menu is a context menu and flag it // determine if this menu is a context menu and flag it
@ -568,6 +570,10 @@ nsPopupSetFrame::ActivatePopup(nsPopupFrameList* aEntry, PRBool aActivateFlag)
viewManager->SetViewVisibility(view, nsViewVisibility_kHide); viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
nsRect r(0, 0, 0, 0); nsRect r(0, 0, 0, 0);
viewManager->ResizeView(view, r); viewManager->ResizeView(view, r);
if (aEntry->mIsOpen) {
aEntry->mIsOpen = PR_FALSE;
FireDOMEvent(NS_LITERAL_STRING("DOMMenuInactive"), aEntry->mPopupContent);
}
} }
} }
} }

Просмотреть файл

@ -72,7 +72,8 @@ struct nsPopupFrameList {
nsAutoString mPopupAlign; // This child's align. nsAutoString mPopupAlign; // This child's align.
nsAutoString mPopupType; nsAutoString mPopupType;
PRBool mCreateHandlerSucceeded; // Did the create handler succeed? PRPackedBool mCreateHandlerSucceeded; // Did the create handler succeed?
PRPackedBool mIsOpen;
nsSize mLastPref; nsSize mLastPref;
public: public: