From e61ef4520cf1c95f0bc4b6074aed091bcc6ba35d Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Fri, 28 Apr 2000 23:24:59 +0000 Subject: [PATCH] add OptionDisabled so the nsHTMLOptionElement can notify a select that an option has just been disabled --- layout/forms/nsComboboxControlFrame.cpp | 22 +++++++++++-- layout/forms/nsComboboxControlFrame.h | 5 +-- layout/forms/nsISelectControlFrame.h | 6 ++++ layout/forms/nsListControlFrame.cpp | 10 ++++++ layout/forms/nsListControlFrame.h | 1 + .../html/forms/public/nsISelectControlFrame.h | 6 ++++ .../html/forms/src/nsComboboxControlFrame.cpp | 22 +++++++++++-- .../html/forms/src/nsComboboxControlFrame.h | 5 +-- .../html/forms/src/nsGfxListControlFrame.cpp | 33 ++++++++++++++++++- layout/html/forms/src/nsGfxListControlFrame.h | 5 +-- layout/html/forms/src/nsListControlFrame.cpp | 10 ++++++ layout/html/forms/src/nsListControlFrame.h | 1 + 12 files changed, 113 insertions(+), 13 deletions(-) diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 6060ab460b4f..28d30ba37f9b 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -1319,6 +1319,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext, plainLstFrame->FirstChild(aPresContext, nsnull, &frame); nsIScrollableFrame * scrollFrame; if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsIScrollableFrame), (void**)&scrollFrame))) { + nsIFrame * incrementalChild; + aReflowState.reflowCommand->GetNext(incrementalChild); nsRect rect; plainLstFrame->GetRect(rect); nsresult rvv = plainLstFrame->Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); @@ -1979,6 +1981,20 @@ nsComboboxControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue) return rv; } +NS_IMETHODIMP +nsComboboxControlFrame::OptionDisabled(nsIContent * aContent) +{ + nsISelectControlFrame* listFrame = nsnull; + nsIFrame* dropdownFrame = GetDropdownFrame(); + nsresult rv = dropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame), + (void**)&listFrame); + if (NS_SUCCEEDED(rv) && listFrame) { + rv = listFrame->OptionDisabled(aContent); + NS_RELEASE(listFrame); + } + return rv; +} + NS_IMETHODIMP nsComboboxControlFrame::HandleEvent(nsIPresContext* aPresContext, nsGUIEvent* aEvent, @@ -2403,9 +2419,9 @@ nsComboboxControlFrame::Paint(nsIPresContext* aPresContext, #endif nsAreaFrame::Paint(aPresContext,aRenderingContext,aDirtyRect,aWhichLayer); - if (kGoodToGo) { - return NS_OK; - } + //if (kGoodToGo) { + // return NS_OK; + //} if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { if (mDisplayFrame) { diff --git a/layout/forms/nsComboboxControlFrame.h b/layout/forms/nsComboboxControlFrame.h index 8fa32a1ff6ff..845fd2682839 100644 --- a/layout/forms/nsComboboxControlFrame.h +++ b/layout/forms/nsComboboxControlFrame.h @@ -28,8 +28,8 @@ #endif #ifdef DEBUG_rods -//#define DO_REFLOW_DEBUG -//#define DO_REFLOW_COUNTER +#define DO_REFLOW_DEBUG +#define DO_REFLOW_COUNTER //#define DO_UNCONSTRAINED_CHECK //#define DO_PIXELS //#define DO_NEW_REFLOW @@ -170,6 +170,7 @@ public: NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue); NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue); NS_IMETHOD DoneAddingContent(PRBool aIsDone); + NS_IMETHOD OptionDisabled(nsIContent * aContent); //nsIStatefulFrame NS_IMETHOD GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType); diff --git a/layout/forms/nsISelectControlFrame.h b/layout/forms/nsISelectControlFrame.h index 6badb9489600..55f2b25e7b19 100644 --- a/layout/forms/nsISelectControlFrame.h +++ b/layout/forms/nsISelectControlFrame.h @@ -66,6 +66,12 @@ public: */ NS_IMETHOD DoneAddingContent(PRBool aIsDone) = 0; + /** + * Notification that an option has been disabled + */ + + NS_IMETHOD OptionDisabled(nsIContent * aContent) = 0; + }; #endif diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index ae83285eb991..1dbe20c6ade4 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -2341,6 +2341,16 @@ nsListControlFrame::GetOptionsContainer(nsIPresContext* aPresContext, nsIFrame** return FirstChild(aPresContext, nsnull, aFrame); } +NS_IMETHODIMP +nsListControlFrame::OptionDisabled(nsIContent * aContent) +{ + if (IsContentSelected(aContent)) { + PRInt32 inx = GetSelectedIndexFromContent(aContent); + SetOptionSelected(inx, PR_FALSE); + } + return NS_OK; +} + // Send out an onchange notification. nsresult nsListControlFrame::SelectionChanged(nsIContent* aContent) diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index 85990a820b88..6cf218a196fc 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -150,6 +150,7 @@ public: NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue); NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue); NS_IMETHOD DoneAddingContent(PRBool aIsDone); + NS_IMETHOD OptionDisabled(nsIContent * aContent); //nsIStatefulFrame NS_IMETHOD GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType); diff --git a/layout/html/forms/public/nsISelectControlFrame.h b/layout/html/forms/public/nsISelectControlFrame.h index 6badb9489600..55f2b25e7b19 100644 --- a/layout/html/forms/public/nsISelectControlFrame.h +++ b/layout/html/forms/public/nsISelectControlFrame.h @@ -66,6 +66,12 @@ public: */ NS_IMETHOD DoneAddingContent(PRBool aIsDone) = 0; + /** + * Notification that an option has been disabled + */ + + NS_IMETHOD OptionDisabled(nsIContent * aContent) = 0; + }; #endif diff --git a/layout/html/forms/src/nsComboboxControlFrame.cpp b/layout/html/forms/src/nsComboboxControlFrame.cpp index 6060ab460b4f..28d30ba37f9b 100644 --- a/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -1319,6 +1319,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext, plainLstFrame->FirstChild(aPresContext, nsnull, &frame); nsIScrollableFrame * scrollFrame; if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsIScrollableFrame), (void**)&scrollFrame))) { + nsIFrame * incrementalChild; + aReflowState.reflowCommand->GetNext(incrementalChild); nsRect rect; plainLstFrame->GetRect(rect); nsresult rvv = plainLstFrame->Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); @@ -1979,6 +1981,20 @@ nsComboboxControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue) return rv; } +NS_IMETHODIMP +nsComboboxControlFrame::OptionDisabled(nsIContent * aContent) +{ + nsISelectControlFrame* listFrame = nsnull; + nsIFrame* dropdownFrame = GetDropdownFrame(); + nsresult rv = dropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame), + (void**)&listFrame); + if (NS_SUCCEEDED(rv) && listFrame) { + rv = listFrame->OptionDisabled(aContent); + NS_RELEASE(listFrame); + } + return rv; +} + NS_IMETHODIMP nsComboboxControlFrame::HandleEvent(nsIPresContext* aPresContext, nsGUIEvent* aEvent, @@ -2403,9 +2419,9 @@ nsComboboxControlFrame::Paint(nsIPresContext* aPresContext, #endif nsAreaFrame::Paint(aPresContext,aRenderingContext,aDirtyRect,aWhichLayer); - if (kGoodToGo) { - return NS_OK; - } + //if (kGoodToGo) { + // return NS_OK; + //} if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { if (mDisplayFrame) { diff --git a/layout/html/forms/src/nsComboboxControlFrame.h b/layout/html/forms/src/nsComboboxControlFrame.h index 8fa32a1ff6ff..845fd2682839 100644 --- a/layout/html/forms/src/nsComboboxControlFrame.h +++ b/layout/html/forms/src/nsComboboxControlFrame.h @@ -28,8 +28,8 @@ #endif #ifdef DEBUG_rods -//#define DO_REFLOW_DEBUG -//#define DO_REFLOW_COUNTER +#define DO_REFLOW_DEBUG +#define DO_REFLOW_COUNTER //#define DO_UNCONSTRAINED_CHECK //#define DO_PIXELS //#define DO_NEW_REFLOW @@ -170,6 +170,7 @@ public: NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue); NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue); NS_IMETHOD DoneAddingContent(PRBool aIsDone); + NS_IMETHOD OptionDisabled(nsIContent * aContent); //nsIStatefulFrame NS_IMETHOD GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType); diff --git a/layout/html/forms/src/nsGfxListControlFrame.cpp b/layout/html/forms/src/nsGfxListControlFrame.cpp index d5d8550d3051..2180e72c6da6 100644 --- a/layout/html/forms/src/nsGfxListControlFrame.cpp +++ b/layout/html/forms/src/nsGfxListControlFrame.cpp @@ -356,6 +356,11 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { + nsFrameState state; + GetFrameState(&state); + state |= NS_FRAME_HAS_DIRTY_CHILDREN; + SetFrameState(state); + DO_GLOBAL_REFLOW_COUNT("nsGfxListControlFrame", aReflowState.reason); REFLOW_COUNTER_REQUEST(); @@ -2561,6 +2566,16 @@ nsGfxListControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue) return NS_OK; } +NS_IMETHODIMP +nsGfxListControlFrame::OptionDisabled(nsIContent * aContent) +{ + if (IsContentSelected(aContent)) { + PRInt32 inx = GetSelectedIndexFromContent(aContent); + SetOptionSelected(inx, PR_FALSE); + } + return NS_OK; +} + //---------------------------------------------------------------------- // End nsISelectControlFrame //---------------------------------------------------------------------- @@ -3154,7 +3169,23 @@ nsGfxListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent) } else { nsIFrame * parentFrame; frame->GetParent(&parentFrame); - stateManager->GetEventTarget(&frame); +#if 0 + nsCOMPtr scrollable(do_QueryInterface(parentFrame)); + if (scrollable) { + if (!IsClickingInCombobox(aMouseEvent)) { + return NS_OK; + } + } + nsIFrame * parentsParentFrame; + frame->GetParent(&parentsParentFrame); + nsCOMPtr parentScrollable(do_QueryInterface(parentsParentFrame)); + if (parentScrollable) { + if (!IsClickingInCombobox(aMouseEvent)) { + return NS_OK; + } + } + //stateManager->GetEventTarget(&frame); +#endif listFrame = do_QueryInterface(frame); if (listFrame) { if (!IsClickingInCombobox(aMouseEvent)) { diff --git a/layout/html/forms/src/nsGfxListControlFrame.h b/layout/html/forms/src/nsGfxListControlFrame.h index 7b76718ee410..150e301af6c6 100644 --- a/layout/html/forms/src/nsGfxListControlFrame.h +++ b/layout/html/forms/src/nsGfxListControlFrame.h @@ -27,8 +27,8 @@ #endif #ifdef DEBUG_rods -#define DO_REFLOW_DEBUG -#define DO_REFLOW_COUNTER +//#define DO_REFLOW_DEBUG +//#define DO_REFLOW_COUNTER //#define DO_UNCONSTRAINED_CHECK //#define DO_PIXELS #define DO_DRAGGING @@ -249,6 +249,7 @@ public: NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue); NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue); NS_IMETHOD DoneAddingContent(PRBool aIsDone); + NS_IMETHOD OptionDisabled(nsIContent * aContent); //nsIStatefulFrame NS_IMETHOD GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType); diff --git a/layout/html/forms/src/nsListControlFrame.cpp b/layout/html/forms/src/nsListControlFrame.cpp index ae83285eb991..1dbe20c6ade4 100644 --- a/layout/html/forms/src/nsListControlFrame.cpp +++ b/layout/html/forms/src/nsListControlFrame.cpp @@ -2341,6 +2341,16 @@ nsListControlFrame::GetOptionsContainer(nsIPresContext* aPresContext, nsIFrame** return FirstChild(aPresContext, nsnull, aFrame); } +NS_IMETHODIMP +nsListControlFrame::OptionDisabled(nsIContent * aContent) +{ + if (IsContentSelected(aContent)) { + PRInt32 inx = GetSelectedIndexFromContent(aContent); + SetOptionSelected(inx, PR_FALSE); + } + return NS_OK; +} + // Send out an onchange notification. nsresult nsListControlFrame::SelectionChanged(nsIContent* aContent) diff --git a/layout/html/forms/src/nsListControlFrame.h b/layout/html/forms/src/nsListControlFrame.h index 85990a820b88..6cf218a196fc 100644 --- a/layout/html/forms/src/nsListControlFrame.h +++ b/layout/html/forms/src/nsListControlFrame.h @@ -150,6 +150,7 @@ public: NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue); NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue); NS_IMETHOD DoneAddingContent(PRBool aIsDone); + NS_IMETHOD OptionDisabled(nsIContent * aContent); //nsIStatefulFrame NS_IMETHOD GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType);