9797}
9898
9999
100+ re_simpleXmlTag = re .compile (r"(\<[^>]+\>)+" )
100101
101- re_simpleXmlTag = re .compile (r"\<[^>]+\>" )
102102
103+ def _subHtmlTag (match ):
104+ startIndex , endIndex = match .span ()
105+ return "" if startIndex == 0 or match .string [startIndex - 1 ].isspace () \
106+ or endIndex == len (match .string ) or match .string [endIndex ].isspace () else " "
103107
104108def _processHtml (text ):
105109 """ Strips HTML tags from text if it is HTML """
106- return re_simpleXmlTag .sub (" " , text ) if text .startswith ("<html>" ) else text
110+ return re_simpleXmlTag .sub (_subHtmlTag , text ) if text .startswith ("<html>" ) else text
107111
108112
109113class JABTextInfo (textInfos .offsets .OffsetsTextInfo ):
@@ -320,6 +324,9 @@ def _get_states(self):
320324 for state in stateStrings :
321325 if state in JABStatesToNVDAStates :
322326 stateSet .add (JABStatesToNVDAStates [state ])
327+ if self .role is controlTypes .Role .TOGGLEBUTTON and controlTypes .State .CHECKED in stateSet :
328+ stateSet .discard (controlTypes .State .CHECKED )
329+ stateSet .add (controlTypes .State .PRESSED )
323330 if "editable" not in stateStrings and self ._JABAccContextInfo .accessibleText :
324331 stateSet .add (controlTypes .State .READONLY )
325332 if "visible" not in stateStrings :
@@ -333,7 +340,12 @@ def _get_states(self):
333340 return stateSet
334341
335342 def _get_value (self ):
336- if self .role not in [controlTypes .Role .CHECKBOX ,controlTypes .Role .MENU ,controlTypes .Role .MENUITEM ,controlTypes .Role .RADIOBUTTON ,controlTypes .Role .BUTTON ] and self ._JABAccContextInfo .accessibleValue and not self ._JABAccContextInfo .accessibleText :
343+ if self .role not in [
344+ controlTypes .Role .TOGGLEBUTTON , controlTypes .Role .CHECKBOX ,
345+ controlTypes .Role .MENU , controlTypes .Role .MENUITEM ,
346+ controlTypes .Role .RADIOBUTTON , controlTypes .Role .BUTTON ] \
347+ and self ._JABAccContextInfo .accessibleValue \
348+ and not self ._JABAccContextInfo .accessibleText :
337349 return self .jabContext .getCurrentAccessibleValueFromContext ()
338350
339351 def _get_description (self ):
@@ -372,7 +384,8 @@ def _get_positionInfo(self):
372384 return info
373385
374386 parent = self .parent
375- if isinstance (parent ,JAB ) and self .role in (controlTypes .Role .TREEVIEWITEM ,controlTypes .Role .LISTITEM ):
387+ if isinstance (parent , JAB ) and self .role in (
388+ controlTypes .Role .TREEVIEWITEM , controlTypes .Role .LISTITEM , controlTypes .Role .TAB ):
376389 index = self ._JABAccContextInfo .indexInParent + 1
377390 childCount = parent ._JABAccContextInfo .childrenCount
378391 info ['indexInGroup' ]= index
@@ -389,7 +402,7 @@ def _get_activeChild(self):
389402 def _get_parent (self ):
390403 if not hasattr (self ,'_parent' ):
391404 jabContext = self .jabContext .getAccessibleParentFromContext ()
392- if jabContext :
405+ if jabContext and self . indexInParent is not None :
393406 self ._parent = JAB (jabContext = jabContext )
394407 else :
395408 self ._parent = super (JAB ,self ).parent
0 commit comments