Skip to content

Commit 6158737

Browse files
Incubates #7321
2 parents 6c68b5f + d4de85d commit 6158737

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎nvdaHelper/vbufBackends/mshtml/mshtml.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ inline void getAttributesFromHTMLDOMNode(IHTMLDOMNode* pHTMLDOMNode,wstring& nod
469469
macro_addHTMLAttributeToMap(L"onclick",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
470470
macro_addHTMLAttributeToMap(L"onmousedown",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
471471
macro_addHTMLAttributeToMap(L"onmouseup",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
472+
macro_addHTMLAttributeToMap(L"required",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
472473
//ARIA properties:
473474
macro_addHTMLAttributeToMap(L"role",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);
474475
macro_addHTMLAttributeToMap(L"aria-valuenow",false,pHTMLAttributeCollection2,attribsMap,tempVar,tempAttribNode);

‎source/NVDAObjects/IAccessible/MSHTML.py‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class HTMLAttribCache(object):
7171
def __init__(self,HTMLNode):
7272
self.HTMLNode=HTMLNode
7373
self.cache={}
74+
self.containsCache={}
7475

7576
def __getitem__(self,item):
7677
try:
@@ -84,6 +85,20 @@ def __getitem__(self,item):
8485
self.cache[item]=value
8586
return value
8687

88+
def __contains__(self,item):
89+
try:
90+
return self.containsCache[item]
91+
except LookupError:
92+
pass
93+
contains=item in self.cache
94+
if not contains:
95+
try:
96+
contains=self.HTMLNode.hasAttribute(item)
97+
except (COMError,NameError):
98+
pass
99+
self.containsCache[item]=contains
100+
return contains
101+
87102
nodeNamesToNVDARoles={
88103
"FRAME":controlTypes.ROLE_FRAME,
89104
"IFRAME":controlTypes.ROLE_INTERNALFRAME,
@@ -735,8 +750,9 @@ def _get_states(self):
735750
state=aria.ariaSortValuesToNVDAStates.get(ariaSort)
736751
if state is not None:
737752
states.add(state)
753+
htmlRequired='required' in self.HTMLAttributes
738754
ariaRequired=self.HTMLAttributes['aria-required']
739-
if ariaRequired=="true":
755+
if htmlRequired or ariaRequired=="true":
740756
states.add(controlTypes.STATE_REQUIRED)
741757
ariaSelected=self.HTMLAttributes['aria-selected']
742758
if ariaSelected=="true":

‎source/virtualBuffers/MSHTML.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#A part of NonVisual Desktop Access (NVDA)
33
#This file is covered by the GNU General Public License.
44
#See the file COPYING for more details.
5-
#Copyright (C) 2009-2016 NV Access Limited, Babbage B.V.
5+
#Copyright (C) 2009-2017 NV Access Limited, Babbage B.V.
66

77
from comtypes import COMError
88
import eventHandler
@@ -77,7 +77,7 @@ def _normalizeControlField(self,attrs):
7777
states.add(controlTypes.STATE_EDITABLE)
7878
if 'HTMLAttrib::onclick' in attrs or 'HTMLAttrib::onmousedown' in attrs or 'HTMLAttrib::onmouseup' in attrs:
7979
states.add(controlTypes.STATE_CLICKABLE)
80-
if attrs.get('HTMLAttrib::aria-required','false')=='true':
80+
if 'HTMLAttrib::required' in attrs or attrs.get('HTMLAttrib::aria-required','false')=='true':
8181
states.add(controlTypes.STATE_REQUIRED)
8282
description=None
8383
ariaDescribedBy=attrs.get('HTMLAttrib::aria-describedby')

0 commit comments

Comments
 (0)