diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index f8a112f11a9..2f9c92feae6 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -290,22 +290,25 @@ GetNonEmptyTextFrameAndNode(nsIFrame* aFrame, nsTextNode*& aTextNode) { nsTextFrame* text = do_QueryFrame(aFrame); - if (!text) { - return false; + bool isNonEmptyTextFrame = text && text->GetContentLength() != 0; + + if (isNonEmptyTextFrame) { + nsIContent* content = text->GetContent(); + NS_ASSERTION(content && content->IsNodeOfType(nsINode::eTEXT), + "unexpected content type for nsTextFrame"); + + nsTextNode* node = static_cast(content); + MOZ_ASSERT(node->TextLength() != 0, + "frame's GetContentLength() should be 0 if the text node " + "has no content"); + + aTextFrame = text; + aTextNode = node; } - nsIContent* content = text->GetContent(); - NS_ASSERTION(content && content->IsNodeOfType(nsINode::eTEXT), - "unexpected content type for nsTextFrame"); - - nsTextNode* node = static_cast(content); - if (node->TextLength() == 0) { - return false; - } - - aTextFrame = text; - aTextNode = node; - return true; + MOZ_ASSERT(IsNonEmptyTextFrame(aFrame) == isNonEmptyTextFrame, + "our logic should agree with IsNonEmptyTextFrame"); + return isNonEmptyTextFrame; } /** @@ -1308,7 +1311,7 @@ GetUndisplayedCharactersBeforeFrame(nsTextFrame* aFrame) /** * Traverses the nsTextFrames for an SVGTextFrame and records a * TextNodeCorrespondenceProperty on each for the number of undisplayed DOM - * characters between each frame. This is done by iterating simultaenously + * characters between each frame. This is done by iterating simultaneously * over the nsTextNodes and nsTextFrames and noting when nsTextNodes (or * parts of them) are skipped when finding the next nsTextFrame. */