diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index 061c7caa41b..53756d9ed6c 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -345,6 +345,18 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, return skiprv; } #endif + // XXX So this may do it too often + // the side effect of this is if the user has scrolled to some other place in the list and + // an incremental reflow comes through the list gets scrolled to the first selected item + // I haven't been able to make it do it, but it will do it + // basically the real solution is to know when all the reframes are there. + if (aReflowState.reason == eReflowReason_Incremental) { + nsCOMPtr content = getter_AddRefs(GetOptionContent(mSelectedIndex)); + if (content) { + ScrollToFrame(content); + } + } + // Strategy: Let the inherited reflow happen as though the width and height of the // ScrollFrame are big enough to allow the listbox to // shrink to fit the longest option element line in the list. @@ -853,10 +865,6 @@ nsListControlFrame::SingleSelection() } // Display the new selection SetContentSelected(mSelectedIndex, PR_TRUE); - nsCOMPtr content = getter_AddRefs(GetOptionContent(mSelectedIndex)); - if (content) { - ScrollToFrame(content); - } } else { // Selecting the currently selected item so do nothing. } @@ -1418,6 +1426,11 @@ nsListControlFrame::SetContentSelected(PRInt32 aIndex, PRBool aSelected) if (nsnull != content) { if (aSelected) { DisplaySelected(content); + // Now that it is selected scroll to it + nsCOMPtr content(do_QueryInterface(content)); + if (content) { + ScrollToFrame(content); + } } else { DisplayDeselected(content); } @@ -1523,7 +1536,11 @@ nsListControlFrame::Reset(nsIPresContext* aPresContext) PRUint32 numOptions; options->GetLength(&numOptions); - mSelectedIndex = kNothingSelected; + mSelectedIndex = kNothingSelected; + mStartExtendedIndex = kNothingSelected; + mEndExtendedIndex = kNothingSelected; + PRBool multiple; + GetMultiple(&multiple); Deselect(); PRUint32 i; @@ -1536,10 +1553,11 @@ nsListControlFrame::Reset(nsIPresContext* aPresContext) mSelectedIndex = i; SetContentSelected(i, PR_TRUE); - // Now that it is selected scroll to it - nsCOMPtr content(do_QueryInterface(option)); - if (content) { - ScrollToFrame(content); + if (multiple) { + mStartExtendedIndex = i; + if (mEndExtendedIndex == kNothingSelected) { + mEndExtendedIndex = i; + } } if (mComboboxFrame) { mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // don't dispatch event @@ -2586,6 +2604,16 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent) if (!IsClickingInCombobox(aMouseEvent)) { return NS_OK; } + } else { + nsIFrame * parentFrame; + frame->GetParent(&parentFrame); + stateManager->GetEventTarget(&frame); + nsCOMPtr listFrame(do_QueryInterface(frame)); + if (listFrame) { + if (!IsClickingInCombobox(aMouseEvent)) { + return NS_OK; + } + } } // This will consume the focus event we get from the clicking on the dropdown //stateManager->ConsumeFocusEvents(PR_TRUE); diff --git a/mozilla/layout/html/forms/src/nsGfxListControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxListControlFrame.cpp index 7c64d68136e..c198042a5e0 100644 --- a/mozilla/layout/html/forms/src/nsGfxListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxListControlFrame.cpp @@ -114,6 +114,11 @@ nsGfxListControlFrame::nsGfxListControlFrame() mIsAllContentHere = PR_FALSE; mIsAllFramesHere = PR_FALSE; mHasBeenInitialized = PR_FALSE; + + mCacheSize.width = -1; + mCacheSize.height = -1; + mCachedMaxElementSize.width = -1; + mCachedMaxElementSize.height = -1; } //--------------------------------------------------------- @@ -330,6 +335,25 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, } } +#if 1 + nsresult skiprv = nsFormControlFrame::SkipResizeReflow(mCacheSize, mCachedMaxElementSize, aPresContext, + aDesiredSize, aReflowState, aStatus); + if (NS_SUCCEEDED(skiprv)) { + return skiprv; + } +#endif + // XXX So this may do it too often + // the side effect of this is if the user has scrolled to some other place in the list and + // an incremental reflow comes through the list gets scrolled to the first selected item + // I haven't been able to make it do it, but it will do it + // basically the real solution is to know when all the reframes are there. + if (aReflowState.reason == eReflowReason_Incremental) { + nsCOMPtr content = getter_AddRefs(GetOptionContent(mSelectedIndex)); + if (content) { + ScrollToFrame(content); + } + } + nsIFrame * firstChildFrame = nsnull; FirstChild(nsnull, &firstChildFrame); @@ -606,6 +630,8 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, } #endif + nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize); + return NS_OK; } @@ -872,10 +898,6 @@ nsGfxListControlFrame::SingleSelection() } // Display the new selection SetContentSelected(mSelectedIndex, PR_TRUE); - nsCOMPtr content = getter_AddRefs(GetOptionContent(mSelectedIndex)); - if (content) { - ScrollToFrame(content); - } } else { // Selecting the currently selected item so do nothing. } @@ -1435,6 +1457,11 @@ nsGfxListControlFrame::SetContentSelected(PRInt32 aIndex, PRBool aSelected) if (nsnull != content) { if (aSelected) { DisplaySelected(content); + // Now that it is selected scroll to it + nsCOMPtr content(do_QueryInterface(content)); + if (content) { + ScrollToFrame(content); + } } else { DisplayDeselected(content); } @@ -1540,7 +1567,11 @@ nsGfxListControlFrame::Reset(nsIPresContext* aPresContext) PRUint32 numOptions; options->GetLength(&numOptions); - mSelectedIndex = kNothingSelected; + mSelectedIndex = kNothingSelected; + mStartExtendedIndex = kNothingSelected; + mEndExtendedIndex = kNothingSelected; + PRBool multiple; + GetMultiple(&multiple); Deselect(); PRUint32 i; @@ -1553,10 +1584,11 @@ nsGfxListControlFrame::Reset(nsIPresContext* aPresContext) mSelectedIndex = i; SetContentSelected(i, PR_TRUE); - // Now that it is selected scroll to it - nsCOMPtr content(do_QueryInterface(option)); - if (content) { - ScrollToFrame(content); + if (multiple) { + mStartExtendedIndex = i; + if (mEndExtendedIndex == kNothingSelected) { + mEndExtendedIndex = i; + } } if (mComboboxFrame) { mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // don't dispatch event diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index 061c7caa41b..53756d9ed6c 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -345,6 +345,18 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, return skiprv; } #endif + // XXX So this may do it too often + // the side effect of this is if the user has scrolled to some other place in the list and + // an incremental reflow comes through the list gets scrolled to the first selected item + // I haven't been able to make it do it, but it will do it + // basically the real solution is to know when all the reframes are there. + if (aReflowState.reason == eReflowReason_Incremental) { + nsCOMPtr content = getter_AddRefs(GetOptionContent(mSelectedIndex)); + if (content) { + ScrollToFrame(content); + } + } + // Strategy: Let the inherited reflow happen as though the width and height of the // ScrollFrame are big enough to allow the listbox to // shrink to fit the longest option element line in the list. @@ -853,10 +865,6 @@ nsListControlFrame::SingleSelection() } // Display the new selection SetContentSelected(mSelectedIndex, PR_TRUE); - nsCOMPtr content = getter_AddRefs(GetOptionContent(mSelectedIndex)); - if (content) { - ScrollToFrame(content); - } } else { // Selecting the currently selected item so do nothing. } @@ -1418,6 +1426,11 @@ nsListControlFrame::SetContentSelected(PRInt32 aIndex, PRBool aSelected) if (nsnull != content) { if (aSelected) { DisplaySelected(content); + // Now that it is selected scroll to it + nsCOMPtr content(do_QueryInterface(content)); + if (content) { + ScrollToFrame(content); + } } else { DisplayDeselected(content); } @@ -1523,7 +1536,11 @@ nsListControlFrame::Reset(nsIPresContext* aPresContext) PRUint32 numOptions; options->GetLength(&numOptions); - mSelectedIndex = kNothingSelected; + mSelectedIndex = kNothingSelected; + mStartExtendedIndex = kNothingSelected; + mEndExtendedIndex = kNothingSelected; + PRBool multiple; + GetMultiple(&multiple); Deselect(); PRUint32 i; @@ -1536,10 +1553,11 @@ nsListControlFrame::Reset(nsIPresContext* aPresContext) mSelectedIndex = i; SetContentSelected(i, PR_TRUE); - // Now that it is selected scroll to it - nsCOMPtr content(do_QueryInterface(option)); - if (content) { - ScrollToFrame(content); + if (multiple) { + mStartExtendedIndex = i; + if (mEndExtendedIndex == kNothingSelected) { + mEndExtendedIndex = i; + } } if (mComboboxFrame) { mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // don't dispatch event @@ -2586,6 +2604,16 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent) if (!IsClickingInCombobox(aMouseEvent)) { return NS_OK; } + } else { + nsIFrame * parentFrame; + frame->GetParent(&parentFrame); + stateManager->GetEventTarget(&frame); + nsCOMPtr listFrame(do_QueryInterface(frame)); + if (listFrame) { + if (!IsClickingInCombobox(aMouseEvent)) { + return NS_OK; + } + } } // This will consume the focus event we get from the clicking on the dropdown //stateManager->ConsumeFocusEvents(PR_TRUE);