terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Replace UIA CompareInBounds with til::point comparators

Open carlos-zamora opened this issue 2 years ago • 3 comments

This PR replaces the uses of Viewport::CompareInBounds() in the UIA code with til::point comparators. Additionally, it simplifies the logic further by using std::max and std::min.

In doing so, we are no longer hitting the assert in CompareInBounds().

Closes #14542

carlos-zamora avatar Dec 14 '22 01:12 carlos-zamora

Since this looks like a new version of #13244, which was reverted in #13907, I may need an explanation as to why the reason stated for the revert doesn't apply :smile:

DHowett avatar Dec 14 '22 16:12 DHowett

@DHowett

Ok. This is "great". Here's what happened:

  • PR #13244:
    • this code:
        if (!bufferSize.IsInBounds(_start, true) || !bufferSize.IsInBounds(_end, true))
        {
            THROW_HR(E_FAIL);
        }
  • is replaced with this code:
        THROW_HR_IF(E_FAIL, !bufferSize.IsInBounds(_start) || !bufferSize.IsInBounds(_end));
  • Due to this specific change, #13866 occurs. Turns out, the rest of the change is mostly fine. But since we were prepping for a release, it was much easier to revert the change (that's definitely on me).
  • This PR:
    • This time around, I'm not making that mistake of removing the true. I've manually verified that #13866 doesn't occur.
    • Also, #13244 included a change to remove the second param from IsInBounds(), which is what specifically lead to the change above.

carlos-zamora avatar Dec 14 '22 18:12 carlos-zamora

We could still do the other CompareInBounds() replacements throughout the codebase (as in #13244). Figured specifically focusing on UIA would be nicer though.

carlos-zamora avatar Dec 14 '22 18:12 carlos-zamora

Hello @carlos-zamora!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

ghost avatar Dec 19 '22 18:12 ghost