Fixing bug 52334. Making iframe's load their document even if they are not displayed. r=jkeiser@netscae.com, sr=rpotts@netscape.com, a=asa@mozilla.org

This commit is contained in:
jst%netscape.com 2002-04-04 02:09:19 +00:00
Родитель 6fea29075e
Коммит aa9f71957d
56 изменённых файлов: 3629 добавлений и 3033 удалений

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

@ -130,17 +130,28 @@ nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIW
return NS_OK;
}
void nsAccessibilityService::GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell **aOwnerShell, nsIContent **aOwnerContent)
void nsAccessibilityService::GetOwnerFor(nsIPresShell *aPresShell,
nsIPresShell **aOwnerShell,
nsIContent **aOwnerContent)
{
*aOwnerShell = nsnull;
*aOwnerContent = nsnull;
nsCOMPtr<nsIPresContext> presContext;
aPresShell->GetPresContext(getter_AddRefs(presContext));
if (!presContext)
return;
nsCOMPtr<nsIDocument> doc;
aPresShell->GetDocument(getter_AddRefs(doc));
if (!doc)
return;
nsCOMPtr<nsISupports> pcContainer;
presContext->GetContainer(getter_AddRefs(pcContainer));
if (!pcContainer)
return;
nsCOMPtr<nsISupports> docShellSupports(do_QueryInterface(pcContainer));
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(pcContainer));
if (!treeItem)
@ -166,17 +177,11 @@ void nsAccessibilityService::GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell
if (!parentDoc)
return;
nsCOMPtr<nsIContent> rootContent;
parentDoc->GetRootContent(getter_AddRefs(rootContent));
parentDoc->FindContentForSubDocument(doc, aOwnerContent);
nsCOMPtr<nsIContent> tempContent;
parentPresShell->FindContentForShell(docShellSupports, getter_AddRefs(tempContent));
if (tempContent) {
*aOwnerContent = tempContent;
if (*aOwnerContent) {
*aOwnerShell = parentPresShell;
NS_ADDREF(*aOwnerShell);
NS_ADDREF(*aOwnerContent);
}
}
@ -250,46 +255,46 @@ nsAccessibilityService::CreateIFrameAccessible(nsIDOMNode* aDOMNode, nsIAccessib
NS_WARNING("No outer pres shell in CreateHTMLIFrameAccessible!");
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPresContext> outerPresContext;
outerPresShell->GetPresContext(getter_AddRefs(outerPresContext));
if (!outerPresContext) {
NS_WARNING("No outer pres context in CreateHTMLIFrameAccessible!");
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocument> doc;
if (NS_SUCCEEDED(content->GetDocument(*getter_AddRefs(doc))) && doc) {
if (outerPresShell) {
nsCOMPtr<nsISupports> supps;
outerPresShell->GetSubShellFor(content, getter_AddRefs(supps));
if (supps) {
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(supps));
if (docShell) {
nsCOMPtr<nsIPresShell> innerPresShell;
docShell->GetPresShell(getter_AddRefs(innerPresShell));
if (innerPresShell) {
nsCOMPtr<nsIWeakReference> innerWeakShell(do_GetWeakReference(innerPresShell));
nsCOMPtr<nsIDocument> innerDoc;
innerPresShell->GetDocument(getter_AddRefs(innerDoc));
if (innerDoc) {
nsCOMPtr<nsIAccessible> innerRootAccessible(new nsHTMLIFrameRootAccessible(aDOMNode, innerWeakShell));
if (innerRootAccessible) {
nsHTMLIFrameAccessible* outerRootAccessible = new nsHTMLIFrameAccessible(aDOMNode, innerRootAccessible, outerWeakShell, innerDoc);
if (outerRootAccessible) {
*_retval = NS_STATIC_CAST(nsIAccessible*, outerRootAccessible);
if (*_retval) {
NS_ADDREF(*_retval);
return NS_OK;
}
}
}
}
nsCOMPtr<nsIDocument> sub_doc;
doc->GetSubDocumentFor(content, getter_AddRefs(sub_doc));
if (sub_doc) {
nsCOMPtr<nsIPresShell> innerPresShell;
sub_doc->GetShellAt(0, getter_AddRefs(innerPresShell));
if (innerPresShell) {
nsCOMPtr<nsIWeakReference> innerWeakShell =
do_GetWeakReference(innerPresShell);
nsCOMPtr<nsIAccessible> innerRootAccessible =
new nsHTMLIFrameRootAccessible(aDOMNode, innerWeakShell);
if (innerRootAccessible) {
nsHTMLIFrameAccessible* outerRootAccessible =
new nsHTMLIFrameAccessible(aDOMNode, innerRootAccessible,
outerWeakShell, sub_doc);
if (outerRootAccessible) {
*_retval = outerRootAccessible;
NS_ADDREF(*_retval);
return NS_OK;
}
}
}
}
}
return NS_ERROR_FAILURE;
}

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

@ -27,3 +27,4 @@ nsIStyleSheet.h
nsIStyleSheetLinkingElement.h
nsITextContent.h
nsIContentList.h
nsIFrameLoader.h

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

@ -56,6 +56,7 @@ nsIPrivateDOMImplementation.h \
nsIContentSerializer.h \
nsIHTMLToTextSink.h \
nsIContentList.h \
nsIFrameLoader.h \
$(NULL)
XPIDLSRCS = \

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

@ -48,6 +48,7 @@ EXPORTS = \
nsIContentSerializer.h \
nsIHTMLToTextSink.h \
nsIContentList.h \
nsIFrameLoader.h \
$(NULL)
MODULE=content

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

@ -227,13 +227,32 @@ public:
/**
* Return the parent document of this document. Will return null
* unless this document is within a compound document and has a parent.
* unless this document is within a compound document and has a
* parent. Note that this parent chain may cross chrome boundaries.
*/
NS_IMETHOD GetParentDocument(nsIDocument** aParent) = 0;
/**
* Set the parent document of this document.
*/
NS_IMETHOD SetParentDocument(nsIDocument* aParent) = 0;
NS_IMETHOD AddSubDocument(nsIDocument* aSubDoc) = 0;
NS_IMETHOD GetNumberOfSubDocuments(PRInt32* aCount) = 0;
NS_IMETHOD GetSubDocumentAt(PRInt32 aIndex, nsIDocument** aSubDoc) = 0;
/**
* Set the sub document for aContent to aSubDoc.
*/
NS_IMETHOD SetSubDocumentFor(nsIContent *aContent, nsIDocument* aSubDoc) = 0;
/**
* Get the sub document for aContent
*/
NS_IMETHOD GetSubDocumentFor(nsIContent *aContent,
nsIDocument** aSubDoc) = 0;
/**
* Find the content node for which aDocument is a sub document.
*/
NS_IMETHOD FindContentForSubDocument(nsIDocument *aDocument,
nsIContent **aContent) = 0;
/**
* Return the root content object for this document.
@ -373,6 +392,16 @@ public:
NS_IMETHOD AddReference(void *aKey, nsISupports *aReference) = 0;
NS_IMETHOD RemoveReference(void *aKey, nsISupports **aOldReference) = 0;
/**
* Set the container (docshell) for this document.
*/
NS_IMETHOD SetContainer(nsISupports *aContainer) = 0;
/**
* Get the container (docshell) for this document.
*/
NS_IMETHOD GetContainer(nsISupports **aContainer) = 0;
};

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

@ -43,7 +43,7 @@
#include "nsAString.h"
// Forward declarations
class nsIDOMElement;
class nsIContent;
class nsIDocShell;
class nsIURI;
@ -57,18 +57,42 @@ class nsIURI;
{ 0x0080d493, 0x96b4, 0x4606, \
{0xa7, 0x43, 0x0f, 0x47, 0xee, 0x87, 0x14, 0xd1} }
// CID for the nsIFrameLoader implementation
#define NS_FRAMELOADER_CID \
{ 0x712603da, 0xf245, 0x4503, \
{0xa5, 0x41, 0xb0, 0x49, 0xcb, 0x06, 0x81, 0xae} }
#define NS_FRAMELOADER_CONTRACTID "@mozilla.org/content/frameloader"
class nsIFrameLoader : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAMELOADER_IID)
NS_IMETHOD Init(nsIDOMElement *aOwner) = 0;
/**
* Initialize the frame loader, hand it the owner content. Note that
* the owner content reference is a weak reference, if the owner
* content is destroyed before the frame loader goes away the owner
* content must call the Destroy() method to clear the owner content
* reference.
*/
NS_IMETHOD Init(nsIContent *aOwner) = 0;
NS_IMETHOD LoadURI(nsIURI *aURI) = 0;
/**
* Start loading the frame. This method figures out what to load
* from the owner content in the frame loader.
*/
NS_IMETHOD LoadFrame() = 0;
/**
* Get the docshell from the frame loader.
*/
NS_IMETHOD GetDocShell(nsIDocShell **aDocShell) = 0;
/**
* Destroy the frame loader and everything inside it. This will
* clear the weak owner content reference.
*/
NS_IMETHOD Destroy() = 0;
};
@ -78,6 +102,9 @@ class nsIFrameLoaderOwner : public nsISupports
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAMELOADEROWNER_IID)
/**
* Get the frame loader from the frame loader owner.
*/
NS_IMETHOD GetFrameLoader(nsIFrameLoader **aFrameLoader) = 0;
};

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

@ -55,8 +55,8 @@ REQUIRES = xpcom \
imglib2 \
gfx2 \
uriloader \
webbrwsr \
webBrowser_core \
webbrwsr \
webBrowser_core \
$(NULL)
CPPSRCS = \
@ -97,9 +97,11 @@ CPPSRCS = \
nsScriptLoader.cpp \
nsStyleLinkElement.cpp \
nsContentAreaDragDrop.cpp \
nsFrameLoader.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk

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

@ -43,6 +43,7 @@ REQUIRES = xpcom \
uconv \
chrome \
docshell \
uriloader \
pref \
xpconnect \
util \
@ -68,10 +69,10 @@ CPP_OBJS= \
.\$(OBJDIR)\nsCommentNode.obj \
.\$(OBJDIR)\nsGenericDOMDataNode.obj \
.\$(OBJDIR)\nsGenericDOMNodeList.obj \
.\$(OBJDIR)\nsGenericElement.obj \
.\$(OBJDIR)\nsContentList.obj \
.\$(OBJDIR)\nsContentIterator.obj \
.\$(OBJDIR)\nsContentPolicy.obj \
.\$(OBJDIR)\nsGenericElement.obj \
.\$(OBJDIR)\nsContentList.obj \
.\$(OBJDIR)\nsContentIterator.obj \
.\$(OBJDIR)\nsContentPolicy.obj \
.\$(OBJDIR)\nsDocument.obj \
.\$(OBJDIR)\nsDocumentEncoder.obj \
.\$(OBJDIR)\nsDocumentFragment.obj \
@ -79,7 +80,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsDOMAttribute.obj \
.\$(OBJDIR)\nsDOMAttributeMap.obj \
.\$(OBJDIR)\nsDOMDocumentType.obj \
.\$(OBJDIR)\nsGeneratedIterator.obj \
.\$(OBJDIR)\nsGeneratedIterator.obj \
.\$(OBJDIR)\nsNameSpaceManager.obj \
.\$(OBJDIR)\nsNodeInfo.obj \
.\$(OBJDIR)\nsNodeInfoManager.obj \
@ -91,12 +92,13 @@ CPP_OBJS= \
.\$(OBJDIR)\nsTreeWalker.obj \
.\$(OBJDIR)\nsXMLContentSerializer.obj \
.\$(OBJDIR)\nsHTMLContentSerializer.obj \
.\$(OBJDIR)\nsParserUtils.obj \
.\$(OBJDIR)\nsPlainTextSerializer.obj \
.\$(OBJDIR)\nsContentUtils.obj \
.\$(OBJDIR)\nsScriptLoader.obj \
.\$(OBJDIR)\nsStyleLinkElement.obj \
.\$(OBJDIR)\nsContentAreaDragDrop.obj \
.\$(OBJDIR)\nsParserUtils.obj \
.\$(OBJDIR)\nsPlainTextSerializer.obj \
.\$(OBJDIR)\nsContentUtils.obj \
.\$(OBJDIR)\nsScriptLoader.obj \
.\$(OBJDIR)\nsStyleLinkElement.obj \
.\$(OBJDIR)\nsContentAreaDragDrop.obj \
.\$(OBJDIR)\nsFrameLoader.obj \
$(NULL)
LINCS=-I..\..\html\base\src -I..\..\html\style\src \

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

