diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index c2b6519890a..0922b654554 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -2367,12 +2367,6 @@ nsHTMLDocument::ResolveName(const nsAString& aName, //---------------------------- -/* virtual */ nsIContent* -nsHTMLDocument::GetBodyContentExternal() -{ - return GetBodyElement(); -} - // forms related stuff NS_IMETHODIMP diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h index 6ff20627aae..336f2c6569b 100644 --- a/content/html/document/src/nsHTMLDocument.h +++ b/content/html/document/src/nsHTMLDocument.h @@ -174,8 +174,6 @@ public: mDisableCookieAccess = PR_TRUE; } - virtual nsIContent* GetBodyContentExternal(); - class nsAutoEditingState { public: nsAutoEditingState(nsHTMLDocument* aDoc, EditingState aState) diff --git a/content/html/document/src/nsIHTMLDocument.h b/content/html/document/src/nsIHTMLDocument.h index d00c8234855..d6ee9a6b8b9 100644 --- a/content/html/document/src/nsIHTMLDocument.h +++ b/content/html/document/src/nsIHTMLDocument.h @@ -49,8 +49,8 @@ class nsContentList; class nsWrapperCache; #define NS_IHTMLDOCUMENT_IID \ -{ 0x30001b0c, 0xdb25, 0x4318, \ - { 0x85, 0xb8, 0x48, 0xb4, 0xea, 0x54, 0x8f, 0x23 } } +{ 0x51a360fa, 0xd659, 0x4d85, \ + { 0xa5, 0xc5, 0x4a, 0xbb, 0x0d, 0x97, 0x0f, 0x7a } } /** @@ -164,12 +164,6 @@ public: */ virtual void DisableCookieAccess() = 0; - /** - * Get the first child of the root , but don't do - * anything -related (like nsIDOMHTMLDocument::GetBody). - */ - virtual nsIContent* GetBodyContentExternal() = 0; - /** * Called when this nsIHTMLDocument's editor is destroyed. */ diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 7dc877676c9..d56c32f8e5a 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -67,7 +67,6 @@ #include "nsITheme.h" #include "nsThemeConstants.h" #include "nsIServiceManager.h" -#include "nsIHTMLDocument.h" #include "nsLayoutUtils.h" #include "nsINameSpaceManager.h" #include "nsBlockFrame.h" @@ -85,6 +84,8 @@ #include "nsCSSRenderingBorders.h" +using namespace mozilla; + /** * This is a small wrapper class to encapsulate image drawing that can draw an * nsStyleImage image, which may internally be a real image, a sub image, or a @@ -937,36 +938,43 @@ nsCSSRendering::FindBackgroundStyleFrame(nsIFrame* aForFrame) const nsStyleBackground* result = aForFrame->GetStyleBackground(); // Check if we need to do propagation from BODY rather than HTML. - if (result->IsTransparent()) { - nsIContent* content = aForFrame->GetContent(); - // The root element content can't be null. We wouldn't know what - // frame to create for aFrame. - // Use |GetOwnerDoc| so it works during destruction. - if (content) { - nsIDocument* document = content->GetOwnerDoc(); - nsCOMPtr htmlDoc = do_QueryInterface(document); - if (htmlDoc) { - nsIContent* bodyContent = htmlDoc->GetBodyContentExternal(); - // We need to null check the body node (bug 118829) since - // there are cases, thanks to the fix for bug 5569, where we - // will reflow a document with no body. In particular, if a - // SCRIPT element in the head blocks the parser and then has a - // SCRIPT that does "document.location.href = 'foo'", then - // nsParser::Terminate will call |DidBuildModel| methods - // through to the content sink, which will call |StartLayout| - // and thus |InitialReflow| on the pres shell. See bug 119351 - // for the ugly details. - if (bodyContent) { - nsIFrame *bodyFrame = bodyContent->GetPrimaryFrame(); - if (bodyFrame) { - return nsLayoutUtils::GetStyleFrame(bodyFrame); - } - } - } - } + if (!result->IsTransparent()) { + return aForFrame; } - return aForFrame; + nsIContent* content = aForFrame->GetContent(); + // The root element content can't be null. We wouldn't know what + // frame to create for aFrame. + // Use |GetOwnerDoc| so it works during destruction. + if (!content) { + return aForFrame; + } + + nsIDocument* document = content->GetOwnerDoc(); + if (!document) { + return aForFrame; + } + + dom::Element* bodyContent = document->GetBodyElement(); + // We need to null check the body node (bug 118829) since + // there are cases, thanks to the fix for bug 5569, where we + // will reflow a document with no body. In particular, if a + // SCRIPT element in the head blocks the parser and then has a + // SCRIPT that does "document.location.href = 'foo'", then + // nsParser::Terminate will call |DidBuildModel| methods + // through to the content sink, which will call |StartLayout| + // and thus |InitialReflow| on the pres shell. See bug 119351 + // for the ugly details. + if (!bodyContent) { + return aForFrame; + } + + nsIFrame *bodyFrame = bodyContent->GetPrimaryFrame(); + if (!bodyFrame) { + return aForFrame; + } + + return nsLayoutUtils::GetStyleFrame(bodyFrame); } /** @@ -1027,11 +1035,10 @@ FindElementBackground(nsIFrame* aForFrame, nsIFrame* aRootElementFrame, // We should only look at the background if we're in an HTML document nsIDocument* document = content->GetOwnerDoc(); - nsCOMPtr htmlDoc = do_QueryInterface(document); - if (!htmlDoc) + if (!document) return PR_TRUE; - nsIContent* bodyContent = htmlDoc->GetBodyContentExternal(); + dom::Element* bodyContent = document->GetBodyElement(); if (bodyContent != content) return PR_TRUE; // this wasn't the background that was propagated diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index 645d1e237eb..f81fb80b6f1 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -63,8 +63,6 @@ #include "nsIDocument.h" #include "nsIPresShell.h" #include "nsStyleConsts.h" -#include "nsIHTMLDocument.h" -#include "nsIDOMHTMLElement.h" #include "nsCSSAnonBoxes.h" #include "nsRuleWalker.h" #include "nsRuleData.h"