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

Add ability to recognize links to the same page #16994

Merged
merged 76 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
4e1f7cd
Add ability to recognize links to the same page
nvdaes Aug 12, 2024
60dd50a
Add IAccessible::value to vbuf
LeonarddeR Aug 13, 2024
9d13634
Merge pull request #4 from LeonarddeR/accValue
nvdaes Aug 13, 2024
445be6c
Add internal link state for some links in virtualBuffers
nvdaes Aug 13, 2024
82d34be
Cleanup code
nvdaes Aug 14, 2024
e0ac8a8
Merge branch 'master' into links
nvdaes Aug 14, 2024
253e576
Make _valueToSamePage function private
nvdaes Aug 14, 2024
eb01b6f
Add configuration options and unassigned command to cycle between rep…
nvdaes Aug 14, 2024
5cf585c
Don't check if object is internal link if the option is disabled
nvdaes Aug 14, 2024
ba36a24
dd configuration to format document settings panel
nvdaes Aug 14, 2024
4c4d8e3
Add urlUtils module
nvdaes Aug 14, 2024
a965d2d
Updated user guide nentioning this option, without a specific section
nvdaes Aug 14, 2024
fae812b
Update documentation for changes
nvdaes Aug 14, 2024
cedfc69
Enable reporting of link type by default, addressing reviewsuggestion
nvdaes Aug 15, 2024
362e583
Apply suggestions from code review
nvdaes Aug 15, 2024
549a40c
Revert some changes
nvdaes Aug 15, 2024
5e35313
Add braille label for INTERNAL_LINK state, addressing review suggestion
nvdaes Aug 15, 2024
13bf11d
Use urlparse for function to check same page links, suggested by reviewr
nvdaes Aug 15, 2024
bf290bb
Merge branch 'master' into links
nvdaes Aug 15, 2024
b032b2e
Several changes as proposed in review, working
LeonarddeR Aug 15, 2024
c156c71
Merge pull request #5 from LeonarddeR/linksFollowUp
nvdaes Aug 15, 2024
456facb
Pre-commit auto-fix
pre-commit-ci[bot] Aug 15, 2024
b483be6
Update changes for developers
nvdaes Aug 15, 2024
a18de14
Don't consider same page if fragment contains a path like in Gmail la…
nvdaes Aug 15, 2024
5efea77
Add support for Edge
LeonarddeR Aug 16, 2024
f84d23e
Add LINKED state check
LeonarddeR Aug 16, 2024
ffad846
Merge pull request #6 from LeonarddeR/linksEdge
nvdaes Aug 16, 2024
37c9bf4
Apply suggestions from code review
nvdaes Aug 16, 2024
d4b9ea2
Mention developer in changelog
nvdaes Aug 16, 2024
69bd7e7
Update changes for developers
nvdaes Aug 16, 2024
e207ca5
Applysuggestions from coderabbitai
nvdaes Aug 16, 2024
07ddb09
Ensure that fragments of internal links are alnum
nvdaes Aug 16, 2024
984a59e
Accept more characters in fragments
nvdaes Aug 16, 2024
90bbd12
Use link type property, instead of isInternalLink
nvdaes Aug 17, 2024
4b21bb3
Fix documentation for function
nvdaes Aug 17, 2024
d602cbe
Apply suggestions from coderabbitai
nvdaes Aug 17, 2024
4fbe4cb
Add STETE_LINK_TYPE
nvdaes Aug 17, 2024
cd347d2
Merge branch 'master' into links
nvdaes Aug 31, 2024
df22719
Apply suggestions from code review
nvdaes Sep 2, 2024
a0af6ee
Address review
nvdaes Sep 2, 2024
d1c6286
Fix system tests
nvdaes Sep 2, 2024
af32760
Apply suggestions from code review
nvdaes Sep 3, 2024
65d82db
Pre-commit auto-fix
pre-commit-ci[bot] Sep 3, 2024
161b2fa
Fux urlUtils
nvdaes Sep 3, 2024
a2b1a88
Add type hint for gesture
nvdaes Sep 3, 2024
f0cbcbe
Improve unit tests
nvdaes Sep 3, 2024
9e767d2
Improve urlUtils
nvdaes Sep 3, 2024
48f1b61
Fix urlUtils
nvdaes Sep 3, 2024
db0c8cd
Fix variable
nvdaes Sep 3, 2024
fab26cf
Add toggleBooleanValue function
nvdaes Sep 3, 2024
b91c8d2
Pre-commit auto-fix
pre-commit-ci[bot] Sep 3, 2024
0bcc928
Fix changes for developers
nvdaes Sep 3, 2024
4849e6b
Merge branch 'links' of https://github.com/nvdaes/nvda into links
nvdaes Sep 3, 2024
bbce160
Update changes for developers
nvdaes Sep 3, 2024
8fb71ca
Remove % from invalidChars
nvdaes Sep 3, 2024
d6d59f8
Fix script and function to toggle boolean values
nvdaes Sep 3, 2024
1fc8382
Pre-commit auto-fix
pre-commit-ci[bot] Sep 3, 2024
4e331d5
Apply suggestions from code review
nvdaes Sep 4, 2024
e526e25
Merge remote-tracking branch 'nvaccess/master' into links
nvdaes Sep 4, 2024
0cb9b6b
Remove accidentally included info
nvdaes Sep 4, 2024
19bcae9
Apply the same page link concept, not anchor approach
nvdaes Sep 4, 2024
ce7396b
Pre-commit auto-fix
pre-commit-ci[bot] Sep 4, 2024
1dab305
Fix script
nvdaes Sep 4, 2024
64cbf92
Uppercase URL word
nvdaes Sep 4, 2024
da60228
Pre-commit auto-fix
pre-commit-ci[bot] Sep 4, 2024
8eddd33
Fix grammar in vaariable names
nvdaes Sep 4, 2024
1529e2c
Merge branch 'links' of https://github.com/nvdaes/nvda into links
nvdaes Sep 4, 2024
9dff709
Add missing translator comments
nvdaes Sep 4, 2024
30381ed
Add missing import
nvdaes Sep 4, 2024
8620913
Fix variable name
nvdaes Sep 4, 2024
957d541
Fix variable name
nvdaes Sep 4, 2024
96d8462
Improve function name
nvdaes Sep 4, 2024
aa83277
Don't toggle report link type if report link is disabled
nvdaes Sep 4, 2024
b8eb917
Update tests/unit/test_util/test_urlUtils.py
seanbudd Sep 5, 2024
2ca89c0
Merge branch 'master' into links
seanbudd Sep 5, 2024
18b0034
Merge branch 'master' into links
seanbudd Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
nvdaes marked this conversation as resolved.
Show resolved Hide resolved
SysFreeString(value);
value=NULL;
nvdaes marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

