Resurrect nsIFrameLoader[Owner] as scriptable interfaces; bug 280992 r+sr=bzbarsky

This commit is contained in:
bryner%brianryner.com 2005-02-08 06:55:00 +00:00
Родитель 2502721eb0
Коммит 91542d5229
8 изменённых файлов: 106 добавлений и 54 удалений

Просмотреть файл

@ -92,6 +92,7 @@ XPIDLSRCS = \
nsIScriptEventHandler.idl \
nsIScriptEventManager.idl \
nsIImageLoadingContent.idl \
nsIFrameLoader.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -517,9 +517,7 @@ public:
/** svg elements */
eSVG = 0x00000040,
/** comment nodes */
eCOMMENT = 0x00000080,
/** frame elements (frame, iframe) */
eFRAME_ELEMENT = 0x00000100
eCOMMENT = 0x00000080
};
/**

Просмотреть файл

@ -0,0 +1,69 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Johnny Stenback <jst@netscape.com> (original author)
* Brian Ryner <bryner@brianryner.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIDocShell;
[scriptable, uuid(eb1a6413-c79f-4189-95b9-7070df9529b1)]
interface nsIFrameLoader : nsISupports
{
/**
* Get the docshell from the frame loader.
*/
readonly attribute nsIDocShell docShell;
/**
* Start loading the frame. This method figures out what to load
* from the owner content in the frame loader.
*/
void loadFrame();
/**
* Destroy the frame loader and everything inside it. This will
* clear the weak owner content reference.
*/
void destroy();
};
[scriptable, uuid(feaf9285-05ac-4898-a69f-c3bd350767e4)]
interface nsIFrameLoaderOwner : nsISupports
{
readonly attribute nsIFrameLoader frameLoader;
};

Просмотреть файл

@ -83,10 +83,7 @@
// we'd need to re-institute a fixed version of bug 98158.
#define MAX_DEPTH_CONTENT_FRAMES 10
nsFrameLoader::~nsFrameLoader()
{
Destroy();
}
NS_IMPL_ISUPPORTS1(nsFrameLoader, nsIFrameLoader)
nsresult
nsFrameLoader::LoadFrame()
@ -282,7 +279,7 @@ nsFrameLoader::GetDocShell(nsIDocShell **aDocShell)
return NS_OK;
}
void
NS_IMETHODIMP
nsFrameLoader::Destroy()
{
if (mOwnerContent) {
@ -308,6 +305,7 @@ nsFrameLoader::Destroy()
}
mDocShell = nsnull;
return NS_OK;
}
nsresult

Просмотреть файл

@ -41,41 +41,27 @@
#include "nsIDocShell.h"
#include "nsStringFwd.h"
#include "nsIFrameLoader.h"
class nsIContent;
class nsFrameLoader
class nsFrameLoader : public nsIFrameLoader
{
public:
nsFrameLoader(nsIContent *aOwner) : mOwnerContent(aOwner) {}
~nsFrameLoader() NS_HIDDEN;
void AddRef()
{
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "nsFrameLoader", sizeof(nsFrameLoader));
}
NS_DECL_ISUPPORTS
NS_DECL_NSIFRAMELOADER
void Release()
{
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "nsFrameLoader");
if (mRefCnt == 0)
delete this;
}
private:
~nsFrameLoader() { nsFrameLoader::Destroy(); }
NS_HIDDEN_(nsresult) LoadFrame();
NS_HIDDEN_(nsresult) GetDocShell(nsIDocShell **aDocShell);
NS_HIDDEN_(void) Destroy();
protected:
NS_HIDDEN_(nsresult) EnsureDocShell();
NS_HIDDEN_(void) GetURL(nsString& aURL);
nsCOMPtr<nsIDocShell> mDocShell;
nsIContent *mOwnerContent; // WEAK
nsAutoRefCnt mRefCnt;
};
#endif

Просмотреть файл

