Skip to content

Commit

Permalink
Merge 445be6c into 0b0bfb0
Browse files Browse the repository at this point in the history
  • Loading branch information
nvdaes authored Aug 13, 2024
2 parents 0b0bfb0 + 445be6c commit af3213b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
14 changes: 10 additions & 4 deletions nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,10 +1000,16 @@ VBufStorage_fieldNode_t* GeckoVBufBackend_t::fillVBuf(
}

BSTR value=NULL;
if(pacc->get_accValue(varChild,&value)==S_OK) {
if(value&&SysStringLen(value)==0) {
SysFreeString(value);
value=NULL;
if (pacc->get_accValue(varChild, &value) == S_OK) {
if (value) {
if (role == ROLE_SYSTEM_LINK) {
// For links, store the IAccessible value to handle same page link detection.
parentNode->addAttribute(L"IAccessible::value", value);
}
if (SysStringLen(value)==0) {
SysFreeString(value);
value=NULL;
}
}
}

Expand Down
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
18 changes: 15 additions & 3 deletions source/virtualBuffers/gecko_ia2.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,20 @@ def _normalizeControlField(self, attrs): # noqa: C901
attrs["roleTextBraille"] = roleTextBraille
if attrs.get("IAccessible2::attribute_dropeffect", "none") != "none":
states.add(controlTypes.State.DROPTARGET)
if role == controlTypes.Role.LINK and controlTypes.State.LINKED not in states:
# This is a named link destination, not a link which can be activated. The user doesn't care about these.
role = controlTypes.Role.TEXTFRAME
if role == controlTypes.Role.LINK:
if controlTypes.State.LINKED not in states:
# This is a named link destination, not a link which can be activated. The user doesn't care about these.
role = controlTypes.Role.TEXTFRAME
else:
attrs["value"] = self.NVDAObjectAtStart.value
documentConstantIdentifier = self.obj.documentConstantIdentifier
value = attrs.get("value", "")
if (
value
and documentConstantIdentifier
and value.startswith(f"{documentConstantIdentifier}#")
):
states.add(controlTypes.State.INTERNAL_LINK)
level = attrs.get("IAccessible2::attribute_level", "")
xmlRoles = attrs.get("IAccessible2::attribute_xml-roles", "").split(" ")
landmark = next((xr for xr in xmlRoles if xr in aria.landmarkRoles), None)
Expand Down Expand Up @@ -210,6 +221,7 @@ def _normalizeControlField(self, attrs): # noqa: C901
attrs["detailsRoles"] = set(self._normalizeDetailsRole(detailsRoles))
if config.conf["debugLog"]["annotations"]:
log.debug(f"detailsRoles: {attrs['detailsRoles']}")
log.info(attrs)
return super()._normalizeControlField(attrs)

def _normalizeDetailsRole(self, detailsRoles: str) -> Iterable[Optional[controlTypes.Role]]:
Expand Down

0 comments on commit af3213b

Please sign in to comment.