Bug 676538: Fix regression that caused text-decorations on inline *child* of block to draw at the offset for the block rather than the inline. r=dbaron

The FrameProperty representing baseline is set when a block defines
text-decorations and has vertically-aligned children, but we were
retrieving it whether the block or the vertically-aligned frame itself
defined the decorations.  As a result, we "undo" the frame offset to get
the baseline from the child in that case.
This commit is contained in:
Vitor Menezes 2011-08-10 12:44:17 -07:00
Родитель 922f4abda2
Коммит cc47ff48ae
2 изменённых файлов: 24 добавлений и 13 удалений

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

@ -1495,7 +1495,7 @@ nsLineLayout::VerticalAlignLine()
if (vAlign.GetUnit() != eStyleUnit_Enumerated || if (vAlign.GetUnit() != eStyleUnit_Enumerated ||
vAlign.GetIntValue() != NS_STYLE_VERTICAL_ALIGN_BASELINE) { vAlign.GetIntValue() != NS_STYLE_VERTICAL_ALIGN_BASELINE) {
const nscoord offset = baselineY - (pfd->mBounds.y); const nscoord offset = baselineY - pfd->mBounds.y;
f->Properties().Set(nsIFrame::LineBaselineOffset(), f->Properties().Set(nsIFrame::LineBaselineOffset(),
NS_INT32_TO_PTR(offset)); NS_INT32_TO_PTR(offset));
} }

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

@ -4279,7 +4279,12 @@ nsTextFrame::GetTextDecorations(nsPresContext* aPresContext,
bool nearestBlockFound = false; bool nearestBlockFound = false;
for (nsIFrame* f = this, *fParent; f; f = fParent) { for (nsIFrame* f = this, *fChild = nsnull;
f;
fChild = f,
f = nsLayoutUtils::GetParentOrPlaceholderFor(
aPresContext->FrameManager(), f))
{
nsStyleContext *const context = f->GetStyleContext(); nsStyleContext *const context = f->GetStyleContext();
if (!context->HasTextDecorationLines()) { if (!context->HasTextDecorationLines()) {
break; break;
@ -4297,10 +4302,7 @@ nsTextFrame::GetTextDecorations(nsPresContext* aPresContext,
nsLayoutUtils::GetColor(f, eCSSProperty_text_decoration_color); nsLayoutUtils::GetColor(f, eCSSProperty_text_decoration_color);
} }
fParent = nsLayoutUtils::GetParentOrPlaceholderFor( const bool firstBlock = !nearestBlockFound && nsLayoutUtils::GetAsBlock(f);
aPresContext->FrameManager(), f);
const bool firstBlock = !nearestBlockFound &&
nsLayoutUtils::GetAsBlock(fParent);
// Not updating positions once we hit a parent block is equivalent to // Not updating positions once we hit a parent block is equivalent to
// the CSS 2.1 spec that blocks should propagate decorations down to their // the CSS 2.1 spec that blocks should propagate decorations down to their
@ -4308,19 +4310,28 @@ nsTextFrame::GetTextDecorations(nsPresContext* aPresContext,
// However, if we're vertically aligned within a block, then we need to // However, if we're vertically aligned within a block, then we need to
// recover the right baseline from the line by querying the FrameProperty // recover the right baseline from the line by querying the FrameProperty
// that should be set (see nsLineLayout::VerticalAlignLine). // that should be set (see nsLineLayout::VerticalAlignLine).
if (firstBlock && if (firstBlock) {
(styleText->mVerticalAlign.GetUnit() != eStyleUnit_Enumerated || // At this point, fChild can't be null since TextFrames can't be blocks
styleText->mVerticalAlign.GetIntValue() != const nsStyleCoord& vAlign =
NS_STYLE_VERTICAL_ALIGN_BASELINE)) { fChild->GetStyleContext()->GetStyleTextReset()->mVerticalAlign;
baselineOffset = frameTopOffset - if (vAlign.GetUnit() != eStyleUnit_Enumerated ||
NS_PTR_TO_INT32(f->Properties().Get(nsIFrame::LineBaselineOffset())); vAlign.GetIntValue() != NS_STYLE_VERTICAL_ALIGN_BASELINE)
{
// Since offset is the offset in the child's coordinate space, we have
// to undo the accumulation to bring the transform out of the block's
// coordinate space
baselineOffset =
frameTopOffset - (fChild->GetRect().y - fChild->GetRelativeOffset().y)
- NS_PTR_TO_INT32(
fChild->Properties().Get(nsIFrame::LineBaselineOffset()));
}
} }
else if (!nearestBlockFound) { else if (!nearestBlockFound) {
baselineOffset = frameTopOffset - f->GetBaseline(); baselineOffset = frameTopOffset - f->GetBaseline();
} }
nearestBlockFound = nearestBlockFound || firstBlock; nearestBlockFound = nearestBlockFound || firstBlock;
frameTopOffset += f->GetRect().Y() - f->GetRelativeOffset().y; frameTopOffset += f->GetRect().y - f->GetRelativeOffset().y;
const PRUint8 style = styleText->GetDecorationStyle(); const PRUint8 style = styleText->GetDecorationStyle();
// Accumulate only elements that have decorations with a genuine style // Accumulate only elements that have decorations with a genuine style