Speed up _isNVDAObjectInApplication in virtual buffers by using the buffer. (#9303)
_isNVDAObjectInApplication is called by various TreeInterceptor implementations whenever we need to determine whether an object is contained within the document.
It needs to walk ancestors in order to make a determination and often ends up walking to the root object.
We cache results for an object and its ancestors, but this only really helps focus, since that's the only place where we reuse cached ancestors.
Thus, object navigation and events for anything other than the focus don't benefit.
Virtual buffers only know about objects that should be considered part of the document.
Therefore, if an object is in the buffer (a relatively fast check), we can immediately conclude that it is not within an application.
This avoids the need to walk the remaining ancestors.
To facilitate this, part of _isNVDAObjectInApplication has been split into a separate method, _isNVDAObjectInApplication_noWalk.
This method can return a definite answer if possible or it can return None, in which case we walk to the next ancestor.
The Gecko vbuf's __contains__ method also had to be tweaked to return early for dead objects.
Otherwise, _isNVDAObjectInApplication walks ancestors and ends up hitting the desktop object.