Bug 1154227 - Fix the painting of text-shadow in vertical writing modes. r=smontagu

This commit is contained in:
Jonathan Kew 2015-04-27 09:35:59 +01:00
Родитель e4803e8cad
Коммит 577029853b
1 изменённых файлов: 28 добавлений и 2 удалений

Просмотреть файл

@ -5559,8 +5559,25 @@ nsTextFrame::PaintOneShadow(uint32_t aOffset, uint32_t aLength,
// This rect is the box which is equivalent to where the shadow will be painted.
// The origin of aBoundingBox is the text baseline left, so we must translate it by
// that much in order to make the origin the top-left corner of the text bounding box.
gfxRect shadowGfxRect = aBoundingBox +
gfxPoint(aFramePt.x + aLeftSideOffset, aTextBaselinePt.y) + shadowOffset;
// Note that aLeftSideOffset is line-left, so actually means top offset in
// vertical writing modes.
gfxRect shadowGfxRect;
WritingMode wm = GetWritingMode();
if (wm.IsVertical()) {
shadowGfxRect = aBoundingBox;
if (wm.IsVerticalRL()) {
// for vertical-RL, reverse direction of x-coords of bounding box
shadowGfxRect.x = -shadowGfxRect.XMost();
}
shadowGfxRect +=
gfxPoint(aTextBaselinePt.x, aFramePt.y + aLeftSideOffset);
} else {
shadowGfxRect =
aBoundingBox + gfxPoint(aFramePt.x + aLeftSideOffset,
aTextBaselinePt.y);
}
shadowGfxRect += shadowOffset;
nsRect shadowRect(NSToCoordRound(shadowGfxRect.X()),
NSToCoordRound(shadowGfxRect.Y()),
NSToCoordRound(shadowGfxRect.Width()),
@ -6073,6 +6090,10 @@ nsTextFrame::PaintShadows(nsCSSShadowArray* aShadow,
gfxTextRun::Metrics shadowMetrics =
mTextRun->MeasureText(aOffset, aLength, gfxFont::LOOSE_INK_EXTENTS,
nullptr, &aProvider);
if (GetWritingMode().IsLineInverted()) {
Swap(shadowMetrics.mAscent, shadowMetrics.mDescent);
shadowMetrics.mBoundingBox.y = -shadowMetrics.mBoundingBox.YMost();
}
if (GetStateBits() & TEXT_HYPHEN_BREAK) {
AddHyphenToMetrics(this, mTextRun, &shadowMetrics,
gfxFont::LOOSE_INK_EXTENTS, aCtx);
@ -6096,6 +6117,11 @@ nsTextFrame::PaintShadows(nsCSSShadowArray* aShadow,
run++;
}
if (mTextRun->IsVertical()) {
Swap(shadowMetrics.mBoundingBox.x, shadowMetrics.mBoundingBox.y);
Swap(shadowMetrics.mBoundingBox.width, shadowMetrics.mBoundingBox.height);
}
for (uint32_t i = aShadow->Length(); i > 0; --i) {
PaintOneShadow(aOffset, aLength,
aShadow->ShadowAt(i - 1), &aProvider,