Back out for now, until I have a chance to fix reftests depending on old behavior.

This commit is contained in:
dbaron@dbaron.org 2008-02-19 09:28:00 -08:00
parent f68cc8299a
commit 33c8af3660
7 changed files with 38 additions and 46 deletions

View File

@ -7,7 +7,7 @@
#include "nsHTMLDocument.h"
%}
%pseudo-iid nsIHTMLDocument 48546d61-6097-462b-89b1-57e2221444dc
%pseudo-iid nsIHTMLDocument 61e989a8-70cd-4582-845e-6e5e12559a83
NS_INTERFACE_MAP_BEGIN(nsHTMLDocument, nsDocument)
NS_INTERFACE_MAP_ENTRY(nsIHTMLDocument)

View File

@ -3561,12 +3561,6 @@ nsHTMLDocument::ResolveName(const nsAString& aName,
//----------------------------
/* virtual */ nsIContent*
nsHTMLDocument::GetBodyContentExternal()
{
return GetBodyContent();
}
nsIContent*
nsHTMLDocument::GetBodyContent()
{

View File

@ -212,8 +212,6 @@ public:
mDisableCookieAccess = PR_TRUE;
}
virtual nsIContent* GetBodyContentExternal();
void EndUpdate(nsUpdateType aUpdateType);
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsHTMLDocument, nsDocument)

View File

@ -54,11 +54,9 @@ class nsIContent;
class nsIDOMHTMLBodyElement;
class nsIScriptElement;
// Update htmldocument.gqi when updating this IID!
// 48546d61-6097-462b-89b1-57e2221444dc
#define NS_IHTMLDOCUMENT_IID \
{ 0x48546d61, 0x6097, 0x462b, \
{ 0x89, 0xb1, 0x57, 0xe2, 0x22, 0x14, 0x44, 0xdc } }
{ 0x61e989a8, 0x70cd, 0x4582, \
{ 0x84, 0x5e, 0x6e, 0x5e, 0x12, 0x55, 0x9a, 0x83 } }
/**
* HTML document extensions to nsIDocument.
@ -175,12 +173,6 @@ public:
* Disables getting and setting cookies
*/
virtual void DisableCookieAccess() = 0;
/**
* Get the first <body> child of the root <html>, but don't do
* anything <frameset>-related (like nsIDOMHTMLDocument::GetBody).
*/
virtual nsIContent* GetBodyContentExternal() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLDocument, NS_IHTMLDOCUMENT_IID)

View File

@ -65,7 +65,8 @@
#include "nsITheme.h"
#include "nsThemeConstants.h"
#include "nsIServiceManager.h"
#include "nsIHTMLDocument.h"
#include "nsIDOMHTMLBodyElement.h"
#include "nsIDOMHTMLDocument.h"
#include "nsLayoutUtils.h"
#include "nsINameSpaceManager.h"
@ -3146,23 +3147,27 @@ FindCanvasBackground(nsIFrame* aForFrame,
if (content) {
// Use |GetOwnerDoc| so it works during destruction.
nsIDocument* document = content->GetOwnerDoc();
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document);
nsCOMPtr<nsIDOMHTMLDocument> 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 = aForFrame->PresContext()->GetPresShell()->
GetPrimaryFrameFor(bodyContent);
if (bodyFrame)
result = bodyFrame->GetStyleBackground();
if (!document->IsCaseSensitive()) { // HTML, not XHTML
nsCOMPtr<nsIDOMHTMLElement> body;
htmlDoc->GetBody(getter_AddRefs(body));
nsCOMPtr<nsIContent> bodyContent = do_QueryInterface(body);
// 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 = aForFrame->PresContext()->GetPresShell()->
GetPrimaryFrameFor(bodyContent);
if (bodyFrame)
result = bodyFrame->GetStyleBackground();
}
}
}
}
@ -3212,11 +3217,16 @@ FindElementBackground(nsIFrame* aForFrame,
// We should only look at the <html> background if we're in an HTML document
nsIDocument* document = content->GetOwnerDoc();
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document);
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(document);
if (!htmlDoc)
return PR_TRUE;
nsIContent* bodyContent = htmlDoc->GetBodyContentExternal();
if (document->IsCaseSensitive()) // XHTML, not HTML
return PR_TRUE;
nsCOMPtr<nsIDOMHTMLElement> body;
htmlDoc->GetBody(getter_AddRefs(body));
nsCOMPtr<nsIContent> bodyContent = do_QueryInterface(body);
if (bodyContent != content)
return PR_TRUE; // this wasn't the background that was propagated

View File

@ -70,7 +70,7 @@
#include "nsPresState.h"
#include "nsIGlobalHistory3.h"
#include "nsDocShellCID.h"
#include "nsIHTMLDocument.h"
#include "nsIDOMHTMLDocument.h"
#include "nsEventDispatcher.h"
#include "nsContentUtils.h"
#include "nsLayoutUtils.h"
@ -2107,9 +2107,11 @@ nsGfxScrollFrameInner::IsLTR() const
nsIContent *root = document->GetRootContent();
// But for HTML we want the body element.
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document);
if (htmlDoc) {
nsIContent *bodyContent = htmlDoc->GetBodyContentExternal();
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(document);
if (htmlDoc && !document->IsCaseSensitive()) { // HTML, not XHTML
nsCOMPtr<nsIDOMHTMLElement> body;
htmlDoc->GetBody(getter_AddRefs(body));
nsCOMPtr<nsIContent> bodyContent = do_QueryInterface(body);
if (bodyContent)
root = bodyContent; // we can trust the document to hold on to it
}

View File

@ -501,10 +501,6 @@ random-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 379316-2.html 379316-2-ref.html # bug
== 379361-1.html 379361-1-ref.html
== 379361-2.html 379361-2-ref.html
== 379361-3.html 379361-3-ref.html
== 379461-1.xhtml 379461-1.html
== 379461-2.xhtml 379461-2.html
== 379461-3.xhtml 379461-3.html
!= 379461-3.xhtml about:blank # there is a scrollbar
== 380004-1.html 380004-1-ref.html
== 380227-1.html 380227-1-ref.html
== 380842-1.html 380842-1-ref.html