Fix for bug 376032 - posinset and setsize incorrect for html radio buttons, r=ginn.chen

This commit is contained in:
surkov.alexander@gmail.com 2007-04-03 01:27:43 -07:00
Родитель 6486ab880c
Коммит d4796e4b04
1 изменённых файлов: 32 добавлений и 14 удалений

Просмотреть файл

@ -152,32 +152,50 @@ nsHTMLRadioButtonAccessible::GetAttributes(nsIPersistentProperties **aAttributes
nsAutoString tagName; nsAutoString tagName;
mDOMNode->GetLocalName(tagName); mDOMNode->GetLocalName(tagName);
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
NS_ENSURE_STATE(content);
nsAutoString type;
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::type, type);
nsAutoString name;
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::name, name);
nsCOMPtr<nsIDOMHTMLInputElement> radio(do_QueryInterface(mDOMNode)); nsCOMPtr<nsIDOMHTMLInputElement> radio(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLFormElement> form; nsCOMPtr<nsIDOMHTMLFormElement> form;
radio->GetForm(getter_AddRefs(form)); radio->GetForm(getter_AddRefs(form));
NS_ENSURE_TRUE(form, NS_OK); NS_ENSURE_TRUE(form, NS_OK);
nsCOMPtr<nsIDOMNodeList> radios; nsCOMPtr<nsIDOMNodeList> inputs;
form->GetElementsByTagNameNS(nsURI, tagName, getter_AddRefs(radios)); form->GetElementsByTagNameNS(nsURI, tagName, getter_AddRefs(inputs));
NS_ENSURE_TRUE(radios, NS_OK); NS_ENSURE_TRUE(inputs, NS_OK);
// setsize PRUint32 inputsCount = 0;
PRUint32 radiosCount = 0; inputs->GetLength(&inputsCount);
radios->GetLength(&radiosCount);
// posinset // Get posinset and setsize.
PRInt32 indexOf = 0; PRInt32 indexOf = 0;
for (PRUint32 index = 0; index < radiosCount; index++) { PRInt32 count = 0;
nsCOMPtr<nsIDOMNode> item;
radios->Item(index, getter_AddRefs(item)); for (PRUint32 index = 0; index < inputsCount; index++) {
if (item == mDOMNode) { nsCOMPtr<nsIDOMNode> itemNode;
indexOf = index; inputs->Item(index, getter_AddRefs(itemNode));
break;
nsCOMPtr<nsIContent> item(do_QueryInterface(itemNode));
if (item &&
item->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
type, eCaseMatters) &&
item->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::name,
name, eCaseMatters)) {
count++;
if (itemNode == mDOMNode)
indexOf = count;
} }
} }
nsAccessibilityUtils:: nsAccessibilityUtils::
SetAccGroupAttrs(*aAttributes, 0, indexOf + 1, radiosCount); SetAccGroupAttrs(*aAttributes, 0, indexOf, count);
return NS_OK; return NS_OK;
} }