Bug 1220438 - Correct baseline offset computation of text decoration for vertical-rl. r=jfkthame

MozReview-Commit-ID: 5VHapeQ6mBU

--HG--
extra : rebase_source : 9814a77550a0d2125f6d3ba7e55594929b65fd8b
This commit is contained in:
Xidorn Quan 2016-04-01 16:29:31 +11:00
Родитель 2cf5799f02
Коммит 7fc0c87369
1 изменённых файлов: 21 добавлений и 12 удалений

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

@ -4965,16 +4965,22 @@ nsTextFrame::GetTextDecorations(
bool useOverride = false; bool useOverride = false;
nscolor overrideColor = NS_RGBA(0, 0, 0, 0); nscolor overrideColor = NS_RGBA(0, 0, 0, 0);
// frameBStartOffset represents the offset to f's BStart from our baseline in our bool nearestBlockFound = false;
// coordinate space WritingMode wm = GetWritingMode();
bool vertical = wm.IsVertical();
// physicalBlockStartOffset represents the offset from our baseline
// to f's physical block start, which is top in horizontal writing
// mode, and left in vertical writing modes, in our coordinate space.
// This physical block start is logical block start in most cases,
// but for vertical-rl, it is logical block end, and consequently in
// that case, it starts from the descent instead of ascent.
nscoord physicalBlockStartOffset =
wm.IsVerticalRL() ? GetSize().width - mAscent : mAscent;
// baselineOffset represents the offset from our baseline to f's baseline or // baselineOffset represents the offset from our baseline to f's baseline or
// the nearest block's baseline, in our coordinate space, whichever is closest // the nearest block's baseline, in our coordinate space, whichever is closest
// during the particular iteration // during the particular iteration
nscoord frameBStartOffset = mAscent, nscoord baselineOffset = 0;
baselineOffset = 0;
bool nearestBlockFound = false;
bool vertical = GetWritingMode().IsVertical();
for (nsIFrame* f = this, *fChild = nullptr; for (nsIFrame* f = this, *fChild = nullptr;
f; f;
@ -5017,19 +5023,22 @@ nsTextFrame::GetTextDecorations(
const nscoord lineBaselineOffset = LazyGetLineBaselineOffset(fChild, const nscoord lineBaselineOffset = LazyGetLineBaselineOffset(fChild,
fBlock); fBlock);
baselineOffset = frameBStartOffset - lineBaselineOffset - baselineOffset = physicalBlockStartOffset - lineBaselineOffset -
(vertical ? fChild->GetNormalPosition().x (vertical ? fChild->GetNormalPosition().x
: fChild->GetNormalPosition().y); : fChild->GetNormalPosition().y);
} }
} }
else if (!nearestBlockFound) { else if (!nearestBlockFound) {
// use a dummy WritingMode, because nsTextFrame::GetLogicalBaseLine // offset here is the offset from f's baseline to f's top/left
// doesn't use it anyway // boundary. It's descent for vertical-rl, and ascent otherwise.
baselineOffset = frameBStartOffset - f->GetLogicalBaseline(WritingMode()); nscoord offset = wm.IsVerticalRL() ?
f->GetSize().width - f->GetLogicalBaseline(wm) :
f->GetLogicalBaseline(wm);
baselineOffset = physicalBlockStartOffset - offset;
} }
nearestBlockFound = nearestBlockFound || firstBlock; nearestBlockFound = nearestBlockFound || firstBlock;
frameBStartOffset += physicalBlockStartOffset +=
vertical ? f->GetNormalPosition().x : f->GetNormalPosition().y; vertical ? f->GetNormalPosition().x : f->GetNormalPosition().y;
const uint8_t style = styleText->GetDecorationStyle(); const uint8_t style = styleText->GetDecorationStyle();