Bug 1450208: Change nsRange::ExtractRectFromOffset to use simpler, hopefully safer logic to determine whether text is vertical. r=bz

Instead of checking nsIFrame::IsTextFrame() and then casting to nsTextFrame,
the new code just checks the writing mode of the frame. Less casts; less
chance of pointer errors.

MozReview-Commit-ID: LrtthZjwYq6

--HG--
extra : rebase_source : 487ed4de272f514fe1f495ed1c2ddb9c8574d0a2
This commit is contained in:
Brad Werth 2018-03-30 08:52:53 -07:00
parent 3a0c426d41
commit 19d279bd7d

View File

@ -2911,16 +2911,15 @@ static void ExtractRectFromOffset(nsIFrame* aFrame,
const int32_t aOffset, nsRect* aR,
bool aFlushToOriginEdge, bool aClampToEdge)
{
MOZ_ASSERT(aFrame);
MOZ_ASSERT(aR);
nsPoint point;
aFrame->GetPointFromOffset(aOffset, &point);
// Determine if point was generated from a vertical text run, which will change
// our math on the output rect.
bool isVertical = false;
if (aFrame->IsTextFrame()) {
nsTextFrame* textFrame = static_cast<nsTextFrame*>(aFrame);
isVertical = textFrame->GetTextRun(nsTextFrame::eInflated)->IsVertical();
}
// Determine if aFrame has a vertical writing mode, which will change our math
// on the output rect.
bool isVertical = aFrame->GetWritingMode().IsVertical();
if (!aClampToEdge && !aR->Contains(point)) {
// If point is outside aR, and we aren't clamping, output an empty rect