Skip to content

Commit

Permalink
Announce the way an item is sorted (if any) according to its aria-sor…
Browse files Browse the repository at this point in the history
…t property, on both individual NVDAObjects, and in virtualBuffers, for both MSHTML and gecko ia2. NVDA will report "sorted ascending", "sorted descending" or just "sorted" depending on what kind of sort it is. Announcement as it changes is not supported yet and may need bug fixes in some web browsers.
  • Loading branch information
michaelDCurran committed May 16, 2011
1 parent d7abe00 commit 5d31a28
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions nvdaHelper/vbufBackends/mshtml/mshtml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ inline void getAttributesFromHTMLDOMNode(IHTMLDOMNode* pHTMLDOMNode,wstring& nod
macro_addHTMLAttributeToMap(L"onmouseup",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
//ARIA properties:
macro_addHTMLAttributeToMap(L"role",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
macro_addHTMLAttributeToMap(L"aria-sort",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
macro_addHTMLAttributeToMap(L"aria-selected",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
macro_addHTMLAttributeToMap(L"aria-level",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
macro_addHTMLAttributeToMap(L"aria-required",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
Expand Down
10 changes: 10 additions & 0 deletions source/NVDAObjects/IAccessible/MSHTML.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,16 @@ def _get_states(self):
states=set()
e=self.HTMLNode
if e:
try:
ariaSorted=e.GetAttribute('aria-sort')
except (COMError, NameError):
ariaSorted=None
if ariaSorted=="ascending":
states.add(controlTypes.STATE_SORTED_ASCENDING)
elif ariaSorted=="descending":
states.add(controlTypes.STATE_SORTED_DESCENDING)
elif ariaSorted=="other":
states.add(controlTypes.STATE_SORTED)
try:
ariaRequired=e.GetAttribute('aria-required')
except (COMError, NameError):
Expand Down
7 changes: 7 additions & 0 deletions source/NVDAObjects/IAccessible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,13 @@ def _get_states(self):
states.add(controlTypes.STATE_DRAGGING)
if IA2Attribs.get("dropeffect", "none") != "none":
states.add(controlTypes.STATE_DROPTARGET)
sorted = IA2Attribs.get("sort")
if sorted=="ascending":
states.add(controlTypes.STATE_SORTED_ASCENDING)
elif sorted=="descending":
states.add(controlTypes.STATE_SORTED_DESCENDING)
elif sorted=="other":
states.add(controlTypes.STATE_SORTED)
if controlTypes.STATE_HASPOPUP in states and controlTypes.STATE_AUTOCOMPLETE in states:
states.remove(controlTypes.STATE_HASPOPUP)
if controlTypes.STATE_HALFCHECKED in states:
Expand Down
8 changes: 7 additions & 1 deletion source/controlTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@
STATE_DRAGGABLE=0x10000000
STATE_DRAGGING=0x20000000
STATE_DROPTARGET=0x40000000

STATE_SORTED=0x80000000
STATE_SORTED_ASCENDING=0x100000000
STATE_SORTED_DESCENDING=0x200000000
STATES_SORTED=frozenset([STATE_SORTED,STATE_SORTED_ASCENDING,STATE_SORTED_DESCENDING])

speechRoleLabels={
ROLE_UNKNOWN:_("unknown"),
Expand Down Expand Up @@ -352,4 +355,7 @@
STATE_DRAGGABLE:_("draggable"),
STATE_DRAGGING:_("dragging"),
STATE_DROPTARGET:_("drop target"),
STATE_SORTED:_("sorted"),
STATE_SORTED_ASCENDING:_("sorted ascending"),
STATE_SORTED_DESCENDING:_("sorted descending"),
}
2 changes: 2 additions & 0 deletions source/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ def processNegativeStates(role, states, reason, negativeStates):
# Restrict "not checked" in a similar way to "not selected".
if (role in (controlTypes.ROLE_CHECKBOX, controlTypes.ROLE_RADIOBUTTON, controlTypes.ROLE_CHECKMENUITEM) or controlTypes.STATE_CHECKABLE in states) and (controlTypes.STATE_HALFCHECKED not in states) and (reason != REASON_CHANGE or controlTypes.STATE_FOCUSED in states):
speakNegatives.add(controlTypes.STATE_CHECKED)
if reason==REASON_CHANGE and not controlTypes.STATES_SORTED&states:
speakNegatives.add(controlTypes.STATE_SORTED)
if reason == REASON_CHANGE:
# We want to speak this state only if it is changing to negative.
speakNegatives.add(controlTypes.STATE_DROPTARGET)
Expand Down
7 changes: 7 additions & 0 deletions source/virtualBuffers/MSHTML.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def _normalizeControlField(self,attrs):
states.add(controlTypes.STATE_CLICKABLE)
if attrs.get('HTMLAttrib::aria-required','false')=='true':
states.add(controlTypes.STATE_REQUIRED)
ariaSorted=attrs.get('HTMLAttrib::aria-sort')
if ariaSorted=="ascending":
states.add(controlTypes.STATE_SORTED_ASCENDING)
elif ariaSorted=="descending":
states.add(controlTypes.STATE_SORTED_DESCENDING)
elif ariaSorted=="other":
states.add(controlTypes.STATE_SORTED)
ariaSelected=attrs.get('HTMLAttrib::aria-selected')
if ariaSelected=="true":
states.add(controlTypes.STATE_SELECTED)
Expand Down
7 changes: 7 additions & 0 deletions source/virtualBuffers/gecko_ia2.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ def _normalizeControlField(self,attrs):
states.add(controlTypes.STATE_DRAGGABLE)
elif grabbed == "true":
states.add(controlTypes.STATE_DRAGGING)
sorted = attrs.get("IAccessible2::attribute_aria-sorted")
if sorted=="ascending":
states.add(controlTypes.STATE_SORTED_ASCENDING)
elif sorted=="descending":
states.add(controlTypes.STATE_SORTED_DESCENDING)
elif sorted=="other":
states.add(controlTypes.STATE_SORTED)
if attrs.get("IAccessible2::attribute_dropeffect", "none") != "none":
states.add(controlTypes.STATE_DROPTARGET)
if role==controlTypes.ROLE_LINK and controlTypes.STATE_LINKED not in states:
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- When punctuation or other symbols are repeated more than four times, the number of repetitions is now announced instead of speaking the repeated symbols. (#43)
- New braille translation table: Norwegian 8 dot computer braille. (#1456)
- Speech no longer unnaturally pauses at the end of each line when using the say all command. (#149)
- NVDA will now announce whether something is sorted (according to the aria-sort property) where available in web browsers


== Changes ==
Expand Down

0 comments on commit 5d31a28

Please sign in to comment.