Back out Smaug's patch from bug 395609 due to a Txul regression.

This commit is contained in:
reed@reedloden.com 2008-02-26 19:51:00 -08:00
parent 52a3d728ad
commit ad47a157a8
4 changed files with 42 additions and 102 deletions

View File

@ -69,7 +69,6 @@ REQUIRES = xpcom \
webshell \
view \
htmlparser \
docshell \
$(NULL)
ifdef MOZ_XUL

View File

@ -135,7 +135,7 @@
#include "nsGkAtoms.h"
#include "nsXULContentUtils.h"
#include "nsNodeUtils.h"
#include "nsFrameLoader.h"
#include "prlog.h"
#include "rdf.h"
@ -215,32 +215,26 @@ PRUint32 nsXULPrototypeAttribute::gNumCacheSets;
PRUint32 nsXULPrototypeAttribute::gNumCacheFills;
#endif
class nsXULElementTearoff : public nsIDOMElementCSSInlineStyle,
public nsIFrameLoaderOwner
class nsXULElementTearoff : public nsIDOMElementCSSInlineStyle
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsXULElementTearoff,
nsIDOMElementCSSInlineStyle)
NS_DECL_ISUPPORTS
nsXULElementTearoff(nsXULElement *aElement)
: mElement(aElement)
{
}
NS_FORWARD_NSIDOMELEMENTCSSINLINESTYLE(static_cast<nsXULElement*>(mElement.get())->)
NS_FORWARD_NSIFRAMELOADEROWNER(static_cast<nsXULElement*>(mElement.get())->);
NS_FORWARD_NSIDOMELEMENTCSSINLINESTYLE(mElement->)
private:
nsCOMPtr<nsIDOMXULElement> mElement;
nsRefPtr<nsXULElement> mElement;
};
NS_IMPL_CYCLE_COLLECTION_1(nsXULElementTearoff, mElement)
NS_IMPL_ADDREF(nsXULElementTearoff)
NS_IMPL_RELEASE(nsXULElementTearoff)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsXULElementTearoff)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsXULElementTearoff)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXULElementTearoff)
NS_INTERFACE_MAP_ENTRY(nsIFrameLoaderOwner)
NS_INTERFACE_MAP_BEGIN(nsXULElementTearoff)
NS_INTERFACE_MAP_ENTRY(nsIDOMElementCSSInlineStyle)
NS_INTERFACE_MAP_END_AGGREGATED(mElement)
@ -263,9 +257,6 @@ nsXULElement::nsXULSlots::nsXULSlots(PtrBits aFlags)
nsXULElement::nsXULSlots::~nsXULSlots()
{
NS_IF_RELEASE(mControllers); // Forces release
if (mFrameLoader) {
mFrameLoader->Destroy();
}
}
nsINode::nsSlots*
@ -414,9 +405,6 @@ nsXULElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
} else if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
inst = NS_GetDOMClassInfoInstance(eDOMClassInfo_XULElement_id);
NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
} else if (aIID.Equals(NS_GET_IID(nsIFrameLoaderOwner))) {
inst = static_cast<nsIFrameLoaderOwner*>(new nsXULElementTearoff(this));
NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
} else {
return PostQueryInterface(aIID, aInstancePtr);
}
@ -824,29 +812,6 @@ nsXULElement::MaybeAddPopupListener(nsIAtom* aLocalName)
// nsIContent interface
//
nsresult
nsXULElement::BindToTree(nsIDocument* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent,
PRBool aCompileEventHandlers)
{
nsresult rv = nsGenericElement::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
// We're in a document now. Kick off the frame load.
nsCOMPtr<nsIFrameLoader> fl;
GetFrameLoader(getter_AddRefs(fl));
if (fl) {
fl->LoadFrame();
}
}
return rv;
}
void
nsXULElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
{
@ -861,18 +826,9 @@ nsXULElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
// mDocument in nsGlobalWindow::SetDocShell, but I'm not
// sure whether that would fix all possible cycles through
// mControllers.)
nsXULSlots* slots = static_cast<nsXULSlots*>(GetExistingDOMSlots());
nsDOMSlots* slots = GetExistingDOMSlots();
if (slots) {
NS_IF_RELEASE(slots->mControllers);
if (slots->mFrameLoader) {
// This element is being taken out of the document, destroy the
// possible frame loader.
// XXXbz we really want to only partially destroy the frame
// loader... we don't want to tear down the docshell. Food for
// later bug.
slots->mFrameLoader->Destroy();
slots->mFrameLoader = nsnull;
}
}
nsGenericElement::UnbindFromTree(aDeep, aNullParent);
@ -1110,14 +1066,6 @@ nsXULElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
SetTitlebarColor(color);
}
if (aName == nsGkAtoms::src && document) {
nsCOMPtr<nsIFrameLoader> fl;
GetFrameLoader(getter_AddRefs(fl));
if (fl) {
fl->LoadFrame();
}
}
// XXX need to check if they're changing an event handler: if
// so, then we need to unhook the old one. Or something.
}
@ -1525,13 +1473,9 @@ nsXULElement::GetAttrCount() const
void
nsXULElement::DestroyContent()
{
nsXULSlots* slots = static_cast<nsXULSlots*>(GetExistingDOMSlots());
nsDOMSlots* slots = GetExistingDOMSlots();
if (slots) {
NS_IF_RELEASE(slots->mControllers);
if (slots->mFrameLoader) {
slots->mFrameLoader->Destroy();
slots->mFrameLoader = nsnull;
}
NS_IF_RELEASE(slots->mControllers);
}
nsGenericElement::DestroyContent();
@ -2004,28 +1948,6 @@ nsXULElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
return NS_OK;
}
nsresult
nsXULElement::GetFrameLoader(nsIFrameLoader** aFrameLoader)
{
*aFrameLoader = nsnull;
// Allow frame loader only on objects for which a container box object
// can be obtained.
nsIAtom* tag = Tag();
if (tag != nsGkAtoms::browser &&
tag != nsGkAtoms::editor &&
tag != nsGkAtoms::iframe) {
return NS_OK;
}
nsXULSlots* slots = static_cast<nsXULSlots*>(GetSlots());
NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY);
if (!slots->mFrameLoader && IsInDoc()) {
slots->mFrameLoader = new nsFrameLoader(this);
NS_ENSURE_TRUE(slots->mFrameLoader, NS_ERROR_OUT_OF_MEMORY);
}
NS_IF_ADDREF(*aFrameLoader = slots->mFrameLoader);
return NS_OK;
}
NS_IMETHODIMP
nsXULElement::GetParentTree(nsIDOMXULMultiSelectControlElement** aTreeElement)
{

View File

@ -77,7 +77,6 @@
#include "nsAutoPtr.h"
#include "nsGenericElement.h"
#include "nsDOMScriptObjectHolder.h"
#include "nsIFrameLoader.h"
class nsIDocument;
class nsString;
@ -549,9 +548,6 @@ public:
PRBool aNotify);
// nsIContent
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
PRBool aCompileEventHandlers);
virtual void UnbindFromTree(PRBool aDeep, PRBool aNullParent);
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
virtual nsIAtom *GetIDAttributeName() const;
@ -624,8 +620,6 @@ public:
nsresult GetStyle(nsIDOMCSSStyleDeclaration** aStyle);
nsresult GetFrameLoader(nsIFrameLoader** aFrameLoader);
virtual void RecompileScriptEventListeners();
// This function should ONLY be used by BindToTree implementations.
@ -661,8 +655,6 @@ protected:
public:
nsXULSlots(PtrBits aFlags);
virtual ~nsXULSlots();
nsCOMPtr<nsIFrameLoader> mFrameLoader;
};
virtual nsINode::nsSlots* CreateSlots();