@ -445,7 +445,7 @@ nsDocumentChildNodes::DropReference()
// ==================================================================
nsDocument::nsDocument() : mIsGoingAway(PR_FALSE),
mCSSLoader(nsnull)
mCSSLoader(nsnull), mSubDocuments(nsnull)
{
NS_INIT_REFCNT();
@ -476,6 +476,7 @@ nsDocument::nsDocument() : mIsGoingAway(PR_FALSE),
mObservers.InsertElementAt(observer, 0);
}
nsDocument::~nsDocument()
{
// XXX Inform any remaining observers that we are going away.
@ -501,11 +502,12 @@ nsDocument::~nsDocument()
mParentDocument = nsnull;
// Delete references to sub-documents
indx = mSubDocuments.Count();
while (--indx >= 0) {
nsIDocument* subdoc = (nsIDocument*) mSubDocuments.ElementAt(indx);
NS_RELEASE(subdoc);
// Kill the subdocument map, doing this will release its strong
// references, if any.
if (mSubDocuments) {
PL_DHashTableDestroy(mSubDocuments);
mSubDocuments = nsnull;
}
if (mRootContent) {
@ -671,25 +673,28 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup)
NS_IF_RELEASE(mPrincipal);
mDocumentLoadGroup = nsnull;
// Delete references to sub-documents
PRInt32 indx = mSubDocuments.Count();
while (--indx >= 0) {
nsIDocument* subdoc = (nsIDocument*) mSubDocuments.ElementAt(indx);
NS_RELEASE(subdoc);
// Delete references to sub-documents and kill the subdocument map,
// if any. It holds strong references
if (mSubDocuments) {
PL_DHashTableDestroy(mSubDocuments);
mSubDocuments = nsnull;
}
mRootContent = nsnull;
PRUint32 count, i;
mChildren->Count(&count);
for (i = 0; i < count; i++) {
nsCOMPtr<nsIContent> content(dont_AddRef(NS_STATIC_CAST(nsIContent*,mChildren->ElementAt(i))));
nsCOMPtr<nsIContent> content =
dont_AddRef(NS_STATIC_CAST(nsIContent *, mChildren->ElementAt(i)));
content->SetDocument(nsnull, PR_TRUE, PR_TRUE);
ContentRemoved(nsnull, content, indx);
ContentRemoved(nsnull, content, i);
}
mChildren->Clear();
// Delete references to style sheets
indx = mStyleSheets.Count();
PRInt32 indx = mStyleSheets.Count();
while (--indx >= 0) {
nsIStyleSheet* sheet = (nsIStyleSheet*) mStyleSheets.ElementAt(indx);
sheet->SetOwningDocument(nsnull);
@ -723,8 +728,9 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup)
if (aLoadGroup) {
mDocumentLoadGroup = getter_AddRefs(NS_GetWeakReference(aLoadGroup));
// there was an assertion here that aLoadGroup was not null. This is no longer valid
// nsWebShell::SetDocument does not create a load group, and it works just fine.
// there was an assertion here that aLoadGroup was not null. This
// is no longer valid nsWebShell::SetDocument does not create a
// load group, and it works just fine.
}
if (NS_OK == rv)
@ -1159,26 +1165,151 @@ nsDocument::SetParentDocument(nsIDocument* aParent)
return NS_OK;
}
NS_IMETHODIMP
nsDocument::AddSubDocument(nsIDocument* aSubDoc)
PR_STATIC_CALLBACK(void)
SubDocClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
{
NS_ADDREF(aSubDoc);
mSubDocuments.AppendElement(aSubDoc);
SubDocMapEntry *e = NS_STATIC_CAST(SubDocMapEntry *, entry);
NS_RELEASE(e->mKey);
NS_IF_RELEASE(e->mSubDocument);
}
PR_STATIC_CALLBACK(void)
SubDocInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry, const void *key)
{
SubDocMapEntry *e =
NS_CONST_CAST(SubDocMapEntry *,
NS_STATIC_CAST(const SubDocMapEntry *, entry));
e->mKey = NS_CONST_CAST(nsIContent *,
NS_STATIC_CAST(const nsIContent *, key));
NS_ADDREF(e->mKey);
e->mSubDocument = nsnull;
}
NS_IMETHODIMP
nsDocument::SetSubDocumentFor(nsIContent *aContent, nsIDocument* aSubDoc)
{
NS_ENSURE_TRUE(aContent, NS_ERROR_UNEXPECTED);
if (!aSubDoc) {
// aSubDoc is nsnull, remove the mapping
if (mSubDocuments) {
SubDocMapEntry *entry =
NS_STATIC_CAST(SubDocMapEntry*,
PL_DHashTableOperate(mSubDocuments, aContent,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_LIVE(entry)) {
entry->mSubDocument->SetParentDocument(nsnull);
PL_DHashTableRawRemove(mSubDocuments, entry);
}
}
} else {
if (!mSubDocuments) {
// Create a new hashtable
static PLDHashTableOps hash_table_ops =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashGetKeyStub,
PL_DHashVoidPtrKeyStub,
PL_DHashMatchEntryStub,
PL_DHashMoveEntryStub,
SubDocClearEntry,
PL_DHashFinalizeStub,
SubDocInitEntry
};
mSubDocuments = PL_NewDHashTable(&hash_table_ops, nsnull,
sizeof(SubDocMapEntry), 16);
if (!mSubDocuments) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
// Add a mapping to the hash table
SubDocMapEntry *entry =
NS_STATIC_CAST(SubDocMapEntry*,
PL_DHashTableOperate(mSubDocuments, aContent,
PL_DHASH_ADD));
if (!entry) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (entry->mSubDocument) {
entry->mSubDocument->SetParentDocument(nsnull);
// Release the old sub document
NS_RELEASE(entry->mSubDocument);
}
entry->mSubDocument = aSubDoc;
NS_ADDREF(entry->mSubDocument);
aSubDoc->SetParentDocument(this);
}
return NS_OK;
}
NS_IMETHODIMP
nsDocument::GetNumberOfSubDocuments(PRInt32* aCount)
nsDocument::GetSubDocumentFor(nsIContent *aContent, nsIDocument** aSubDoc)
{
*aCount = mSubDocuments.Count();
*aSubDoc = nsnull;
if (mSubDocuments) {
SubDocMapEntry *entry =
NS_STATIC_CAST(SubDocMapEntry*,
PL_DHashTableOperate(mSubDocuments, aContent,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_LIVE(entry)) {
*aSubDoc = entry->mSubDocument;
NS_ADDREF(*aSubDoc);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsDocument::GetSubDocumentAt(PRInt32 aIndex, nsIDocument** aSubDoc)
PR_STATIC_CALLBACK(PLDHashOperator)
FindContentEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)
{
*aSubDoc = (nsIDocument*) mSubDocuments.SafeElementAt(aIndex);
NS_IF_ADDREF(*aSubDoc);
SubDocMapEntry *entry = NS_STATIC_CAST(SubDocMapEntry*, hdr);
FindContentData *data = NS_STATIC_CAST(FindContentData*, arg);
if (entry->mSubDocument == data->mSubDocument) {
data->mResult = entry->mKey;
return PL_DHASH_STOP;
}
return PL_DHASH_NEXT;
}
NS_IMETHODIMP
nsDocument::FindContentForSubDocument(nsIDocument *aDocument,
nsIContent **aContent)
{
NS_ENSURE_ARG_POINTER(aDocument);
if (!mSubDocuments) {
*aContent = nsnull;
return NS_OK;
}
FindContentData data(aDocument);
PL_DHashTableEnumerate(mSubDocuments, FindContentEnumerator, &data);
*aContent = data.mResult;
NS_IF_ADDREF(*aContent);
return NS_OK;
}
@ -1740,23 +1871,18 @@ nsDocument::EndLoad()
if (docShellAsItem) {
docShellAsItem->GetSameTypeParent(getter_AddRefs(docShellParent));
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIDocument> parent_doc;
GetDocumentFromDocShellTreeItem(docShellParent, getter_AddRefs(doc));
GetDocumentFromDocShellTreeItem(docShellParent,
getter_AddRefs(parent_doc));
if (doc) {
nsCOMPtr<nsIPresShell> shell;
doc->GetShellAt(0, getter_AddRefs(shell));
if (parent_doc) {
nsCOMPtr<nsIContent> target_content;
if (shell) {
nsCOMPtr<nsIContent> target_content;
parent_doc->FindContentForSubDocument(this,
getter_AddRefs(target_content));
nsCOMPtr<nsISupports> docshell_identity(docShell);
shell->FindContentForShell(docshell_identity,
getter_AddRefs(target_content));
target_frame = do_QueryInterface(target_content);
}
target_frame = do_QueryInterface(target_content);
}
}
}
@ -2145,8 +2271,8 @@ nsDocument::GetDocumentElement(nsIDOMElement** aDocumentElement)
nsresult res = NS_OK;
if (nsnull != mRootContent) {
res = mRootContent->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aDocumentElement);
if (mRootContent) {
res = CallQueryInterface(mRootContent, aDocumentElement);
NS_ASSERTION(NS_OK == res, "Must be a DOM Element");
} else {
*aDocumentElement = nsnull;
@ -3471,6 +3597,25 @@ nsDocument::RemoveReference(void *aKey, nsISupports **aOldReference)
return NS_OK;
}
NS_IMETHODIMP
nsDocument::SetContainer(nsISupports *aContainer)
{
mDocumentContainer = dont_AddRef(NS_GetWeakReference(aContainer));
return NS_OK;
}
NS_IMETHODIMP
nsDocument::GetContainer(nsISupports **aContainer)
{
nsCOMPtr<nsISupports> container = do_QueryReferent(mDocumentContainer);
*aContainer = container;
NS_IF_ADDREF(*aContainer);
return NS_OK;
}
#ifdef IBMBIDI
/**
* Check if bidi enabled (set depending on the presence of RTL

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

@ -69,6 +69,8 @@
#include "nsScriptLoader.h"
#include "nsICSSLoader.h"
#include "pldhash.h"
class nsIEventListenerManager;
class nsDOMStyleSheetList;
class nsIOutputStream;
@ -212,6 +214,29 @@ protected:
void* mScriptObject;
};
// Helper structs for the content->subdoc map
class SubDocMapEntry : public PLDHashEntryHdr
{
public:
// Both of these are strong references
nsIContent *mKey; // must be first, to look like PLDHashEntryStub
nsIDocument *mSubDocument;
};
struct FindContentData
{
FindContentData(nsIDocument *aSubDoc)
: mSubDocument(aSubDoc), mResult(nsnull)
{
}
nsISupports *mSubDocument;
nsIContent *mResult;
};
// Base class for our document implementations.
//
// Note that this class *implements* nsIDOMXMLDocument, but it's not
@ -367,9 +392,11 @@ public:
*/
NS_IMETHOD GetParentDocument(nsIDocument** aParent);
NS_IMETHOD SetParentDocument(nsIDocument* aParent);
NS_IMETHOD AddSubDocument(nsIDocument* aSubDoc);
NS_IMETHOD GetNumberOfSubDocuments(PRInt32* aCount);
NS_IMETHOD GetSubDocumentAt(PRInt32 aIndex, nsIDocument** aSubDoc);
NS_IMETHOD SetSubDocumentFor(nsIContent *aContent, nsIDocument* aSubDoc);
NS_IMETHOD GetSubDocumentFor(nsIContent *aContent, nsIDocument** aSubDoc);
NS_IMETHOD FindContentForSubDocument(nsIDocument *aDocument,
nsIContent **aContent);
/**
* Return the root content object for this document.
@ -492,6 +519,8 @@ public:
NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager*& aNodeInfoManager);
NS_IMETHOD AddReference(void *aKey, nsISupports *aReference);
NS_IMETHOD RemoveReference(void *aKey, nsISupports **aOldReference);
NS_IMETHOD SetContainer(nsISupports *aContainer);
NS_IMETHOD GetContainer(nsISupports **aContainer);
// nsIDOMNode
NS_DECL_NSIDOMNODE
@ -573,13 +602,16 @@ protected:
nsCOMPtr<nsIURI> mDocumentBaseURL;
nsIPrincipal* mPrincipal;
nsWeakPtr mDocumentLoadGroup;
nsWeakPtr mDocumentContainer;
nsString mCharacterSet;
PRInt32 mCharacterSetSource;
nsVoidArray mCharSetObservers;
nsIDocument* mParentDocument;
nsVoidArray mSubDocuments;
PLDHashTable *mSubDocuments;
nsVoidArray mPresShells;
nsCOMPtr<nsISupportsArray> mChildren; // contains owning references
nsIContent* mRootContent; // a weak reference to the only element in

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -40,13 +40,14 @@
#include "nsIFrameLoader.h"
#include "nsIDOMHTMLIFrameElement.h"
#include "nsIDOMHTMLFrameElement.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMWindow.h"
#include "nsIPresContext.h"
#include "nsIPresShell.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMWindow.h"
#include "nsPIDOMWindow.h"
#include "nsIWebNavigation.h"
#include "nsIChromeEventHandler.h"
#include "nsIDocShell.h"
@ -56,9 +57,6 @@
#include "nsIDocShellLoadInfo.h"
#include "nsIBaseWindow.h"
#include "nsIWebShell.h"
#include "nsIWebProgressListener.h"
#include "nsIWebProgress.h"
#include "nsWeakReference.h"
#include "nsIScriptSecurityManager.h"
#include "nsICodebasePrincipal.h"
@ -66,10 +64,17 @@
#include "nsIURI.h"
#include "nsNetUtil.h"
class nsFrameLoader : public nsIFrameLoader,
public nsIDOMEventListener,
public nsIWebProgressListener,
public nsSupportsWeakReference
#include "nsHTMLAtoms.h"
#include "nsINameSpaceManager.h"
// Bug 8065: Limit content frame depth to some reasonable level. This
// does not count chrome frames when determining depth, nor does it
// prevent chrome recursion.
#define MAX_DEPTH_CONTENT_FRAMES 25
class nsFrameLoader : public nsIFrameLoader
{
public:
nsFrameLoader();
@ -79,26 +84,19 @@ public:
NS_DECL_ISUPPORTS
// nsIFrameLoader
NS_IMETHOD Init(nsIDOMElement *aOwner);
NS_IMETHOD LoadURI(nsIURI *aURI);
NS_IMETHOD Init(nsIContent *aOwner);
NS_IMETHOD LoadFrame();
NS_IMETHOD GetDocShell(nsIDocShell **aDocShell);
NS_IMETHOD Destroy();
// nsIDOMEventListener
NS_DECL_NSIDOMEVENTLISTENER
// nsIWebProgressListener
NS_DECL_NSIWEBPROGRESSLISTENER
protected:
nsresult GetPresContext(nsIPresContext **aPresContext);
nsresult EnsureDocShell();
void GetURL(nsAString& aURL);
nsCOMPtr<nsIDocShell> mDocShell;
nsCOMPtr<nsIDOMElement> mOwnerElement;
nsCOMPtr<nsIURI> mURI;
nsIContent *mOwnerContent; // WEAK
};
nsresult
@ -112,26 +110,22 @@ NS_NewFrameLoader(nsIFrameLoader **aFrameLoader)
return NS_OK;
}
nsFrameLoader::nsFrameLoader()
: mOwnerContent(nsnull)
{
NS_INIT_ISUPPORTS();
}
nsFrameLoader::~nsFrameLoader()
{
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin(do_QueryInterface(mDocShell));
if (treeOwnerAsWin) {
treeOwnerAsWin->Destroy();
}
Destroy();
}
// QueryInterface implementation for nsFrameLoader
NS_INTERFACE_MAP_BEGIN(nsFrameLoader)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIFrameLoader)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
@ -139,27 +133,49 @@ NS_IMPL_ADDREF(nsFrameLoader);
NS_IMPL_RELEASE(nsFrameLoader);
NS_IMETHODIMP
nsFrameLoader::Init(nsIDOMElement *aOwner)
nsFrameLoader::Init(nsIContent *aOwner)
{
mOwnerElement = aOwner;
mOwnerContent = aOwner; // WEAK
return NS_OK;
}
NS_IMETHODIMP
nsFrameLoader::LoadURI(nsIURI *aURI)
nsFrameLoader::LoadFrame()
{
mURI = aURI;
NS_ENSURE_TRUE(mOwnerContent, NS_ERROR_NOT_INITIALIZED);
nsresult rv = EnsureDocShell();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc;
mOwnerContent->GetDocument(*getter_AddRefs(doc));
NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
// Prevent recursion
nsAutoString src;
GetURL(src);
src.Trim(" \t\n\r");
if (src.IsEmpty()) {
// about:blank will be synthesized into a frame if not URL is
// loaded into it (bug 35986)
// mCreatingViewer=PR_TRUE;
return NS_OK;
}
// Make an absolute URI
nsCOMPtr<nsIURI> base_uri;
doc->GetBaseURL(*getter_AddRefs(base_uri));
nsAutoString doc_charset;
doc->GetDocumentCharacterSet(doc_charset);
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), src,
doc_charset.IsEmpty() ? nsnull :
NS_ConvertUCS2toUTF8(doc_charset).get(), base_uri);
NS_ENSURE_SUCCESS(rv, rv);
// Check for security
nsCOMPtr<nsIScriptSecurityManager> secMan =
@ -197,31 +213,21 @@ nsFrameLoader::LoadURI(nsIURI *aURI)
loadInfo->SetInheritOwner(PR_TRUE);
nsCOMPtr<nsIDOMDocument> dom_doc;
mOwnerElement->GetOwnerDocument(getter_AddRefs(dom_doc));
nsCOMPtr<nsIDocument> doc(do_QueryInterface(dom_doc));
if (doc) {
doc->GetBaseURL(*getter_AddRefs(referrer));
}
referrer = base_uri;
}
loadInfo->SetReferrer(referrer);
// Check if we are allowed to load absURL
rv = secMan->CheckLoadURI(referrer, mURI,
rv = secMan->CheckLoadURI(referrer, uri,
nsIScriptSecurityManager::STANDARD);
if (NS_FAILED(rv)) {
return rv; // We're not
}
nsCOMPtr<nsIWebProgress> webProgress(do_GetInterface(mDocShell));
if (webProgress) {
webProgress->AddProgressListener(this);
}
rv = mDocShell->LoadURI(mURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE);
// Kick off the load...
rv = mDocShell->LoadURI(uri, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE,
PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to load URL");
return rv;
@ -241,12 +247,25 @@ nsFrameLoader::GetDocShell(nsIDocShell **aDocShell)
NS_IMETHODIMP
nsFrameLoader::Destroy()
{
return NS_OK;
}
if (mOwnerContent) {
nsCOMPtr<nsIDocument> doc;
NS_IMETHODIMP
nsFrameLoader::HandleEvent(nsIDOMEvent *aEvent)
{
mOwnerContent->GetDocument(*getter_AddRefs(doc));
if (doc) {
doc->SetSubDocumentFor(mOwnerContent, nsnull);
}
mOwnerContent = nsnull;
}
nsCOMPtr<nsIBaseWindow> base_win(do_QueryInterface(mDocShell));
if (base_win) {
base_win->Destroy();
}
mDocShell = nsnull;
return NS_OK;
}
@ -256,10 +275,8 @@ nsFrameLoader::GetPresContext(nsIPresContext **aPresContext)
{
*aPresContext = nsnull;
nsCOMPtr<nsIDOMDocument> dom_doc;
mOwnerElement->GetOwnerDocument(getter_AddRefs(dom_doc));
nsCOMPtr<nsIDocument> doc(do_QueryInterface(dom_doc));
nsCOMPtr<nsIDocument> doc;
mOwnerContent->GetDocument(*getter_AddRefs(doc));
while (doc) {
nsCOMPtr<nsIPresShell> presShell;
@ -287,16 +304,15 @@ nsFrameLoader::EnsureDocShell()
return NS_OK;
}
#if 0
nsCOMPtr<nsIPresContext> presContext;
GetPresContext(getter_AddRefs(presContext));
NS_ENSURE_TRUE(presContext, NS_ERROR_UNEXPECTED);
// Bug 8065: Don't exceed some maximum depth in content frames
// (MAX_DEPTH_CONTENT_FRAMES)
PRInt32 depth = 0;
nsCOMPtr<nsISupports> parentAsSupports;
aPresContext->GetContainer(getter_AddRefs(parentAsSupports));
presContext->GetContainer(getter_AddRefs(parentAsSupports));
if (parentAsSupports) {
nsCOMPtr<nsIDocShellTreeItem> parentAsItem =
@ -321,32 +337,16 @@ nsFrameLoader::EnsureDocShell()
}
}
}
#endif
// Create the docshell...
mDocShell = do_CreateInstance("@mozilla.org/webshell;1");
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
#if 0
// notify the pres shell that a docshell has been created
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsISupports> subShellAsSupports(do_QueryInterface(mDocShell));
NS_ENSURE_TRUE(subShellAsSupports, NS_ERROR_FAILURE);
presShell->SetSubShellFor(mContent, subShellAsSupports);
// We need to be able to get back to the presShell to unset the
// subshell at destruction
mPresShellWeak = getter_AddRefs(NS_GetWeakReference(presShell));
}
#endif
// Get the frame name and tell the docshell about it.
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
nsAutoString frameName;
mOwnerElement->GetAttribute(NS_LITERAL_STRING("name"), frameName);
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, frameName);
if (!frameName.IsEmpty()) {
docShellAsItem->SetName(frameName.get());
@ -356,178 +356,148 @@ nsFrameLoader::EnsureDocShell()
// child. If it's not a web-shell then some things will not operate
// properly.
nsCOMPtr<nsIPresContext> presContext;
GetPresContext(getter_AddRefs(presContext));
// what if !presContext ?
nsCOMPtr<nsISupports> container;
presContext->GetContainer(getter_AddRefs(container));
if (container) {
nsCOMPtr<nsIDocShellTreeNode> parentAsNode(do_QueryInterface(container));
if (parentAsNode) {
nsCOMPtr<nsIDocShellTreeItem> parentAsItem =
do_QueryInterface(parentAsNode);
nsCOMPtr<nsIDocShellTreeNode> parentAsNode(do_QueryInterface(container));
if (parentAsNode) {
nsCOMPtr<nsIDocShellTreeItem> parentAsItem =
do_QueryInterface(parentAsNode);
PRInt32 parentType;
parentAsItem->GetItemType(&parentType);
PRInt32 parentType;
parentAsItem->GetItemType(&parentType);
nsAutoString value, valuePiece;
PRBool isContent;
nsAutoString value;
PRBool isContent;
isContent = PR_FALSE;
mOwnerElement->GetAttribute(NS_LITERAL_STRING("type"), value);
isContent = PR_FALSE;
if (!value.IsEmpty()) {
// we accept "content" and "content-xxx" values.
// at time of writing, we expect "xxx" to be "primary", but
// someday it might be an integer expressing priority
if (mOwnerContent->IsContentOfType(nsIContent::eXUL)) {
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value);
}
if (!value.IsEmpty()) {
// we accept "content" and "content-xxx" values.
// at time of writing, we expect "xxx" to be "primary", but
// someday it might be an integer expressing priority
if (value.Length() >= 7) {
ToLowerCase(value);
nsAutoString::const_iterator start, end;
value.BeginReading(start);
value.EndReading(end);
// string iterators!
nsAutoString::const_iterator iter(start);
iter.advance(7);
const nsAString& valuePiece = Substring(start, iter);
value.Left(valuePiece, 7);
if (valuePiece.EqualsIgnoreCase("content") &&
(value.Length() == 7 ||
value.Mid(valuePiece, 7, 1) == 1 &&
valuePiece.EqualsWithConversion("-"))) {
if (valuePiece.Equals(NS_LITERAL_STRING("content")) &&
(iter == end || *iter == '-')) {
isContent = PR_TRUE;
}
}
if (isContent) {
// The web shell's type is content.
docShellAsItem->SetItemType(nsIDocShellTreeItem::typeContent);
} else {
// Inherit our type from our parent webshell. If it is
// chrome, we'll be chrome. If it is content, we'll be
// content.
docShellAsItem->SetItemType(parentType);
}
parentAsNode->AddChild(docShellAsItem);
if (isContent) {
nsCOMPtr<nsIDocShellTreeOwner> parentTreeOwner;
parentAsItem->GetTreeOwner(getter_AddRefs(parentTreeOwner));
if(parentTreeOwner) {
PRBool is_primary = value.EqualsIgnoreCase("content-primary");
parentTreeOwner->ContentShellAdded(docShellAsItem, is_primary,
value.get());
}
}
// connect the container...
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
nsCOMPtr<nsIWebShellContainer> outerContainer =
do_QueryInterface(container);
if (outerContainer) {
webShell->SetContainer(outerContainer);
}
// Make sure all shells have links back to the content element
// in the nearest enclosing chrome shell.
nsCOMPtr<nsIChromeEventHandler> chromeEventHandler;
if (parentType == nsIDocShellTreeItem::typeChrome) {
// Our parent shell is a chrome shell. It is therefore our nearest
// enclosing chrome shell.
chromeEventHandler = do_QueryInterface(mOwnerElement);
NS_WARN_IF_FALSE(chromeEventHandler,
"This mContent should implement this.");
} else {
nsCOMPtr<nsIDocShell> parentShell(do_QueryInterface(parentAsNode));
// Our parent shell is a content shell. Get the chrome info from
// it and use that for our shell as well.
parentShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler));
}
// Should this be in the layout code?
mDocShell->SetChromeEventHandler(chromeEventHandler);
}
if (isContent) {
// The web shell's type is content.
docShellAsItem->SetItemType(nsIDocShellTreeItem::typeContent);
} else {
// Inherit our type from our parent webshell. If it is
// chrome, we'll be chrome. If it is content, we'll be
// content.
docShellAsItem->SetItemType(parentType);
}
parentAsNode->AddChild(docShellAsItem);
if (isContent) {
nsCOMPtr<nsIDocShellTreeOwner> parentTreeOwner;
parentAsItem->GetTreeOwner(getter_AddRefs(parentTreeOwner));
if(parentTreeOwner) {
// value is lowercased above.
PRBool is_primary = value.Equals(NS_LITERAL_STRING("content-primary"));
parentTreeOwner->ContentShellAdded(docShellAsItem, is_primary,
value.get());
}
}
// connect the container...
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
nsCOMPtr<nsIWebShellContainer> outerContainer =
do_QueryInterface(container);
if (outerContainer) {
webShell->SetContainer(outerContainer);
}
// Make sure all shells have links back to the content element
// in the nearest enclosing chrome shell.
nsCOMPtr<nsIChromeEventHandler> chromeEventHandler;
if (parentType == nsIDocShellTreeItem::typeChrome) {
// Our parent shell is a chrome shell. It is therefore our nearest
// enclosing chrome shell.
chromeEventHandler = do_QueryInterface(mOwnerContent);
NS_WARN_IF_FALSE(chromeEventHandler,
"This mContent should implement this.");
} else {
nsCOMPtr<nsIDocShell> parentShell(do_QueryInterface(parentAsNode));
// Our parent shell is a content shell. Get the chrome event
// handler from it and use that for our shell as well.
parentShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler));
}
mDocShell->SetChromeEventHandler(chromeEventHandler);
}
// This is nasty, this code (the do_GetInterface(mDocShell) below)
// *must* come *after* the above call to
// mDocShell->SetChromeEventHandler() for the global window to get
// the right chrome event handler.
// Tell the window about the frame that hosts it.
nsCOMPtr<nsIDOMElement> frame_element(do_QueryInterface(mOwnerContent));
NS_ASSERTION(frame_element, "frame loader owner element not a DOM element!");
nsCOMPtr<nsIDOMWindow> win(do_GetInterface(mDocShell));
nsCOMPtr<nsPIDOMWindow> win_private(do_QueryInterface(win));
NS_ENSURE_TRUE(win_private, NS_ERROR_UNEXPECTED);
win_private->SetFrameElementInternal(frame_element);
nsCOMPtr<nsIBaseWindow> base_win(do_QueryInterface(mDocShell));
NS_ENSURE_TRUE(base_win, NS_ERROR_UNEXPECTED);
// This is kinda whacky, this call doesn't really create anything,
// but it must be called to make sure things are properly
// initialized
base_win->Create();
return NS_OK;
}
NS_IMETHODIMP
nsFrameLoader::OnStateChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt32 aStateFlags, PRUint32 aStatus)
void
nsFrameLoader::GetURL(nsAString& aURI)
{
if (!((~aStateFlags) & (nsIWebProgressListener::STATE_IS_DOCUMENT |
nsIWebProgressListener::STATE_TRANSFERRING))) {
nsCOMPtr<nsIDOMWindow> win(do_GetInterface(mDocShell));
nsCOMPtr<nsIDOMEventTarget> eventTarget(do_QueryInterface(win));
aURI.Truncate();
if (eventTarget) {
eventTarget->AddEventListener(NS_LITERAL_STRING("load"), this,
PR_FALSE);
}
nsCOMPtr<nsIAtom> type;
mOwnerContent->GetTag(*getter_AddRefs(type));
if (type == nsHTMLAtoms::object) {
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, aURI);
} else {
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, aURI);
}
return NS_OK;
}
NS_IMETHODIMP
nsFrameLoader::OnProgressChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt32 aCurSelfProgress,
PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress,
PRInt32 aMaxTotalProgress)
{
return NS_OK;
}
NS_IMETHODIMP
nsFrameLoader::OnLocationChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsIURI *location)
{
return NS_OK;
}
NS_IMETHODIMP
nsFrameLoader::OnStatusChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsresult aStatus,
const PRUnichar *aMessage)
{
return NS_OK;
}
NS_IMETHODIMP
nsFrameLoader::OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, PRInt32 state)
{
return NS_OK;
}

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

@ -1620,8 +1620,8 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
PRBool intermediateCapture = PR_FALSE;
//Capturing stage evaluation
if (NS_EVENT_FLAG_BUBBLE != aFlags && aEvent->message != NS_PAGE_LOAD
&& aEvent->message != NS_SCRIPT_LOAD &&
if (NS_EVENT_FLAG_BUBBLE != aFlags && aEvent->message != NS_PAGE_LOAD &&
aEvent->message != NS_SCRIPT_LOAD &&
aEvent->message != NS_IMAGE_ERROR && aEvent->message != NS_IMAGE_LOAD) {
//Initiate capturing phase. Special case first call to document
if (parent) {

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

@ -91,15 +91,16 @@ private:
// objects for each of these instance variables, we put them off
// in a side structure that's only allocated when the content is
// accessed through the DOM.
typedef struct {
struct nsDOMSlots
{
nsChildContentList *mChildNodes;
nsDOMCSSDeclaration *mStyle;
nsDOMAttributeMap* mAttributeMap;
nsVoidArray *mRangeList;
nsIEventListenerManager* mListenerManager;
nsIContent* mBindingParent; // The nearest enclosing content node with a binding
// that created us. [Weak]
} nsDOMSlots;
nsIContent* mBindingParent; // The nearest enclosing content node with a
// binding that created us. [Weak]
};
class nsNode3Tearoff : public nsIDOM3Node

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

@ -416,6 +416,8 @@ nsContentDLF::CreateDocument(const char* aCommand,
break;
docv->SetUAStyleSheet(gUAStyleSheet);
doc->SetContainer(aContainer);
// Initialize the document to begin loading the data. An
// nsIStreamListener connected to the parser is returned in
// aDocListener.
@ -512,6 +514,9 @@ nsContentDLF::CreateRDFDocument(const char* aCommand,
* An nsIStreamListener connected to the parser is returned in
* aDocListener.
*/
doc->SetContainer(aContainer);
rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener, PR_TRUE);
if (NS_SUCCEEDED(rv)) {
/*

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

@ -97,6 +97,7 @@
#include "nsISelection.h"
#include "nsITextContent.h"
#include "nsIXBLService.h"
#include "nsIFrameLoader.h"
#include "nsLayoutAtoms.h"
#include "nsPlainTextSerializer.h"
#include "nsRange.h"
@ -275,6 +276,7 @@ extern nsresult NS_NewXBLService(nsIXBLService** aResult);
extern nsresult NS_NewBindingManager(nsIBindingManager** aResult);
extern nsresult NS_NewNodeInfoManager(nsINodeInfoManager** aResult);
extern nsresult NS_NewContentPolicy(nsIContentPolicy** aResult);
extern nsresult NS_NewFrameLoader(nsIFrameLoader** aResult);
#ifdef MOZ_XUL
extern nsresult NS_NewXULElementFactory(nsIElementFactory** aResult);
@ -342,6 +344,7 @@ MAKE_CTOR(CreatePlainTextSerializer, nsIContentSerializer, NS_NewPla
MAKE_CTOR(CreateXBLService, nsIXBLService, NS_NewXBLService)
MAKE_CTOR(CreateBindingManager, nsIBindingManager, NS_NewBindingManager)
MAKE_CTOR(CreateContentPolicy, nsIContentPolicy, NS_NewContentPolicy)
MAKE_CTOR(CreateFrameLoader, nsIFrameLoader, NS_NewFrameLoader)
MAKE_CTOR(CreateNodeInfoManager, nsINodeInfoManager, NS_NewNodeInfoManager)
MAKE_CTOR(CreateComputedDOMStyle, nsIComputedDOMStyle, NS_NewComputedDOMStyle)
#ifdef MOZ_XUL
@ -728,6 +731,11 @@ static const nsModuleComponentInfo gComponents[] = {
NS_CONTENTPOLICY_CONTRACTID,
CreateContentPolicy },
{ "Frame Loader",
NS_FRAMELOADER_CID,
NS_FRAMELOADER_CONTRACTID,
CreateFrameLoader },
{ "NodeInfoManager",
NS_NODEINFOMANAGER_CID,
NS_NODEINFOMANAGER_CONTRACTID,

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

@ -1531,39 +1531,36 @@ nsEventStateManager::GetParentScrollingView(nsMouseScrollEvent *aEvent,
{
if (!aEvent) return NS_ERROR_FAILURE;
if (!aPresContext) return NS_ERROR_FAILURE;
nsCOMPtr<nsISupports> shell;
aPresContext->GetContainer(getter_AddRefs(shell));
if (!shell) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(shell);
if (!treeItem) return NS_ERROR_FAILURE;
/* get our docshell's parent */
nsCOMPtr<nsIDocShellTreeItem> parent;
treeItem->GetParent(getter_AddRefs(parent));
if (!parent) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocShell> pDocShell = do_QueryInterface(parent);
if (!pDocShell) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIPresShell> pPresShell;
pDocShell->GetPresShell(getter_AddRefs(pPresShell));
if (!pPresShell) return NS_ERROR_FAILURE;
{
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
NS_ASSERTION(presShell, "No presshell in prescontext!");
presShell->GetDocument(getter_AddRefs(doc));
}
NS_ASSERTION(doc, "No document in prescontext!");
nsCOMPtr<nsIDocument> parentDoc;
pPresShell->GetDocument(getter_AddRefs(parentDoc));
doc->GetParentDocument(getter_AddRefs(parentDoc));
nsCOMPtr<nsIContent> rootContent;
parentDoc->GetRootContent(getter_AddRefs(rootContent));
if (!parentDoc) {
return NS_OK;
}
nsCOMPtr<nsIDocShell> ourDS = do_QueryInterface(shell);
nsCOMPtr<nsIPresShell> pPresShell;
parentDoc->GetShellAt(0, getter_AddRefs(pPresShell));
NS_ENSURE_TRUE(pPresShell, NS_ERROR_FAILURE);
/* now find the content node in our parent docshell's document that corresponds
to our docshell */
/* now find the content node in our parent docshell's document that
corresponds to our docshell */
nsCOMPtr<nsIContent> frameContent;
pPresShell->FindContentForShell(ourDS, getter_AddRefs(frameContent));
if (!frameContent) return NS_ERROR_FAILURE;
parentDoc->FindContentForSubDocument(doc, getter_AddRefs(frameContent));
NS_ENSURE_TRUE(frameContent, NS_ERROR_FAILURE);
/*
get this content node's frame, and use it as the new event target,
@ -1571,6 +1568,7 @@ nsEventStateManager::GetParentScrollingView(nsMouseScrollEvent *aEvent,
Note that we don't actually need to translate the event coordinates
because they are not used by DoWheelScroll().
*/
nsIFrame* frameFrame = nsnull;
pPresShell->GetPrimaryFrameFor(frameContent, &frameFrame);
if (!frameFrame) return NS_ERROR_FAILURE;
@ -2745,7 +2743,7 @@ nsEventStateManager::ShiftFocusInternal(PRBool aForward, nsIContent* aStart)
nsCOMPtr<nsISupports> pcContainer;
mPresContext->GetContainer(getter_AddRefs(pcContainer));
NS_ASSERTION(pcContainer, "no container for presContext");
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(pcContainer));
PRBool docHasFocus = PR_FALSE;
@ -2838,19 +2836,32 @@ nsEventStateManager::ShiftFocusInternal(PRBool aForward, nsIContent* aStart)
// Check to see if the next focused element has a subshell.
// This is the case for an IFRAME or FRAME element. If it
// does, we send focus into the subshell.
nsCOMPtr<nsISupports> shellObject;
presShell->GetSubShellFor(nextFocus, getter_AddRefs(shellObject));
if (shellObject) {
nsCOMPtr<nsIDocShell> subShell = do_QueryInterface(shellObject);
if (subShell) {
SetContentState(nsnull, NS_EVENT_STATE_FOCUS);
nsIFrame* nextFocusFrame = nsnull;
presShell->GetPrimaryFrameFor(nextFocus, &nextFocusFrame);
presShell->ScrollFrameIntoView(nextFocusFrame, NS_PRESSHELL_SCROLL_ANYWHERE,
NS_PRESSHELL_SCROLL_ANYWHERE);
TabIntoDocument(subShell, aForward);
nsCOMPtr<nsIDocShell> sub_shell;
nsCOMPtr<nsIDocument> doc, sub_doc;
nextFocus->GetDocument(*getter_AddRefs(doc));
if (doc) {
doc->GetSubDocumentFor(nextFocus, getter_AddRefs(sub_doc));
if (sub_doc) {
nsCOMPtr<nsISupports> container;
sub_doc->GetContainer(getter_AddRefs(container));
sub_shell = do_QueryInterface(container);
}
}
if (sub_shell) {
SetContentState(nsnull, NS_EVENT_STATE_FOCUS);
nsIFrame* nextFocusFrame = nsnull;
presShell->GetPrimaryFrameFor(nextFocus, &nextFocusFrame);
presShell->ScrollFrameIntoView(nextFocusFrame,
NS_PRESSHELL_SCROLL_ANYWHERE,
NS_PRESSHELL_SCROLL_ANYWHERE);
TabIntoDocument(sub_shell, aForward);
} else {
// there is no subshell, so just focus nextFocus
#ifdef DEBUG_DOCSHELL_FOCUS
@ -2927,23 +2938,28 @@ nsEventStateManager::ShiftFocusInternal(PRBool aForward, nsIContent* aStart)
if (parentDS) {
nsCOMPtr<nsIPresShell> parentShell;
parentDS->GetPresShell(getter_AddRefs(parentShell));
nsCOMPtr<nsIContent> shellContent;
parentShell->FindContentForShell(docShell, getter_AddRefs(shellContent));
nsCOMPtr<nsIContent> docContent;
nsCOMPtr<nsIDocument> parent_doc;
parentShell->GetDocument(getter_AddRefs(parent_doc));
parent_doc->FindContentForSubDocument(mDocument,
getter_AddRefs(docContent));
nsCOMPtr<nsIPresContext> parentPC;
parentShell->GetPresContext(getter_AddRefs(parentPC));
nsCOMPtr<nsIEventStateManager> parentESM;
parentPC->GetEventStateManager(getter_AddRefs(parentESM));
SetContentState(nsnull, NS_EVENT_STATE_FOCUS);
#ifdef DEBUG_DOCSHELL_FOCUS
printf("popping out focus to parent docshell\n");
#endif
parentESM->MoveCaretToFocus();
parentESM->ShiftFocus(aForward, shellContent);
parentESM->ShiftFocus(aForward, docContent);
}
} else {
PRBool tookFocus = PR_FALSE;
@ -4647,6 +4663,14 @@ PRBool
nsEventStateManager::IsIFrameDoc(nsIDocShell* aDocShell)
{
NS_ASSERTION(aDocShell, "docshell is null");
nsCOMPtr<nsIPresShell> presShell;
aDocShell->GetPresShell(getter_AddRefs(presShell));
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
NS_ASSERTION(doc, "No document in presshell!");
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(aDocShell);
nsCOMPtr<nsIDocShellTreeItem> parentItem;
treeItem->GetParent(getter_AddRefs(parentItem));
@ -4654,12 +4678,17 @@ nsEventStateManager::IsIFrameDoc(nsIDocShell* aDocShell)
return PR_FALSE;
nsCOMPtr<nsIDocShell> parentDS = do_QueryInterface(parentItem);
nsCOMPtr<nsIPresShell> parentShell;
parentDS->GetPresShell(getter_AddRefs(parentShell));
NS_ASSERTION(parentShell, "presshell is null");
nsCOMPtr<nsIPresShell> parentPresShell;
parentDS->GetPresShell(getter_AddRefs(parentPresShell));
NS_ASSERTION(parentPresShell, "presshell is null");
nsCOMPtr<nsIDocument> parentDoc;
parentPresShell->GetDocument(getter_AddRefs(parentDoc));
nsCOMPtr<nsIContent> docContent;
parentShell->FindContentForShell(aDocShell, getter_AddRefs(docContent));
parentDoc->FindContentForSubDocument(doc, getter_AddRefs(docContent));
if (!docContent)
return PR_FALSE;

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

@ -32,10 +32,10 @@ REQUIRES = xpcom \
webshell \
htmlparser \
necko \
uriloader \
view \
pref \
docshell \
uriloader \
xpconnect \
caps \
editor \

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

@ -2335,12 +2335,12 @@ nsGenericHTMLElement::GetBaseURL(const nsHTMLValue& aBaseHref,
baseHref.Trim(" \t\n\r");
nsIURI* url = nsnull;
{
result = NS_NewURI(&url, baseHref, nsnull, docBaseURL);
}
result = NS_NewURI(&url, baseHref, nsnull, docBaseURL);
NS_IF_RELEASE(docBaseURL);
*aBaseURL = url;
}
return result;
}
@ -4575,32 +4575,6 @@ nsGenericHTMLElement::SetElementFocus(PRBool aDoFocus)
return RemoveFocus(presContext);
}
nsresult
nsGenericHTMLElement::HandleFrameOnloadEvent(nsIDOMEvent* aEvent)
{
NS_ENSURE_TRUE(aEvent, NS_OK);
nsAutoString type;
aEvent->GetType(type);
if (!type.EqualsIgnoreCase("load")) {
return NS_OK;
}
nsCOMPtr<nsIPresContext> ctx;
GetPresContext(this, getter_AddRefs(ctx));
NS_ENSURE_TRUE(ctx, NS_OK);
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_PAGE_LOAD;
return HandleDOMEvent(ctx, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
// static
nsresult
nsGenericHTMLElement::SetProtocolInHrefString(const nsAString &aHref,

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

@ -465,8 +465,6 @@ public:
protected:
nsresult SetElementFocus(PRBool aDoFocus);
nsresult HandleFrameOnloadEvent(nsIDOMEvent* aEvent);
PRBool IsEventName(nsIAtom* aName);
};

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

@ -37,7 +37,6 @@
* ***** END LICENSE BLOCK ***** */
#include "nsIDOMHTMLFrameElement.h"
#include "nsIDOMNSHTMLFrameElement.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMWindow.h"
#include "nsIScriptGlobalObject.h"
@ -49,14 +48,14 @@
#include "nsIDOMDocument.h"
#include "nsIWebNavigation.h"
#include "nsIChromeEventHandler.h"
#include "nsIDocShell.h"
#include "nsDOMError.h"
class nsHTMLFrameElement : public nsGenericHTMLLeafElement,
public nsIDOMHTMLFrameElement,
public nsIDOMNSHTMLFrameElement,
public nsIChromeEventHandler,
public nsIDOMEventListener
public nsIChromeEventHandler
{
public:
nsHTMLFrameElement();
@ -83,9 +82,6 @@ public:
// nsIChromeEventHandler
NS_DECL_NSICHROMEEVENTHANDLER
// nsIDOMEventListener
NS_DECL_NSIDOMEVENTLISTENER
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute,
const nsAString& aValue,
nsHTMLValue& aResult);
@ -143,7 +139,6 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLFrameElement,
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLFrameElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLFrameElement)
NS_INTERFACE_MAP_ENTRY(nsIChromeEventHandler)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLFrameElement)
NS_HTML_CONTENT_INTERFACE_MAP_END
@ -191,33 +186,21 @@ NS_IMETHODIMP
nsHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
{
NS_ENSURE_ARG_POINTER(aContentDocument);
*aContentDocument = nsnull;
NS_ENSURE_TRUE(mDocument, NS_OK);
if (!mDocument) {
return NS_OK;
}
nsCOMPtr<nsIPresShell> presShell;
nsCOMPtr<nsIDocument> content_document;
mDocument->GetShellAt(0, getter_AddRefs(presShell));
NS_ENSURE_TRUE(presShell, NS_OK);
mDocument->GetSubDocumentFor(this, getter_AddRefs(content_document));
nsCOMPtr<nsISupports> tmp;
if (!content_document) {
return NS_OK;
}
presShell->GetSubShellFor(this, getter_AddRefs(tmp));
NS_ENSURE_TRUE(tmp, NS_OK);
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(tmp);
NS_ENSURE_TRUE(webNav, NS_OK);
nsCOMPtr<nsIDOMDocument> domDoc;
webNav->GetDocument(getter_AddRefs(domDoc));
*aContentDocument = domDoc;
NS_IF_ADDREF(*aContentDocument);
return NS_OK;
return CallQueryInterface(content_document, aContentDocument);
}
NS_IMETHODIMP
@ -329,8 +312,3 @@ nsHTMLFrameElement::HandleChromeEvent(nsIPresContext* aPresContext,
return HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags,aEventStatus);
}
nsresult
nsHTMLFrameElement::HandleEvent(nsIDOMEvent *aEvent)
{
return HandleFrameOnloadEvent(aEvent);
}

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

@ -37,11 +37,10 @@
* ***** END LICENSE BLOCK ***** */
#include "nsIDOMHTMLIFrameElement.h"
#include "nsIDOMNSHTMLFrameElement.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsIHTMLContent.h"
#include "nsIFrameLoader.h"
#include "nsGenericHTMLElement.h"
#include "nsHTMLAtoms.h"
#include "nsIStyleContext.h"
@ -54,12 +53,14 @@
#include "nsIChromeEventHandler.h"
#include "nsDOMError.h"
#include "nsRuleNode.h"
#include "nsIDocShell.h"
#include "nsIInterfaceRequestorUtils.h"
class nsHTMLIFrameElement : public nsGenericHTMLContainerElement,
public nsIDOMHTMLIFrameElement,
public nsIDOMNSHTMLFrameElement,
public nsIChromeEventHandler,
public nsIDOMEventListener
public nsIFrameLoaderOwner
{
public:
nsHTMLIFrameElement();
@ -86,8 +87,11 @@ public:
// nsIChromeEventHandler
NS_DECL_NSICHROMEEVENTHANDLER
// nsIDOMEventListener
NS_DECL_NSIDOMEVENTLISTENER
// nsIFrameLoaderOwner
NS_IMETHOD GetFrameLoader(nsIFrameLoader **aFrameLoader);
// nsIContent
NS_IMETHOD SetParent(nsIContent *aParent);
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute,
const nsAString& aValue,
@ -101,6 +105,14 @@ public:
#ifdef DEBUG
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
#endif
protected:
// This doesn't really ensure a frame loade in all cases, only when
// it makes sense.
nsresult EnsureFrameLoader();
nsresult LoadSrc();
nsCOMPtr<nsIFrameLoader> mFrameLoader;
};
nsresult
@ -136,6 +148,9 @@ nsHTMLIFrameElement::nsHTMLIFrameElement()
nsHTMLIFrameElement::~nsHTMLIFrameElement()
{
if (mFrameLoader) {
mFrameLoader->Destroy();
}
}
@ -148,7 +163,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLIFrameElement,
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLIFrameElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLFrameElement)
NS_INTERFACE_MAP_ENTRY(nsIChromeEventHandler)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
NS_INTERFACE_MAP_ENTRY(nsIFrameLoaderOwner)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLIFrameElement)
NS_HTML_CONTENT_INTERFACE_MAP_END
@ -189,71 +204,123 @@ NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, MarginHeight, marginheight)
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, MarginWidth, marginwidth)
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Name, name)
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Scrolling, scrolling)
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Src, src)
NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Width, width)
NS_IMETHODIMP
nsHTMLIFrameElement::GetSrc(nsAString& aSrc)
{
nsGenericHTMLContainerElement::GetAttr(kNameSpaceID_None, nsHTMLAtoms::src,
aSrc);
return NS_OK;
}
NS_IMETHODIMP
nsHTMLIFrameElement::SetSrc(const nsAString& aSrc)
{
SetAttribute(NS_LITERAL_STRING("src"), aSrc);
return LoadSrc();
}
NS_IMETHODIMP
nsHTMLIFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
{
NS_ENSURE_ARG_POINTER(aContentDocument);
*aContentDocument = nsnull;
NS_ENSURE_TRUE(mDocument, NS_OK);
nsresult rv = EnsureFrameLoader();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPresShell> presShell;
if (!mFrameLoader) {
return NS_OK;
}
mDocument->GetShellAt(0, getter_AddRefs(presShell));
NS_ENSURE_TRUE(presShell, NS_OK);
nsCOMPtr<nsIDocShell> doc_shell;
mFrameLoader->GetDocShell(getter_AddRefs(doc_shell));
nsCOMPtr<nsISupports> tmp;
nsCOMPtr<nsIDOMWindow> win(do_GetInterface(doc_shell));
presShell->GetSubShellFor(this, getter_AddRefs(tmp));
NS_ENSURE_TRUE(tmp, NS_OK);
if (!win) {
return NS_OK;
}
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(tmp);
NS_ENSURE_TRUE(webNav, NS_OK);
nsCOMPtr<nsIDOMDocument> domDoc;
webNav->GetDocument(getter_AddRefs(domDoc));
*aContentDocument = domDoc;
NS_IF_ADDREF(*aContentDocument);
return NS_OK;
return win->GetDocument(aContentDocument);
}
NS_IMETHODIMP
nsHTMLIFrameElement::GetContentWindow(nsIDOMWindow** aContentWindow)
{
NS_ENSURE_ARG_POINTER(aContentWindow);
*aContentWindow = nsnull;
nsCOMPtr<nsIDOMDocument> content_doc;
nsresult rv = GetContentDocument(getter_AddRefs(content_doc));
nsresult rv = EnsureFrameLoader();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc(do_QueryInterface(content_doc));
if (!doc) {
if (!mFrameLoader) {
return NS_OK;
}
nsCOMPtr<nsIScriptGlobalObject> globalObj;
doc->GetScriptGlobalObject(getter_AddRefs(globalObj));
nsCOMPtr<nsIDocShell> doc_shell;
mFrameLoader->GetDocShell(getter_AddRefs(doc_shell));
nsCOMPtr<nsIDOMWindow> window (do_QueryInterface(globalObj));
nsCOMPtr<nsIDOMWindow> win(do_GetInterface(doc_shell));
*aContentWindow = window;
*aContentWindow = win;
NS_IF_ADDREF(*aContentWindow);
return NS_OK;
}
nsresult
nsHTMLIFrameElement::EnsureFrameLoader()
{
if (mFrameLoader || !mParent) {
return NS_OK;
}
nsresult rv = NS_NewFrameLoader(getter_AddRefs(mFrameLoader));
NS_ENSURE_SUCCESS(rv, rv);
mFrameLoader->Init(this);
return NS_OK;
}
NS_IMETHODIMP
nsHTMLIFrameElement::GetFrameLoader(nsIFrameLoader **aFrameLoader)
{
*aFrameLoader = mFrameLoader;
NS_IF_ADDREF(*aFrameLoader);
return NS_OK;
}
nsresult
nsHTMLIFrameElement::LoadSrc()
{
nsresult rv = EnsureFrameLoader();
NS_ENSURE_SUCCESS(rv, rv);
if (!mFrameLoader) {
return NS_OK;
}
rv = mFrameLoader->LoadFrame();
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to load URL");
return rv;
}
NS_IMETHODIMP
nsHTMLIFrameElement::SetParent(nsIContent *aParent)
{
nsresult rv = nsGenericHTMLContainerElement::SetParent(aParent);
NS_ENSURE_SUCCESS(rv, rv);
return LoadSrc();
}
NS_IMETHODIMP
nsHTMLIFrameElement::StringToAttribute(nsIAtom* aAttribute,
const nsAString& aValue,
@ -366,7 +433,7 @@ MapAttributesIntoRule(const nsIHTMLMappedAttributes* aAttributes,
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
if (value.GetUnit() == eHTMLUnit_Pixel)
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
else if (value.GetUnit() == eHTMLUnit_Percent)
aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());
}
@ -377,7 +444,8 @@ MapAttributesIntoRule(const nsIHTMLMappedAttributes* aAttributes,
}
NS_IMETHODIMP
nsHTMLIFrameElement::GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType,
nsHTMLIFrameElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
PRInt32 aModType,
PRInt32& aHint) const
{
if ((aAttribute == nsHTMLAtoms::width) ||
@ -419,20 +487,15 @@ nsHTMLIFrameElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
//*****************************************************************************
// nsHTMLIFrameElement::nsIChromeEventHandler
//*****************************************************************************
//*****************************************************************************
NS_IMETHODIMP
nsHTMLIFrameElement::HandleChromeEvent(nsIPresContext* aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
PRUint32 aFlags,
nsEventStatus* aEventStatus)
{
return HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags,aEventStatus);
}
nsresult
nsHTMLIFrameElement::HandleEvent(nsIDOMEvent *aEvent)
{
return HandleFrameOnloadEvent(aEvent);
}

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

@ -190,30 +190,18 @@ nsHTMLObjectElement::GetContentDocument(nsIDOMDocument** aContentDocument)
*aContentDocument = nsnull;
NS_ENSURE_TRUE(mDocument, NS_OK);
if (!mDocument) {
return NS_OK;
}
nsCOMPtr<nsIPresShell> presShell;
nsCOMPtr<nsIDocument> sub_doc;
mDocument->GetSubDocumentFor(this, getter_AddRefs(sub_doc));
mDocument->GetShellAt(0, getter_AddRefs(presShell));
NS_ENSURE_TRUE(presShell, NS_OK);
if (!sub_doc) {
return NS_OK;
}
nsCOMPtr<nsISupports> tmp;
presShell->GetSubShellFor(this, getter_AddRefs(tmp));
if (!tmp) return NS_OK;
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(tmp);
NS_ENSURE_TRUE(webNav, NS_OK);
nsCOMPtr<nsIDOMDocument> domDoc;
webNav->GetDocument(getter_AddRefs(domDoc));
*aContentDocument = domDoc;
NS_IF_ADDREF(*aContentDocument);
return NS_OK;
return CallQueryInterface(sub_doc, aContentDocument);
}
NS_IMETHODIMP

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

