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
Support the HTML5 required attribute in MSHTML documents #7321
Conversation
This looks good so far, but can you please also support this in focus mode. See aria-required in |
Hmm, good point. However, it seems this is going to be more difficult than I thought
It seems the node doesn't expose the required attribute correctly. |
A, it turns out that I can use HTMLNode.hasAttribute('required')
|
@michaelDCurran: this is now working. I added a contains method to the HTMLAttribCache to support stuff like 'required' in self.HTMLAttributes. I decided to give it a separate cache, as I didn't want to change the behaviour of getitem. This nieuw contains_ method fixes a bug where 'attribute' in HTMLAttributes resulted in a freeze of NVDA. |
@@ -71,6 +71,7 @@ class HTMLAttribCache(object): | |||
def __init__(self,HTMLNode): | |||
self.HTMLNode=HTMLNode | |||
self.cache={} | |||
self.containsCache={} |
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.
This can be a set rather than a dictionary
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.
Mm, not sure whether we're on the same track here. Changing this to a set means that we lose track of the attributes for which hasAttribute has returned False in the past, so in other words, False evaluations won't get cached. We either need a dictionary for this, or have two sets for hasAttribute True and hasAttribute False. Could it be that you overlooked this, or is it your intention not to cache the Falses?
@@ -84,6 +85,23 @@ def __getitem__(self,item): | |||
self.cache[item]=value | |||
return value | |||
|
|||
def __contains__(self,item): | |||
try: | |||
return self.containsCache[item] |
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.
Then change this to return item in self.containsCache
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.
If we do this, the block below that actually runs hasAttribute never gets executed.
return self.containsCache[item] | ||
except LookupError: | ||
pass | ||
value = self[item] |
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.
I would perhaps only check item in self.containsCache, then item in self.cache, and if none of them then node.hasattribute(item) and add the answer to containsCache. hasattribute should work for any value that getattribute would work for.
Make sure to test on several versions of Internet Explorer. At very least what ever Internet Explorer comes with Windows 7. |
This is a good point. I hope I have a proper vm around for this.
|
@michaelDCurran: Would you be able to explain why you belief containsCache should be a set rather than a dictionary? See #7321 (comment) If you agree with containsCache being a dictionary anyway, this is ready for another review. |
This looks good to me. Ignore the set/dictionary comment. |
@LeonarddeR If you are finnished with this I'll incubate it? |
@michaelDCurran commented on 19 jul. 2017 03:37 CEST:
Yes, go ahead. Thanks a lot! |
Link to issue number:
As far as I know, this pr has no dedicated issue for itself. This pr is based on findings in #7320 (comment)
Summary of the issue:
NVDA does not report the required state of a html element when the HTML5 required attribute is used for this.
Description of how this pull request fixes the issue:
Added support for required in de NVDAHelper MSHTML vbuf backend and associated python code.
Testing performed:
For required
For not required
Note that required="false" will still result in required state being added, but this is no bug according to the spec. I've seen the same behaviour in Firefox.
Change log entry:
I consider the absence of this feature to be a bug.