Rewrite how NVDA deals with API classes for NVDAObjects.
Previously API classes were really just Window, and anything that directly inherited from Window, but had different resolution (e.g. IAccessible, JAB, and UIA).
There wasn't really an easy way to allow API classes such as IAccessible to have other possible API classes of their own.
Now this is possible.
Code is not yet totally complete.
Specific changes:
*All API classe NVDAObjects must implement a kwargsFromSuper method. This method should take the keyword arguments that its super class's constructor would take, and it should return keyword arguments that its own constructor must take. E.g. IAccessible's kwargsFromSuper would take a windowHandle, and return keyword arguments of windowHandle, IAccessibleObject, and IAccessibleChildID.
A part from this method making it easier to handle API classes, this also means that NVDAObject constructors no longer need to support instanciation with only arguments of a base (e.g. IAccessible used to have to support being instanciated with just a windowHandle). Now this is not supported, if something like this needed to be done, you'd have to call kwargsFromSuper first, and then pass that to IAccessible's constructor.
KwargsFromSuper also takes a relation keyword argument, this works rather like the relation argument on the old findBestAPIClass (i.e. it can be "parent") but it can now also be "focus", or "foreground", or a tuple representing a point on the screen.
KwargsFromSuper thus replaces ObjectFromPoint, ObjectWithFocus and ObjectInForeground on all subclasses of NVDAObject.
KwargsFromSuper has so far been implemented on Window, IAccessible, JAB and UIA.
*All API class NVDAObjects who wish to advertize that they know about other sub API classes of themself, and that one of them should be used, should implement a class method called getPossibleAPIClasses.
getPossibleAPIClasses takes the same keyword arguments as this class's constructor, and should yield possible API classes, in order of preference.
getPossibleAPIClasses has so far been implemented on Window (its very similar to the old findBestAPIClass on Window).
Its planned to be implemented on IAccessible, in order to advertize MSHTML.
*The base NVDAObject class now contains a class method called findBestAPIClass. This is rather different to the old findBestAPIClass as it works over multiple levels, and also returns not just an API class, but also the kwargs needed to construct the class.
findBestAPIClass starts at the class it was executed on. If this class implements a getPossibleAPIClasses method, it loops through the possible API classes yielded, executing kwargsFromSuper on each, until one of them successfully executes with out raising RuntimeError.
It then goes around again, checking if this new API class has a getPossibleAPIClasses etc. Once an API class does not have a getPossibleAPIClasses, this API class is returned, along with the kwargs used to construct it.
*DynamicNVDAObjectType.__call__: make use of the new findBestAPIClass method.
*Window.correctAPIForRelation: make use of the new findBestAPIClass method.