Skip to content

Commit

Permalink
Merge 4e1f7cd into c8a847b
Browse files Browse the repository at this point in the history
  • Loading branch information
nvdaes authored Aug 12, 2024
2 parents c8a847b + 4e1f7cd commit faef7e2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
22 changes: 22 additions & 0 deletions source/NVDAObjects/IAccessible/ia2Web.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,30 @@ def _get_states(self):
if popupState:
states.discard(controlTypes.State.HASPOPUP)
states.add(popupState)
if self.isInternalLink:
states.add(controlTypes.State.INTERNAL_LINK)
return states

@property
def isInternalLink(self) -> bool:
if self.role != controlTypes.Role.LINK:
return False
if (
not hasattr(self, "treeInterceptor")
or self.treeInterceptor is None
or not self.treeInterceptor.documentConstantIdentifier
):
return False
documentConstantIdentifier = self.treeInterceptor.documentConstantIdentifier
if documentConstantIdentifier.endswith("/"):
documentConstantIdentifier = documentConstantIdentifier[:-1]
queryParamCharPos = documentConstantIdentifier.find("?")
if queryParamCharPos > 0:
documentConstantIdentifier = documentConstantIdentifier[:queryParamCharPos]
if self.value.startswith(f"{documentConstantIdentifier}#"):
return True
return False

def _get_landmark(self):
xmlRoles = self.IA2Attributes.get("xml-roles", "").split(" ")
landmark = next((xr for xr in xmlRoles if xr in aria.landmarkRoles), None)
Expand Down
4 changes: 4 additions & 0 deletions source/controlTypes/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def negativeDisplayString(self) -> str:
HASPOPUP_GRID = setBit(48)
HASPOPUP_LIST = setBit(49)
HASPOPUP_TREE = setBit(50)
INTERNAL_LINK = setBit(51)


STATES_SORTED = frozenset([State.SORTED, State.SORTED_ASCENDING, State.SORTED_DESCENDING])
Expand Down Expand Up @@ -204,6 +205,9 @@ def negativeDisplayString(self) -> str:
State.HASPOPUP_LIST: _("opens list"),
# Translators: Presented when a control has a pop-up tree.
State.HASPOPUP_TREE: _("opens tree"),
# Translators: Presented when a link destination points to the page containing the link.
# For example, links of a table of contents of a document with different sections.
State.INTERNAL_LINK: _("same page"),
}


Expand Down

0 comments on commit faef7e2

Please sign in to comment.