From 75d7a96f194e7dc8be4fd9a29e9554b869f56964 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Tue, 21 Sep 1999 21:20:50 +0000 Subject: [PATCH] Added nsIRollupListener for rolling up the dropdown git-svn-id: svn://10.0.0.236/trunk@48625 18797224-902f-48f8-a5cc-f745e15eee43 --- .../layout/forms/nsComboboxControlFrame.cpp | 47 +++++++++++++++++-- mozilla/layout/forms/nsComboboxControlFrame.h | 8 +++- .../html/forms/src/nsComboboxControlFrame.cpp | 47 +++++++++++++++++-- .../html/forms/src/nsComboboxControlFrame.h | 8 +++- 4 files changed, 98 insertions(+), 12 deletions(-) diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index e3317e62d6f..8696ace3ef2 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -159,6 +159,10 @@ nsComboboxControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) *aInstancePtr = (void *)(nsIStatefulFrame*)this; NS_ADDREF_THIS(); return NS_OK; + } else if (aIID.Equals(nsCOMTypeInfo::GetIID())) { + *aInstancePtr = (void*)(nsIRollupListener*)this; + NS_ADDREF_THIS(); + return NS_OK; } return nsAreaFrame::QueryInterface(aIID, aInstancePtr); } @@ -356,6 +360,21 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup) void nsComboboxControlFrame::ShowList(nsIPresContext* aPresContext, PRBool aShowList) { + nsIWidget * widget = nsnull; + + // Get parent view + nsIFrame * listFrame; + if (NS_OK == mListControlFrame->QueryInterface(kIFrameIID, (void **)&listFrame)) { + nsIView * view = nsnull; + listFrame->GetView(&view); + NS_ASSERTION(view != nsnull, "nsComboboxControlFrame view is null"); + view->GetWidget(widget); + if (nsnull != widget) { + widget->CaptureRollupEvents((nsIRollupListener *)this, !mDroppedDown); + NS_RELEASE(widget); + } + } + if (PR_TRUE == aShowList) { ShowPopup(PR_TRUE); mDroppedDown = PR_TRUE; @@ -954,11 +973,9 @@ nsComboboxControlFrame::ListWasSelected(nsIPresContext* aPresContext) NS_IMETHODIMP nsComboboxControlFrame::ToggleList(nsIPresContext* aPresContext) { - if (PR_TRUE == mDroppedDown) { - ShowList(aPresContext, PR_FALSE); - } else { - ShowList(aPresContext, PR_TRUE); - } + + ShowList(aPresContext, (PR_FALSE == mDroppedDown)); + return NS_OK; } @@ -1393,6 +1410,26 @@ nsComboboxControlFrame::Blur(nsIDOMEvent* aEvent) return NS_OK; } +/*nsresult +nsComboboxControlFrame::HandleEvent(nsIDOMEvent* aEvent) +{ + ToggleList(mPresContext); + return NS_OK; +}*/ + +//---------------------------------------------------------------------- + //nsIRollupListener +//---------------------------------------------------------------------- +NS_IMETHODIMP +nsComboboxControlFrame::Rollup() +{ + if (mDroppedDown) { + ShowDropDown(PR_FALSE); + mListControlFrame->CaptureMouseEvents(PR_FALSE); + } + return NS_OK; +} + //---------------------------------------------------------------------- // nsIStatefulFrame // XXX Do we need to implement this here? It is already implemented in diff --git a/mozilla/layout/forms/nsComboboxControlFrame.h b/mozilla/layout/forms/nsComboboxControlFrame.h index e63a511827b..8929af38470 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.h +++ b/mozilla/layout/forms/nsComboboxControlFrame.h @@ -29,6 +29,7 @@ #include "nsIAnonymousContentCreator.h" #include "nsISelectControlFrame.h" #include "nsIStatefulFrame.h" +#include "nsIRollupListener.h" class nsButtonControlFrame; class nsTextControlFrame; @@ -51,7 +52,8 @@ class nsComboboxControlFrame : public nsAreaFrame, public nsIDOMFocusListener, public nsIAnonymousContentCreator, public nsISelectControlFrame, - public nsIStatefulFrame + public nsIStatefulFrame, + public nsIRollupListener { public: nsComboboxControlFrame(); @@ -161,6 +163,10 @@ public: NS_IMETHOD SaveState(nsISupports** aState); NS_IMETHOD RestoreState(nsISupports* aState); + //nsIRollupListener + NS_IMETHOD Rollup(); + + protected: // nsHTMLContainerFrame diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index e3317e62d6f..8696ace3ef2 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -159,6 +159,10 @@ nsComboboxControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) *aInstancePtr = (void *)(nsIStatefulFrame*)this; NS_ADDREF_THIS(); return NS_OK; + } else if (aIID.Equals(nsCOMTypeInfo::GetIID())) { + *aInstancePtr = (void*)(nsIRollupListener*)this; + NS_ADDREF_THIS(); + return NS_OK; } return nsAreaFrame::QueryInterface(aIID, aInstancePtr); } @@ -356,6 +360,21 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup) void nsComboboxControlFrame::ShowList(nsIPresContext* aPresContext, PRBool aShowList) { + nsIWidget * widget = nsnull; + + // Get parent view + nsIFrame * listFrame; + if (NS_OK == mListControlFrame->QueryInterface(kIFrameIID, (void **)&listFrame)) { + nsIView * view = nsnull; + listFrame->GetView(&view); + NS_ASSERTION(view != nsnull, "nsComboboxControlFrame view is null"); + view->GetWidget(widget); + if (nsnull != widget) { + widget->CaptureRollupEvents((nsIRollupListener *)this, !mDroppedDown); + NS_RELEASE(widget); + } + } + if (PR_TRUE == aShowList) { ShowPopup(PR_TRUE); mDroppedDown = PR_TRUE; @@ -954,11 +973,9 @@ nsComboboxControlFrame::ListWasSelected(nsIPresContext* aPresContext) NS_IMETHODIMP nsComboboxControlFrame::ToggleList(nsIPresContext* aPresContext) { - if (PR_TRUE == mDroppedDown) { - ShowList(aPresContext, PR_FALSE); - } else { - ShowList(aPresContext, PR_TRUE); - } + + ShowList(aPresContext, (PR_FALSE == mDroppedDown)); + return NS_OK; } @@ -1393,6 +1410,26 @@ nsComboboxControlFrame::Blur(nsIDOMEvent* aEvent) return NS_OK; } +/*nsresult +nsComboboxControlFrame::HandleEvent(nsIDOMEvent* aEvent) +{ + ToggleList(mPresContext); + return NS_OK; +}*/ + +//---------------------------------------------------------------------- + //nsIRollupListener +//---------------------------------------------------------------------- +NS_IMETHODIMP +nsComboboxControlFrame::Rollup() +{ + if (mDroppedDown) { + ShowDropDown(PR_FALSE); + mListControlFrame->CaptureMouseEvents(PR_FALSE); + } + return NS_OK; +} + //---------------------------------------------------------------------- // nsIStatefulFrame // XXX Do we need to implement this here? It is already implemented in diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.h b/mozilla/layout/html/forms/src/nsComboboxControlFrame.h index e63a511827b..8929af38470 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.h +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.h @@ -29,6 +29,7 @@ #include "nsIAnonymousContentCreator.h" #include "nsISelectControlFrame.h" #include "nsIStatefulFrame.h" +#include "nsIRollupListener.h" class nsButtonControlFrame; class nsTextControlFrame; @@ -51,7 +52,8 @@ class nsComboboxControlFrame : public nsAreaFrame, public nsIDOMFocusListener, public nsIAnonymousContentCreator, public nsISelectControlFrame, - public nsIStatefulFrame + public nsIStatefulFrame, + public nsIRollupListener { public: nsComboboxControlFrame(); @@ -161,6 +163,10 @@ public: NS_IMETHOD SaveState(nsISupports** aState); NS_IMETHOD RestoreState(nsISupports* aState); + //nsIRollupListener + NS_IMETHOD Rollup(); + + protected: // nsHTMLContainerFrame