Skip to content

Commit

Permalink
Bug 1138092 - Add sanity check before checking ruby-align in TextAlig…
Browse files Browse the repository at this point in the history
…nLine. r=dbaron

--HG--
extra : source : a799c7cadf0dbb3efccee3076987acdc0fdabc79
  • Loading branch information
upsuper committed Mar 4, 2015
1 parent 8346b9d commit 543cbfa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions layout/generic/nsLineLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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++;
}
Expand All @@ -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++;
}
Expand Down

0 comments on commit 543cbfa

Please sign in to comment.