New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OffsetsTextInfo.boundingRects property: make sure there is a location to work with when calculating intersections #9100

merged 2 commits into from Jan 10, 2019


None yet
3 participants
Copy link

leonardder commented Dec 21, 2018

Link to issue number:


Summary of the issue:

I received a bug reports where the boundingRects code for OffsetsTextInfo failed as follows:

Log snippet WARNING - (13:43:58.411): Could not execute function event_gainFocus defined in NVDAObjects module due to unsupported kwargs: {} Traceback (most recent call last): File "eventHandler.pyc", line 100, in next File "NVDAObjects\__init__.pyc", line 972, in event_gainFocus File "vision\__init__.pyc", line 541, in handleGainFocus File "vision\NVDAHighlighter.pyc", line 65, in updateContextRect File "vision\__init__.pyc", line 237, in updateContextRect File "vision\__init__.pyc", line 165, in getContextRect File "vision\__init__.pyc", line 176, in _getRectFromTextInfo File "baseObject.pyc", line 32, in __get__ File "textInfos\offsets.pyc", line 233, in _get_boundingRects File "locationHelper.pyc", line 335, in intersection TypeError: other should be one of locationHelper.RectLTRB, locationHelper.RectLTWH, ctypes.wintypes.RECT, textInfos.Rect

This was tested with Firefox with the NVDA highlighter in the vision framework (#9064)

Description of how this pull request fixes the issue:

  1. EventGandler tries to executes functions, and if they fails because of unsupported arguments (which is a type error), it tries to use extensionPoints.callWithSupportedKwargs instead. However, locationHelper caused a TypeError as well, which triggered the exception handler. Therefore, I somewhat reworded the logged warning in the eventHandler.
  2. The boundingRects property caused a TypeError because it tried to throw a None type object in locationHelper.RectLTWH.intersection. Now, if either the location of the NVDAObject or the foreground object it lives in is None, a LookupError is raised instead.

Testing performed:

Unfortunately, I wasn't able to reproduce the issue myself, so it wasn't possible to test this particular case.

Known issues with pull request:


Change log entry:

None needed.

OffsetsTextInfo.boundingRects property: make sure there is a location…
… to work with when calculating intersections

@leonardder leonardder requested a review from feerrenrut Dec 21, 2018

@@ -208,7 +209,10 @@ def _get_boundingRects(self):
# If the inclusive end offset is greater than the start offset, we are working with a range.
# If not, i.e. the range only contains one character, we have only one location to deal with.
objLocation = self.obj.rootNVDAObject.location if isinstance(self.obj, TreeInterceptor) else self.obj.location
obj = self.obj.rootNVDAObject if isinstance(self.obj, TreeInterceptor) else self.obj
objLocation = obj.location or api.getForegroundObject().location

This comment has been minimized.


michaelDCurran Jan 9, 2019


Would an idea be to walk up the parents until finding a valid location? Foreground does seem a little inaccurate to me, when a direct parent would be much closer to the correct coordinates? Do make sure to break the loop after say 100 iterations just in case there is a broken parent chain that repeetes. However, if this idea doesn't really suit what you're going for, I'm happy to keep the foreground idea.

This comment has been minimized.


leonardder Jan 9, 2019


This makes sense!

@michaelDCurran michaelDCurran merged commit d512084 into nvaccess:master Jan 10, 2019

1 check passed

continuous-integration/appveyor/pr AppVeyor build succeeded

@nvaccessAuto nvaccessAuto added this to the 2019.1 milestone Jan 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment