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

When reporting URL of a link use caret position instead of navigator object #14723

Merged
merged 10 commits into from
Mar 29, 2023

Conversation

lukaszgo1
Copy link
Contributor

@lukaszgo1 lukaszgo1 commented Mar 16, 2023

Link to issue number:

Closes #14659

Summary of the issue:

In #14583 @XLTechie added a global commands which allows to report a URL for the link at the position of the navigator object. While this is a huge improvement compared to either having copy the URL to the clipboard or accessing the URL from the status bar from the web browser, the fact that these scripts report destination for the link at the navigator object rather than focus / caret position makes their usage impractical for people who prefer to work with review cursor / navigator object not following focus / caret.

Description of user facing changes

When user requests URL of a link NVDA reports URL of a link at the position of the caret / focus.

Description of development approach

Script for reporting URL was modified so that it first tries to get an object at the current caret position, and if that fails from the focused object. User guide and documentation for global commands were updated accordingly.
After @XLTechie's review it was noticed that the script fails to work for links without href attribute, as part of this PR I've added handling for such links.

Testing strategy:

Tested various objects which are links, linked graphics, and non links in both focus and browse mode, in Firefox and IE.

Known issues with pull request:

None known

Change log entries:

Changes

  • Script for reporting destination of a link now reports destination for the link at the caret / focus position rather than for the navigator object.

Bug fixes:

  • When trying to report URL for links without href attribute NVDA is no longer silent - the fact that the given link has no destination is reported instead.

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • Security precautions taken.

@lukaszgo1 lukaszgo1 requested review from a team as code owners March 16, 2023 15:39
@lukaszgo1
Copy link
Contributor Author

@XLTechie You may want to review / test this.

@XLTechie

This comment was marked as outdated.

Copy link
Collaborator

@XLTechie XLTechie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will be fine. I'm not really sure if it covers more common use cases, but it appears to be slightly more flexible, at the cost of making the review cursor a bit less useful for link identification with some configurations. That probably won't be a problem for most users, and as stated, most likely won't notice either way.

source/globalCommands.py Outdated Show resolved Hide resolved
source/globalCommands.py Outdated Show resolved Hide resolved
user_docs/en/userGuide.t2t Outdated Show resolved Hide resolved
@XLTechie
Copy link
Collaborator

@lukaszgo1 As an aside, you may want to handle the case of the very first link/graphic (Ctrl+Home position) on the Appveyor website. Noticed when downloading the try build for this PR in Firefox.

"Not a link" is not announced, yet there is no link.

Perhaps if Value is None, we should also announce "not a link"? I would like to say "Link has no apparent destination", because it might still be clickable somehow.

If you try to open the Window version of reportLinkDestination, this happens:

IO - inputCore.InputManager.executeGesture (04:47:09.187) - winInputHook (20220):
Input: kb(desktop):NVDA+k
IO - inputCore.InputManager.executeGesture (04:47:09.325) - winInputHook (20220):
Input: kb(desktop):NVDA+k
ERROR - scriptHandler.executeScript (04:47:09.340) - MainThread (19360):
error executing script: <bound method GlobalCommands.script_reportLinkDestination of <globalCommands.GlobalCommands object at 0x0719EB90>> with gesture 'NVDA+k'
Traceback (most recent call last):
  File "scriptHandler.pyc", line 289, in executeScript
  File "globalCommands.pyc", line 3659, in script_reportLinkDestination
  File "ui.pyc", line 106, in browseableMessage
  File "html\__init__.pyc", line 19, in escape
AttributeError: 'NoneType' object has no attribute 'replace'

If you just try the speaking report, you get the following (dev info included):

IO - speech.speech.speak (03:30:59.874) - MainThread (2428):
Speaking ['heading', 'level 1', 'link', 'AppVeyor']
IO - inputCore.InputManager.executeGesture (03:31:01.816) - winInputHook (18724):
Input: kb(desktop):NVDA+k
IO - inputCore.InputManager.executeGesture (03:31:03.248) - winInputHook (18724):
Input: kb(desktop):NVDA+f1
DEBUG - gui.contextHelp.bindHelpEvent (03:31:03.279) - MainThread (2428):
Did context help binding for LogViewer
INFO - globalCommands.script_navigatorObject_devInfo (03:31:03.334) - MainThread (2428):
Developer info for navigator object:
name: 'AppVeyor'
role: Role.LINK
processID: 11596
roleText: None
states: State.LINKED
isFocusable: False
hasFocus: False
Python object: <NVDAObjects.IAccessible.mozilla.Mozilla object at 0x04B1A970>
Python class mro: (<class 'NVDAObjects.IAccessible.mozilla.Mozilla'>, <class 'NVDAObjects.IAccessible.ia2Web.Ia2Web'>, <class 'NVDAObjects.IAccessible.IAccessible'>, <class 'NVDAObjects.window.Window'>, <class 'NVDAObjects.NVDAObject'>, <class 'documentBase.TextContainerObject'>, <class 'baseObject.ScriptableObject'>, <class 'baseObject.AutoPropertyObject'>, <class 'garbageHandler.TrackedObject'>, <class 'object'>)
description: ''
location: RectLTWH(left=370, top=113, width=144, height=54)
value: None
TextInfo: <class 'NVDAObjects.IAccessible.IA2TextTextInfo'>
appModule: AppModule(appModuleHandler, appName='firefox', processID=11596)
appModule.productName: 'Firefox'
appModule.productVersion: '111.0'
appModule.helperLocalBindingHandle: c_long(116676168)
windowHandle: 2426720
windowClassName: 'MozillaWindowClass'
windowControlID: 0
windowStyle: 382664704
extendedWindowStyle: 256
windowThreadID: 11600
windowText: 'nvda pr14723-27847,9913f99d - AppVeyor — Mozilla Firefox'
displayText: ''
IAccessibleObject: <POINTER(IAccessible2) ptr=0x6fa349c at 8ee030>
IAccessibleChildID: 0
IAccessible event parameters: windowHandle=2426720, objectID=-4, childID=-159383565
IAccessible accName: 'AppVeyor'
IAccessible accRole: ROLE_SYSTEM_LINK
IAccessible accState: STATE_SYSTEM_LINKED, STATE_SYSTEM_VALID (4194304)
IAccessible accDescription: ''
IAccessible accValue: None
IAccessible2 windowHandle: 2426720
IAccessible2 uniqueID: -159383565
IAccessible2 role: ROLE_SYSTEM_LINK
IAccessible2 states: IA2_STATE_OPAQUE, IA2_STATE_SELECTABLE_TEXT (5120)
IAccessible2 attributes: 'display:block;class:collapse-only;margin-bottom:0px;tag:a;text-indent:-9999px;formatting:block;text-align:left;margin-right:0px;margin-left:0px;margin-top:0px;'
IAccessible2 relations: containingDocument * 1, containingTabPane * 1, containingApplication * 1

