Skip to content

Commit 3752b07

Browse files
author
rods@netscape.com
committedApr 28, 2000
add OptionDisabled so the nsHTMLOptionElement can notify a select that an option
has just been disabled
1 parent aec59c5 commit 3752b07

12 files changed

+113
-13
lines changed
 

‎layout/forms/nsComboboxControlFrame.cpp

+19-3
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
13191319
plainLstFrame->FirstChild(aPresContext, nsnull, &frame);
13201320
nsIScrollableFrame * scrollFrame;
13211321
if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsIScrollableFrame), (void**)&scrollFrame))) {
1322+
nsIFrame * incrementalChild;
1323+
aReflowState.reflowCommand->GetNext(incrementalChild);
13221324
nsRect rect;
13231325
plainLstFrame->GetRect(rect);
13241326
nsresult rvv = plainLstFrame->Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
@@ -1979,6 +1981,20 @@ nsComboboxControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
19791981
return rv;
19801982
}
19811983

1984+
NS_IMETHODIMP
1985+
nsComboboxControlFrame::OptionDisabled(nsIContent * aContent)
1986+
{
1987+
nsISelectControlFrame* listFrame = nsnull;
1988+
nsIFrame* dropdownFrame = GetDropdownFrame();
1989+
nsresult rv = dropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
1990+
(void**)&listFrame);
1991+
if (NS_SUCCEEDED(rv) && listFrame) {
1992+
rv = listFrame->OptionDisabled(aContent);
1993+
NS_RELEASE(listFrame);
1994+
}
1995+
return rv;
1996+
}
1997+
19821998
NS_IMETHODIMP
19831999
nsComboboxControlFrame::HandleEvent(nsIPresContext* aPresContext,
19842000
nsGUIEvent* aEvent,
@@ -2403,9 +2419,9 @@ nsComboboxControlFrame::Paint(nsIPresContext* aPresContext,
24032419
#endif
24042420
nsAreaFrame::Paint(aPresContext,aRenderingContext,aDirtyRect,aWhichLayer);
24052421

2406-
if (kGoodToGo) {
2407-
return NS_OK;
2408-
}
2422+
//if (kGoodToGo) {
2423+
// return NS_OK;
2424+
//}
24092425

24102426
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
24112427
if (mDisplayFrame) {

‎layout/forms/nsComboboxControlFrame.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
#endif
2929

3030
#ifdef DEBUG_rods
31-
//#define DO_REFLOW_DEBUG
32-
//#define DO_REFLOW_COUNTER
31+
#define DO_REFLOW_DEBUG
32+
#define DO_REFLOW_COUNTER
3333
//#define DO_UNCONSTRAINED_CHECK
3434
//#define DO_PIXELS
3535
//#define DO_NEW_REFLOW
@@ -170,6 +170,7 @@ class nsComboboxControlFrame : public nsAreaFrame,
170170
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
171171
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
172172
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
173+
NS_IMETHOD OptionDisabled(nsIContent * aContent);
173174

174175
//nsIStatefulFrame
175176
NS_IMETHOD GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType);

‎layout/forms/nsISelectControlFrame.h

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ class nsISelectControlFrame : public nsISupports {
6666
*/
6767
NS_IMETHOD DoneAddingContent(PRBool aIsDone) = 0;
6868

69+
/**
70+
* Notification that an option has been disabled
71+
*/
72+
73+
NS_IMETHOD OptionDisabled(nsIContent * aContent) = 0;
74+
6975
};
7076

7177
#endif

‎layout/forms/nsListControlFrame.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -2341,6 +2341,16 @@ nsListControlFrame::GetOptionsContainer(nsIPresContext* aPresContext, nsIFrame**
23412341
return FirstChild(aPresContext, nsnull, aFrame);
23422342
}
23432343

2344+
NS_IMETHODIMP
2345+
nsListControlFrame::OptionDisabled(nsIContent * aContent)
2346+
{
2347+
if (IsContentSelected(aContent)) {
2348+
PRInt32 inx = GetSelectedIndexFromContent(aContent);
2349+
SetOptionSelected(inx, PR_FALSE);
2350+
}
2351+
return NS_OK;
2352+
}
2353+
23442354
// Send out an onchange notification.
23452355
nsresult
23462356
nsListControlFrame::SelectionChanged(nsIContent* aContent)

‎layout/forms/nsListControlFrame.h

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class nsListControlFrame : public nsScrollFrame,
150150
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
151151
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
152152
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
153+
NS_IMETHOD OptionDisabled(nsIContent * aContent);
153154

154155
//nsIStatefulFrame
155156
NS_IMETHOD GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType);

‎layout/html/forms/public/nsISelectControlFrame.h

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ class nsISelectControlFrame : public nsISupports {
6666
*/
6767
NS_IMETHOD DoneAddingContent(PRBool aIsDone) = 0;
6868

69+
/**
70+
* Notification that an option has been disabled
71+
*/
72+
73+
NS_IMETHOD OptionDisabled(nsIContent * aContent) = 0;
74+
6975
};
7076

7177
#endif

‎layout/html/forms/src/nsComboboxControlFrame.cpp

+19-3
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
13191319
plainLstFrame->FirstChild(aPresContext, nsnull, &frame);
13201320
nsIScrollableFrame * scrollFrame;
13211321
if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsIScrollableFrame), (void**)&scrollFrame))) {
1322+
nsIFrame * incrementalChild;
1323+
aReflowState.reflowCommand->GetNext(incrementalChild);
13221324
nsRect rect;
13231325
plainLstFrame->GetRect(rect);
13241326
nsresult rvv = plainLstFrame->Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
@@ -1979,6 +1981,20 @@ nsComboboxControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
19791981
return rv;
19801982
}
19811983

