зеркало из https://github.com/mozilla/gecko-dev.git
Make assignments to DOM 'selectedIndex' change the focused index for lists/comboboxes. b=279868 r+sr=bzbarsky
This commit is contained in:
Родитель
5957d55507
Коммит
c967eac0c7
|
@ -1105,8 +1105,19 @@ nsHTMLSelectElement::GetSelectedIndex(PRInt32* aValue)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLSelectElement::SetSelectedIndex(PRInt32 aIndex)
|
||||
{
|
||||
return SetOptionsSelectedByIndex(aIndex, aIndex, PR_TRUE,
|
||||
PR_TRUE, PR_TRUE, PR_TRUE, nsnull);
|
||||
PRInt32 oldSelectedIndex = mSelectedIndex;
|
||||
|
||||
nsresult rv = SetOptionsSelectedByIndex(aIndex, aIndex, PR_TRUE,
|
||||
PR_TRUE, PR_TRUE, PR_TRUE, nsnull);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsISelectControlFrame* selectFrame = GetSelectFrame();
|
||||
if (selectFrame) {
|
||||
rv = selectFrame->OnSetSelectedIndex(oldSelectedIndex, mSelectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -1815,7 +1815,6 @@ nsComboboxControlFrame::DoneAddingChildren(PRBool aIsDone)
|
|||
rv = CallQueryInterface(mDropdownFrame, &listFrame);
|
||||
if (listFrame) {
|
||||
rv = listFrame->DoneAddingChildren(aIsDone);
|
||||
NS_RELEASE(listFrame);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
@ -1850,12 +1849,12 @@ NS_IMETHODIMP
|
|||
nsComboboxControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
|
||||
{
|
||||
nsISelectControlFrame* listFrame = nsnull;
|
||||
nsresult rv = CallQueryInterface(mDropdownFrame, &listFrame);
|
||||
if (listFrame) {
|
||||
rv = listFrame->GetOptionSelected(aIndex, aValue);
|
||||
NS_RELEASE(listFrame);
|
||||
}
|
||||
return rv;
|
||||
NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
|
||||
|
||||
CallQueryInterface(mDropdownFrame, &listFrame);
|
||||
NS_ASSERTION(listFrame, "No list frame!");
|
||||
|
||||
return listFrame->GetOptionSelected(aIndex, aValue);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -1869,11 +1868,7 @@ nsComboboxControlFrame::GetDummyFrame(nsIFrame** aFrame)
|
|||
CallQueryInterface(mDropdownFrame, &listFrame);
|
||||
NS_ASSERTION(listFrame, "No list frame!");
|
||||
|
||||
if (listFrame) {
|
||||
listFrame->GetDummyFrame(aFrame);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return listFrame->GetDummyFrame(aFrame);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1885,11 +1880,19 @@ nsComboboxControlFrame::SetDummyFrame(nsIFrame* aFrame)
|
|||
CallQueryInterface(mDropdownFrame, &listFrame);
|
||||
NS_ASSERTION(listFrame, "No list frame!");
|
||||
|
||||
if (listFrame) {
|
||||
listFrame->SetDummyFrame(aFrame);
|
||||
}
|
||||
return listFrame->SetDummyFrame(aFrame);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::OnSetSelectedIndex(PRInt32 aOldIndex, PRInt32 aNewIndex)
|
||||
{
|
||||
nsISelectControlFrame* listFrame = nsnull;
|
||||
NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
|
||||
|
||||
CallQueryInterface(mDropdownFrame, &listFrame);
|
||||
NS_ASSERTION(listFrame, "No list frame!");
|
||||
|
||||
return listFrame->OnSetSelectedIndex(aOldIndex, aNewIndex);
|
||||
}
|
||||
|
||||
// End nsISelectControlFrame
|
||||
|
|
|
@ -187,6 +187,7 @@ public:
|
|||
NS_IMETHOD OnOptionTextChanged(nsIDOMHTMLOptionElement* option);
|
||||
NS_IMETHOD GetDummyFrame(nsIFrame** aFrame);
|
||||
NS_IMETHOD SetDummyFrame(nsIFrame* aFrame);
|
||||
NS_IMETHOD OnSetSelectedIndex(PRInt32 aOldIndex, PRInt32 aNewIndex);
|
||||
|
||||
//nsIRollupListener
|
||||
// NS_DECL_NSIROLLUPLISTENER
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
|
||||
// IID for the nsISelectControlFrame class
|
||||
#define NS_ISELECTCONTROLFRAME_IID \
|
||||
{ 0x162a2ae3, 0x5a79, 0x11d3, \
|
||||
{ 0x96, 0xea, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } }
|
||||
// {162A2AE3-5A79-11d3-96EA-0060B0FB9956}
|
||||
{ 0x62a3bc8e, 0x1312, 0x42f3, \
|
||||
{ 0x96, 0x7c, 0x37, 0x0f, 0x16, 0x9a, 0xd3, 0xbf } }
|
||||
// 62a3bc8e-1312-42f3-967c-370f169ad3bf
|
||||
|
||||
class nsIDOMHTMLOptionElement;
|
||||
|
||||
|
@ -98,6 +98,12 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetDummyFrame(nsIFrame** aFrame) = 0;
|
||||
NS_IMETHOD SetDummyFrame(nsIFrame* aFrame) = 0;
|
||||
|
||||
/**
|
||||
* Notify the frame when selectedIndex was changed
|
||||
*/
|
||||
NS_IMETHOD OnSetSelectedIndex(PRInt32 aOldIndex, PRInt32 aNewIndex) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2192,6 +2192,20 @@ nsListControlFrame::SetDummyFrame(nsIFrame* aFrame)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsListControlFrame::OnSetSelectedIndex(PRInt32 aOldIndex, PRInt32 aNewIndex)
|
||||
{
|
||||
if (mComboboxFrame) {
|
||||
mComboboxFrame->UpdateRecentIndex(aOldIndex);
|
||||
}
|
||||
|
||||
ScrollToIndex(aNewIndex);
|
||||
mStartSelectionIndex = aNewIndex;
|
||||
mEndSelectionIndex = aNewIndex;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// End nsISelectControlFrame
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -186,6 +186,7 @@ public:
|
|||
NS_IMETHOD OnOptionTextChanged(nsIDOMHTMLOptionElement* option);
|
||||
NS_IMETHOD GetDummyFrame(nsIFrame** aFrame);
|
||||
NS_IMETHOD SetDummyFrame(nsIFrame* aFrame);
|
||||
NS_IMETHOD OnSetSelectedIndex(PRInt32 aOldIndex, PRInt32 aNewIndex);
|
||||
|
||||
// mouse event listeners
|
||||
nsresult MouseDown(nsIDOMEvent* aMouseEvent);
|
||||
|
|
Загрузка…
Ссылка в новой задаче