From 07f4430218ab5bbc7b5f005bd9add17b2eceb40d Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 3 Apr 2017 12:38:31 +0200 Subject: [PATCH] Bug 1117227 part 4 - Make overflow mark baseline computation aware of writing-mode --- layout/generic/TextOverflow.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index 8c557d2ce8..8487edd6b5 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -223,10 +223,21 @@ void nsDisplayTextOverflowMarker::PaintTextToContext(nsRenderingContext* aCtx, nsPoint aOffsetFromRect) { - gfxFloat y = nsLayoutUtils::GetSnappedBaselineY(mFrame, aCtx->ThebesContext(), - mRect.y, mAscent); - nsPoint baselinePt(mRect.x, NSToCoordFloor(y)); - nsPoint pt = baselinePt + aOffsetFromRect; + WritingMode wm = mFrame->GetWritingMode(); + nsPoint pt(mRect.x, mRect.y); + if (wm.IsVertical()) { + if (wm.IsVerticalLR()) { + pt.x = NSToCoordFloor(nsLayoutUtils::GetSnappedBaselineX( + mFrame, aCtx->ThebesContext(), pt.x, mAscent)); + } else { + pt.x = NSToCoordFloor(nsLayoutUtils::GetSnappedBaselineX( + mFrame, aCtx->ThebesContext(), pt.x + mRect.width, -mAscent)); + } + } else { + pt.y = NSToCoordFloor(nsLayoutUtils::GetSnappedBaselineY( + mFrame, aCtx->ThebesContext(), pt.y, mAscent)); + } + pt += aOffsetFromRect; if (mStyle->mType == NS_STYLE_TEXT_OVERFLOW_ELLIPSIS) { gfxTextRun* textRun = GetEllipsisTextRun(mFrame);