mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-30 01:59:29 +00:00
Bug 443881 – take into account separators in xul menus when group attributes are calculating, r=MarcoZ, sr=neil
This commit is contained in:
parent
f0df97ad39
commit
5009816d79
@ -225,21 +225,46 @@ nsAccUtils::SetAccAttrsForXULContainerItem(nsIDOMNode *aNode,
|
||||
// Get item index.
|
||||
PRInt32 indexOf = 0;
|
||||
container->GetIndexOfItem(item, &indexOf);
|
||||
|
||||
PRUint32 setSize = itemsCount, posInSet = indexOf;
|
||||
for (PRUint32 index = 0; index < itemsCount; index++) {
|
||||
nsCOMPtr<nsIDOMXULElement> currItem;
|
||||
container->GetItemAtIndex(index, getter_AddRefs(currItem));
|
||||
nsCOMPtr<nsIDOMNode> currNode(do_QueryInterface(currItem));
|
||||
|
||||
// Calculate set size and position in the set.
|
||||
PRUint32 setSize = 0, posInSet = 0;
|
||||
for (PRInt32 index = indexOf; index >= 0; index--) {
|
||||
nsCOMPtr<nsIDOMXULElement> item;
|
||||
container->GetItemAtIndex(index, getter_AddRefs(item));
|
||||
|
||||
nsCOMPtr<nsIAccessible> itemAcc;
|
||||
nsAccessNode::GetAccService()->GetAccessibleFor(item,
|
||||
getter_AddRefs(itemAcc));
|
||||
|
||||
if (itemAcc) {
|
||||
PRUint32 itemRole = nsAccessible::Role(itemAcc);
|
||||
if (itemRole == nsIAccessibleRole::ROLE_SEPARATOR)
|
||||
break; // We reached the beginning of our group.
|
||||
|
||||
PRUint32 itemState = nsAccessible::State(itemAcc);
|
||||
if (!(itemState & nsIAccessibleStates::STATE_INVISIBLE)) {
|
||||
setSize++;
|
||||
posInSet++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (PRInt32 index = indexOf + 1; index < itemsCount; index++) {
|
||||
nsCOMPtr<nsIDOMXULElement> item;
|
||||
container->GetItemAtIndex(index, getter_AddRefs(item));
|
||||
|
||||
nsCOMPtr<nsIAccessible> itemAcc;
|
||||
nsAccessNode::GetAccService()->GetAccessibleFor(currNode,
|
||||
nsAccessNode::GetAccService()->GetAccessibleFor(item,
|
||||
getter_AddRefs(itemAcc));
|
||||
if (!itemAcc ||
|
||||
nsAccessible::State(itemAcc) & nsIAccessibleStates::STATE_INVISIBLE) {
|
||||
setSize--;
|
||||
if (index < static_cast<PRUint32>(indexOf))
|
||||
posInSet--;
|
||||
|
||||
if (itemAcc) {
|
||||
PRUint32 itemRole = nsAccessible::Role(itemAcc);
|
||||
if (itemRole == nsIAccessibleRole::ROLE_SEPARATOR)
|
||||
break; // We reached the end of our group.
|
||||
|
||||
PRUint32 itemState = nsAccessible::State(itemAcc);
|
||||
if (!(itemState & nsIAccessibleStates::STATE_INVISIBLE))
|
||||
setSize++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,7 +278,7 @@ nsAccUtils::SetAccAttrsForXULContainerItem(nsIDOMNode *aNode,
|
||||
parentContainer.swap(container);
|
||||
}
|
||||
|
||||
SetAccGroupAttrs(aAttributes, level, posInSet + 1, setSize);
|
||||
SetAccGroupAttrs(aAttributes, level, posInSet, setSize);
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
@ -21,20 +21,24 @@
|
||||
try {
|
||||
return this.mAttrs.getStringProperty(aName);
|
||||
} catch (e) {
|
||||
alert(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
this.mAcc = gAccService.getAccessibleFor(document.getElementById(aId));
|
||||
this.mAttrs = this.mAcc.attributes;
|
||||
ok(this.mAcc, "Can't get accessible for " + aId);
|
||||
|
||||
if (this.mAcc)
|
||||
this.mAttrs = this.mAcc.attributes;
|
||||
}
|
||||
|
||||
function testGroupAtts(aID, aPosInSet, aSetSize)
|
||||
function testGroupAttrs(aID, aPosInSet, aSetSize, aLevel)
|
||||
{
|
||||
var attrs = new accAttributes(aID);
|
||||
is(attrs.getAttribute("posinset"), aPosInSet, "Wrong posinset on " + aID);
|
||||
is(attrs.getAttribute("setsize"), aSetSize, "Wrong setsize on " + aID);
|
||||
if (aLevel)
|
||||
is(attrs.getAttribute("level"), aLevel, "Wrong level on " + aID);
|
||||
}
|
||||
|
||||
function doTest()
|
||||
@ -45,17 +49,36 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// xul:listbox (bug 417317)
|
||||
testGroupAtts("item1", "1", "2");
|
||||
testGroupAtts("item2", "2", "2");
|
||||
testGroupAttrs("item1", "1", "2");
|
||||
testGroupAttrs("item2", "2", "2");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// xul:menu (bug 443881)
|
||||
var menu1 = document.getElementById("menu_item1");
|
||||
menu1.open = true;
|
||||
|
||||
window.setTimeout(function() {
|
||||
var menu2 = document.getElementById("menu_item2");
|
||||
menu2.open = true;
|
||||
|
||||
window.setTimeout(function() {
|
||||
testGroupAttrs("menu_item1.1", "1", "1");
|
||||
testGroupAttrs("menu_item1.2", "1", "3");
|
||||
testGroupAttrs("menu_item1.4", "2", "3");
|
||||
testGroupAttrs("menu_item2", "3", "3");
|
||||
testGroupAttrs("menu_item2.1", "1", "2", "1");
|
||||
testGroupAttrs("menu_item2.2", "2", "2", "1");
|
||||
|
||||
SimpleTest.finish();
|
||||
}, 0);
|
||||
}, 0);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ARIA menu (bug 441888)
|
||||
testGroupAtts("aria-menuitem", "1", "3");
|
||||
testGroupAtts("aria-menuitemcheckbox", "2", "3");
|
||||
testGroupAtts("aria-menuitemradio", "3", "3");
|
||||
testGroupAtts("aria-menuitem2", "1", "1");
|
||||
|
||||
SimpleTest.finish();
|
||||
testGroupAttrs("aria-menuitem", "1", "3");
|
||||
testGroupAttrs("aria-menuitemcheckbox", "2", "3");
|
||||
testGroupAttrs("aria-menuitemradio", "3", "3");
|
||||
testGroupAttrs("aria-menuitem2", "1", "1");
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
@ -68,7 +91,18 @@
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=417317"
|
||||
title="Certain types of LISTITEM accessibles no longer get attributes set like 'x of y', regression from fix for bug 389926">
|
||||
Mozilla Bug 417317
|
||||
</a>
|
||||
</a><br/>
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=443881"
|
||||
title="take into account separators in xul menus when group attributes are calculating">
|
||||
Mozilla Bug 443881
|
||||
</a><br/>
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=441888"
|
||||
title="ARIA checked menu items are not included in the total list of menu items">
|
||||
Mozilla Bug 441888
|
||||
</a><br/>
|
||||
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
@ -81,6 +115,24 @@
|
||||
<listitem label="item2" id="item2"/>
|
||||
</listbox>
|
||||
|
||||
<menubar>
|
||||
<menu label="item1" id="menu_item1">
|
||||
<menupopup>
|
||||
<menuitem label="item1.1" id="menu_item1.1"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="item1.2" id="menu_item1.2"/>
|
||||
<menuitem label="item1.3" hidden="true"/>
|
||||
<menuitem label="item1.4" id="menu_item1.4"/>
|
||||
<menu label="item2" id="menu_item2">
|
||||
<menupopup>
|
||||
<menuitem label="item2.1" id="menu_item2.1"/>
|
||||
<menuitem label="item2.2" id="menu_item2.2"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menubar>
|
||||
|
||||
<vbox>
|
||||
<description role="menuitem" id="aria-menuitem"
|
||||
value="conventional menuitem"/>
|
||||
|
@ -20,8 +20,6 @@
|
||||
<property name="accessibleType" readonly="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
if (this.localName == "menuseparator")
|
||||
return Components.interfaces.nsIAccessibleProvider.XULMenuSeparator;
|
||||
return Components.interfaces.nsIAccessibleProvider.XULMenuitem;
|
||||
]]>
|
||||
</getter>
|
||||
@ -271,6 +269,18 @@
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
<binding id="menuseparator" extends="chrome://global/content/bindings/menu.xml#menuitem-base"/>
|
||||
<binding id="menuseparator"
|
||||
extends="chrome://global/content/bindings/menu.xml#menuitem-base">
|
||||
<implementation>
|
||||
<!-- nsIAccessibleProvider -->
|
||||
<property name="accessibleType" readonly="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
return Components.interfaces.nsIAccessibleProvider.XULMenuSeparator;
|
||||
]]>
|
||||
</getter>
|
||||
</property>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
</bindings>
|
||||
|
Loading…
x
Reference in New Issue
Block a user