From b07784414420ecbe81c1726ed1f28c05e37d2a25 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Thu, 3 Aug 2000 14:13:40 +0000 Subject: [PATCH] 47302 - moved the RegUnRegAccessKey to the Destroy Method 44788 - Comboboxes do not obey style height 42661 - javascript "selected = true" doesn't inform onChange of b=47302, 44788, 42661 r=kmclusk git-svn-id: svn://10.0.0.236/trunk@75493 18797224-902f-48f8-a5cc-f745e15eee43 --- .../layout/forms/nsComboboxControlFrame.cpp | 31 +++++++++++++------ mozilla/layout/forms/nsComboboxControlFrame.h | 2 +- .../layout/forms/nsIComboboxControlFrame.h | 2 +- .../forms/public/nsIComboboxControlFrame.h | 2 +- .../html/forms/src/nsComboboxControlFrame.cpp | 31 +++++++++++++------ .../html/forms/src/nsComboboxControlFrame.h | 2 +- 6 files changed, 48 insertions(+), 22 deletions(-) diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index e43cdc3f5ba..b1dcccc145c 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -267,7 +267,6 @@ nsComboboxControlFrame::~nsComboboxControlFrame() } NS_IF_RELEASE(mButtonContent); - nsFormControlFrame::RegUnRegAccessKey(mPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_FALSE); NS_IF_RELEASE(mPresContext); } @@ -347,6 +346,8 @@ nsComboboxControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter) NS_IMETHODIMP nsComboboxControlFrame::MakeSureSomethingIsSelected(nsIPresContext* aPresContext) { + REFLOW_DEBUG_MSG("CBX::MakeSureSomethingIsSelected\n"); + nsIFormControlFrame* fcFrame = nsnull; nsIFrame* dropdownFrame = GetDropdownFrame(); nsresult rv = dropdownFrame->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame); @@ -1517,6 +1518,13 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext, REFLOW_DEBUG_MSG4("firstPassState.mComputedWidth %d - size.width %d dspBorderPadding.right %d\n", PX(firstPassState.mComputedWidth), PX(size.width), PX(dspBorderPadding.right)); } } + + // Fix for Bug 44788 (remove this comment later) + if (firstPassState.mComputedHeight > 0 && NS_UNCONSTRAINEDSIZE != firstPassState.mComputedHeight) { + size.height = firstPassState.mComputedHeight; + } + + // this reflows and makes and last minute adjustments ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus, mDisplayFrame, buttonFrame, mItemDisplayWidth, scrollbarWidth, @@ -1806,7 +1814,7 @@ nsComboboxControlFrame::GetDropDown(nsIFrame** aDropDownFrame) } NS_IMETHODIMP -nsComboboxControlFrame::ListWasSelected(nsIPresContext* aPresContext) +nsComboboxControlFrame::ListWasSelected(nsIPresContext* aPresContext, PRBool aForceUpdate) // Added "aForceUpdate" for Bug 42661 { if (aPresContext == nsnull) { aPresContext = mPresContext; @@ -1817,7 +1825,7 @@ nsComboboxControlFrame::ListWasSelected(nsIPresContext* aPresContext) PRInt32 indx; mListControlFrame->GetSelectedIndex(&indx); - UpdateSelection(PR_TRUE, PR_FALSE, indx); + UpdateSelection(PR_TRUE, aForceUpdate, indx); // Added "aForceUpdate" for Bug 42661 return NS_OK; } @@ -1838,16 +1846,19 @@ nsComboboxControlFrame::UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUp if (mListControlFrame) { // Check to see if the selection changed if (mSelectedIndex != aNewIndex || aForceUpdate) { - //???if (mSelectedIndex != aNewIndex || (aForceUpdate && aNewIndex != kSizeNotSet)) { mListControlFrame->GetSelectedItem(mTextStr); // Update text box + + // Fix for Bug 42661 (remove comment later) #ifdef DO_REFLOW_DEBUG char * str = mTextStr.ToNewCString(); - REFLOW_DEBUG_MSG2("UpdateSelection %s\n", str); - delete [] str; + REFLOW_DEBUG_MSG2("UpdateSelection %s\n", str); + delete [] str; #endif + mSelectedIndex = aNewIndex; mListControlFrame->UpdateSelection(aDoDispatchEvent, aForceUpdate, mContent); + } else { + mSelectedIndex = aNewIndex; } - mSelectedIndex = aNewIndex; } return NS_OK; @@ -1897,7 +1908,7 @@ nsComboboxControlFrame::SelectionChanged() shouldSetValue = PR_TRUE; } else { shouldSetValue = value != mTextStr; - REFLOW_DEBUG_MSG3("**** SelectionChanged Old[%s] New[%s]\n", value.ToNewCString(), mTextStr.ToNewCString()); + REFLOW_DEBUG_MSG3("**** CBX::SelectionChanged Old[%s] New[%s]\n", value.ToNewCString(), mTextStr.ToNewCString()); } if (shouldSetValue) { if (mTextStr.Length() == 0) { @@ -2287,6 +2298,8 @@ nsComboboxControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight) NS_IMETHODIMP nsComboboxControlFrame::Destroy(nsIPresContext* aPresContext) { + nsFormControlFrame::RegUnRegAccessKey(mPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_FALSE); + if (mDroppedDown) { nsCOMPtr widget; // Get parent view @@ -2356,7 +2369,7 @@ nsComboboxControlFrame::SetInitialChildList(nsIPresContext* aPresContext, nsIFrame * child = aChildList; while (child != nsnull) { nsIFormControlFrame* fcFrame = nsnull; - nsresult rv = child->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame); + rv = child->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame); if (NS_FAILED(rv) && fcFrame == nsnull) { mDisplayFrame = child; break; diff --git a/mozilla/layout/forms/nsComboboxControlFrame.h b/mozilla/layout/forms/nsComboboxControlFrame.h index f0adb239a47..7449a20bb15 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.h +++ b/mozilla/layout/forms/nsComboboxControlFrame.h @@ -159,7 +159,7 @@ public: NS_IMETHOD ShowDropDown(PRBool aDoDropDown); NS_IMETHOD GetDropDown(nsIFrame** aDropDownFrame); NS_IMETHOD SetDropDown(nsIFrame* aDropDownFrame); - NS_IMETHOD ListWasSelected(nsIPresContext* aPresContext); + NS_IMETHOD ListWasSelected(nsIPresContext* aPresContext, PRBool aForceUpdate); NS_IMETHOD UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUpdate, PRInt32 aNewIndex); NS_IMETHOD AbsolutelyPositionDropDown(); NS_IMETHOD GetAbsoluteRect(nsRect* aRect); diff --git a/mozilla/layout/forms/nsIComboboxControlFrame.h b/mozilla/layout/forms/nsIComboboxControlFrame.h index 3bff46958c8..38dd1cb024c 100644 --- a/mozilla/layout/forms/nsIComboboxControlFrame.h +++ b/mozilla/layout/forms/nsIComboboxControlFrame.h @@ -77,7 +77,7 @@ public: * Notifies the Combobox the List was selected * */ - NS_IMETHOD ListWasSelected(nsIPresContext* aPresContext) = 0; + NS_IMETHOD ListWasSelected(nsIPresContext* aPresContext, PRBool aForceUpdate) = 0; /** * Asks the Combobox to update the display frame diff --git a/mozilla/layout/html/forms/public/nsIComboboxControlFrame.h b/mozilla/layout/html/forms/public/nsIComboboxControlFrame.h index 3bff46958c8..38dd1cb024c 100644 --- a/mozilla/layout/html/forms/public/nsIComboboxControlFrame.h +++ b/mozilla/layout/html/forms/public/nsIComboboxControlFrame.h @@ -77,7 +77,7 @@ public: * Notifies the Combobox the List was selected * */ - NS_IMETHOD ListWasSelected(nsIPresContext* aPresContext) = 0; + NS_IMETHOD ListWasSelected(nsIPresContext* aPresContext, PRBool aForceUpdate) = 0; /** * Asks the Combobox to update the display frame diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index e43cdc3f5ba..b1dcccc145c 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -267,7 +267,6 @@ nsComboboxControlFrame::~nsComboboxControlFrame() } NS_IF_RELEASE(mButtonContent); - nsFormControlFrame::RegUnRegAccessKey(mPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_FALSE); NS_IF_RELEASE(mPresContext); } @@ -347,6 +346,8 @@ nsComboboxControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter) NS_IMETHODIMP nsComboboxControlFrame::MakeSureSomethingIsSelected(nsIPresContext* aPresContext) { + REFLOW_DEBUG_MSG("CBX::MakeSureSomethingIsSelected\n"); + nsIFormControlFrame* fcFrame = nsnull; nsIFrame* dropdownFrame = GetDropdownFrame(); nsresult rv = dropdownFrame->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame); @@ -1517,6 +1518,13 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext, REFLOW_DEBUG_MSG4("firstPassState.mComputedWidth %d - size.width %d dspBorderPadding.right %d\n", PX(firstPassState.mComputedWidth), PX(size.width), PX(dspBorderPadding.right)); } } + + // Fix for Bug 44788 (remove this comment later) + if (firstPassState.mComputedHeight > 0 && NS_UNCONSTRAINEDSIZE != firstPassState.mComputedHeight) { + size.height = firstPassState.mComputedHeight; + } + + // this reflows and makes and last minute adjustments ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus, mDisplayFrame, buttonFrame, mItemDisplayWidth, scrollbarWidth, @@ -1806,7 +1814,7 @@ nsComboboxControlFrame::GetDropDown(nsIFrame** aDropDownFrame) } NS_IMETHODIMP -nsComboboxControlFrame::ListWasSelected(nsIPresContext* aPresContext) +nsComboboxControlFrame::ListWasSelected(nsIPresContext* aPresContext, PRBool aForceUpdate) // Added "aForceUpdate" for Bug 42661 { if (aPresContext == nsnull) { aPresContext = mPresContext; @@ -1817,7 +1825,7 @@ nsComboboxControlFrame::ListWasSelected(nsIPresContext* aPresContext) PRInt32 indx; mListControlFrame->GetSelectedIndex(&indx); - UpdateSelection(PR_TRUE, PR_FALSE, indx); + UpdateSelection(PR_TRUE, aForceUpdate, indx); // Added "aForceUpdate" for Bug 42661 return NS_OK; } @@ -1838,16 +1846,19 @@ nsComboboxControlFrame::UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUp if (mListControlFrame) { // Check to see if the selection changed if (mSelectedIndex != aNewIndex || aForceUpdate) { - //???if (mSelectedIndex != aNewIndex || (aForceUpdate && aNewIndex != kSizeNotSet)) { mListControlFrame->GetSelectedItem(mTextStr); // Update text box + + // Fix for Bug 42661 (remove comment later) #ifdef DO_REFLOW_DEBUG char * str = mTextStr.ToNewCString(); - REFLOW_DEBUG_MSG2("UpdateSelection %s\n", str); - delete [] str; + REFLOW_DEBUG_MSG2("UpdateSelection %s\n", str); + delete [] str; #endif + mSelectedIndex = aNewIndex; mListControlFrame->UpdateSelection(aDoDispatchEvent, aForceUpdate, mContent); + } else { + mSelectedIndex = aNewIndex; } - mSelectedIndex = aNewIndex; } return NS_OK; @@ -1897,7 +1908,7 @@ nsComboboxControlFrame::SelectionChanged() shouldSetValue = PR_TRUE; } else { shouldSetValue = value != mTextStr; - REFLOW_DEBUG_MSG3("**** SelectionChanged Old[%s] New[%s]\n", value.ToNewCString(), mTextStr.ToNewCString()); + REFLOW_DEBUG_MSG3("**** CBX::SelectionChanged Old[%s] New[%s]\n", value.ToNewCString(), mTextStr.ToNewCString()); } if (shouldSetValue) { if (mTextStr.Length() == 0) { @@ -2287,6 +2298,8 @@ nsComboboxControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight) NS_IMETHODIMP nsComboboxControlFrame::Destroy(nsIPresContext* aPresContext) { + nsFormControlFrame::RegUnRegAccessKey(mPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_FALSE); + if (mDroppedDown) { nsCOMPtr widget; // Get parent view @@ -2356,7 +2369,7 @@ nsComboboxControlFrame::SetInitialChildList(nsIPresContext* aPresContext, nsIFrame * child = aChildList; while (child != nsnull) { nsIFormControlFrame* fcFrame = nsnull; - nsresult rv = child->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame); + rv = child->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame); if (NS_FAILED(rv) && fcFrame == nsnull) { mDisplayFrame = child; break; diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.h b/mozilla/layout/html/forms/src/nsComboboxControlFrame.h index f0adb239a47..7449a20bb15 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.h +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.h @@ -159,7 +159,7 @@ public: NS_IMETHOD ShowDropDown(PRBool aDoDropDown); NS_IMETHOD GetDropDown(nsIFrame** aDropDownFrame); NS_IMETHOD SetDropDown(nsIFrame* aDropDownFrame); - NS_IMETHOD ListWasSelected(nsIPresContext* aPresContext); + NS_IMETHOD ListWasSelected(nsIPresContext* aPresContext, PRBool aForceUpdate); NS_IMETHOD UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUpdate, PRInt32 aNewIndex); NS_IMETHOD AbsolutelyPositionDropDown(); NS_IMETHOD GetAbsoluteRect(nsRect* aRect);