Bug 1548188 Part 1: Make nsRange::GetPartialTextRect use IsInlineReversed to determine whether start is before end. r=bzbarsky

The existing logic uses RightToLeft as a determinator of whether or not the start point is above-and-to-the-left of the end point. We can get that directly (and correctly) with IsInlineReversed.

Differential Revision: https://phabricator.services.mozilla.com/D44701

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brad Werth 2019-09-04 19:53:42 +00:00
parent 7a49cd3dd7
commit a99718cb94

View File

@ -2561,16 +2561,19 @@ static nsresult GetPartialTextRect(nsLayoutUtils::RectCallback* aCallback,
f->EnsureTextRun(nsTextFrame::eInflated); f->EnsureTextRun(nsTextFrame::eInflated);
NS_ENSURE_TRUE(f->GetTextRun(nsTextFrame::eInflated), NS_ENSURE_TRUE(f->GetTextRun(nsTextFrame::eInflated),
NS_ERROR_OUT_OF_MEMORY); NS_ERROR_OUT_OF_MEMORY);
bool rtl = f->GetTextRun(nsTextFrame::eInflated)->IsRightToLeft(); bool topLeftToBottomRight =
!f->GetTextRun(nsTextFrame::eInflated)->IsInlineReversed();
nsRect r = f->GetRectRelativeToSelf(); nsRect r = f->GetRectRelativeToSelf();
if (fstart < aStartOffset) { if (fstart < aStartOffset) {
// aStartOffset is within this frame // aStartOffset is within this frame
ExtractRectFromOffset(f, aStartOffset, &r, rtl, aClampToEdge); ExtractRectFromOffset(f, aStartOffset, &r, !topLeftToBottomRight,
aClampToEdge);
textContentStart = aStartOffset; textContentStart = aStartOffset;
} }
if (fend > aEndOffset) { if (fend > aEndOffset) {
// aEndOffset is in the middle of this frame // aEndOffset is in the middle of this frame
ExtractRectFromOffset(f, aEndOffset, &r, !rtl, aClampToEdge); ExtractRectFromOffset(f, aEndOffset, &r, topLeftToBottomRight,
aClampToEdge);
textContentEnd = aEndOffset; textContentEnd = aEndOffset;
} }
r = nsLayoutUtils::TransformFrameRectToAncestor(f, r, relativeTo); r = nsLayoutUtils::TransformFrameRectToAncestor(f, r, relativeTo);