@ -3363,9 +3363,17 @@ nsGenericHTMLFormElement::FindAndSetForm()
//----------------------------------------------------------------------
nsGenericHTMLFrameElement::~nsGenericHTMLFrameElement()
{
if (mFrameLoader) {
mFrameLoader->Destroy();
}
}
NS_INTERFACE_MAP_BEGIN(nsGenericHTMLFrameElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLFrameElement)
NS_INTERFACE_MAP_ENTRY(nsIChromeEventHandler)
NS_INTERFACE_MAP_ENTRY(nsIFrameLoaderOwner)
NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
nsresult
@ -3421,6 +3429,13 @@ nsGenericHTMLFrameElement::EnsureFrameLoader()
return NS_OK;
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::GetFrameLoader(nsIFrameLoader **aFrameLoader)
{
NS_IF_ADDREF(*aFrameLoader = mFrameLoader);
return NS_OK;
}
nsresult
nsGenericHTMLFrameElement::LoadSrc()
{
@ -3502,12 +3517,6 @@ nsGenericHTMLFrameElement::HandleChromeEvent(nsPresContext* aPresContext,
return HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags,aEventStatus);
}
PRBool
nsGenericHTMLFrameElement::IsContentOfType(PRUint32 aFlags) const
{
return !(aFlags & ~(eELEMENT | eHTML | eFRAME_ELEMENT));
}
//----------------------------------------------------------------------
void

Просмотреть файл

@ -862,6 +862,7 @@ protected:
class nsGenericHTMLFrameElement : public nsGenericHTMLElement,
public nsIDOMNSHTMLFrameElement,
public nsIFrameLoaderOwner,
public nsIChromeEventHandler
{
public:
@ -869,18 +870,7 @@ public:
: nsGenericHTMLElement(aNodeInfo)
{
}
static nsGenericHTMLFrameElement* FromContent(nsIContent *aContent)
{
if (aContent->IsContentOfType(eFRAME_ELEMENT))
return NS_STATIC_CAST(nsGenericHTMLFrameElement*, aContent);
return nsnull;
}
nsFrameLoader* GetFrameLoader()
{
return mFrameLoader;
}
virtual ~nsGenericHTMLFrameElement();
// nsISupports
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
@ -891,6 +881,9 @@ public:
// nsIChromeEventHandler
NS_DECL_NSICHROMEEVENTHANDLER
// nsIFrameLoaderOwner
NS_DECL_NSIFRAMELOADEROWNER
// nsIContent
virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull);
virtual void SetParent(nsIContent *aParent);
@ -904,7 +897,6 @@ public:
virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify);
virtual PRBool IsContentOfType(PRUint32 aFlags) const;
// nsIDOMNSHTMLElement
NS_IMETHOD GetTabIndex(PRInt32 *aTabIndex);
@ -917,7 +909,7 @@ protected:
nsresult LoadSrc();
nsresult GetContentDocument(nsIDOMDocument** aContentDocument);
nsRefPtr<nsFrameLoader> mFrameLoader;
nsCOMPtr<nsIFrameLoader> mFrameLoader;
};
//----------------------------------------------------------------------

Просмотреть файл

@ -69,7 +69,7 @@
#include "nsIDOMHTMLFrameElement.h"
#include "nsIDOMHTMLIFrameElement.h"
#include "nsIDOMXULElement.h"
#include "nsFrameLoader.h"
#include "nsIFrameLoader.h"
#include "nsLayoutAtoms.h"
#include "nsIScriptSecurityManager.h"
#include "nsXPIDLString.h"
@ -157,7 +157,7 @@ protected:
nsHTMLReflowMetrics& aDesiredSize);
virtual PRIntn GetSkipSides() const;
nsRefPtr<nsFrameLoader> mFrameLoader;
nsCOMPtr<nsIFrameLoader> mFrameLoader;
PRPackedBool mOwnsFrameLoader;
PRPackedBool mIsInline;
nsIView* mInnerView;
@ -597,11 +597,10 @@ nsSubDocumentFrame::GetDocShell(nsIDocShell **aDocShell)
}
if (!mFrameLoader) {
nsGenericHTMLFrameElement *frameElement =
nsGenericHTMLFrameElement::FromContent(content);
nsCOMPtr<nsIFrameLoaderOwner> loaderOwner = do_QueryInterface(content);
if (frameElement) {
mFrameLoader = frameElement->GetFrameLoader();
if (loaderOwner) {
loaderOwner->GetFrameLoader(getter_AddRefs(mFrameLoader));
}
if (!mFrameLoader) {