Add support for UIA with chromium based browsers #12025
Hmm perhaps there should be more structure here eg "namespaces". Consider if we moved the files:
There was a problem hiding this comment.
I've been looking at the layout of this code and reconsidering whether a nested structure is better. I think it is better for this code to stick with a flatter structure, otherwise there are dependencies going in the wrong direction:
I will however rename spartan_edge and anaheim _edge to spartanEdge and anaheimEdge respectively.
UIA.Web is a new base for browser specific implementations: - spartan-edge - Chromium based browsers: anaheim-edge, chrome This commit is a direct move (no alterations) of code to preserve history. - Move function splitUIAElementAttribs - Move EdgeTextInfo - Move shareable aspects of class EdgeNode: * _get_role * _get_states * _get_ariaProperties * _get_isCurrent * _get_roleText * _get_placeholder * _get_landmark - Move class EdgeList - Move class EdgeHeadingQuickNavItem - Move class EdgeHeadingQuicknavIterator - Move shareable aspects of class EdgeHTMLTreeInterceptor: * makeTextInfo * shouldPassThrough * _iterNodesByType
This is a module containing common classes above the browser specific classes (edge.py, chromium.py). The browser specific classes inherit from these web module classes. - Move splitUIAElementAttribs(attribsString) from edge module to web module - Move common implementation of edge.EdgeNode and rename to web.UIAWeb(UIA), edge.EdgeNode now inherits from web.UIAWeb. - Move implementation of edge.EdgeList and rename to web.List(UIAWeb), edge.EdgeList now inherits from web.List - Move implementation of edge.EdgeHTMLTreeInterceptor and rename to web.UIAWebTreeInterceptor, edge.EdgeHTMLTreeInterceptor now inherits from web.UIAWebTreeInterceptor
The concrete implementation relied on knowing that self is actually a subclass and providing varied behaviour. Instead, abstract this test so it can be altered via polymorphism.
Trade off: slight degradation of performance. UIATextInfo._getTextWithFieldsForUIARange: Test each child to see if it is clipped by or lives completely outside the parent text range, and if so appropriately clip the child range and break out of the for loop. Previously these checks only happened on the final child to try and avoid extra calls, but Edge sometimes returns many more children then it should when on the end of a list, and a trivial slow down is much preferred over a 20 second freeze.
Trade-off: only the first line is fetched. speech.getObjectSpeech: If the given object should have its text presented (E.g. a document or edit field) and the line at the selection cannot be fetched, then only present the first line. Previously the text for the entire object would be fetched, which in the case of Edgium, was extremely costly and could cause a freeze of 10 seconds or more.
As headings are exposed in the element tree, don't expose them in format fields.
Make sure interactive / presentational lists are presented correctly in browseMode in Edgium.
… with UIA Embedded object characters in Edgium should not stop overriding labels from being used.
Allows ignoring of layout tables when configured to do so.
Ensure the value of comboboxes are used as content.
Names of controls (that do not use their name as content) are always reported: Currently no way to tell if author has explicitly set name. Therefore always report the name if the control is not of a type that by definition uses its name for content. This may cause some duplicate speaking, but that is currently better than nothing at all.
…12319) Fixes #12114 PR #12025 started catching only very specific exceptions when getting selection of edit fields. However in Firefox attempting to get caret for non focused edit fields results in RuntimeError which made it impossible to speak these controls. Description of how this pull request fixes the issue: When getting content of edit fields in speech, we're now catching RuntimeError as well and treating this situation like no selection.