Skip to content

UIA handler reorganization: gather UIA modules into a public "UIAHandler" package#13089

Merged
seanbudd merged 20 commits into
nvaccess:masterfrom
josephsl:UIAHandlerReorg
Nov 29, 2021
Merged

UIA handler reorganization: gather UIA modules into a public "UIAHandler" package#13089
seanbudd merged 20 commits into
nvaccess:masterfrom
josephsl:UIAHandlerReorg

Conversation

@josephsl

Copy link
Copy Markdown
Contributor

Link to issue number:

Closes #10916

Summary of the issue:

The bulk of UIA support code resides in a private UIA handler module (_UIAHandler.py). It was done that way to support Windows releases without usable UIA implementations such as Windows XP. Also, other UIA support modules such as custom annotations were added to support specific UIA scenarios.

Description of how this pull request fixes the issue:

Reorganized UIA handler as follows:

  • UIA handler and other support modules is now part of a UIAHandler package, similar to IAccessibleHandler reorganization that took place recently.
  • The public ane private UIA handler modules were combined under one module (UIAHandler/init.py).
  • Additional uIA modules such as UIC custom annotations and properties, constatns, browse mode, and UIA utils are now part of UIAHandler package.
  • NVDA source code that referred to old file locations were edited to point to UIAHandler package modules.
  • Linted UIAHandler.UIAHandler.getNearestWindowHandle method.

Testing strategy:

Manual, unit, and system tests:

  1. Performed unit tests whenever commits were made.
  2. Performed system tests whenever commits were made.
  3. Ran linter to make sure it passed before commiting changes.
  4. Ran UIA scenarios manually such as console support, Windows apps, UIA+Excel, among other things to make sure functionality remained the same.

Known issues with pull request:

None (haven't found add-ons that use the old modules)

Change log entries:

Changes for developers:

UIA handler module and other UIA support modules are now part of UIAHandler package. (#10916

Then mention the renamed files:

  • UIAHandler.py and _UIAHandler.py -> UIAHandler/init.py (you don't have to mention this if you want)
  • UIAUtils.py -> UIAHandler/utils.py
  • UIABrowseMode.py -> UIAHandler/browseMode.py
  • _UIAConstants.py -> UIAHandler/constants.py
  • _UIACustomProps.py -> UIAHandler/customPropts.py
  • _UIACustomAnnotations.py -> UIAHandler/customAnnotations.py

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

… public module. Re nvaccess#10916.

When UIA handler first appeared in 2008, it was housed in UIAHandler.py, the public-facing module. In 2011, a private _UIAHandler.py module was created to handle lack of usable UIA implementation in Windows XP, Server 2003, and older releases of Windows Vista and Server 2008. Since NVDA 2017.4, Windows 7 SP1 and Server 2008 R2 SP1 are required, meaning a usable UIA implementation is available. For backward compatibility, the private/public split was kept.
Recognizing maintenance issues with private/public module, a reorganization effort was proposed in 2020, with the work taking place in 2021. This effort aims to combine private and public UIA handler modules under one file, as well as bring UIA support modules under a package, similar to IAccessible handler reorganization in 2021. As a first step, contents of private UIA handler module is now part of public UIA handler, with other NVDA modules importing the private module to be edited to use the public module (later commit). Module header is based on a combination of both public and private modules.
Combined module contents:
1. Module header
2. Public module contents (UIA handler object definition, init/terminate methods) placed between bulk of private module content and UIA debug check function
With the contents of the private module moved to public UIA handler module, there is no need to keep the private module around anymore. Therefore remove the private module.
…. Re nvaccess#10916.

Reorganization: convert UIA handler from a module to a package (source/UIAHandler/__init__.py). The new UIA handler package will be home of various UIA related modules such as UIA custom properties and annotations support.
Import changes:
* _UIAConstants -> UIAHandler.constants
* _UIACustomAnnotations -> UIAHandler.customAnnocations
* _UIACustomProps -> UIAHandler.customProps
…ndler. Re nvaccess#10916.

Transfer UIA utils module to UIA handler package, along with editing UIA constants module import to be relative import.
…and custom props modules as contents were transferred to UIA handler package and renamed. Re nvaccess#10916
In addition to resolving lint issues (Flake8), linted UIAHandler.handler.getNearistWindowHandle method.
…omRange import from UIAHandler.browseMode module as it is not used. Re nvaccess#10916.

According to Flake8, UIAHandler.utils.getUIATextAttributeValueFromRange is imported but unused in UIAHandler.browseMode.py, therefore remove this import.
@josephsl josephsl requested a review from a team as a code owner November 24, 2021 04:30
@josephsl josephsl requested a review from seanbudd November 24, 2021 04:30

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This generally looks good to me.

I would also consider moving all/most of the constants at the top of source/UIAHandler/__init__.py into separate files within the module.
This could be done in a follow up PR to make reviewing this PR easier.

Additionally, merging this PR will require reviews and feedback from other developers.

return False


handler: Optional[UIAHandler] = None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This, and the initialization code, might be better suited to the top of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree it would be nicer. The only problem you may encounter would be a Linter complain about UIAHandler not being defined yet. This can be easily worked around either by:

  • placing UIAHandler in quotes or
  • moving UIAHandler to a separate file, though this should happen in a follow up.

@josephsl

josephsl commented Nov 24, 2021 via email

Copy link
Copy Markdown
Contributor Author

@seanbudd seanbudd requested a review from feerrenrut November 24, 2021 05:15
Comment thread source/NVDAObjects/UIA/wordDocument.py Outdated
return False


handler: Optional[UIAHandler] = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree it would be nicer. The only problem you may encounter would be a Linter complain about UIAHandler not being defined yet. This can be easily worked around either by:

  • placing UIAHandler in quotes or
  • moving UIAHandler to a separate file, though this should happen in a follow up.

@josephsl

Copy link
Copy Markdown
Contributor Author

Hi,

As for a follow-up issue/PR pair, I guess it will discuss splitting UIA handler main module into two or more files. While we are at it, I think a long-term proposal would be to provide similar interfaces/modules between IAccessible and UIA handlers (and perhaps add JAB handler to the mix later), perhaps in 2023 cycle.

Thanks.

…ttribute from that module is used. Re nvaccess#10916.

Comment from Lukasz Golonka: since word document module (UIA) imports UIAHandler.utils but no attribute is used, remove the import altogether.
@josephsl

Copy link
Copy Markdown
Contributor Author

Hi,

As for putting initialize/terminate/handler class at the top of the UIA handler main module, I think it would be best to do it as part of a follow-up pull request that splits the main UIA module into two or more files. That way not only we can take care of this, but also lets us lint changes.

Thanks.

@feerrenrut feerrenrut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me.

Let's get this merged in and monitor for issues. Good work @josephsl

@seanbudd seanbudd merged commit d025cd1 into nvaccess:master Nov 29, 2021
@nvaccessAuto nvaccessAuto added this to the 2022.1 milestone Nov 29, 2021
@josephsl josephsl deleted the UIAHandlerReorg branch December 27, 2021 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UIA handler (backward compatibility): unify public and private modules under a package

5 participants