-
-
Notifications
You must be signed in to change notification settings - Fork 652
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
I6358 support aria current #6860
Changes from 1 commit
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 |
---|---|---|
|
@@ -388,6 +388,9 @@ | |
) | ||
SELECTION_SHAPE = 0xC0 #: Dots 7 and 8 | ||
|
||
# used to separate chunks of text when programmatically joined | ||
TEXT_SEPARATOR = " " | ||
|
||
def NVDAObjectHasUsefulText(obj): | ||
import displayModel | ||
role = obj.role | ||
|
@@ -630,9 +633,16 @@ def getBrailleTextForProperties(**propertyValues): | |
# Translators: Displayed in braille for a table cell column number. | ||
# %s is replaced with the column number. | ||
textList.append(_("c%s") % columnNumber) | ||
ariaCurrent = propertyValues.get('current', False) | ||
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. nit: Please rename to current. |
||
if ariaCurrent: | ||
try: | ||
textList.append(controlTypes.isCurrentLabels[ariaCurrent]) | ||
except KeyError: | ||
log.debugWarning("Aria-current value not handled: %s"%ariaCurrent) | ||
textList.append(controlTypes.isCurrentLabels[True]) | ||
if includeTableCellCoords and cellCoordsText: | ||
textList.append(cellCoordsText) | ||
return " ".join([x for x in textList if x]) | ||
return TEXT_SEPARATOR.join([x for x in textList if x]) | ||
|
||
class NVDAObjectRegion(Region): | ||
"""A region to provide a braille representation of an NVDAObject. | ||
|
@@ -655,7 +665,7 @@ def update(self): | |
obj = self.obj | ||
presConfig = config.conf["presentation"] | ||
role = obj.role | ||
text = getBrailleTextForProperties(name=obj.name, role=role, | ||
text = getBrailleTextForProperties(name=obj.name, role=role, current=obj.isCurrent, | ||
value=obj.value if not NVDAObjectHasUsefulText(obj) else None , | ||
states=obj.states, | ||
description=obj.description if presConfig["reportObjectDescriptions"] else None, | ||
|
@@ -668,7 +678,7 @@ def update(self): | |
mathPres.ensureInit() | ||
if mathPres.brailleProvider: | ||
try: | ||
text += " " + mathPres.brailleProvider.getBrailleForMathMl( | ||
text += TEXT_SEPARATOR + mathPres.brailleProvider.getBrailleForMathMl( | ||
obj.mathMl) | ||
except (NotImplementedError, LookupError): | ||
pass | ||
|
@@ -698,12 +708,16 @@ def getControlFieldBraille(info, field, ancestors, reportStart, formatConfig): | |
role = field.get("role", controlTypes.ROLE_UNKNOWN) | ||
states = field.get("states", set()) | ||
value=field.get('value',None) | ||
ariaCurrent=field.get('current', None) | ||
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. Please rename. |
||
|
||
if presCat == field.PRESCAT_LAYOUT: | ||
text = [] | ||
# The only item we report for these fields is clickable, if present. | ||
if controlTypes.STATE_CLICKABLE in states: | ||
return getBrailleTextForProperties(states={controlTypes.STATE_CLICKABLE}) | ||
return None | ||
text.append(getBrailleTextForProperties(states={controlTypes.STATE_CLICKABLE})) | ||
if ariaCurrent: | ||
text.append(getBrailleTextForProperties(current=ariaCurrent)) | ||
return TEXT_SEPARATOR.join(text) if len(text) != 0 else None | ||
|
||
elif role in (controlTypes.ROLE_TABLECELL, controlTypes.ROLE_TABLECOLUMNHEADER, controlTypes.ROLE_TABLEROWHEADER) and field.get("table-id"): | ||
# Table cell. | ||
|
@@ -713,7 +727,8 @@ def getControlFieldBraille(info, field, ancestors, reportStart, formatConfig): | |
"states": states, | ||
"rowNumber": field.get("table-rownumber"), | ||
"columnNumber": field.get("table-columnnumber"), | ||
"includeTableCellCoords": reportTableCellCoords | ||
"includeTableCellCoords": reportTableCellCoords, | ||
"current": ariaCurrent, | ||
} | ||
if reportTableHeaders: | ||
props["columnHeaderText"] = field.get("table-columnheadertext") | ||
|
@@ -724,7 +739,7 @@ def getControlFieldBraille(info, field, ancestors, reportStart, formatConfig): | |
# Don't report the role for math here. | ||
# However, we still need to pass it (hence "_role"). | ||
"_role" if role == controlTypes.ROLE_MATH else "role": role, | ||
"states": states,"value":value} | ||
"states": states,"value":value, "current":ariaCurrent} | ||
if config.conf["presentation"]["reportKeyboardShortcuts"]: | ||
kbShortcut = field.get("keyboardShortcut") | ||
if kbShortcut: | ||
|
@@ -736,15 +751,15 @@ def getControlFieldBraille(info, field, ancestors, reportStart, formatConfig): | |
content = field.get("content") | ||
if content: | ||
if text: | ||
text += " " | ||
text += TEXT_SEPARATOR | ||
text += content | ||
elif role == controlTypes.ROLE_MATH: | ||
import mathPres | ||
mathPres.ensureInit() | ||
if mathPres.brailleProvider: | ||
try: | ||
if text: | ||
text += " " | ||
text += TEXT_SEPARATOR | ||
text += mathPres.brailleProvider.getBrailleForMathMl( | ||
info.getMathMl(field)) | ||
except (NotImplementedError, LookupError): | ||
|
@@ -772,7 +787,7 @@ def getFormatFieldBraille(field, isAtStart, formatConfig): | |
# Translators: Displayed in braille for a heading with a level. | ||
# %s is replaced with the level. | ||
textList.append(_("h%s")%headingLevel) | ||
return " ".join([x for x in textList if x]) | ||
return TEXT_SEPARATOR.join([x for x in textList if x]) | ||
|
||
class TextInfoRegion(Region): | ||
|
||
|
@@ -836,7 +851,7 @@ def _getTypeformFromFormatField(self, field): | |
def _addFieldText(self, text, contentPos): | ||
if self.rawText: | ||
# Separate this field text from the rest of the text. | ||
text = " " + text | ||
text = TEXT_SEPARATOR + text | ||
self.rawText += text | ||
textLen = len(text) | ||
self.rawTextTypeforms.extend((louis.plain_text,) * textLen) | ||
|
@@ -854,7 +869,7 @@ def _addTextWithFields(self, info, formatConfig, isSelection=False): | |
if self._endsWithField: | ||
# The last item added was a field, | ||
# so add a space before the content. | ||
self.rawText += " " | ||
self.rawText += TEXT_SEPARATOR | ||
self.rawTextTypeforms.append(louis.plain_text) | ||
self._rawToContentPos.append(self._currentContentPos) | ||
if isSelection and self.selectionStart is None: | ||
|
@@ -982,7 +997,7 @@ def update(self): | |
# There is no text left after stripping line ending characters, | ||
# or the last item added can be navigated with a cursor. | ||
# Add a space in case the cursor is at the end of the reading unit. | ||
self.rawText += " " | ||
self.rawText += TEXT_SEPARATOR | ||
rawTextLen += 1 | ||
self.rawTextTypeforms.append(louis.plain_text) | ||
self._rawToContentPos.append(self._currentContentPos) | ||
|
@@ -1373,7 +1388,7 @@ def getFocusContextRegions(obj, oldFocusRegions=None): | |
for index, parent in enumerate(ancestors[newAncestorsStart:ancestorsEnd], newAncestorsStart): | ||
if not parent.isPresentableFocusAncestor: | ||
continue | ||
region = NVDAObjectRegion(parent, appendText=" ") | ||
region = NVDAObjectRegion(parent, appendText=TEXT_SEPARATOR) | ||
region._focusAncestorIndex = index | ||
region.update() | ||
yield region | ||
|
@@ -1404,7 +1419,7 @@ def getFocusRegions(obj, review=False): | |
region2 = None | ||
if isinstance(obj, TreeInterceptor): | ||
obj = obj.rootNVDAObject | ||
region = NVDAObjectRegion(obj, appendText=" " if region2 else "") | ||
region = NVDAObjectRegion(obj, appendText=TEXT_SEPARATOR if region2 else "") | ||
region.update() | ||
yield region | ||
if region2: | ||
|
@@ -1423,7 +1438,7 @@ def formatCellsForLog(cells): | |
# optimisation: This gets called a lot, so needs to be as efficient as possible. | ||
# List comprehensions without function calls are faster than loops. | ||
# For str.join, list comprehensions are faster than generator comprehensions. | ||
return " ".join([ | ||
return TEXT_SEPARATOR.join([ | ||
"".join([str(dot + 1) for dot in xrange(8) if cell & (1 << dot)]) | ||
if cell else "-" | ||
for cell in cells]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -613,6 +613,23 @@ | |
REASON_ONLYCACHE="onlyCache" | ||
#} | ||
|
||
# Text to use for 'current' values. These describe if an item is the current item | ||
# within a particular kind of selection. | ||
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. Please change the comment prefix to
This means it'll be treated as the documentation of the variable by epydoc (the code doc tool). |
||
isCurrentLabels = { | ||
# Translators: Presented when an item is marked as current in a collection of items | ||
True:_("current"), | ||
# Translators: Presented when a page item is marked as current in a collection of page items | ||
"page":_("current page"), | ||
# Translators: Presented when a step item is marked as current in a collection of step items | ||
"step":_("current step"), | ||
# Translators: Presented when a location item is marked as current in a collection of location items | ||
"location":_("current location"), | ||
# Translators: Presented when a date item is marked as current in a collection of date items | ||
"date":_("current date"), | ||
# Translators: Presented when a time item is marked as current in a collection of time items | ||
"time":_("current time"), | ||
} | ||
|
||
def processPositiveStates(role, states, reason, positiveStates): | ||
positiveStates = positiveStates.copy() | ||
# The user never cares about certain states. | ||
|
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.
_get_foo
, which will create a property namedfoo
.current
looks kinda weird. We feel the nameisCurrent
is probably best. While this is perhaps a tiny bit misleading (the "is" prefix normally suggests it's a boolean), it's the best we could come up with... and it is boolean-ish anyway in the sense that it's either current or not, with the type just being a nicety for the user.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.
Yeah ok. I'm not 100% comfortable with the name, but I can't think of anything better.