Expand Down
32 changes: 32 additions & 0 deletions source/NVDAObjects/IAccessible/ia2Web.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,40 @@ 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
value = self.value
if not value:
return False
if not hasattr(self, "treeInterceptor"):
return False
ti = self.treeInterceptor
if ti is None or not hasattr(ti, "documentConstantIdentifier"):
return False
nvdaes marked this conversation as resolved.
Show resolved Hide resolved
documentConstantIdentifier = ti.documentConstantIdentifier
if self._valueToSamePage(value, documentConstantIdentifier):
return True
return False

def _valueToSamePage(self, value: str, constantIdentifier: str) -> bool:
nvdaes marked this conversation as resolved.
Show resolved Hide resolved
"""Function used to check if link destination points to the same page"""
if not value or not constantIdentifier:
return False
if constantIdentifier.endswith("/"):
constantIdentifier = constantIdentifier[:-1]
queryParamCharPos = constantIdentifier.find("?")
if queryParamCharPos > 0:
constantIdentifier = constantIdentifier[:queryParamCharPos]
if value.startswith(f"{constantIdentifier}#"):
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"),
nvdaes marked this conversation as resolved.
Show resolved Hide resolved
}


Expand Down
9 changes: 6 additions & 3 deletions source/virtualBuffers/gecko_ia2.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,12 @@ 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
elif self.NVDAObjectAtStart.isInternalLink:
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