зеркало из https://github.com/mozilla/gecko-dev.git
Renamed some methods and changed the selected item to be able to pass the currently selected index instead of just being able to get the currently selected item
This commit is contained in:
Родитель
c72c25f2d3
Коммит
0362529f13
|
@ -597,7 +597,7 @@ nsListControlFrame::DisplayDeselected(nsIContent* aContent)
|
|||
|
||||
//---------------------------------------------------------
|
||||
PRInt32
|
||||
nsListControlFrame::GetSelectedIndex(nsIFrame *aHitFrame)
|
||||
nsListControlFrame::GetSelectedIndexFromFrame(nsIFrame *aHitFrame)
|
||||
{
|
||||
PRInt32 index = kNothingSelected;
|
||||
// Get the content of the frame that was selected
|
||||
|
@ -690,7 +690,7 @@ nsListControlFrame::SingleSelection()
|
|||
// Store previous selection
|
||||
PRInt32 oldSelectedIndex = mSelectedIndex;
|
||||
// Get Current selection
|
||||
PRInt32 newSelectedIndex = (PRInt32)GetSelectedIndex(mHitFrame);
|
||||
PRInt32 newSelectedIndex = (PRInt32)GetSelectedIndexFromFrame(mHitFrame);
|
||||
if (newSelectedIndex != kNothingSelected) {
|
||||
if (oldSelectedIndex != newSelectedIndex) {
|
||||
// Deselect the previous selection if there is one
|
||||
|
@ -712,7 +712,7 @@ void
|
|||
nsListControlFrame::MultipleSelection(PRBool aIsShift, PRBool aIsControl)
|
||||
{
|
||||
if (nsnull != mHitFrame) {
|
||||
mSelectedIndex = (PRInt32)GetSelectedIndex(mHitFrame);
|
||||
mSelectedIndex = (PRInt32)GetSelectedIndexFromFrame(mHitFrame);
|
||||
if (kNothingSelected != mSelectedIndex) {
|
||||
if ((aIsShift) || (mButtonDown && (!aIsControl))) {
|
||||
// Shift is held down
|
||||
|
@ -943,7 +943,7 @@ nsListControlFrame::HandleLikeDropDownListEvent(nsIPresContext& aPresContext,
|
|||
|
||||
if (nsnull != mHitFrame) {
|
||||
PRInt32 oldSelectedIndex = mSelectedIndex;
|
||||
PRInt32 newSelectedIndex = GetSelectedIndex(mHitFrame);
|
||||
PRInt32 newSelectedIndex = GetSelectedIndexFromFrame(mHitFrame);
|
||||
if (kNothingSelected != newSelectedIndex) {
|
||||
if (oldSelectedIndex != newSelectedIndex) {
|
||||
if (oldSelectedIndex != kNothingSelected) {
|
||||
|
@ -957,7 +957,7 @@ nsListControlFrame::HandleLikeDropDownListEvent(nsIPresContext& aPresContext,
|
|||
} else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
|
||||
// Start by finding the newly "hit" content from the hit frame
|
||||
if (nsnull != mHitFrame) {
|
||||
PRInt32 index = GetSelectedIndex(mHitFrame);
|
||||
PRInt32 index = GetSelectedIndexFromFrame(mHitFrame);
|
||||
if (kNothingSelected != index) {
|
||||
SetFrameSelected(index, PR_TRUE);
|
||||
mSelectedIndex = index;
|
||||
|
@ -1142,7 +1142,7 @@ nsListControlFrame::GetOptionAsContent(nsIDOMHTMLCollection* aCollection,PRUint3
|
|||
nsIDOMHTMLOptionElement* optionElement = GetOption(*aCollection, aIndex);
|
||||
if (nsnull != optionElement) {
|
||||
content = nsnull;
|
||||
nsresult result = optionElement->QueryInterface(nsCOMTypeInfo<nsIContent>::GetIID(),(void**) &content);
|
||||
optionElement->QueryInterface(nsCOMTypeInfo<nsIContent>::GetIID(),(void**) &content);
|
||||
NS_RELEASE(optionElement);
|
||||
}
|
||||
|
||||
|
@ -1499,6 +1499,14 @@ nsListControlFrame::GetSelectedItem(nsString & aStr)
|
|||
return rv;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsListControlFrame::GetSelectedIndex(PRInt32 * aIndex)
|
||||
{
|
||||
*aIndex = mSelectedIndex;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
PRBool
|
||||
nsListControlFrame::IsInDropDownMode()
|
||||
|
|
|
@ -99,6 +99,7 @@ public:
|
|||
// nsIListControlFrame
|
||||
NS_IMETHOD SetComboboxFrame(nsIFrame* aComboboxFrame);
|
||||
NS_IMETHOD GetSelectedItem(nsString & aStr);
|
||||
NS_IMETHOD GetSelectedIndex(PRInt32* aIndex);
|
||||
NS_IMETHOD CaptureMouseEvents(PRBool aGrabMouseEvents);
|
||||
NS_IMETHOD GetMaximumSize(nsSize &aSize);
|
||||
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
|
||||
|
@ -164,7 +165,7 @@ protected:
|
|||
nsresult HandleLikeListEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
PRInt32 GetSelectedIndex(nsIFrame *aHitFrame);
|
||||
PRInt32 GetSelectedIndexFromFrame(nsIFrame *aHitFrame);
|
||||
|
||||
// Data Members
|
||||
nscoord mBorderOffsetY;
|
||||
|
|
|
@ -597,7 +597,7 @@ nsListControlFrame::DisplayDeselected(nsIContent* aContent)
|
|||
|
||||
//---------------------------------------------------------
|
||||
PRInt32
|
||||
nsListControlFrame::GetSelectedIndex(nsIFrame *aHitFrame)
|
||||
nsListControlFrame::GetSelectedIndexFromFrame(nsIFrame *aHitFrame)
|
||||
{
|
||||
PRInt32 index = kNothingSelected;
|
||||
// Get the content of the frame that was selected
|
||||
|
@ -690,7 +690,7 @@ nsListControlFrame::SingleSelection()
|
|||
// Store previous selection
|
||||
PRInt32 oldSelectedIndex = mSelectedIndex;
|
||||
// Get Current selection
|
||||
PRInt32 newSelectedIndex = (PRInt32)GetSelectedIndex(mHitFrame);
|
||||
PRInt32 newSelectedIndex = (PRInt32)GetSelectedIndexFromFrame(mHitFrame);
|
||||
if (newSelectedIndex != kNothingSelected) {
|
||||
if (oldSelectedIndex != newSelectedIndex) {
|
||||
// Deselect the previous selection if there is one
|
||||
|
@ -712,7 +712,7 @@ void
|
|||
nsListControlFrame::MultipleSelection(PRBool aIsShift, PRBool aIsControl)
|
||||
{
|
||||
if (nsnull != mHitFrame) {
|
||||
mSelectedIndex = (PRInt32)GetSelectedIndex(mHitFrame);
|
||||
mSelectedIndex = (PRInt32)GetSelectedIndexFromFrame(mHitFrame);
|
||||
if (kNothingSelected != mSelectedIndex) {
|
||||
if ((aIsShift) || (mButtonDown && (!aIsControl))) {
|
||||
// Shift is held down
|
||||
|
@ -943,7 +943,7 @@ nsListControlFrame::HandleLikeDropDownListEvent(nsIPresContext& aPresContext,
|
|||
|
||||
if (nsnull != mHitFrame) {
|
||||
PRInt32 oldSelectedIndex = mSelectedIndex;
|
||||
PRInt32 newSelectedIndex = GetSelectedIndex(mHitFrame);
|
||||
PRInt32 newSelectedIndex = GetSelectedIndexFromFrame(mHitFrame);
|
||||
if (kNothingSelected != newSelectedIndex) {
|
||||
if (oldSelectedIndex != newSelectedIndex) {
|
||||
if (oldSelectedIndex != kNothingSelected) {
|
||||
|
@ -957,7 +957,7 @@ nsListControlFrame::HandleLikeDropDownListEvent(nsIPresContext& aPresContext,
|
|||
} else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
|
||||
// Start by finding the newly "hit" content from the hit frame
|
||||
if (nsnull != mHitFrame) {
|
||||
PRInt32 index = GetSelectedIndex(mHitFrame);
|
||||
PRInt32 index = GetSelectedIndexFromFrame(mHitFrame);
|
||||
if (kNothingSelected != index) {
|
||||
SetFrameSelected(index, PR_TRUE);
|
||||
mSelectedIndex = index;
|
||||
|
@ -1142,7 +1142,7 @@ nsListControlFrame::GetOptionAsContent(nsIDOMHTMLCollection* aCollection,PRUint3
|
|||
nsIDOMHTMLOptionElement* optionElement = GetOption(*aCollection, aIndex);
|
||||
if (nsnull != optionElement) {
|
||||
content = nsnull;
|
||||
nsresult result = optionElement->QueryInterface(nsCOMTypeInfo<nsIContent>::GetIID(),(void**) &content);
|
||||
optionElement->QueryInterface(nsCOMTypeInfo<nsIContent>::GetIID(),(void**) &content);
|
||||
NS_RELEASE(optionElement);
|
||||
}
|
||||
|
||||
|
@ -1499,6 +1499,14 @@ nsListControlFrame::GetSelectedItem(nsString & aStr)
|
|||
return rv;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsListControlFrame::GetSelectedIndex(PRInt32 * aIndex)
|
||||
{
|
||||
*aIndex = mSelectedIndex;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
PRBool
|
||||
nsListControlFrame::IsInDropDownMode()
|
||||
|
|
|
@ -99,6 +99,7 @@ public:
|
|||
// nsIListControlFrame
|
||||
NS_IMETHOD SetComboboxFrame(nsIFrame* aComboboxFrame);
|
||||
NS_IMETHOD GetSelectedItem(nsString & aStr);
|
||||
NS_IMETHOD GetSelectedIndex(PRInt32* aIndex);
|
||||
NS_IMETHOD CaptureMouseEvents(PRBool aGrabMouseEvents);
|
||||
NS_IMETHOD GetMaximumSize(nsSize &aSize);
|
||||
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
|
||||
|
@ -164,7 +165,7 @@ protected:
|
|||
nsresult HandleLikeListEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
PRInt32 GetSelectedIndex(nsIFrame *aHitFrame);
|
||||
PRInt32 GetSelectedIndexFromFrame(nsIFrame *aHitFrame);
|
||||
|
||||
// Data Members
|
||||
nscoord mBorderOffsetY;
|
||||
|
|
Загрузка…
Ссылка в новой задаче