Fix MoveEndpointByUnit (TextUnit_Word/Line) degenerate range creation

ITextRangeProvider::MoveEndpointByUnit for TextUnit_Word and
TextUnit_Line will not create a degenerate range in certain cases when
at the beginning or end of a document.

The problem can be found in CreateNextWordStartPosition(),
CreatePreviousWordEndPosition(), CreateNextWordStartPosition(), and
CreatePreviousWordEndPosition(). The problem can be illustrated by the
case below:
            Text
            ^   ^
	start   end
When the above case is at the beginning of the document, and you
try to create a degenerate range by moving end to the start,
CreatePrevious[Word/Line]Position() will call
CreatePreviousTextAnchorPosition(). This will return a null position
because there is no previous text anchor. This causes
CreatePrevious[Word/Line]Position() to think that end is at the
beginning of the document, and as a result will leave end where it is.
However, end is still at the end of the first anchor and not at the
beginning of the document.

This change fixes the above issue by checking the text offset to see if
the position is truly at the beginning/end of the document, or if there
is actually more text to traverse.

This change is related to the bug fix found here:
https://chromium-review.googlesource.com/c/chromium/src/+/1604407

Bug: 961884
Change-Id: I60b2baa56fe1437b66e12e1c0884631edfb77686
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1612255
Commit-Queue: Alison Maher <almaher@microsoft.com>
Reviewed-by: Nektarios Paisios <nektar@chromium.org>
Reviewed-by: Kurt Catti-Schmidt <kschmi@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#661607}
3 files changed