diff --git a/mozilla/layout/base/nsCSSRendering.cpp b/mozilla/layout/base/nsCSSRendering.cpp index 04a9f210a3e..565ec6cf43e 100644 --- a/mozilla/layout/base/nsCSSRendering.cpp +++ b/mozilla/layout/base/nsCSSRendering.cpp @@ -2509,9 +2509,16 @@ FindElementBackground(nsIPresContext* aPresContext, nsCOMPtr content; aForFrame->GetContent(getter_AddRefs(content)); - nsCOMPtr body = do_QueryInterface(content); - if (!body || !parentFrame) - return PR_TRUE; // not frame for BODY element + if (!content || !content->IsContentOfType(nsIContent::eHTML)) + return PR_TRUE; // not frame for an HTML element + + if (!parentFrame) + return PR_TRUE; // no parent to look at + + nsCOMPtr tag; + content->GetTag(*getter_AddRefs(tag)); + if (tag != nsHTMLAtoms::body) + return PR_TRUE; // not frame for element // We should only look at the background if we're in an HTML document nsCOMPtr node(do_QueryInterface(content)); diff --git a/mozilla/layout/html/style/src/nsCSSRendering.cpp b/mozilla/layout/html/style/src/nsCSSRendering.cpp index 04a9f210a3e..565ec6cf43e 100644 --- a/mozilla/layout/html/style/src/nsCSSRendering.cpp +++ b/mozilla/layout/html/style/src/nsCSSRendering.cpp @@ -2509,9 +2509,16 @@ FindElementBackground(nsIPresContext* aPresContext, nsCOMPtr content; aForFrame->GetContent(getter_AddRefs(content)); - nsCOMPtr body = do_QueryInterface(content); - if (!body || !parentFrame) - return PR_TRUE; // not frame for BODY element + if (!content || !content->IsContentOfType(nsIContent::eHTML)) + return PR_TRUE; // not frame for an HTML element + + if (!parentFrame) + return PR_TRUE; // no parent to look at + + nsCOMPtr tag; + content->GetTag(*getter_AddRefs(tag)); + if (tag != nsHTMLAtoms::body) + return PR_TRUE; // not frame for element // We should only look at the background if we're in an HTML document nsCOMPtr node(do_QueryInterface(content));