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

Support IAccessible2 "mark" text attribute. #16910

Merged
merged 1 commit into from
Aug 28, 2024
Merged

Conversation

jcsteh
Copy link
Contributor

@jcsteh jcsteh commented Jul 25, 2024

Link to issue number:

None.

Summary of the issue:

Text fragments is a new web concept that allows you to link directly to a specified piece of arbitrary text on a page without needing a predefined id. For example:
https://www.jantrid.net/#:~:text=browsers%20were%20much%20simpler
As well as scrolling to the element containing the text, the browser will highlight the text. Because this could span a partial object, this can't be exposed using IA2_ROLE_MARK. Instead, similar to spelling errors, this is exposed using an IAccessible2 text attribute, specifically the new attribute mark:true.

This will also be used eventually to support CSS custom highlights.

Description of user facing changes

In Mozilla Firefox, NVDA will report the highlighted text when a URL containing a text fragment is visited.

Description of development approach

NVDA already supports the "marked" attribute on FormatFields. To be consistent with IA2_ROLE_MARK, it was decided to name the IA2 attribute "mark" instead of "marked". This PR simply maps the attribute appropriately in normalizeIA2TextFormatField.

Testing strategy:

  1. Opened this test case in Firefox Nightly (this isn't enabled in Firefox release yet):
    data:text/html,<p>The first phrase.</p><p>The second <b>phrase.</b></p>#:~:text=second phrase
  2. Moved to the second line.
  3. Verified that NVDA reported "The marked second phrase not marked."

Known issues with pull request:

None with the PR itself.

I did notice that we report "highlighted" for controlTypes.Role.MARKED_CONTENT, but we report "marked" for the marked FormatField key, even though these are the same concept. I wonder whether the marked FormatField key should report "highlighted" instead.

Code Review Checklist:

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

Summary by CodeRabbit

  • New Features
    • Enhanced accessibility in Mozilla Firefox by enabling NVDA to report highlighted text when visiting URLs with text fragments.
  • Bug Fixes
    • Improved processing of the formatField attribute, ensuring accurate handling of the mark key for better functionality.

@jcsteh
Copy link
Contributor Author

jcsteh commented Jul 25, 2024

Note that Chrome supports text fragments, but even though it scrolls to the fragment, it does not yet expose the highlight to IAccessible2. That change will need to be made in Chrome.

@XLTechie
Copy link
Collaborator

XLTechie commented Jul 25, 2024 via email

@jcsteh
Copy link
Contributor Author

jcsteh commented Jul 25, 2024

I tend to agree. I wasn't sure whether there was a good reason this is currently reported as "marked", though, so thought I'd avoid making that change here.

@LeonarddeR
Copy link
Collaborator

Is this new mark attribute already formalized in some IA2 spec? If so, I don't see a reason to wait for this to land in FF at all. It wouldn't be sitting in the way.

@jcsteh
Copy link
Contributor Author

jcsteh commented Jul 26, 2024

It's not formalised yet. I will file a PR against IA2 at some point to add it. I'm holding off at this point because it's slightly possible (though very unlikely) that I'll discover something before the Firefox patches land that requires me to change how this is exposed.

@jcsteh
Copy link
Contributor Author

jcsteh commented Jul 26, 2024

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Jul 30, 2024
@jcsteh jcsteh marked this pull request as ready for review August 28, 2024 04:18
@jcsteh jcsteh requested a review from a team as a code owner August 28, 2024 04:18
@jcsteh jcsteh requested a review from seanbudd August 28, 2024 04:18
Copy link
Contributor

coderabbitai bot commented Aug 28, 2024

Walkthrough

The changes introduce new functionality in NVDA to enhance accessibility in Mozilla Firefox. The normalizeIA2TextFormatField function now processes a new attribute, mark, to set a marked key in the formatField dictionary. Additionally, NVDA will report highlighted text when a URL with a text fragment is visited, improving contextual navigation for users.

Changes

Files Change Summary
source/NVDAObjects/IAccessible/__init__.py, user_docs/en/changes.md Introduced a new attribute mark in normalizeIA2TextFormatField to set marked to True if mark is "true"; added functionality to report highlighted text in Firefox when visiting URLs with text fragments.

Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5b6804d and a12323e.

Files selected for processing (2)
  • source/NVDAObjects/IAccessible/init.py (1 hunks)
  • user_docs/en/changes.md (1 hunks)
Additional context used
Path-based instructions (2)
source/NVDAObjects/IAccessible/__init__.py (2)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious. When providing code suggestions, particularly when requested, ensure GitHub's suggestion format is used, i.e.: suggestion <code changes>


Pattern **/*.py: _, pgettext, ngettext, and ngettext are defined globally, errors for this being undefined can be ignored.

user_docs/en/changes.md (3)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious. When providing code suggestions, particularly when requested, ensure GitHub's suggestion format is used, i.e.: suggestion <code changes>


Pattern **/*.md: Focus on grammar, spelling, and punctuation. Also consider readability and clarity of contents. Ensure that changes follow the style of one sentence per line, suggest changes if this is not met.


Pattern user_docs/en/changes.md: Ensure each change log entry references an issue or pull request number. Change log entries can also include a reference to a GitHub author. Examples of valid change log entries: * Item with sub-items (#123, @username): * sub-item * bar (#342) * Item with. Multiple lines. (#143)

Additional comments not posted (1)
user_docs/en/changes.md (1)

8-8: Ensure one sentence per line for readability.

The entry is well-formed and follows the required format. For better readability and clarity, ensure that each sentence is on a separate line.

* In Mozilla Firefox, NVDA will report the highlighted text when a URL containing a text fragment is visited. 
* (#16910, @jcsteh)

The code changes are approved.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

source/NVDAObjects/IAccessible/__init__.py Show resolved Hide resolved
@seanbudd seanbudd merged commit 49a4dc0 into nvaccess:master Aug 28, 2024
2 checks passed
@seanbudd
Copy link
Member

Thanks @jcsteh !

@github-actions github-actions bot added this to the 2025.1 milestone Aug 28, 2024
@jcsteh jcsteh deleted the mark branch August 28, 2024 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants