Skip to content

Commit 253ac40

Browse files
authored
Merge 8ef45ec into 365f4f0
2 parents 365f4f0 + 8ef45ec commit 253ac40

4 files changed

Lines changed: 45 additions & 12 deletions

File tree

source/NVDAObjects/IAccessible/chromium.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@
55

66
"""NVDAObjects for the Chromium browser project
77
"""
8-
8+
import typing
99
from typing import Dict, Optional
1010
from comtypes import COMError
11+
12+
import config
1113
import controlTypes
1214
from NVDAObjects.IAccessible import IAccessible
1315
from virtualBuffers.gecko_ia2 import Gecko_ia2 as GeckoVBuf, Gecko_ia2_TextInfo as GeckoVBufTextInfo
1416
from . import ia2Web
1517
from logHandler import log
1618

19+
if typing.TYPE_CHECKING:
20+
# F401 imported but unused, actually used as a string within type annotation (to avoid having to import
21+
# at run time)
22+
from treeInterceptorHandler import TreeInterceptor # noqa: F401
1723

1824
supportedAriaDetailsRoles: Dict[str, Optional[controlTypes.Role]] = {
1925
"comment": controlTypes.Role.COMMENT,
@@ -82,11 +88,28 @@ def __contains__(self, obj):
8288

8389
class Document(ia2Web.Document):
8490

85-
def _get_treeInterceptorClass(self):
86-
states = self.states
87-
if controlTypes.State.EDITABLE not in states and controlTypes.State.BUSY not in states:
88-
return ChromeVBuf
89-
return super(Document, self).treeInterceptorClass
91+
def _get_treeInterceptorClass(self) -> typing.Type["TreeInterceptor"]:
92+
shouldLoadVBufOnBusyFeatureFlag = bool(
93+
config.conf["virtualBuffers"]["loadChromiumVbufOnBusyState"]
94+
)
95+
vBufUnavailableStates = { # if any of these are in states, don't return ChromeVBuf
96+
controlTypes.State.EDITABLE,
97+
}
98+
if not shouldLoadVBufOnBusyFeatureFlag:
99+
log.debug(
100+
f"loadChromiumVBufOnBusyState feature flag is {shouldLoadVBufOnBusyFeatureFlag},"
101+
" vbuf WILL NOT be loaded when state of the document is busy."
102+
)
103+
vBufUnavailableStates.add(controlTypes.State.BUSY)
104+
else:
105+
log.debug(
106+
f"loadChromiumVBufOnBusyState feature flag is {shouldLoadVBufOnBusyFeatureFlag},"
107+
" vbuf WILL be loaded when state of the document is busy."
108+
)
109+
if self.states.intersection(vBufUnavailableStates):
110+
return super().treeInterceptorClass
111+
return ChromeVBuf
112+
90113

91114
class ComboboxListItem(IAccessible):
92115
"""

source/NVDAObjects/__init__.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
import controlTypes
2727
import appModuleHandler
2828
import treeInterceptorHandler
29+
from treeInterceptorHandler import (
30+
TreeInterceptor,
31+
)
2932
import braille
3033
import vision
3134
import globalPluginHandler
@@ -352,10 +355,15 @@ def __ne__(self,other):
352355

353356
focusRedirect=None #: Another object which should be treeted as the focus if focus is ever given to this object.
354357

355-
def _get_treeInterceptorClass(self):
358+
treeInterceptorClass: typing.Type[TreeInterceptor]
359+
"""Type definition for auto prop '_get_treeInterceptorClass'"""
360+
361+
def _get_treeInterceptorClass(self) -> typing.Type[TreeInterceptor]:
356362
"""
357-
If this NVDAObject should use a treeInterceptor, then this property provides the L{treeInterceptorHandler.TreeInterceptor} class it should use.
363+
If this NVDAObject should use a treeInterceptor, then this property
364+
provides the L{treeInterceptorHandler.TreeInterceptor} class it should use.
358365
If not then it should be not implemented.
366+
@raises NotImplementedError when no TreeInterceptor class is available.
359367
"""
360368
raise NotImplementedError
361369

@@ -368,10 +376,10 @@ def _get_treeInterceptorClass(self):
368376
#: @type: bool
369377
shouldCreateTreeInterceptor = True
370378

371-
#: Type definition for auto prop '_get_treeInterceptor'
372-
treeInterceptor: treeInterceptorHandler.TreeInterceptor
379+
treeInterceptor: typing.Optional[TreeInterceptor]
380+
"""Type definition for auto prop '_get_treeInterceptor'"""
373381

374-
def _get_treeInterceptor(self) -> treeInterceptorHandler.TreeInterceptor:
382+
def _get_treeInterceptor(self) -> typing.Optional[TreeInterceptor]:
375383
"""Retrieves the treeInterceptor associated with this object.
376384
If a treeInterceptor has not been specifically set,
377385
the L{treeInterceptorHandler} is asked if it can find a treeInterceptor containing this object.
@@ -392,7 +400,7 @@ def _get_treeInterceptor(self) -> treeInterceptorHandler.TreeInterceptor:
392400
self._treeInterceptor=weakref.ref(ti)
393401
return ti
394402

395-
def _set_treeInterceptor(self,obj):
403+
def _set_treeInterceptor(self, obj: typing.Optional[TreeInterceptor]):
396404
"""Specifically sets a treeInterceptor to be associated with this object.
397405
"""
398406
if obj:

source/config/configSpec.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
trapNonCommandGestures = boolean(default=true)
175175
enableOnPageLoad = boolean(default=true)
176176
autoFocusFocusableElements = boolean(default=False)
177+
loadChromiumVbufOnBusyState = boolean(default=True)
177178
178179
[touch]
179180
enabled = boolean(default=true)

user_docs/en/changes.t2t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ This will improve performance for some Java applications including IntelliJ IDEA
4444
- This can be overridden by changing the "Windows Console support" setting in NVDA's advanced settings panel.
4545
- To find your Windows Console's NVDA API level, set "Windows Console support" to "UIA when available", then check the NVDA+F1 log opened from a running Windows Console instance.
4646
-
47+
- The Chromium virtual buffer is now loaded even when the document object has the MSAA ``STATE_SYSTEM_BUSY`` exposed via IA2. (#13306)
4748
-
4849

4950

0 commit comments

Comments
 (0)