View File

@ -211,12 +211,13 @@ protected:
nsCOMPtr<nsIFrameLoader> mFrameLoader;
nsIView* mInnerView;
PRPackedBool mDidCreateDoc;
PRPackedBool mOwnsFrameLoader;
PRPackedBool mIsInline;
PRPackedBool mPostedReflowCallback;
};
nsSubDocumentFrame::nsSubDocumentFrame(nsStyleContext* aContext)
: nsLeafFrame(aContext), mDidCreateDoc(PR_FALSE),
: nsLeafFrame(aContext), mDidCreateDoc(PR_FALSE), mOwnsFrameLoader(PR_FALSE),
mIsInline(PR_FALSE), mPostedReflowCallback(PR_FALSE)
{
}
@ -634,8 +635,13 @@ nsSubDocumentFrame::AttributeChanged(PRInt32 aNameSpaceID,
return NS_OK;
}
if (aAttribute == nsGkAtoms::src) {
if (mOwnsFrameLoader && mFrameLoader) {
mFrameLoader->LoadFrame();
}
}
// If the noResize attribute changes, dis/allow frame to be resized
if (aAttribute == nsGkAtoms::noresize) {
else if (aAttribute == nsGkAtoms::noresize) {
// Note that we're not doing content type checks, but that's ok -- if
// they'd fail we will just end up with a null framesetFrame.
if (mContent->GetParent()->Tag() == nsGkAtoms::frameset) {
@ -768,6 +774,13 @@ nsSubDocumentFrame::Destroy()
}
}
if (mFrameLoader && mOwnsFrameLoader) {
// We own this frame loader, and we're going away, so destroy our
// frame loader.
mFrameLoader->Destroy();
}
nsLeafFrame::Destroy();
}
@ -807,7 +820,21 @@ nsSubDocumentFrame::GetDocShell(nsIDocShell **aDocShell)
loaderOwner->GetFrameLoader(getter_AddRefs(mFrameLoader));
}
NS_ENSURE_STATE(mFrameLoader);
if (!mFrameLoader) {
// No frame loader available from the content, create our own...
mFrameLoader = new nsFrameLoader(content);
if (!mFrameLoader)
return NS_ERROR_OUT_OF_MEMORY;
// ... remember that we own this frame loader...
mOwnsFrameLoader = PR_TRUE;
// ... and tell it to start loading.
// the failure to load a URL does not constitute failure to
// create/initialize the docshell and therefore the LoadFrame()
// call's return value should not be propagated.
mFrameLoader->LoadFrame();
}
}
return mFrameLoader->GetDocShell(aDocShell);