-
-
Notifications
You must be signed in to change notification settings - Fork 747
I6358 support aria current #6860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
258dc82
7c41316
0b23b86
75c28c6
8ff0d42
248e278
43bc534
9a7987a
9be84bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -798,6 +798,12 @@ def _get_statusBar(self): | |
| """ | ||
| return None | ||
|
|
||
| def getValueForAriaCurrent(self): | ||
| """Gets the value for aria-current. Normally returns False. If this object is current | ||
| it will return one of the following values: True, "page", "step", "location", "date", "time" | ||
| """ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah ok. I'm not 100% comfortable with the name, but I can't think of anything better. |
||
| return False | ||
|
|
||
| def reportFocus(self): | ||
| """Announces this object in a way suitable such that it gained focus. | ||
| """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -307,6 +307,7 @@ def speakObjectProperties(obj,reason=controlTypes.REASON_QUERY,index=None,**allo | |
| newPropertyValues["_tableID"]=obj.tableID | ||
| except NotImplementedError: | ||
| pass | ||
| newPropertyValues['current']=obj.getValueForAriaCurrent() | ||
| #Get the speech text for the properties we want to speak, and then speak it | ||
| text=getSpeechTextForProperties(reason,**newPropertyValues) | ||
| if text: | ||
|
|
@@ -1001,6 +1002,20 @@ def getSpeechTextForProperties(reason=controlTypes.REASON_QUERY,**propertyValues | |
| if rowCount or columnCount: | ||
| # The caller is entering a table, so ensure that it is treated as a new table, even if the previous table was the same. | ||
| oldTableID = None | ||
| ariaCurrent = propertyValues.get('current', False) | ||
| if ariaCurrent is not None and ariaCurrent != False: | ||
|
||
| if ariaCurrent=="page": | ||
| textList.append(_("current page")) | ||
|
||
| elif ariaCurrent=="step": | ||
| textList.append(_("current step")) | ||
| elif ariaCurrent=="location": | ||
| textList.append(_("current location")) | ||
| elif ariaCurrent=="date": | ||
| textList.append(_("current date")) | ||
| elif ariaCurrent=="time": | ||
| textList.append(_("current time")) | ||
| else: | ||
| textList.append(_("current")) | ||
| indexInGroup=propertyValues.get('positionInfo_indexInGroup',0) | ||
| similarItemsInGroup=propertyValues.get('positionInfo_similarItemsInGroup',0) | ||
| if 0<indexInGroup<=similarItemsInGroup: | ||
|
|
@@ -1035,6 +1050,7 @@ def getControlFieldSpeech(attrs,ancestorAttrs,fieldType,formatConfig=None,extraD | |
| role=attrs.get('role',controlTypes.ROLE_UNKNOWN) | ||
| states=attrs.get('states',set()) | ||
| keyboardShortcut=attrs.get('keyboardShortcut', "") | ||
| ariaCurrent=attrs.get('current', None) | ||
| value=attrs.get('value',"") | ||
| if reason==controlTypes.REASON_FOCUS or attrs.get('alwaysReportDescription',False): | ||
| description=attrs.get('description',"") | ||
|
|
@@ -1050,6 +1066,7 @@ def getControlFieldSpeech(attrs,ancestorAttrs,fieldType,formatConfig=None,extraD | |
| roleText=getSpeechTextForProperties(reason=reason,role=role) | ||
| stateText=getSpeechTextForProperties(reason=reason,states=states,_role=role) | ||
| keyboardShortcutText=getSpeechTextForProperties(reason=reason,keyboardShortcut=keyboardShortcut) if config.conf["presentation"]["reportKeyboardShortcuts"] else "" | ||
| ariaCurrentText=getSpeechTextForProperties(reason=reason,current=ariaCurrent) | ||
| nameText=getSpeechTextForProperties(reason=reason,name=name) | ||
| valueText=getSpeechTextForProperties(reason=reason,value=value) | ||
| descriptionText=(getSpeechTextForProperties(reason=reason,description=description) | ||
|
|
@@ -1112,7 +1129,7 @@ def getControlFieldSpeech(attrs,ancestorAttrs,fieldType,formatConfig=None,extraD | |
| content = attrs.get("content") | ||
| if content and speakContentFirst: | ||
| out.append(content) | ||
| out.extend(x for x in (nameText,(stateText if speakStatesFirst else roleText),(roleText if speakStatesFirst else stateText),valueText,descriptionText,levelText,keyboardShortcutText) if x) | ||
| out.extend(x for x in (nameText,(stateText if speakStatesFirst else roleText),(roleText if speakStatesFirst else stateText),ariaCurrentText,valueText,descriptionText,levelText,keyboardShortcutText) if x) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's possible that someone might set aria-current on a table cell; e.g. in a calendar. So, it also needs to be reported for the table cell case above this. |
||
| if content and not speakContentFirst: | ||
| out.append(content) | ||
| return CHUNK_SEPARATOR.join(out) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding speaking for list items, etc., this can be achieved by handling |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -257,6 +257,12 @@ def _getParagraphOffsets(self,offset): | |
| return lineStart.value,lineEnd.value | ||
|
|
||
| def _normalizeControlField(self,attrs): | ||
|
|
||
|
||
| ariaCurrent = attrs.get("IAccessible2::attribute_current") | ||
|
||
| if ariaCurrent != None: | ||
| attrs['current']= ariaCurrent | ||
| del attrs["IAccessible2::attribute_current"] | ||
|
||
|
|
||
| tableLayout=attrs.get('table-layout') | ||
| if tableLayout: | ||
| attrs['table-layout']=tableLayout=="1" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this a compiled regular expression constant. See re.compile. We tend to name such constants
RE_FOO.