Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion source/NVDAObjects/IAccessible/MSHTML.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,10 @@ def _get_treeInterceptorClass(self):
return super(MSHTML,self).treeInterceptorClass

def _get_isCurrent(self):
return self.HTMLAttributes["aria-current"]
isCurrent = self.HTMLAttributes["aria-current"]
if isCurrent == "false":
isCurrent = None
return isCurrent

def _get_HTMLAttributes(self):
return HTMLAttribCache(self.HTMLNode)
Expand Down
4 changes: 3 additions & 1 deletion source/NVDAObjects/IAccessible/ia2Web.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def _get_positionInfo(self):
return info

def _get_isCurrent(self):
current = self.IA2Attributes.get("current", False)
current = self.IA2Attributes.get("current", None)
if current == "false":
current = None
return current

def _get_placeholder(self):
Expand Down
9 changes: 5 additions & 4 deletions source/NVDAObjects/UIA/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,18 +457,19 @@ def _get_ariaProperties(self):
# RegEx to get the value for the aria-current property. This will be looking for a the value of 'current'
# in a list of strings like "something=true;current=date;". We want to capture one group, after the '='
# character and before the ';' character.
# This could be one of: True, "page", "step", "location", "date", "time"
RE_ARIA_CURRENT_PROP_VALUE = re.compile("current=(\w+);")
# This could be one of: "false", "true", "page", "step", "location", "date", "time"
# "false" is ignored, so it falls back to the default implementation, which is false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the latter false be none?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a comment about the regular expression, which is outside of the isCurrent method and the false here refers to the false as value of the aria-current attribute. That's also the reason why it is written without a capital F. So, I think this comment is correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on Line 461 confuses me a little too. It sounds like it is talking about the default implementation of the isCurrent method, perhaps you could clear this up? I think it would be clearer to say something like:
# "false" is ignored by the regEx and will not produce a match

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, I just commited the improved comment

RE_ARIA_CURRENT_PROP_VALUE = re.compile("current=(?!false)(\w+);")
Copy link
Collaborator

@LeonarddeR LeonarddeR Jan 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex seems a bit broken:

  1. RE_ARIA_CURRENT_PROP_VALUE.match("current=true;dummy=test;") properly matches
  2. RE_ARIA_CURRENT_PROP_VALUE.match("var=val;current=true;dummy=test;") does not match

May be we need a unit test for this. cc @feerrenrut


def _get_isCurrent(self):
ariaProperties=self._getUIACacheablePropertyValue(UIAHandler.UIA_AriaPropertiesPropertyId)
match = self.RE_ARIA_CURRENT_PROP_VALUE.match(ariaProperties)
match = self.RE_ARIA_CURRENT_PROP_VALUE.search(ariaProperties)
log.debug("aria props = %s" % ariaProperties)
if match:
valueOfAriaCurrent = match.group(1)
log.debug("aria current value = %s" % valueOfAriaCurrent)
return valueOfAriaCurrent
return False
return None

def _get_placeholder(self):
ariaPlaceholder = self.ariaProperties.get('placeholder', None)
Expand Down
6 changes: 3 additions & 3 deletions source/NVDAObjects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,10 +820,10 @@ def _get_statusBar(self):

def _get_isCurrent(self):
"""Gets the value that indicates whether this object is the current element in a set of related
elements. This maps to aria-current. Normally returns False. If this object is current
it will return one of the following values: True, "page", "step", "location", "date", "time"
elements. This maps to aria-current. Normally returns None. If this object is current
it will return one of the following values: "true", "page", "step", "location", "date", "time"
"""
return False
return None

def _get_shouldAcceptShowHideCaretEvent(self):
"""Some objects/applications send show/hide caret events when we don't expect it, such as when the cursor is blinking.
Expand Down
2 changes: 1 addition & 1 deletion source/virtualBuffers/MSHTML.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _normalizeFormatField(self, attrs):
def _normalizeControlField(self,attrs):
level=None
ariaCurrent = attrs.get('HTMLAttrib::aria-current', None)
if ariaCurrent is not None:
if ariaCurrent not in (None, "false"):
attrs['current']=ariaCurrent
placeholder = self._getPlaceholderAttribute(attrs, 'HTMLAttrib::aria-placeholder')
if placeholder:
Expand Down
2 changes: 1 addition & 1 deletion source/virtualBuffers/gecko_ia2.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _normalizeControlField(self,attrs):
attrs[attr]=int(attrVal)

current = attrs.get("IAccessible2::attribute_current")
if current is not None:
if current not in (None, 'false'):
attrs['current']= current
placeholder = self._getPlaceholderAttribute(attrs, "IAccessible2::attribute_placeholder")
if placeholder is not None:
Expand Down