@lukaszgo1
Copy link
Contributor Author

[...] I'm not really sure if it covers more common use cases, but it appears to be slightly more flexible, at the cost of making the review cursor a bit less useful for link identification with some configurations.

The only hypothetical case I can think of would be a link which is not reachable in browse mode, and is not focusable. I haven't seen such a control anywhere, so I believe this case can be safely ignored.

As an aside, you may want to handle the case of the very first link/graphic (Ctrl+Home position) on the Appveyor website. Noticed when downloading the try build for this PR in Firefox.
"Not a link" is not announced, yet there is no link.
Perhaps if Value is None, we should also announce "not a link"? I would like to say "Link has no apparent destination", because it might still be clickable somehow.

I've implemented your suggestion, since apparently links with no href are valid in HTML.

@AppVeyorBot
Copy link

  • FAIL: Translation comments check. Translation comments missing or unexpectedly included. See build log for more information.
  • PASS: Unit tests.
  • PASS: Lint check.
  • FAIL: System tests (tags: installer NVDA). See test results for more information.
  • Build (for testing PR): https://ci.appveyor.com/api/buildjobs/06qi34pq19it3dtf/artifacts/output/nvda_snapshot_pr14723-27900,089b35eb.exe
  • CI timing (mins):
    INIT 0.0,
    INSTALL_START 0.8,
    INSTALL_END 0.9,
    BUILD_START 0.0,
    BUILD_END 22.4,
    TESTSETUP_START 0.0,
    TESTSETUP_END 0.3,
    TEST_START 0.0,
    TEST_END 21.4,
    FINISH_END 0.2

See test results for failed build of commit 089b35eba6

Copy link
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM

source/globalCommands.py Outdated Show resolved Hide resolved
Copy link
Member

@Qchristensen Qchristensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the user guide wording be more correct as "speaks the destination URL of the link at the caret position or current focus" (as it tries the caret position first?)

@lukaszgo1 lukaszgo1 requested a review from Qchristensen March 28, 2023 10:25
@AppVeyorBot
Copy link

See test results for failed build of commit 8aafd79a6c

@AppVeyorBot
Copy link

See test results for failed build of commit 12ca9ea044

@seanbudd seanbudd merged commit 57bf2a3 into nvaccess:master Mar 29, 2023
@nvaccessAuto nvaccessAuto added this to the 2023.2 milestone Mar 29, 2023
@lukaszgo1 lukaszgo1 deleted the i14659 branch March 29, 2023 09:39
@amirsol81
Copy link

@lukaszgo1 @seanbudd @XLTechie The "Report Destination URL" feature seems to be rather inaccurate or problematic at the moment. I'm using the latest alpha release )27981), and NVDA+K, when pressed on some links, just says "Blank".
For instance:

  1. Open the following page: https://www.gsmarena.com/samsung_galaxy_s23_s23_plus_s23_ultra_camera_improvements_march_update-news-58071.php
  2. There are some graphical links on the page such as "Samsung Galaxy S23 review", "Samsung Galaxy S23+ review", "Samsung Galaxy S23 series' March update changelog (machine translated", "Our camera shootout video featuring Galaxy S23 Ultra, vivo X90 Pro, Xiaomi 12S Ultra and 13 Pro is out", etc. G and SHIFT+G are also capable of catching them.
  3. When NVDA+K is pressed on them, the message "Blank" is announced.
    Almost all of them point to other pages, and just one of them refers to the same page. I think the destination should be properly caught and reported.

@amirsol81
Copy link

@lukaszgo1 @XLTechie @seanbudd Should I create an issue for the bug I reported in my previous comment, or is the comment enough?

@lukaszgo1
Copy link
Contributor Author

@amirsol81 I cannot reproduce this in latest Firefox Nightly. Could you please create a new issue. In the bug report please mention what web browser you';re using, and if this is a regression from this PR, i.e. if this worked when the URL was reported for the navigator object.

@seanbudd
Copy link
Member

seanbudd commented Apr 3, 2023

yes, please create an issue. Comments on closed PRs are easily lost.

@amirsol81
Copy link

@seanbudd Thanks - I will.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants