Adjust GetBoundingRect for Inclusive end (#4449)

GetBoundingRect() has inclusive endpoints. I previously assumed end was exclusive so I drew the bounding rect wrong.

This also means that we should allow start and end to be the same. Which means that FailFastIf would get hit...
This commit is contained in:
Carlos Zamora 2020-02-03 13:25:08 -08:00 committed by GitHub
parent 3c0d48ce19
commit d375461a66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -983,7 +983,7 @@ const unsigned int UiaTextRangeBase::_getViewportHeight(const SMALL_RECT viewpor
void UiaTextRangeBase::_getBoundingRect(_In_ const COORD startAnchor, _In_ const COORD endAnchor, _Inout_ std::vector<double>& coords) const
{
FAIL_FAST_IF(startAnchor.Y != endAnchor.Y);
FAIL_FAST_IF(startAnchor.X >= endAnchor.X);
FAIL_FAST_IF(startAnchor.X > endAnchor.X);
const auto viewport = _pData->GetViewport();
const auto currentFontSize = _getScreenFontSize();
@ -1005,7 +1005,7 @@ void UiaTextRangeBase::_getBoundingRect(_In_ const COORD startAnchor, _In_ const
#pragma warning(suppress : 26496) // analysis can't see this, TODO GH: 4015 to improve Viewport to be less bad because it'd go away if ConvertToOrigin returned instead of inout'd.
auto endCoord = endAnchor;
viewport.ConvertToOrigin(&endCoord);
bottomRight.x = base::ClampMul<long, long>(endCoord.X, currentFontSize.X);
bottomRight.x = base::ClampMul<long, long>(base::ClampAdd(endCoord.X, 1), currentFontSize.X);
bottomRight.y = base::ClampMul<long, long>(base::ClampAdd(endCoord.Y, 1), currentFontSize.Y);
// convert the coords to be relative to the screen instead of