1984+
NS_IMETHODIMP
1985+
nsComboboxControlFrame::OptionDisabled(nsIContent * aContent)
1986+
{
1987+
nsISelectControlFrame* listFrame = nsnull;
1988+
nsIFrame* dropdownFrame = GetDropdownFrame();
1989+
nsresult rv = dropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
1990+
(void**)&listFrame);
1991+
if (NS_SUCCEEDED(rv) && listFrame) {
1992+
rv = listFrame->OptionDisabled(aContent);
1993+
NS_RELEASE(listFrame);
1994+
}
1995+
return rv;
1996+
}
1997+
19821998
NS_IMETHODIMP
19831999
nsComboboxControlFrame::HandleEvent(nsIPresContext* aPresContext,
19842000
nsGUIEvent* aEvent,
@@ -2403,9 +2419,9 @@ nsComboboxControlFrame::Paint(nsIPresContext* aPresContext,
24032419
#endif
24042420
nsAreaFrame::Paint(aPresContext,aRenderingContext,aDirtyRect,aWhichLayer);
24052421

2406-
if (kGoodToGo) {
2407-
return NS_OK;
2408-
}
2422+
//if (kGoodToGo) {
2423+
// return NS_OK;
2424+
//}
24092425

24102426
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
24112427
if (mDisplayFrame) {

‎layout/html/forms/src/nsComboboxControlFrame.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
#endif
2929

3030
#ifdef DEBUG_rods
31-
//#define DO_REFLOW_DEBUG
32-
//#define DO_REFLOW_COUNTER
31+
#define DO_REFLOW_DEBUG
32+
#define DO_REFLOW_COUNTER
3333
//#define DO_UNCONSTRAINED_CHECK
3434
//#define DO_PIXELS
3535
//#define DO_NEW_REFLOW
@@ -170,6 +170,7 @@ class nsComboboxControlFrame : public nsAreaFrame,
170170
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
171171
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
172172
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
173+
NS_IMETHOD OptionDisabled(nsIContent * aContent);
173174

174175
//nsIStatefulFrame
175176
NS_IMETHOD GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType);

‎layout/html/forms/src/nsGfxListControlFrame.cpp

+32-1
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,11 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext,
356356
const nsHTMLReflowState& aReflowState,
357357
nsReflowStatus& aStatus)
358358
{
359+
nsFrameState state;
360+
GetFrameState(&state);
361+
state |= NS_FRAME_HAS_DIRTY_CHILDREN;
362+
SetFrameState(state);
363+
359364
DO_GLOBAL_REFLOW_COUNT("nsGfxListControlFrame", aReflowState.reason);
360365

361366
REFLOW_COUNTER_REQUEST();
@@ -2561,6 +2566,16 @@ nsGfxListControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
25612566
return NS_OK;
25622567
}
25632568

2569+
NS_IMETHODIMP
2570+
nsGfxListControlFrame::OptionDisabled(nsIContent * aContent)
2571+
{
2572+
if (IsContentSelected(aContent)) {
2573+
PRInt32 inx = GetSelectedIndexFromContent(aContent);
2574+
SetOptionSelected(inx, PR_FALSE);
2575+
}
2576+
return NS_OK;
2577+
}
2578+
25642579
//----------------------------------------------------------------------
25652580
// End nsISelectControlFrame
25662581
//----------------------------------------------------------------------
@@ -3154,7 +3169,23 @@ nsGfxListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
31543169
} else {
31553170
nsIFrame * parentFrame;
31563171
frame->GetParent(&parentFrame);
3157-
stateManager->GetEventTarget(&frame);
3172+
#if 0
3173+
nsCOMPtr<nsIScrollableFrame> scrollable(do_QueryInterface(parentFrame));
3174+
if (scrollable) {
3175+
if (!IsClickingInCombobox(aMouseEvent)) {
3176+
return NS_OK;
3177+
}
3178+
}
3179+
nsIFrame * parentsParentFrame;
3180+
frame->GetParent(&parentsParentFrame);
3181+
nsCOMPtr<nsIScrollableFrame> parentScrollable(do_QueryInterface(parentsParentFrame));
3182+
if (parentScrollable) {
3183+
if (!IsClickingInCombobox(aMouseEvent)) {
3184+
return NS_OK;
3185+
}
3186+
}
3187+
//stateManager->GetEventTarget(&frame);
3188+
#endif
31583189
listFrame = do_QueryInterface(frame);
31593190
if (listFrame) {
31603191
if (!IsClickingInCombobox(aMouseEvent)) {

‎layout/html/forms/src/nsGfxListControlFrame.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#endif
2828

2929
#ifdef DEBUG_rods
30-
#define DO_REFLOW_DEBUG
31-
#define DO_REFLOW_COUNTER
30+
//#define DO_REFLOW_DEBUG
31+
//#define DO_REFLOW_COUNTER
3232
//#define DO_UNCONSTRAINED_CHECK
3333
//#define DO_PIXELS
3434
#define DO_DRAGGING
@@ -249,6 +249,7 @@ class nsGfxListControlFrame : public nsHTMLContainerFrame,
249249
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
250250
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
251251
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
252+
NS_IMETHOD OptionDisabled(nsIContent * aContent);
252253

253254
//nsIStatefulFrame
254255
NS_IMETHOD GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType);

‎layout/html/forms/src/nsListControlFrame.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -2341,6 +2341,16 @@ nsListControlFrame::GetOptionsContainer(nsIPresContext* aPresContext, nsIFrame**
23412341
return FirstChild(aPresContext, nsnull, aFrame);
23422342
}
23432343

2344+
NS_IMETHODIMP
2345+
nsListControlFrame::OptionDisabled(nsIContent * aContent)
2346+
{
2347+
if (IsContentSelected(aContent)) {
2348+
PRInt32 inx = GetSelectedIndexFromContent(aContent);
2349+
SetOptionSelected(inx, PR_FALSE);
2350+
}
2351+
return NS_OK;
2352+
}
2353+
23442354
// Send out an onchange notification.
23452355
nsresult
23462356
nsListControlFrame::SelectionChanged(nsIContent* aContent)

‎layout/html/forms/src/nsListControlFrame.h

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class nsListControlFrame : public nsScrollFrame,
150150
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
151151
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
152152
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
153+
NS_IMETHOD OptionDisabled(nsIContent * aContent);
153154

154155
//nsIStatefulFrame
155156
NS_IMETHOD GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType);

0 commit comments

Comments
 (0)
Failed to load comments.