Bug 1138092 - Add sanity check before checking ruby-align in TextAlignLine. r=dbaron

--HG--
extra : source : a799c7cadf0dbb3efccee3076987acdc0fdabc79
This commit is contained in:
Xidorn Quan 2015-03-04 13:04:11 +11:00
Родитель 8346b9dfaf
Коммит 543cbfa069
1 изменённых файлов: 6 добавлений и 3 удалений

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

@ -2895,7 +2895,10 @@ FindNearestRubyBaseAncestor(nsIFrame* aFrame)
while (aFrame && aFrame->GetType() != nsGkAtoms::rubyBaseFrame) {
aFrame = aFrame->GetParent();
}
MOZ_ASSERT(aFrame, "No ruby base ancestor?");
// XXX It is possible that no ruby base ancestor is found because of
// some edge cases like form control or canvas inside ruby text.
// See bug 1138092 comment 4.
NS_ASSERTION(aFrame, "No ruby base ancestor?");
return aFrame;
}
@ -3066,7 +3069,7 @@ nsLineLayout::TextAlignLine(nsLineBox* aLine,
if (firstFrame->mFrame->StyleContext()->IsInlineDescendantOfRuby()) {
MOZ_ASSERT(!firstFrame->mJustificationAssignment.mGapsAtStart);
nsIFrame* rubyBase = FindNearestRubyBaseAncestor(firstFrame->mFrame);
if (IsRubyAlignSpaceAround(rubyBase)) {
if (rubyBase && IsRubyAlignSpaceAround(rubyBase)) {
firstFrame->mJustificationAssignment.mGapsAtStart = 1;
additionalGaps++;
}
@ -3075,7 +3078,7 @@ nsLineLayout::TextAlignLine(nsLineBox* aLine,
if (lastFrame->mFrame->StyleContext()->IsInlineDescendantOfRuby()) {
MOZ_ASSERT(!lastFrame->mJustificationAssignment.mGapsAtEnd);
nsIFrame* rubyBase = FindNearestRubyBaseAncestor(lastFrame->mFrame);
if (IsRubyAlignSpaceAround(rubyBase)) {
if (rubyBase && IsRubyAlignSpaceAround(rubyBase)) {
lastFrame->mJustificationAssignment.mGapsAtEnd = 1;
additionalGaps++;
}