@ -190,30 +190,18 @@ nsHTMLObjectElement::GetContentDocument(nsIDOMDocument** aContentDocument)
*aContentDocument = nsnull;
NS_ENSURE_TRUE(mDocument, NS_OK);
if (!mDocument) {
return NS_OK;
}
nsCOMPtr<nsIPresShell> presShell;
nsCOMPtr<nsIDocument> sub_doc;
mDocument->GetSubDocumentFor(this, getter_AddRefs(sub_doc));
mDocument->GetShellAt(0, getter_AddRefs(presShell));
NS_ENSURE_TRUE(presShell, NS_OK);
if (!sub_doc) {
return NS_OK;
}
nsCOMPtr<nsISupports> tmp;
presShell->GetSubShellFor(this, getter_AddRefs(tmp));
if (!tmp) return NS_OK;
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(tmp);
NS_ENSURE_TRUE(webNav, NS_OK);
nsCOMPtr<nsIDOMDocument> domDoc;
webNav->GetDocument(getter_AddRefs(domDoc));
*aContentDocument = domDoc;
NS_IF_ADDREF(*aContentDocument);
return NS_OK;
return CallQueryInterface(sub_doc, aContentDocument);
}
NS_IMETHODIMP

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

@ -1503,7 +1503,7 @@ SinkContext::CloseContainer(const nsIParserNode& aNode)
// Flush any collected text content. Release the last text
// node to indicate that no more should be added to it.
FlushTextAndRelease();
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"SinkContext::CloseContainer", aNode, mStackPos-1, mSink);
@ -1604,7 +1604,8 @@ SinkContext::CloseContainer(const nsIParserNode& aNode)
case eHTMLTag_select:
{
nsCOMPtr<nsISelectElement> select = do_QueryInterface(content, &result);
nsCOMPtr<nsISelectElement> select = do_QueryInterface(content);
if (select) {
result = select->DoneAddingChildren();
}
@ -3814,43 +3815,57 @@ HTMLContentSink::DidProcessAToken(void)
PRInt32 oldMaxTokenProcessingTime = GetMaxTokenProcessingTime();
#endif
// There is both a high frequency interrupt mode and a low frequency
// interupt mode controlled by the flag NS_SINK_FLAG_DYNAMIC_LOWER_VALUE
// The high frequency mode interupts the parser frequently to provide
// UI responsiveness at the expense of page load time. The low frequency mode
// interrupts the parser and samples the system clock infrequently to provide fast
// page load time. When the user moves the mouse, clicks or types the mode switches
// to the high frequency interrupt mode. If the user stops moving the mouse or typing
// for a duration of time (mDynamicIntervalSwitchThreshold) it switches to low
// frequency interrupt mode.
// There is both a high frequency interrupt mode and a low
// frequency interupt mode controlled by the flag
// NS_SINK_FLAG_DYNAMIC_LOWER_VALUE The high frequency mode
// interupts the parser frequently to provide UI responsiveness at
// the expense of page load time. The low frequency mode
// interrupts the parser and samples the system clock infrequently
// to provide fast page load time. When the user moves the mouse,
// clicks or types the mode switches to the high frequency
// interrupt mode. If the user stops moving the mouse or typing
// for a duration of time (mDynamicIntervalSwitchThreshold) it
// switches to low frequency interrupt mode.
// Get the current user event time
nsCOMPtr<nsIPresShell> shell;
mDocument->GetShellAt(0, getter_AddRefs(shell));
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
if (!shell) {
// If there's no pres shell in the document, return early since
// we're not laying anything out here.
return NS_OK;
}
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
PRUint32 eventTime;
nsresult rv = vm->GetLastUserEventTime(eventTime);
NS_ENSURE_TRUE(NS_SUCCEEDED(rv), NS_ERROR_FAILURE);
if ((!(mFlags & NS_SINK_FLAG_DYNAMIC_LOWER_VALUE)) &&
(mLastSampledUserEventTime == eventTime)) {
// The magic value of NS_MAX_TOKENS_DEFLECTED_IN_LOW_FREQ_MODE was selected by
// empirical testing. It provides reasonable
// user response and prevents us from sampling the clock too frequently.
// The magic value of NS_MAX_TOKENS_DEFLECTED_IN_LOW_FREQ_MODE
// was selected by empirical testing. It provides reasonable
// user response and prevents us from sampling the clock too
// frequently.
if (mDeflectedCount < NS_MAX_TOKENS_DEFLECTED_IN_LOW_FREQ_MODE) {
mDeflectedCount++;
return NS_OK; // return early to prevent sampling the clock. Note: This prevents
// us from switching to higher frequency (better UI responsive) mode, so
// limit ourselves to doing for no more than
// NS_MAX_TOKENS_DEFLECTED_IN_LOW_FREQ_MODE tokens.
// return early to prevent sampling the clock. Note: This
// prevents us from switching to higher frequency (better UI
// responsive) mode, so limit ourselves to doing for no more
// than NS_MAX_TOKENS_DEFLECTED_IN_LOW_FREQ_MODE tokens.
return NS_OK;
} else {
mDeflectedCount = 0; // reset count and drop through to the code which samples the clock and
// does the dynamic switch between the high frequency and low frequency
// interruption of the parser.
// reset count and drop through to the code which samples the
// clock and does the dynamic switch between the high
// frequency and low frequency interruption of the parser.
mDeflectedCount = 0;
}
}
@ -3858,48 +3873,49 @@ PRInt32 oldMaxTokenProcessingTime = GetMaxTokenProcessingTime();
PRUint32 currentTime = PR_IntervalToMicroseconds(PR_IntervalNow());
// Get the last user event time and compare it with
// the current time to determine if the lower value
// for content notification and max token processing
// should be used. But only consider using the lower
// value if the document has already been loading
// for 2 seconds. 2 seconds was chosen because it is
// greater than the default 3/4 of second that is used
// to determine when to switch between the modes and it
// gives the document a little time to create windows.
// This is important because on some systems (Windows,
// for example) when a window is created and the mouse
// is over it, a mouse move event is sent, which will kick
// us into interactive mode otherwise. It also supresses
// reaction to pressing the ENTER key in the URL bar...
// Get the last user event time and compare it with the current
// time to determine if the lower value for content notification
// and max token processing should be used. But only consider
// using the lower value if the document has already been loading
// for 2 seconds. 2 seconds was chosen because it is greater than
// the default 3/4 of second that is used to determine when to
// switch between the modes and it gives the document a little
// time to create windows. This is important because on some
// systems (Windows, for example) when a window is created and the
// mouse is over it, a mouse move event is sent, which will kick
// us into interactive mode otherwise. It also supresses reaction
// to pressing the ENTER key in the URL bar...
PRUint32 delayBeforeLoweringThreshold = NS_STATIC_CAST(PRUint32, ((2 * mDynamicIntervalSwitchThreshold) + NS_DELAY_FOR_WINDOW_CREATION));
if (((currentTime - mBeginLoadTime) > delayBeforeLoweringThreshold) && mDocument) {
if ((currentTime - eventTime) < NS_STATIC_CAST(PRUint32, mDynamicIntervalSwitchThreshold)) {
// lower the dynamic values to favor
// application responsiveness over page load
// time.
mFlags |= NS_SINK_FLAG_DYNAMIC_LOWER_VALUE;
}
else {
// raise the content notification and
// MaxTokenProcessing time to favor overall
// page load speed over responsiveness
mFlags &= ~NS_SINK_FLAG_DYNAMIC_LOWER_VALUE;
if ((currentTime - mBeginLoadTime) > delayBeforeLoweringThreshold) {
if ((currentTime - eventTime) <
NS_STATIC_CAST(PRUint32, mDynamicIntervalSwitchThreshold)) {
// lower the dynamic values to favor application
// responsiveness over page load time.
mFlags |= NS_SINK_FLAG_DYNAMIC_LOWER_VALUE;
} else {
// raise the content notification and MaxTokenProcessing time
// to favor overall page load speed over responsiveness
mFlags &= ~NS_SINK_FLAG_DYNAMIC_LOWER_VALUE;
}
}
#ifdef NS_DEBUG
PRInt32 newMaxTokenProcessingTime = GetMaxTokenProcessingTime();
PRInt32 newMaxTokenProcessingTime = GetMaxTokenProcessingTime();
if (newMaxTokenProcessingTime != oldMaxTokenProcessingTime) {
// printf("Changed dynamic interval : MaxTokenProcessingTime %d\n", GetMaxTokenProcessingTime());
}
if (newMaxTokenProcessingTime != oldMaxTokenProcessingTime) {
// printf("Changed dynamic interval : MaxTokenProcessingTime %d\n",
// GetMaxTokenProcessingTime());
}
#endif
if ((currentTime - mDelayTimerStart) > NS_STATIC_CAST(PRUint32, GetMaxTokenProcessingTime())) {
return NS_ERROR_HTMLPARSER_INTERRUPTED;
}
if ((currentTime - mDelayTimerStart) >
NS_STATIC_CAST(PRUint32, GetMaxTokenProcessingTime())) {
return NS_ERROR_HTMLPARSER_INTERRUPTED;
}
}
return NS_OK;
@ -4146,7 +4162,7 @@ nsresult
HTMLContentSink::ProcessAREATag(const nsIParserNode& aNode)
{
nsresult rv = NS_OK;
if (nsnull != mCurrentMap) {
if (mCurrentMap) {
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
nsIHTMLContent* area;
rv = CreateContentObject(aNode, nodeType, nsnull, nsnull, &area);

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

@ -1477,7 +1477,7 @@ nsHTMLDocument::FlushPendingNotifications(PRBool aFlushReflows,
}
}
if ((isSafeToFlush) && (mParser)) {
if (isSafeToFlush && mParser) {
nsCOMPtr<nsIContentSink> sink;
// XXX Ack! Parser doesn't addref sink before passing it back
@ -3750,34 +3750,33 @@ nsHTMLDocument::ResolveName(const nsAString& aName,
PRBool
nsHTMLDocument::GetBodyContent()
{
nsCOMPtr<nsIDOMElement> root;
nsCOMPtr<nsIContent> root;
GetDocumentElement(getter_AddRefs(root));
GetRootContent(getter_AddRefs(root));
if (!root) {
return PR_FALSE;
}
NS_NAMED_LITERAL_STRING(bodyStr, "BODY");
nsCOMPtr<nsIDOMNode> child;
root->GetFirstChild(getter_AddRefs(child));
PRInt32 i, child_count;
root->ChildCount(child_count);
while (child) {
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(child));
for (i = 0; i < child_count; i++) {
nsCOMPtr<nsIContent> child;
if (domElement) {
nsAutoString tagName;
domElement->GetTagName(tagName);
root->ChildAt(i, *getter_AddRefs(child));
NS_ENSURE_TRUE(child, NS_ERROR_UNEXPECTED);
ToUpperCase(tagName);
if (bodyStr.Equals(tagName)) {
mBodyContent = child;
nsCOMPtr<nsINodeInfo> ni;
child->GetNodeInfo(*getter_AddRefs(ni));
return PR_TRUE;
}
if (ni && ni->Equals(nsHTMLAtoms::body) &&
(ni->NamespaceEquals(kNameSpaceID_None) ||
ni->NamespaceEquals(kNameSpaceID_HTML))) {
mBodyContent = do_QueryInterface(child);
return PR_TRUE;
}
nsIDOMNode *tmpNode = child;
tmpNode->GetNextSibling(getter_AddRefs(child));
}
return PR_FALSE;

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

@ -2657,7 +2657,7 @@ CSSStyleSheetImpl::SetDisabled(PRBool aDisabled)
PRBool oldState = mDisabled;
mDisabled = aDisabled;
if ((nsnull != mDocument) && (mDisabled != oldState)) {
if (mDocument && (mDisabled != oldState)) {
mDocument->SetStyleSheetDisabledState(this, mDisabled);
}

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

@ -2310,6 +2310,13 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFrameLoader.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>UnicharUtilsStatic.o</PATH>
@ -3445,6 +3452,11 @@
<PATH>nsContentAreaDragDrop.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFrameLoader.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>UnicharUtilsStatic.o</PATH>
@ -5799,6 +5811,13 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFrameLoader.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>UnicharUtilsStaticDebug.o</PATH>
@ -6934,6 +6953,11 @@
<PATH>nsContentAreaDragDrop.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFrameLoader.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>UnicharUtilsStaticDebug.o</PATH>
@ -7262,6 +7286,12 @@
<PATH>nsContentAreaDragDrop.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>content.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFrameLoader.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</GROUP>
<GROUP><NAME>build</NAME>
<FILEREF>

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

@ -445,6 +445,8 @@ nsXULDocument::nsXULDocument(void)
#ifdef IBMBIDI
mBidiEnabled = PR_FALSE;
#endif // IBMBIDI
mSubDocuments = nsnull;
}
nsIFastLoadService* nsXULDocument::gFastLoadService = nsnull;
@ -472,14 +474,11 @@ nsXULDocument::~nsXULDocument()
observer->DocumentWillBeDestroyed(this);
}
// mParentDocument is never refcounted
// Delete references to sub-documents
{
i = mSubDocuments.Count();
while (--i >= 0) {
nsIDocument* subdoc = (nsIDocument*) mSubDocuments.ElementAt(i);
NS_RELEASE(subdoc);
}
// Delete references to sub-documents and kill the subdocument map,
// if any. It holds strong references
if (mSubDocuments) {
PL_DHashTableDestroy(mSubDocuments);
mSubDocuments = nsnull;
}
// Delete references to style sheets but only if we aren't a popup document.
@ -526,7 +525,8 @@ nsXULDocument::~nsXULDocument()
NS_IF_RELEASE(gXMLElementFactory);
if (gNameSpaceManager) {
nsServiceManager::ReleaseService(kNameSpaceManagerCID, gNameSpaceManager);
nsServiceManager::ReleaseService(kNameSpaceManagerCID,
gNameSpaceManager);
gNameSpaceManager = nsnull;
}
@ -1122,27 +1122,154 @@ nsXULDocument::SetParentDocument(nsIDocument* aParent)
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::AddSubDocument(nsIDocument* aSubDoc)
PR_STATIC_CALLBACK(void)
SubDocClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
{
NS_ADDREF(aSubDoc);
mSubDocuments.AppendElement(aSubDoc);
return NS_OK;
SubDocMapEntry *e = NS_STATIC_CAST(SubDocMapEntry *, entry);
NS_RELEASE(e->mKey);
NS_IF_RELEASE(e->mSubDocument);
}
PR_STATIC_CALLBACK(void)
SubDocInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry, const void *key)
{
SubDocMapEntry *e =
NS_CONST_CAST(SubDocMapEntry *,
NS_STATIC_CAST(const SubDocMapEntry *, entry));
e->mKey = NS_CONST_CAST(nsIContent *,
NS_STATIC_CAST(const nsIContent *, key));
NS_ADDREF(e->mKey);
e->mSubDocument = nsnull;
}
NS_IMETHODIMP
nsXULDocument::GetNumberOfSubDocuments(PRInt32 *aCount)
nsXULDocument::SetSubDocumentFor(nsIContent *aContent, nsIDocument* aSubDoc)
{
*aCount = mSubDocuments.Count();
return NS_OK;
NS_ENSURE_TRUE(aContent, NS_ERROR_UNEXPECTED);
if (!aSubDoc) {
// aSubDoc is nsnull, remove the mapping
if (mSubDocuments) {
SubDocMapEntry *entry =
NS_STATIC_CAST(SubDocMapEntry*,
PL_DHashTableOperate(mSubDocuments, aContent,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_LIVE(entry)) {
entry->mSubDocument->SetParentDocument(nsnull);
PL_DHashTableRawRemove(mSubDocuments, entry);
}
}
} else {
if (!mSubDocuments) {
// Create a new hashtable
static PLDHashTableOps hash_table_ops =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashGetKeyStub,
PL_DHashVoidPtrKeyStub,
PL_DHashMatchEntryStub,
PL_DHashMoveEntryStub,
SubDocClearEntry,
PL_DHashFinalizeStub,
SubDocInitEntry
};
mSubDocuments = PL_NewDHashTable(&hash_table_ops, nsnull,
sizeof(SubDocMapEntry), 16);
if (!mSubDocuments) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
// Add a mapping to the hash table
SubDocMapEntry *entry =
NS_STATIC_CAST(SubDocMapEntry*,
PL_DHashTableOperate(mSubDocuments, aContent,
PL_DHASH_ADD));
if (!entry) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (entry->mSubDocument) {
entry->mSubDocument->SetParentDocument(nsnull);
// Release the old sub document
NS_RELEASE(entry->mSubDocument);
}
entry->mSubDocument = aSubDoc;
NS_ADDREF(entry->mSubDocument);
aSubDoc->SetParentDocument(this);
}
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::GetSubDocumentAt(PRInt32 aIndex, nsIDocument** aSubDoc)
nsXULDocument::GetSubDocumentFor(nsIContent *aContent, nsIDocument** aSubDoc)
{
*aSubDoc = (nsIDocument*) mSubDocuments.SafeElementAt(aIndex);
NS_IF_ADDREF(*aSubDoc);
*aSubDoc = nsnull;
if (mSubDocuments) {
SubDocMapEntry *entry =
NS_STATIC_CAST(SubDocMapEntry*,
PL_DHashTableOperate(mSubDocuments, aContent,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
*aSubDoc = entry->mSubDocument;
NS_ADDREF(*aSubDoc);
}
}
return NS_OK;
}
PR_STATIC_CALLBACK(PLDHashOperator)
FindContentEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)
{
SubDocMapEntry *entry = NS_STATIC_CAST(SubDocMapEntry*, hdr);
FindContentData *data = NS_STATIC_CAST(FindContentData*, arg);
if (entry->mSubDocument == data->mSubDocument) {
data->mResult = NS_CONST_CAST(nsIContent *, entry->mKey);
return PL_DHASH_STOP;
}
return PL_DHASH_NEXT;
}
NS_IMETHODIMP
nsXULDocument::FindContentForSubDocument(nsIDocument *aDocument,
nsIContent **aContent)
{
NS_ENSURE_ARG_POINTER(aDocument);
if (!mSubDocuments) {
*aContent = nsnull;
return NS_OK;
}
FindContentData data(aDocument);
PL_DHashTableEnumerate(mSubDocuments, FindContentEnumerator, &data);
*aContent = data.mResult;
NS_IF_ADDREF(*aContent);
return NS_OK;
}
NS_IMETHODIMP
@ -2404,6 +2531,25 @@ nsXULDocument::RemoveReference(void *aKey, nsISupports **aOldReference)
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::SetContainer(nsISupports *aContainer)
{
mDocumentContainer = dont_AddRef(NS_GetWeakReference(aContainer));
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::GetContainer(nsISupports **aContainer)
{
nsCOMPtr<nsISupports> container = do_QueryReferent(mDocumentContainer);
*aContainer = container;
NS_IF_ADDREF(*aContainer);
return NS_OK;
}
void
nsXULDocument::SetDisplaySelection(PRInt8 aToggle)
{

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

@ -222,11 +222,12 @@ public:
NS_IMETHOD SetParentDocument(nsIDocument* aParent);
NS_IMETHOD AddSubDocument(nsIDocument* aSubDoc);
NS_IMETHOD SetSubDocumentFor(nsIContent *aContent, nsIDocument* aSubDoc);
NS_IMETHOD GetNumberOfSubDocuments(PRInt32* aCount);
NS_IMETHOD GetSubDocumentFor(nsIContent *aContent, nsIDocument** aSubDoc);
NS_IMETHOD GetSubDocumentAt(PRInt32 aIndex, nsIDocument** aSubDoc);
NS_IMETHOD FindContentForSubDocument(nsIDocument *aDocument,
nsIContent **aContent);
NS_IMETHOD GetRootContent(nsIContent** aRoot);
@ -333,6 +334,8 @@ public:
NS_IMETHOD AddReference(void *aKey, nsISupports *aReference);
NS_IMETHOD RemoveReference(void *aKey, nsISupports **aOldReference);
NS_IMETHOD SetContainer(nsISupports *aContainer);
NS_IMETHOD GetContainer(nsISupports **aContainer);
virtual void SetDisplaySelection(PRInt8 aToggle);
@ -562,6 +565,7 @@ protected:
nsCOMPtr<nsIURI> mDocumentURL; // [OWNER] ??? compare with loader
nsCOMPtr<nsIURI> mDocumentBaseURL;
nsWeakPtr mDocumentLoadGroup; // [WEAK] leads to loader
nsWeakPtr mDocumentContainer; // [WEAK] leads to container
nsCOMPtr<nsIPrincipal> mDocumentPrincipal; // [OWNER]
nsCOMPtr<nsIContent> mRootContent; // [OWNER]
nsIDocument* mParentDocument; // [WEAK]
@ -590,7 +594,7 @@ protected:
nsCOMPtr<nsIRDFDataSource> mLocalStore;
nsCOMPtr<nsILineBreaker> mLineBreaker; // [OWNER]
nsCOMPtr<nsIWordBreaker> mWordBreaker; // [OWNER]
nsVoidArray mSubDocuments; // [OWNER] of subelements
PLDHashTable *mSubDocuments; // [OWNER] of subelements
PRPackedBool mIsPopup;
PRPackedBool mIsFastLoad;
PRPackedBool mApplyingPersistedAttrs;

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

@ -1158,6 +1158,14 @@ nsDocShell::SetChromeEventHandler(nsIChromeEventHandler * aChromeEventHandler)
{
// Weak reference. Don't addref.
mChromeEventHandler = aChromeEventHandler;
NS_ASSERTION(!mScriptGlobal,
"SetChromeEventHandler() called after the script global "
"object was created! This means that the script global "
"object in this docshell won't get the right chrome event "
"handler. You really don't want to see this assert, FIX "
"YOUR CODE!");
return NS_OK;
}
@ -2441,7 +2449,6 @@ nsDocShell::Stop(PRUint32 aStopFlags)
if (nsIWebNavigation::STOP_CONTENT & aStopFlags) {
if (mContentViewer)
mContentViewer->Stop();
}
if (nsIWebNavigation::STOP_NETWORK & aStopFlags) {
@ -2650,7 +2657,6 @@ nsDocShell::InitWindow(nativeWindow parentNativeWindow,
NS_IMETHODIMP
nsDocShell::Create()
{
NS_ENSURE_STATE(!mContentViewer);
mPrefs = do_GetService(NS_PREF_CONTRACTID);
//GlobalHistory is now set in SetGlobalHistory
// mGlobalHistory = do_GetService(NS_GLOBALHISTORY_CONTRACTID);
@ -2835,8 +2841,6 @@ nsDocShell::GetParentWidget(nsIWidget ** parentWidget)
NS_IMETHODIMP
nsDocShell::SetParentWidget(nsIWidget * aParentWidget)
{
NS_ENSURE_STATE(!mContentViewer);
mParentWidget = aParentWidget;
return NS_OK;
@ -3960,6 +3964,7 @@ nsDocShell::CreateAboutBlankContentViewer()
// generate (about:blank) document to load
docFactory->CreateBlankDocument(loadGroup, getter_AddRefs(blankDoc));
if (blankDoc) {
blankDoc->SetContainer(NS_STATIC_CAST(nsIDocShell *, this));
// create a content viewer for us and the new document
docFactory->CreateInstanceForDocument(NS_ISUPPORTS_CAST(nsIDocShell *, this),
@ -4301,13 +4306,13 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer)
nsCOMPtr<nsIWidget> widget;
NS_ENSURE_SUCCESS(GetMainWidget(getter_AddRefs(widget)), NS_ERROR_FAILURE);
if (!widget) {
NS_ERROR("GetMainWidget coughed up a null widget");
return NS_ERROR_FAILURE;
if (widget) {
NS_ENSURE_SUCCESS(EnsureDeviceContext(), NS_ERROR_FAILURE);
}
nsRect bounds(x, y, cx, cy);
NS_ENSURE_SUCCESS(EnsureDeviceContext(), NS_ERROR_FAILURE);
if (NS_FAILED(mContentViewer->Init(widget, mDeviceContext, bounds))) {
mContentViewer = nsnull;
NS_ERROR("ContentViewer Initialization failed");
@ -4330,7 +4335,7 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer)
focusController->SetSuppressFocus(PR_FALSE,
"Win32-Only Link Traversal Issue");
if (bgSet) {
if (bgSet && widget) {
// Stuff the bgcolor from the last view manager into the new
// view manager. This improves page load continuity.
nsCOMPtr<nsIDocumentViewer> docviewer =

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

@ -1254,7 +1254,7 @@ NS_IMETHODIMP nsWebShell::Create()
// Set the webshell as the default IContentViewerContainer for the loader...
mDocLoader->SetContainer(shellAsContainer);
return nsDocShell::Create();
return nsDocShell::Create();
}
NS_IMETHODIMP nsWebShell::Destroy()

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

@ -46,6 +46,7 @@
#include "nsIDOMLocation.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsIDocument.h"
#include "nsIDOMElement.h"
class nsIDocShell;
class nsIDOMWindowInternal;
@ -66,7 +67,7 @@ public:
NS_IMETHOD GetObjectProperty(const PRUnichar* aProperty,
nsISupports** aObject) = 0;
// This is private because activate/deactivate events are not part
// of the DOM spec.
NS_IMETHOD Activate() = 0;
@ -84,6 +85,12 @@ public:
NS_IMETHOD GetExtantDocument(nsIDOMDocument** aDocument) = 0;
NS_IMETHOD ReallyCloseWindow() = 0;
// Internal getter/setter for the frame element, this version of the
// getter crosses chrome boundaries whereas the public scriptable
// one doesn't for security reasons.
NS_IMETHOD GetFrameElementInternal(nsIDOMElement** aFrameElement) = 0;
NS_IMETHOD SetFrameElementInternal(nsIDOMElement* aFrameElement) = 0;
};
#endif // nsPIDOMWindow_h__

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

@ -185,4 +185,6 @@ interface nsIDOMWindowInternal : nsIDOMWindow
// Ascii base64 data to binary data and vice versa...
DOMString atob(in DOMString aAsciiString);
DOMString btoa(in DOMString aBase64Data);
readonly attribute nsIDOMElement frameElement;
};

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

@ -185,7 +185,8 @@ GlobalWindowImpl::GlobalWindowImpl() :
mLastMouseButtonAction(LL_ZERO), mFullScreen(PR_FALSE),
mOriginalPos(nsnull), mOriginalSize(nsnull),
mGlobalObjectOwner(nsnull),
mDocShell(nsnull), mMutationBits(0), mChromeEventHandler(nsnull)
mDocShell(nsnull), mMutationBits(0), mChromeEventHandler(nsnull),
mFrameElement(nsnull)
{
NS_INIT_REFCNT();
// We could have failed the first time through trying
@ -716,6 +717,38 @@ GlobalWindowImpl::HandleDOMEvent(nsIPresContext* aPresContext,
}
}
if (aEvent->message == NS_PAGE_LOAD) {
nsCOMPtr<nsIContent> content(do_QueryInterface(mFrameElement));
nsCOMPtr<nsIDOMWindowInternal> parent;
GetParentInternal(getter_AddRefs(parent));
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(mDocShell));
PRInt32 itemType = nsIDocShellTreeItem::typeChrome;
if (treeItem) {
treeItem->GetItemType(&itemType);
}
if (content && parent && itemType != nsIDocShellTreeItem::typeChrome) {
// If we're not in chrome, or at a chrome boundary, fire the
// onload event for the frame element.
nsCOMPtr<nsIPresContext> ctx;
mDocShell->GetPresContext(getter_AddRefs(ctx));
NS_ENSURE_TRUE(ctx, NS_OK);
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_PAGE_LOAD;
return content->HandleDOMEvent(ctx, &event, nsnull, NS_EVENT_FLAG_INIT,
&status);
}
}
if (NS_EVENT_FLAG_INIT & aFlags) {
// We're leaving the DOM event loop so if we created an event,
@ -2813,6 +2846,53 @@ GlobalWindowImpl::ReallyCloseWindow()
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::GetFrameElement(nsIDOMElement** aFrameElement)
{
*aFrameElement = nsnull;
nsCOMPtr<nsIDocShell> docShell;
GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIDocShellTreeItem> docShellTI(do_QueryInterface(docShell));
if (!docShellTI) {
return NS_OK;
}
nsCOMPtr<nsIDocShellTreeItem> parent;
docShellTI->GetSameTypeParent(getter_AddRefs(parent));
if (!parent || parent == docShellTI) {
// We're at a chrome boundary, don't expose the chrome iframe
// element to content code.
return NS_OK;
}
*aFrameElement = mFrameElement;
NS_IF_ADDREF(*aFrameElement);
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::GetFrameElementInternal(nsIDOMElement** aFrameElement)
{
*aFrameElement = mFrameElement;
NS_IF_ADDREF(*aFrameElement);
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetFrameElementInternal(nsIDOMElement* aFrameElement)
{
mFrameElement = aFrameElement;
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::UpdateCommands(const nsAString& anAction)
{
@ -4772,6 +4852,7 @@ nsGlobalChromeWindow::GetWindowState(PRUint16* aWindowState)
break;
case nsSizeMode_Normal:
*aWindowState = nsIDOMChromeWindow::STATE_NORMAL;
break;
default:
NS_WARNING("Illegal window state for this chrome window");
break;

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

@ -188,6 +188,9 @@ public:
NS_IMETHOD ReallyCloseWindow();
NS_IMETHOD GetFrameElementInternal(nsIDOMElement** aFrameElement);
NS_IMETHOD SetFrameElementInternal(nsIDOMElement* aFrameElement);
// nsIDOMViewCSS
NS_DECL_NSIDOMVIEWCSS
@ -302,6 +305,8 @@ protected:
nsCOMPtr<nsIDOMPkcs11> mPkcs11;
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
nsIDOMElement* mFrameElement; // WEAK
friend class nsDOMScriptableHelper;
static nsIXPConnect *sXPConnect;
};

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

@ -151,9 +151,11 @@ nsresult nsJSEventListener::HandleEvent(nsIDOMEvent* aEvent)
nsEvent* event;
priv->GetInternalNSEvent(&event);
if (event->message == NS_SCRIPT_ERROR) {
nsScriptErrorEvent *scriptEvent = NS_STATIC_CAST(nsScriptErrorEvent*, event);
nsScriptErrorEvent *scriptEvent =
NS_STATIC_CAST(nsScriptErrorEvent*, event);
argv = ::JS_PushArguments(cx, &stackPtr, "WWi", scriptEvent->errorMsg,
scriptEvent->fileName, scriptEvent->lineNr);
scriptEvent->fileName, scriptEvent->lineNr);
NS_ENSURE_TRUE(argv, NS_ERROR_OUT_OF_MEMORY);
argc = 3;
handledScriptError = PR_TRUE;

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

@ -261,6 +261,8 @@ nsEditor::~nsEditor()
IMETextTxn::ClassShutdown();
PR_AtomicDecrement(&gInstanceCount);
NS_IF_RELEASE(mViewManager);
}
@ -304,7 +306,6 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell, nsIContent *aRoot
ps->GetViewManager(&mViewManager);
if (!mViewManager) {return NS_ERROR_NULL_POINTER;}
mViewManager->Release(); //we want a weak link
mUpdateCount=0;
InsertTextTxn::ClassInit();

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
@ -253,22 +253,12 @@ inLayoutUtils::GetSubDocumentFor(nsIDOMNode* aNode)
nsCOMPtr<nsIDocument> doc;
content->GetDocument(*getter_AddRefs(doc));
if (doc) {
nsCOMPtr<nsIPresShell> shell;
doc->GetShellAt(0, getter_AddRefs(shell));
if (shell) {
nsCOMPtr<nsISupports> supports;
shell->GetSubShellFor(content, getter_AddRefs(supports));
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(supports);
if (docShell) {
nsCOMPtr<nsIContentViewer> contentViewer;
docShell->GetContentViewer(getter_AddRefs(contentViewer));
if (contentViewer) {
nsCOMPtr<nsIDOMDocument> domdoc;
contentViewer->GetDOMDocument(getter_AddRefs(domdoc));
return domdoc;
}
}
}
nsCOMPtr<nsIDocument> sub_doc;
doc->GetSubDocumentFor(content, getter_AddRefs(sub_doc));
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(sub_doc));
return domdoc;
}
}
@ -279,6 +269,7 @@ nsIDOMNode*
inLayoutUtils::GetContainerFor(nsIDOMDocument* aDoc)
{
nsCOMPtr<nsIDOMNode> container;
nsCOMPtr<nsIDocument> doc(do_QueryInterface(aDoc));
// get the doc shell for this document and look for the parent doc shell
nsCOMPtr<nsIDOMWindowInternal> win = inLayoutUtils::GetWindowFor(aDoc);
@ -297,9 +288,17 @@ inLayoutUtils::GetContainerFor(nsIDOMDocument* aDoc)
nsCOMPtr<nsIPresShell> presShell;
parentDocShell->GetPresShell(getter_AddRefs(presShell));
nsCOMPtr<nsIContent> content;
presShell->FindContentForShell(docShell, getter_AddRefs(content));
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(content);
nsCOMPtr<nsIDocument> parent_doc;
presShell->GetDocument(getter_AddRefs(parent_doc));
nsCOMPtr<nsIDOMNode> node;
if (parent_doc) {
nsCOMPtr<nsIContent> content;
parent_doc->FindContentForSubDocument(doc, getter_AddRefs(content));
node = do_QueryInterface(content);
}
return node;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -265,28 +265,6 @@ public:
NS_IMETHOD GetLayoutObjectFor(nsIContent* aContent,
nsISupports** aResult) const = 0;
/**
* Returns the object that acts as a subshell for aContent.
* For example, for an html frame aResult will be an nsIDocShell.
*/
NS_IMETHOD GetSubShellFor(nsIContent* aContent,
nsISupports** aResult) const = 0;
/**
* Establish a relationship between aContent and aSubShell.
* aSubShell will be returned from GetSubShellFor(aContent, ...);
*/
NS_IMETHOD SetSubShellFor(nsIContent* aContent,
nsISupports* aSubShell) = 0;
/**
* Find the content in the map that has aSubShell set
* as its subshell. If there is more than one mapping for
* aSubShell, the result is undefined.
*/
NS_IMETHOD FindContentForShell(nsISupports* aSubShell,
nsIContent** aContent) const = 0;
/**
* Gets the placeholder frame associated with the specified frame. This is
* a helper frame that forwards the request to the frame manager.

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

@ -166,9 +166,6 @@
#include "nsIContentViewer.h"
#include "nsIDocumentViewer.h"
// SubShell map
#include "pldhash.h"
#ifdef IBMBIDI
#include "nsIBidiKeyboard.h"
#endif // IBMBIDI
@ -809,14 +806,6 @@ DummyLayoutRequest::Cancel(nsresult status)
// ----------------------------------------------------------------------------
class SubShellMapEntry : public PLDHashEntryHdr {
public:
nsIContent *key; // must be first, to look like PLDHashEntryStub
nsISupports *subShell;
};
// ----------------------------------------------------------------------------
class PresShell : public nsIPresShell, public nsIViewObserver,
private nsIDocumentObserver, public nsIFocusTracker,
public nsISelectionController,
@ -877,12 +866,6 @@ public:
nsIStyleContext** aStyleContext) const;
NS_IMETHOD GetLayoutObjectFor(nsIContent* aContent,
nsISupports** aResult) const;
NS_IMETHOD GetSubShellFor(nsIContent* aContent,
nsISupports** aResult) const;
NS_IMETHOD SetSubShellFor(nsIContent* aContent,
nsISupports* aSubShell);
NS_IMETHOD FindContentForShell(nsISupports* aSubShell,
nsIContent** aContent) const;
NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aPlaceholderFrame) const;
NS_IMETHOD AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand);
@ -1235,9 +1218,6 @@ protected:
static void sPaintSuppressionCallback(nsITimer* aTimer, void* aPresShell); // A callback for the timer.
// subshell map
PLDHashTable* mSubShellMap; // map of content/subshell pairs
MOZ_TIMER_DECLARE(mReflowWatch) // Used for measuring time spent in reflow
MOZ_TIMER_DECLARE(mFrameCreationWatch) // Used for measuring time spent in frame creation
@ -1675,13 +1655,6 @@ PresShell::Destroy()
// Clobber weak leaks in case of re-entrancy during tear down
mHistoryState = nsnull;
// kill subshell map, if any. It holds only weak references
if (mSubShellMap)
{
PL_DHashTableDestroy(mSubShellMap);
mSubShellMap = nsnull;
}
// release current event content and any content on event stack
NS_IF_RELEASE(mCurrentEventContent);
@ -5529,94 +5502,6 @@ PresShell::GetLayoutObjectFor(nsIContent* aContent,
return result;
}
NS_IMETHODIMP
PresShell::GetSubShellFor(nsIContent* aContent,
nsISupports** aResult) const
{
NS_ENSURE_ARG_POINTER(aContent);
if (mSubShellMap) {
SubShellMapEntry *entry = NS_STATIC_CAST(SubShellMapEntry*,
PL_DHashTableOperate(mSubShellMap, aContent, PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
NS_ADDREF(*aResult = entry->subShell);
return NS_OK;
}
}
*aResult = nsnull;
return NS_OK;
}
NS_IMETHODIMP
PresShell::SetSubShellFor(nsIContent* aContent,
nsISupports* aSubShell)
{
NS_ENSURE_ARG_POINTER(aContent);
// If aSubShell is NULL, then remove the mapping
if (!aSubShell) {
if (mSubShellMap)
PL_DHashTableOperate(mSubShellMap, aContent, PL_DHASH_REMOVE);
} else {
// Create a new hashtable if necessary
if (!mSubShellMap) {
mSubShellMap = PL_NewDHashTable(PL_DHashGetStubOps(), nsnull,
sizeof(SubShellMapEntry), 16);
if (!mSubShellMap)
return NS_ERROR_OUT_OF_MEMORY;
}
// Add a mapping to the hash table
SubShellMapEntry *entry = NS_STATIC_CAST(SubShellMapEntry*,
PL_DHashTableOperate(mSubShellMap, aContent, PL_DHASH_ADD));
entry->key = aContent;
entry->subShell = aSubShell;
}
return NS_OK;
}
struct FindContentData {
FindContentData(nsISupports *aSubShell)
: subShell(aSubShell), result(nsnull) {}
nsISupports *subShell;
nsIContent *result;
};
PR_STATIC_CALLBACK(PLDHashOperator)
FindContentEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)
{
SubShellMapEntry *entry = NS_STATIC_CAST(SubShellMapEntry*, hdr);
FindContentData *data = NS_STATIC_CAST(FindContentData*, arg);
if (entry->subShell == data->subShell) {
data->result = entry->key;
return PL_DHASH_STOP;
}
return PL_DHASH_NEXT;
}
NS_IMETHODIMP
PresShell::FindContentForShell(nsISupports* aSubShell,
nsIContent** aContent) const
{
NS_ENSURE_ARG_POINTER(aSubShell);
if (!mSubShellMap) {
*aContent = nsnull;
return NS_OK;
}
FindContentData data(aSubShell);
PL_DHashTableEnumerate(mSubShellMap, FindContentEnumerator, &data);
NS_IF_ADDREF(*aContent = data.result);
return NS_OK;
}
NS_IMETHODIMP
PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aResult) const

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

@ -265,28 +265,6 @@ public:
NS_IMETHOD GetLayoutObjectFor(nsIContent* aContent,
nsISupports** aResult) const = 0;
/**
* Returns the object that acts as a subshell for aContent.
* For example, for an html frame aResult will be an nsIDocShell.
*/
NS_IMETHOD GetSubShellFor(nsIContent* aContent,
nsISupports** aResult) const = 0;
/**
* Establish a relationship between aContent and aSubShell.
* aSubShell will be returned from GetSubShellFor(aContent, ...);
*/
NS_IMETHOD SetSubShellFor(nsIContent* aContent,
nsISupports* aSubShell) = 0;
/**
* Find the content in the map that has aSubShell set
* as its subshell. If there is more than one mapping for
* aSubShell, the result is undefined.
*/
NS_IMETHOD FindContentForShell(nsISupports* aSubShell,
nsIContent** aContent) const = 0;
/**
* Gets the placeholder frame associated with the specified frame. This is
* a helper frame that forwards the request to the frame manager.

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

@ -416,6 +416,8 @@ nsContentDLF::CreateDocument(const char* aCommand,
break;
docv->SetUAStyleSheet(gUAStyleSheet);
doc->SetContainer(aContainer);
// Initialize the document to begin loading the data. An
// nsIStreamListener connected to the parser is returned in
// aDocListener.
@ -512,6 +514,9 @@ nsContentDLF::CreateRDFDocument(const char* aCommand,
* An nsIStreamListener connected to the parser is returned in
* aDocListener.
*/
doc->SetContainer(aContainer);
rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener, PR_TRUE);
if (NS_SUCCEEDED(rv)) {
/*

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -63,7 +63,6 @@
#define ALL_VIS 0x000F
#define NONE_VIS 0x0000
static NS_DEFINE_IID(kIFramesetFrameIID, NS_IFRAMESETFRAME_IID);
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
/*******************************************************************************
@ -252,7 +251,7 @@ nsresult nsHTMLFramesetFrame::QueryInterface(const nsIID& aIID,
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
} else if (aIID.Equals(kIFramesetFrameIID)) {
} else if (aIID.Equals(NS_GET_IID(nsHTMLFramesetFrame))) {
*aInstancePtr = (void*)this;
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIObserver))) {
@ -327,7 +326,8 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext,
mTopLevelFrameset = (nsHTMLFramesetFrame*)this;
while (parentFrame) {
nsHTMLFramesetFrame* frameset;
rv = parentFrame->QueryInterface(kIFramesetFrameIID, (void**)&frameset);
rv = parentFrame->QueryInterface(NS_GET_IID(nsHTMLFramesetFrame),
(void**)&frameset);
if (NS_SUCCEEDED(rv)) {
mTopLevelFrameset = frameset;
parentFrame->GetParent((nsIFrame**)&parentFrame);
@ -1404,7 +1404,7 @@ PRBool
nsHTMLFramesetFrame::ChildIsFrameset(nsIFrame* aChild)
{
nsIFrame* childFrame = nsnull;
aChild->QueryInterface(kIFramesetFrameIID, (void**)&childFrame);
aChild->QueryInterface(NS_GET_IID(nsHTMLFramesetFrame), (void**)&childFrame);
if (childFrame) {
return PR_TRUE;
}

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

@ -57,7 +57,8 @@ struct nsGUIEvent;
class nsHTMLFramesetFrame;
#define NS_IFRAMESETFRAME_IID \
{ 0xf47deac0, 0x4200, 0x11d2, { 0x80, 0x3c, 0x0, 0x60, 0x8, 0x15, 0xa7, 0x91 } }
{ 0xf47deac0, 0x4200, 0x11d2, \
{ 0x80, 0x3c, 0x0, 0x60, 0x8, 0x15, 0xa7, 0x91 } }
#define NO_COLOR 0xFFFFFFFA
@ -115,8 +116,10 @@ struct nsFramesetDrag {
class nsHTMLFramesetFrame : public nsHTMLContainerFrame,
public nsIObserver
{
public:
// Woohoo, concrete class with an IID!
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAMESETFRAME_IID)
nsHTMLFramesetFrame();
virtual ~nsHTMLFramesetFrame();

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

@ -166,9 +166,6 @@
#include "nsIContentViewer.h"
#include "nsIDocumentViewer.h"
// SubShell map
#include "pldhash.h"
#ifdef IBMBIDI
#include "nsIBidiKeyboard.h"
#endif // IBMBIDI
@ -809,14 +806,6 @@ DummyLayoutRequest::Cancel(nsresult status)
// ----------------------------------------------------------------------------
class SubShellMapEntry : public PLDHashEntryHdr {
public:
nsIContent *key; // must be first, to look like PLDHashEntryStub
nsISupports *subShell;
};
// ----------------------------------------------------------------------------
class PresShell : public nsIPresShell, public nsIViewObserver,
private nsIDocumentObserver, public nsIFocusTracker,
public nsISelectionController,
@ -877,12 +866,6 @@ public:
nsIStyleContext** aStyleContext) const;
NS_IMETHOD GetLayoutObjectFor(nsIContent* aContent,
nsISupports** aResult) const;
NS_IMETHOD GetSubShellFor(nsIContent* aContent,
nsISupports** aResult) const;
NS_IMETHOD SetSubShellFor(nsIContent* aContent,
nsISupports* aSubShell);
NS_IMETHOD FindContentForShell(nsISupports* aSubShell,
nsIContent** aContent) const;
NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aPlaceholderFrame) const;
NS_IMETHOD AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand);
@ -1235,9 +1218,6 @@ protected:
static void sPaintSuppressionCallback(nsITimer* aTimer, void* aPresShell); // A callback for the timer.
// subshell map
PLDHashTable* mSubShellMap; // map of content/subshell pairs
MOZ_TIMER_DECLARE(mReflowWatch) // Used for measuring time spent in reflow
MOZ_TIMER_DECLARE(mFrameCreationWatch) // Used for measuring time spent in frame creation
@ -1675,13 +1655,6 @@ PresShell::Destroy()
// Clobber weak leaks in case of re-entrancy during tear down
mHistoryState = nsnull;
// kill subshell map, if any. It holds only weak references
if (mSubShellMap)
{
PL_DHashTableDestroy(mSubShellMap);
mSubShellMap = nsnull;
}
// release current event content and any content on event stack
NS_IF_RELEASE(mCurrentEventContent);
@ -5529,94 +5502,6 @@ PresShell::GetLayoutObjectFor(nsIContent* aContent,
return result;
}
NS_IMETHODIMP
PresShell::GetSubShellFor(nsIContent* aContent,
nsISupports** aResult) const
{
NS_ENSURE_ARG_POINTER(aContent);
if (mSubShellMap) {
SubShellMapEntry *entry = NS_STATIC_CAST(SubShellMapEntry*,
PL_DHashTableOperate(mSubShellMap, aContent, PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
NS_ADDREF(*aResult = entry->subShell);
return NS_OK;
}
}
*aResult = nsnull;
return NS_OK;
}
NS_IMETHODIMP
PresShell::SetSubShellFor(nsIContent* aContent,
nsISupports* aSubShell)
{
NS_ENSURE_ARG_POINTER(aContent);
// If aSubShell is NULL, then remove the mapping
if (!aSubShell) {
if (mSubShellMap)
PL_DHashTableOperate(mSubShellMap, aContent, PL_DHASH_REMOVE);
} else {
// Create a new hashtable if necessary
if (!mSubShellMap) {
mSubShellMap = PL_NewDHashTable(PL_DHashGetStubOps(), nsnull,
sizeof(SubShellMapEntry), 16);
if (!mSubShellMap)
return NS_ERROR_OUT_OF_MEMORY;
}
// Add a mapping to the hash table
SubShellMapEntry *entry = NS_STATIC_CAST(SubShellMapEntry*,
PL_DHashTableOperate(mSubShellMap, aContent, PL_DHASH_ADD));
entry->key = aContent;
entry->subShell = aSubShell;
}
return NS_OK;
}
struct FindContentData {
FindContentData(nsISupports *aSubShell)
: subShell(aSubShell), result(nsnull) {}
nsISupports *subShell;
nsIContent *result;
};
PR_STATIC_CALLBACK(PLDHashOperator)
FindContentEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)
{
SubShellMapEntry *entry = NS_STATIC_CAST(SubShellMapEntry*, hdr);
FindContentData *data = NS_STATIC_CAST(FindContentData*, arg);
if (entry->subShell == data->subShell) {
data->result = entry->key;
return PL_DHASH_STOP;
}
return PL_DHASH_NEXT;
}
NS_IMETHODIMP
PresShell::FindContentForShell(nsISupports* aSubShell,
nsIContent** aContent) const
{
NS_ENSURE_ARG_POINTER(aSubShell);
if (!mSubShellMap) {
*aContent = nsnull;
return NS_OK;
}
FindContentData data(aSubShell);
PL_DHashTableEnumerate(mSubShellMap, FindContentEnumerator, &data);
NS_IF_ADDREF(*aContent = data.result);
return NS_OK;
}
NS_IMETHODIMP
PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aResult) const

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -63,7 +63,6 @@
#define ALL_VIS 0x000F
#define NONE_VIS 0x0000
static NS_DEFINE_IID(kIFramesetFrameIID, NS_IFRAMESETFRAME_IID);
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
/*******************************************************************************
@ -252,7 +251,7 @@ nsresult nsHTMLFramesetFrame::QueryInterface(const nsIID& aIID,
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
} else if (aIID.Equals(kIFramesetFrameIID)) {
} else if (aIID.Equals(NS_GET_IID(nsHTMLFramesetFrame))) {
*aInstancePtr = (void*)this;
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIObserver))) {
@ -327,7 +326,8 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext,
mTopLevelFrameset = (nsHTMLFramesetFrame*)this;
while (parentFrame) {
nsHTMLFramesetFrame* frameset;
rv = parentFrame->QueryInterface(kIFramesetFrameIID, (void**)&frameset);
rv = parentFrame->QueryInterface(NS_GET_IID(nsHTMLFramesetFrame),
(void**)&frameset);
if (NS_SUCCEEDED(rv)) {
mTopLevelFrameset = frameset;
parentFrame->GetParent((nsIFrame**)&parentFrame);
@ -1404,7 +1404,7 @@ PRBool
nsHTMLFramesetFrame::ChildIsFrameset(nsIFrame* aChild)
{
nsIFrame* childFrame = nsnull;
aChild->QueryInterface(kIFramesetFrameIID, (void**)&childFrame);
aChild->QueryInterface(NS_GET_IID(nsHTMLFramesetFrame), (void**)&childFrame);
if (childFrame) {
return PR_TRUE;
}

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

@ -57,7 +57,8 @@ struct nsGUIEvent;
class nsHTMLFramesetFrame;
#define NS_IFRAMESETFRAME_IID \
{ 0xf47deac0, 0x4200, 0x11d2, { 0x80, 0x3c, 0x0, 0x60, 0x8, 0x15, 0xa7, 0x91 } }
{ 0xf47deac0, 0x4200, 0x11d2, \
{ 0x80, 0x3c, 0x0, 0x60, 0x8, 0x15, 0xa7, 0x91 } }
#define NO_COLOR 0xFFFFFFFA
@ -115,8 +116,10 @@ struct nsFramesetDrag {
class nsHTMLFramesetFrame : public nsHTMLContainerFrame,
public nsIObserver
{
public:
// Woohoo, concrete class with an IID!
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAMESETFRAME_IID)
nsHTMLFramesetFrame();
virtual ~nsHTMLFramesetFrame();

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

@ -2657,7 +2657,7 @@ CSSStyleSheetImpl::SetDisabled(PRBool aDisabled)
PRBool oldState = mDisabled;
mDisabled = aDisabled;
if ((nsnull != mDocument) && (mDisabled != oldState)) {
if (mDocument && (mDisabled != oldState)) {
mDocument->SetStyleSheetDisabledState(this, mDisabled);
}

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

@ -38,9 +38,9 @@
#include "nsCOMPtr.h"
#include "nsIBrowserBoxObject.h"
#include "nsBoxObject.h"
#include "nsIPresShell.h"
#include "nsIFrame.h"
#include "nsIDocShell.h"
#include "nsIDocument.h"
#include "nsXPIDLString.h"
class nsBrowserBoxObject : public nsIBrowserBoxObject, public nsBoxObject
@ -91,15 +91,27 @@ nsBrowserBoxObject::~nsBrowserBoxObject()
NS_IMETHODIMP nsBrowserBoxObject::GetDocShell(nsIDocShell** aResult)
{
*aResult = nsnull;
if (!mPresShell)
return NS_OK;
nsCOMPtr<nsISupports> subShell;
mPresShell->GetSubShellFor(mContent, getter_AddRefs(subShell));
if(!subShell)
return NS_OK;
nsCOMPtr<nsIDocument> doc, sub_doc;
mPresShell->GetDocument(getter_AddRefs(doc));
return CallQueryInterface(subShell, aResult); //Addref happens here.
doc->GetSubDocumentFor(mContent, getter_AddRefs(sub_doc));
if (!sub_doc) {
return NS_OK;
}
nsCOMPtr<nsISupports> container;
sub_doc->GetContainer(getter_AddRefs(container));
if (!container) {
return NS_OK;
}
return CallQueryInterface(container, aResult);
}
// Creation Routine ///////////////////////////////////////////////////////////////////////

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

@ -38,7 +38,7 @@
#include "nsCOMPtr.h"
#include "nsIEditorBoxObject.h"
#include "nsBoxObject.h"
#include "nsIPresShell.h"
#include "nsIDocument.h"
#include "nsIFrame.h"
#include "nsIEditorShell.h"
#include "nsIComponentManager.h"
@ -128,15 +128,27 @@ NS_IMETHODIMP nsEditorBoxObject::GetEditorShell(nsIEditorShell** aResult)
NS_IMETHODIMP nsEditorBoxObject::GetDocShell(nsIDocShell** aResult)
{
*aResult = nsnull;
if (!mPresShell)
return NS_OK;
nsCOMPtr<nsISupports> subShell;
mPresShell->GetSubShellFor(mContent, getter_AddRefs(subShell));
if(!subShell)
return NS_OK;
nsCOMPtr<nsIDocument> doc, sub_doc;
mPresShell->GetDocument(getter_AddRefs(doc));
return CallQueryInterface(subShell, aResult); //Addref happens here.
doc->GetSubDocumentFor(mContent, getter_AddRefs(sub_doc));
if (!sub_doc) {
return NS_OK;
}
nsCOMPtr<nsISupports> container;
sub_doc->GetContainer(getter_AddRefs(container));
if (!container) {
return NS_OK;
}
return CallQueryInterface(container, aResult);
}
// Creation Routine ///////////////////////////////////////////////////////////////////////

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

@ -38,6 +38,7 @@
#include "nsCOMPtr.h"
#include "nsIIFrameBoxObject.h"
#include "nsBoxObject.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIFrame.h"
#include "nsIDocShell.h"
@ -87,15 +88,27 @@ nsIFrameBoxObject::~nsIFrameBoxObject()
NS_IMETHODIMP nsIFrameBoxObject::GetDocShell(nsIDocShell** aResult)
{
*aResult = nsnull;
if (!mPresShell)
return NS_OK;
nsCOMPtr<nsISupports> subShell;
mPresShell->GetSubShellFor(mContent, getter_AddRefs(subShell));
if(!subShell)
return NS_OK;
nsCOMPtr<nsIDocument> doc, sub_doc;
mPresShell->GetDocument(getter_AddRefs(doc));
return CallQueryInterface(subShell, aResult); //Addref happens here.
doc->GetSubDocumentFor(mContent, getter_AddRefs(sub_doc));
if (!sub_doc) {
return NS_OK;
}
nsCOMPtr<nsISupports> container;
sub_doc->GetContainer(getter_AddRefs(container));
if (!container) {
return NS_OK;
}
return CallQueryInterface(container, aResult);
}
// Creation Routine ///////////////////////////////////////////////////////////////////////

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
@ -804,7 +804,7 @@ nsDocLoaderImpl::GetDOMWindow(nsIDOMWindow **aResult)
*aResult = window;
NS_IF_ADDREF(*aResult);
} else {
rv = NS_ERROR_FAILURE;
rv = NS_ERROR_FAILURE;
}
return rv;