зеркало из https://github.com/mozilla/gecko-dev.git
Bug 287730. Fix n of m positional info for HTML radio buttons. r=timeless, sr=bz
This commit is contained in:
Родитель
bd79889f75
Коммит
4f9f6bd7c6
|
@ -43,6 +43,8 @@
|
||||||
#include "nsHTMLFormControlAccessible.h"
|
#include "nsHTMLFormControlAccessible.h"
|
||||||
#include "nsAccessibleText.h"
|
#include "nsAccessibleText.h"
|
||||||
|
|
||||||
|
typedef class nsHTMLRadioButtonAccessible nsHTMLRadioButtonAccessibleWrap;
|
||||||
|
|
||||||
class nsHTMLTextFieldAccessibleWrap : public nsHTMLTextFieldAccessible,
|
class nsHTMLTextFieldAccessibleWrap : public nsHTMLTextFieldAccessible,
|
||||||
public nsAccessibleEditableText
|
public nsAccessibleEditableText
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
#include "nsCURILoader.h"
|
#include "nsCURILoader.h"
|
||||||
#include "nsDocAccessible.h"
|
#include "nsDocAccessible.h"
|
||||||
#include "nsHTMLAreaAccessible.h"
|
#include "nsHTMLAreaAccessible.h"
|
||||||
#include "nsHTMLFormControlAccessible.h"
|
#include "nsHTMLFormControlAccessibleWrap.h"
|
||||||
#include "nsHTMLImageAccessible.h"
|
#include "nsHTMLImageAccessible.h"
|
||||||
#include "nsHTMLLinkAccessible.h"
|
#include "nsHTMLLinkAccessible.h"
|
||||||
#include "nsHTMLSelectAccessible.h"
|
#include "nsHTMLSelectAccessible.h"
|
||||||
|
@ -695,7 +695,7 @@ nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsISupports *aFrame, nsI
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
*_retval = new nsHTMLRadioButtonAccessible(node, weakShell);
|
*_retval = new nsHTMLRadioButtonAccessibleWrap(node, weakShell);
|
||||||
if (! *_retval)
|
if (! *_retval)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ EXPORTS = \
|
||||||
nsAccessibleWrap.h \
|
nsAccessibleWrap.h \
|
||||||
nsDocAccessibleWrap.h \
|
nsDocAccessibleWrap.h \
|
||||||
nsRootAccessibleWrap.h \
|
nsRootAccessibleWrap.h \
|
||||||
|
nsHTMLFormControlAccessibleWrap.h \
|
||||||
nsXULMenuAccessibleWrap.h \
|
nsXULMenuAccessibleWrap.h \
|
||||||
nsXULTreeAccessibleWrap.h \
|
nsXULTreeAccessibleWrap.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
|
@ -72,6 +72,7 @@ CPPSRCS = \
|
||||||
nsTextAccessibleWrap.cpp \
|
nsTextAccessibleWrap.cpp \
|
||||||
nsDocAccessibleWrap.cpp \
|
nsDocAccessibleWrap.cpp \
|
||||||
nsRootAccessibleWrap.cpp \
|
nsRootAccessibleWrap.cpp \
|
||||||
|
nsHTMLFormControlAccessibleWrap.cpp \
|
||||||
nsHTMLWin32ObjectAccessible.cpp \
|
nsHTMLWin32ObjectAccessible.cpp \
|
||||||
nsXULMenuAccessibleWrap.cpp \
|
nsXULMenuAccessibleWrap.cpp \
|
||||||
nsXULTreeAccessibleWrap.cpp \
|
nsXULTreeAccessibleWrap.cpp \
|
||||||
|
@ -83,6 +84,7 @@ EXPORTS = \
|
||||||
nsTextAccessibleWrap.h \
|
nsTextAccessibleWrap.h \
|
||||||
nsDocAccessibleWrap.h \
|
nsDocAccessibleWrap.h \
|
||||||
nsRootAccessibleWrap.h \
|
nsRootAccessibleWrap.h \
|
||||||
|
nsHTMLFormControlAccessibleWrap.h \
|
||||||
nsHTMLWin32ObjectAccessible.h \
|
nsHTMLWin32ObjectAccessible.h \
|
||||||
nsXULMenuAccessibleWrap.h \
|
nsXULMenuAccessibleWrap.h \
|
||||||
nsXULTreeAccessibleWrap.h \
|
nsXULTreeAccessibleWrap.h \
|
||||||
|
|
|
@ -315,7 +315,8 @@ NS_IMETHODIMP nsAccessibleWrap::GetDescription(nsAString& aDescription)
|
||||||
|
|
||||||
// Don't localize the string "of" -- that's just the format of this string.
|
// Don't localize the string "of" -- that's just the format of this string.
|
||||||
// The AT will parse the relevant numbers out and add its own localization.
|
// The AT will parse the relevant numbers out and add its own localization.
|
||||||
nsTextFormatter::ssprintf(aDescription, L"%d of %d", indexInParent, numSiblings);
|
nsTextFormatter::ssprintf(aDescription, NS_LITERAL_STRING("%d of %d").get(),
|
||||||
|
indexInParent, numSiblings);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is mozilla.org code.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is IBM Corporation
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Author: Aaron Leventhal (aleventh@us.ibm.com)
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||||
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#include "nsHTMLFormControlAccessibleWrap.h"
|
||||||
|
#include "nsIDOMHTMLInputElement.h"
|
||||||
|
#include "nsIRadioControlElement.h"
|
||||||
|
#include "nsIRadioGroupContainer.H"
|
||||||
|
#include "nsTextFormatter.h"
|
||||||
|
|
||||||
|
// --------------------------------------------------------
|
||||||
|
// nsXULMenuAccessibleWrap Accessible
|
||||||
|
// --------------------------------------------------------
|
||||||
|
|
||||||
|
nsHTMLRadioButtonAccessibleWrap::nsHTMLRadioButtonAccessibleWrap(nsIDOMNode *aDOMNode,
|
||||||
|
nsIWeakReference *aShell):
|
||||||
|
nsHTMLRadioButtonAccessible(aDOMNode, aShell)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsHTMLRadioButtonAccessibleWrap::GetDescription(nsAString& aDescription)
|
||||||
|
{
|
||||||
|
aDescription.Truncate();
|
||||||
|
|
||||||
|
nsCOMPtr<nsIRadioControlElement> radio(do_QueryInterface(mDOMNode));
|
||||||
|
if (!radio) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_ASSERTION(radio, "We should only have HTML radio buttons here");
|
||||||
|
nsCOMPtr<nsIRadioGroupContainer> radioGroupContainer =
|
||||||
|
radio->GetRadioGroupContainer();
|
||||||
|
|
||||||
|
if (radioGroupContainer) {
|
||||||
|
nsCOMPtr<nsIDOMHTMLInputElement> input(do_QueryInterface(mDOMNode));
|
||||||
|
PRInt32 radioIndex, radioItemsInGroup;
|
||||||
|
if (NS_SUCCEEDED(radioGroupContainer->GetPositionInGroup(input, &radioIndex,
|
||||||
|
&radioItemsInGroup))) {
|
||||||
|
// Don't localize the string "of" -- that's just the format of this string.
|
||||||
|
// The AT will parse the relevant numbers out and add its own localization.
|
||||||
|
nsTextFormatter::ssprintf(aDescription, NS_LITERAL_STRING("%d of %d").get(),
|
||||||
|
radioIndex + 1, radioItemsInGroup);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nsAccessibleWrap::GetDescription(aDescription);
|
||||||
|
}
|
|
@ -166,7 +166,8 @@ NS_IMETHODIMP nsXULTreeitemAccessibleWrap::GetDescription(nsAString& aDescriptio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsTextFormatter::ssprintf(aDescription, L"L%d, %d of %d", level + 1, indexInParent, numSiblings);
|
nsTextFormatter::ssprintf(aDescription, NS_LITERAL_STRING("L%d, %d of %d").get(),
|
||||||
|
level + 1, indexInParent, numSiblings);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,7 @@ EXPORTS = \
|
||||||
nsAccessibleWrap.h \
|
nsAccessibleWrap.h \
|
||||||
nsDocAccessibleWrap.h \
|
nsDocAccessibleWrap.h \
|
||||||
nsRootAccessibleWrap.h \
|
nsRootAccessibleWrap.h \
|
||||||
|
nsHTMLFormControlAccessibleWrap.h \
|
||||||
nsXULMenuAccessibleWrap.h \
|
nsXULMenuAccessibleWrap.h \
|
||||||
nsXULTreeAccessibleWrap.h \
|
nsXULTreeAccessibleWrap.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
|
@ -4204,6 +4204,32 @@ nsDocument::GetCurrentRadioButton(const nsAString& aName,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocument::GetPositionInGroup(nsIDOMHTMLInputElement *aRadio,
|
||||||
|
PRInt32 *aPositionIndex,
|
||||||
|
PRInt32 *aItemsInGroup)
|
||||||
|
{
|
||||||
|
*aPositionIndex = 0;
|
||||||
|
*aItemsInGroup = 1;
|
||||||
|
nsAutoString name;
|
||||||
|
aRadio->GetName(name);
|
||||||
|
if (name.IsEmpty()) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsRadioGroupStruct* radioGroup = nsnull;
|
||||||
|
nsresult rv = GetRadioGroup(name, &radioGroup);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIFormControl> radioControl(do_QueryInterface(aRadio));
|
||||||
|
NS_ASSERTION(radioControl, "Radio button should implement nsIFormControl");
|
||||||
|
*aPositionIndex = radioGroup->mRadioButtons.IndexOf(radioControl);
|
||||||
|
NS_ASSERTION(*aPositionIndex >= 0, "Radio button not found in its own group");
|
||||||
|
*aItemsInGroup = radioGroup->mRadioButtons.Count();
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocument::GetNextRadioButton(const nsAString& aName,
|
nsDocument::GetNextRadioButton(const nsAString& aName,
|
||||||
const PRBool aPrevious,
|
const PRBool aPrevious,
|
||||||
|
|
|
@ -426,6 +426,9 @@ public:
|
||||||
nsIDOMHTMLInputElement* aRadio);
|
nsIDOMHTMLInputElement* aRadio);
|
||||||
NS_IMETHOD GetCurrentRadioButton(const nsAString& aName,
|
NS_IMETHOD GetCurrentRadioButton(const nsAString& aName,
|
||||||
nsIDOMHTMLInputElement** aRadio);
|
nsIDOMHTMLInputElement** aRadio);
|
||||||
|
NS_IMETHOD GetPositionInGroup(nsIDOMHTMLInputElement *aRadio,
|
||||||
|
PRInt32 *aPositionIndex,
|
||||||
|
PRInt32 *aItemsInGroup);
|
||||||
NS_IMETHOD GetNextRadioButton(const nsAString& aName,
|
NS_IMETHOD GetNextRadioButton(const nsAString& aName,
|
||||||
const PRBool aPrevious,
|
const PRBool aPrevious,
|
||||||
nsIDOMHTMLInputElement* aFocusedRadio,
|
nsIDOMHTMLInputElement* aFocusedRadio,
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#define nsIRadioControlElement_h___
|
#define nsIRadioControlElement_h___
|
||||||
|
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
|
#include "nsIRadioGroupContainer.h"
|
||||||
class nsAString;
|
class nsAString;
|
||||||
class nsIForm;
|
class nsIForm;
|
||||||
|
|
||||||
|
@ -106,6 +107,12 @@ public:
|
||||||
* yet).
|
* yet).
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD WillRemoveFromRadioGroup() = 0;
|
NS_IMETHOD WillRemoveFromRadioGroup() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the radio group container for this radio button
|
||||||
|
* @return the radio group container (or null if no container)
|
||||||
|
*/
|
||||||
|
virtual already_AddRefed<nsIRadioGroupContainer> GetRadioGroupContainer() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsIRadioControlElement_h___
|
#endif // nsIRadioControlElement_h___
|
||||||
|
|
|
@ -116,6 +116,19 @@ public:
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD RemoveFromRadioGroup(const nsAString& aName,
|
NS_IMETHOD RemoveFromRadioGroup(const nsAString& aName,
|
||||||
nsIFormControl* aRadio) = 0;
|
nsIFormControl* aRadio) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the radio group position and the number of radio buttons in the group.
|
||||||
|
* that the radio button is in. If the radio button not grouped with any other
|
||||||
|
* radio buttons this method will treat it as being in a group of one.
|
||||||
|
* @param aRadio radio button's pointer
|
||||||
|
* @param aPositionIndex out indicates 0-indexed position in the radio group,
|
||||||
|
* or just 0 if a group cannot be found
|
||||||
|
* @param aItemsInGroup the number of radio buttons in the group
|
||||||
|
*/
|
||||||
|
NS_IMETHOD GetPositionInGroup(nsIDOMHTMLInputElement *aRadio,
|
||||||
|
PRInt32 *aPositionIndex,
|
||||||
|
PRInt32 *aItemsInGroup) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsIRadioGroupContainer_h__ */
|
#endif /* nsIRadioGroupContainer_h__ */
|
||||||
|
|
|
@ -150,6 +150,9 @@ public:
|
||||||
nsIDOMHTMLInputElement* aRadio);
|
nsIDOMHTMLInputElement* aRadio);
|
||||||
NS_IMETHOD GetCurrentRadioButton(const nsAString& aName,
|
NS_IMETHOD GetCurrentRadioButton(const nsAString& aName,
|
||||||
nsIDOMHTMLInputElement** aRadio);
|
nsIDOMHTMLInputElement** aRadio);
|
||||||
|
NS_IMETHOD GetPositionInGroup(nsIDOMHTMLInputElement *aRadio,
|
||||||
|
PRInt32 *aPositionIndex,
|
||||||
|
PRInt32 *aItemsInGroup);
|
||||||
NS_IMETHOD GetNextRadioButton(const nsAString& aName,
|
NS_IMETHOD GetNextRadioButton(const nsAString& aName,
|
||||||
const PRBool aPrevious,
|
const PRBool aPrevious,
|
||||||
nsIDOMHTMLInputElement* aFocusedRadio,
|
nsIDOMHTMLInputElement* aFocusedRadio,
|
||||||
|
@ -1473,7 +1476,48 @@ nsHTMLFormElement::GetCurrentRadioButton(const nsAString& aName,
|
||||||
mSelectedRadioButtons.Get(aName, aRadio);
|
mSelectedRadioButtons.Get(aName, aRadio);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}NS_IMETHODIMP
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsHTMLFormElement::GetPositionInGroup(nsIDOMHTMLInputElement *aRadio,
|
||||||
|
PRInt32 *aPositionIndex,
|
||||||
|
PRInt32 *aItemsInGroup)
|
||||||
|
{
|
||||||
|
*aPositionIndex = 0;
|
||||||
|
*aItemsInGroup = 1;
|
||||||
|
|
||||||
|
nsAutoString name;
|
||||||
|
aRadio->GetName(name);
|
||||||
|
if (name.IsEmpty()) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsISupports> itemWithName;
|
||||||
|
nsresult rv = ResolveName(name, getter_AddRefs(itemWithName));
|
||||||
|
NS_ENSURE_TRUE(rv, rv);
|
||||||
|
nsCOMPtr<nsIDOMNodeList> radioNodeList(do_QueryInterface(itemWithName));
|
||||||
|
|
||||||
|
// XXX If ResolveName could return an nsContentList instead then we
|
||||||
|
// could get an nsContentList instead of using this hacky upcast
|
||||||
|
nsBaseContentList *radioGroup =
|
||||||
|
NS_STATIC_CAST(nsBaseContentList *, (nsIDOMNodeList *)radioNodeList);
|
||||||
|
NS_ASSERTION(radioGroup, "No such radio group in this container");
|
||||||
|
if (!radioGroup) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIContent> currentRadioNode(do_QueryInterface(aRadio));
|
||||||
|
NS_ASSERTION(currentRadioNode, "No nsIContent for current radio button");
|
||||||
|
*aPositionIndex = radioGroup->IndexOf(currentRadioNode, PR_TRUE);
|
||||||
|
NS_ASSERTION(*aPositionIndex >= 0, "Radio button not found in its own group");
|
||||||
|
PRUint32 itemsInGroup;
|
||||||
|
radioGroup->GetLength(&itemsInGroup);
|
||||||
|
*aItemsInGroup = itemsInGroup;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
nsHTMLFormElement::GetNextRadioButton(const nsAString& aName,
|
nsHTMLFormElement::GetNextRadioButton(const nsAString& aName,
|
||||||
const PRBool aPrevious,
|
const PRBool aPrevious,
|
||||||
nsIDOMHTMLInputElement* aFocusedRadio,
|
nsIDOMHTMLInputElement* aFocusedRadio,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче