diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index 5a04d4052f2..8e080572fdd 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -269,6 +269,11 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext, aDesiredSize.width = 0; aDesiredSize.height = 0; + // Add the list frame as a child of the form + if (IsInDropDownMode() == PR_FALSE && !mFormFrame && (eReflowReason_Initial == aReflowState.reason)) { + nsFormFrame::AddFormControlFrame(aPresContext, *this); + } + //--Calculate a width just big enough for the scrollframe to shrink around the //longest element in the list nsHTMLReflowState secondPassState(aReflowState); @@ -1005,6 +1010,10 @@ nsListControlFrame::HandleEvent(nsIPresContext& aPresContext, return NS_OK; } + if (nsFormFrame::GetDisabled(this)) { + return NS_OK; + } + const nsStyleDisplay* disp = (const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display); if (!disp->mVisible) { return NS_OK; @@ -1032,11 +1041,6 @@ nsListControlFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIFrame* aChildList) { mContentFrame = aChildList; - - if (IsInDropDownMode() == PR_FALSE) { - nsFormFrame::AddFormControlFrame(aPresContext, *this); - } - return nsScrollFrame::SetInitialChildList(aPresContext, aListName, aChildList); } @@ -1071,7 +1075,7 @@ nsListControlFrame::Init(nsIPresContext& aPresContext, // get the proper style based on attribute selectors which refer to the // selected attribute. if (!mIsInitializedFromContent) { - InitializeFromContent(); + Reset(); } return result; @@ -1201,34 +1205,6 @@ nsListControlFrame::SetFrameSelected(PRUint32 aIndex, PRBool aSelected) NS_IF_RELEASE(content); } -//--------------------------------------------------------- -void -nsListControlFrame::InitializeFromContent() -{ - PRInt32 length = 0; - GetNumberOfOptions(&length); - nsIDOMHTMLCollection* options = GetOptions(mContent); - nsresult result = NS_OK; - if (nsnull != options) { - for (PRInt32 i = 0; i < length; i++) { - nsIDOMHTMLOptionElement* optionElement = nsnull; - optionElement = GetOption(*options, i); - if (nsnull != optionElement) { - PRBool selected; - optionElement->GetDefaultSelected(&selected); - // Set the selected index for single selection list boxes. - if (selected) { - ToggleSelected(i); - } - NS_RELEASE(optionElement); - } - } - NS_RELEASE(options); - } - -} - - //--------------------------------------------------------- nsIDOMHTMLCollection* nsListControlFrame::GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect) @@ -1378,8 +1354,9 @@ nsListControlFrame::Reset() nsIDOMHTMLOptionElement* option = GetOption(*options, i); if (option) { PRBool selected = PR_FALSE; - option->GetSelected(&selected); + option->GetDefaultSelected(&selected); if (selected) { + mSelectedIndex = i; SetFrameSelected(i, PR_TRUE); } NS_RELEASE(option); @@ -1753,7 +1730,7 @@ nsListControlFrame::DidReflow(nsIPresContext& aPresContext, { if (PR_TRUE == IsInDropDownMode()) { - //SyncViewWithFrame(); + SyncViewWithFrame(); //mState &= ~NS_FRAME_SYNC_FRAME_AND_VIEW; nsresult rv = nsScrollFrame::DidReflow(aPresContext, aStatus); //mState |= NS_FRAME_SYNC_FRAME_AND_VIEW; diff --git a/mozilla/layout/forms/nsListControlFrame.h b/mozilla/layout/forms/nsListControlFrame.h index 5829e3a8f39..38cf730e28b 100644 --- a/mozilla/layout/forms/nsListControlFrame.h +++ b/mozilla/layout/forms/nsListControlFrame.h @@ -152,7 +152,6 @@ protected: void SelectIndex(PRInt32 aIndex); void ToggleSelected(PRInt32 aIndex); void ClearSelection(); - void InitializeFromContent(); void ExtendedSelection(PRInt32 aStartIndex, PRInt32 aEndIndex, PRBool aDoInvert, PRBool aSetValue); nsresult HandleLikeDropDownListEvent(nsIPresContext& aPresContext, diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index 5a04d4052f2..8e080572fdd 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -269,6 +269,11 @@ nsListControlFrame::Reflow(nsIPresContext& aPresContext, aDesiredSize.width = 0; aDesiredSize.height = 0; + // Add the list frame as a child of the form + if (IsInDropDownMode() == PR_FALSE && !mFormFrame && (eReflowReason_Initial == aReflowState.reason)) { + nsFormFrame::AddFormControlFrame(aPresContext, *this); + } + //--Calculate a width just big enough for the scrollframe to shrink around the //longest element in the list nsHTMLReflowState secondPassState(aReflowState); @@ -1005,6 +1010,10 @@ nsListControlFrame::HandleEvent(nsIPresContext& aPresContext, return NS_OK; } + if (nsFormFrame::GetDisabled(this)) { + return NS_OK; + } + const nsStyleDisplay* disp = (const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display); if (!disp->mVisible) { return NS_OK; @@ -1032,11 +1041,6 @@ nsListControlFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIFrame* aChildList) { mContentFrame = aChildList; - - if (IsInDropDownMode() == PR_FALSE) { - nsFormFrame::AddFormControlFrame(aPresContext, *this); - } - return nsScrollFrame::SetInitialChildList(aPresContext, aListName, aChildList); } @@ -1071,7 +1075,7 @@ nsListControlFrame::Init(nsIPresContext& aPresContext, // get the proper style based on attribute selectors which refer to the // selected attribute. if (!mIsInitializedFromContent) { - InitializeFromContent(); + Reset(); } return result; @@ -1201,34 +1205,6 @@ nsListControlFrame::SetFrameSelected(PRUint32 aIndex, PRBool aSelected) NS_IF_RELEASE(content); } -//--------------------------------------------------------- -void -nsListControlFrame::InitializeFromContent() -{ - PRInt32 length = 0; - GetNumberOfOptions(&length); - nsIDOMHTMLCollection* options = GetOptions(mContent); - nsresult result = NS_OK; - if (nsnull != options) { - for (PRInt32 i = 0; i < length; i++) { - nsIDOMHTMLOptionElement* optionElement = nsnull; - optionElement = GetOption(*options, i); - if (nsnull != optionElement) { - PRBool selected; - optionElement->GetDefaultSelected(&selected); - // Set the selected index for single selection list boxes. - if (selected) { - ToggleSelected(i); - } - NS_RELEASE(optionElement); - } - } - NS_RELEASE(options); - } - -} - - //--------------------------------------------------------- nsIDOMHTMLCollection* nsListControlFrame::GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect) @@ -1378,8 +1354,9 @@ nsListControlFrame::Reset() nsIDOMHTMLOptionElement* option = GetOption(*options, i); if (option) { PRBool selected = PR_FALSE; - option->GetSelected(&selected); + option->GetDefaultSelected(&selected); if (selected) { + mSelectedIndex = i; SetFrameSelected(i, PR_TRUE); } NS_RELEASE(option); @@ -1753,7 +1730,7 @@ nsListControlFrame::DidReflow(nsIPresContext& aPresContext, { if (PR_TRUE == IsInDropDownMode()) { - //SyncViewWithFrame(); + SyncViewWithFrame(); //mState &= ~NS_FRAME_SYNC_FRAME_AND_VIEW; nsresult rv = nsScrollFrame::DidReflow(aPresContext, aStatus); //mState |= NS_FRAME_SYNC_FRAME_AND_VIEW; diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.h b/mozilla/layout/html/forms/src/nsListControlFrame.h index 5829e3a8f39..38cf730e28b 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.h +++ b/mozilla/layout/html/forms/src/nsListControlFrame.h @@ -152,7 +152,6 @@ protected: void SelectIndex(PRInt32 aIndex); void ToggleSelected(PRInt32 aIndex); void ClearSelection(); - void InitializeFromContent(); void ExtendedSelection(PRInt32 aStartIndex, PRInt32 aEndIndex, PRBool aDoInvert, PRBool aSetValue); nsresult HandleLikeDropDownListEvent(nsIPresContext& aPresContext,