diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 896bd566f2d..81ac535f63f 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -10549,12 +10549,15 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsPresContext* aPresContext, break; } else if (IsInlineFrame(kid)) { - // Look inside child inline frame for the letter frame - RemoveFirstLetterFrames(aPresContext, aPresShell, - static_cast(kid), - aBlockFrame, aStopLooking); - if (*aStopLooking) { - break; + nsContainerFrame* kidAsContainerFrame = do_QueryFrame(kid); + if (kidAsContainerFrame) { + // Look inside child inline frame for the letter frame. + RemoveFirstLetterFrames(aPresContext, aPresShell, + kidAsContainerFrame, + aBlockFrame, aStopLooking); + if (*aStopLooking) { + break; + } } } prevSibling = kid;