Skip to content
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

Merged
merged 4 commits into from Sep 5, 2017

Conversation

LeonarddeR
Copy link
Collaborator

@LeonarddeR LeonarddeR commented Jun 24, 2017

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

<input id="name" required type="text" />

For not required

<input id="name" type="text" />

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.

@michaelDCurran
Copy link
Member

This looks good so far, but can you please also support this in focus mode. See aria-required in NVDAObjects\IAccessible\MSHTML.py

@LeonarddeR
Copy link
Collaborator Author

Hmm, good point. However, it seems this is going to be more difficult than I thought

<input type="text" required="required" name="cheese" />
>>> nav.HTMLNode.getAttribute('type')
u'text'
>>> nav.HTMLNode.getAttribute('name')
u'cheese'
>>> type(nav.HTMLNode.getAttribute('required'))
<type 'NoneType'>

It seems the node doesn't expose the required attribute correctly.

@LeonarddeR
Copy link
Collaborator Author

LeonarddeR commented Jun 28, 2017 via email

@LeonarddeR
Copy link
Collaborator Author

@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={}
Copy link
Member

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

Copy link
Collaborator Author

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]
Copy link
Member

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

Copy link
Collaborator Author

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]
Copy link
Member

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.

@michaelDCurran
Copy link
Member

Make sure to test on several versions of Internet Explorer. At very least what ever Internet Explorer comes with Windows 7.

@LeonarddeR
Copy link
Collaborator Author

LeonarddeR commented Jul 5, 2017 via email

@LeonarddeR
Copy link
Collaborator Author

@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.

@michaelDCurran
Copy link
Member

This looks good to me. Ignore the set/dictionary comment.

@michaelDCurran
Copy link
Member

@LeonarddeR If you are finnished with this I'll incubate it?

@LeonarddeR
Copy link
Collaborator Author

@michaelDCurran commented on 19 jul. 2017 03:37 CEST:

@LeonarddeR If you are finnished with this I'll incubate it?

Yes, go ahead. Thanks a lot!

michaelDCurran added a commit that referenced this pull request Jul 19, 2017
@michaelDCurran michaelDCurran merged commit 985144f into nvaccess:master Sep 5, 2017
@nvaccessAuto nvaccessAuto added this to the 2017.4 milestone Sep 5, 2017
@josephsl josephsl mentioned this pull request Oct 15, 2017
@LeonarddeR LeonarddeR added the BabbageWork Pull requests filed on behalf of Babbage B.V. label Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BabbageWork Pull requests filed on behalf of Babbage B.V.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants