Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions source/IAccessibleHandler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.

# F401 imported but unused. RelationType should be exposed from IAccessibleHandler, in future __all__
# should be used to export it.
from .types import RelationType # noqa: F401

import re
import struct
from typing import (
Expand Down Expand Up @@ -57,9 +61,6 @@
NAVRELATION_NODE_CHILD_OF = 0x1005
NAVRELATION_EMBEDS = 0x1009

# IAccessible2 relations (not included in the typelib)
IA2_RELATION_FLOWS_FROM = "flowsFrom"
IA2_RELATION_FLOWS_TO = "flowsTo"

# A place to store live IAccessible NVDAObjects, that can be looked up by their window,objectID,
# childID event params.
Expand Down
12 changes: 11 additions & 1 deletion source/IAccessibleHandler/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@
"""Types used in IAccessibleHander.
Kept here so they can be re-used without having to worry about circular imports.
"""

import enum
from typing import Tuple

IAccessibleObjectIdentifierType = Tuple[
int, # windowHandle
int, # objectID
int, # childID
]


# IAccessible2 relations (not included in the typelib)
@enum.unique
class RelationType(enum.Enum):
FLOWS_FROM = "flowsFrom"
FLOWS_TO = "flowsTo"
CONTAINING_DOCUMENT = "containingDocument"
DETAILS = "details"
DETAILS_FOR = "detailsFor"
14 changes: 10 additions & 4 deletions source/NVDAObjects/IAccessible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1486,11 +1486,17 @@ def _getIA2RelationFirstTarget(
pass
return None

def _get_flowsTo(self):
return self._getIA2RelationFirstTarget(IAccessibleHandler.IA2_RELATION_FLOWS_TO)
#: Type definition for auto prop '_get_flowsTo'
flowsTo: typing.Optional["IAccessible"]

def _get_flowsFrom(self):
return self._getIA2RelationFirstTarget(IAccessibleHandler.IA2_RELATION_FLOWS_FROM)
def _get_flowsTo(self) -> typing.Optional["IAccessible"]:
return self._getIA2RelationFirstTarget(IAccessibleHandler.RelationType.FLOWS_TO)

#: Type definition for auto prop '_get_flowsFrom'
flowsFrom: typing.Optional["IAccessible"]

def _get_flowsFrom(self) -> typing.Optional["IAccessible"]:
return self._getIA2RelationFirstTarget(IAccessibleHandler.RelationType.FLOWS_FROM)

def event_valueChange(self):
if isinstance(self, EditableTextWithAutoSelectDetection):
Expand Down
9 changes: 5 additions & 4 deletions source/virtualBuffers/gecko_ia2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import winUser
import mouseHandler
import IAccessibleHandler

import oleacc
from logHandler import log
import textInfos
Expand All @@ -23,9 +24,6 @@
import config
from NVDAObjects.IAccessible import normalizeIA2TextFormatField, IA2TextTextInfo

IA2_RELATION_CONTAINING_DOCUMENT = "containingDocument"


def _getNormalizedCurrentAttrs(attrs: textInfos.ControlField) -> typing.Dict[str, typing.Any]:
valForCurrent = attrs.get("IAccessible2::attribute_current", "false")
try:
Expand Down Expand Up @@ -193,7 +191,10 @@ def _getEmbedderFrame(acc):
# IAccessible NVDAObjects currently fetch IA2, but we need IA2_2 for relationTargetsOfType.
# (Out-of-process, for a single relation, this is cheaper than IA2::relations.)
acc = acc.QueryInterface(IA2.IAccessible2_2)
targets, count = acc.relationTargetsOfType(IA2_RELATION_CONTAINING_DOCUMENT, 1)
targets, count = acc.relationTargetsOfType(
IAccessibleHandler.RelationType.CONTAINING_DOCUMENT,
1 # max relations to fetch
)
if count == 0:
return None
doc = targets[0].QueryInterface(IA2.IAccessible2_2)
Expand Down
5 changes: 5 additions & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ This ensures code will honor the Windows user setting for swapping the primary m
- ``_UIAConstants`` is now ``UIAHandler.constants``
- ``_UIACustomProps`` is now ``UIAHandler.customProps``
- ``_UIACustomAnnotations`` is now ``UIAHandler.customAnnotations``
- The ``IAccessibleHandler`` ``IA2_RELATION_*`` constants have been replaced with the ``IAccessibleHandler.RelationType`` enum. (#13096)
- Removed ``IA2_RELATION_FLOWS_FROM``
- Removed ``IA2_RELATION_FLOWS_TO``
- Removed ``IA2_RELATION_CONTAINING_DOCUMENT``
-
-


Expand Down