зеркало из https://github.com/mozilla/gecko-dev.git
Checking in the fix for bug 52334 for the third time. This time it should stick! Making iframe's load their document even if they're not displayed. r=jkeiser@netscape.com, sr=rpotts@netscape.com.
This commit is contained in:
Родитель
94ee4b573d
Коммит
cd9afd67e1
|
@ -132,17 +132,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)
|
||||
|
@ -168,17 +179,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,46 +257,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,4 +27,5 @@ nsIStyleSheet.h
|
|||
nsIStyleSheetLinkingElement.h
|
||||
nsITextContent.h
|
||||
nsIContentList.h
|
||||
nsIFrameLoader.h
|
||||
mozISanitizingSerializer.h
|
||||
|
|
|
@ -57,6 +57,7 @@ nsIContentSerializer.h \
|
|||
nsIHTMLToTextSink.h \
|
||||
mozISanitizingSerializer.h \
|
||||
nsIContentList.h \
|
||||
nsIFrameLoader.h \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
|
|
|
@ -49,6 +49,7 @@ EXPORTS = \
|
|||
nsIHTMLToTextSink.h \
|
||||
mozISanitizingSerializer.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,46 @@ 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;
|
||||
|
||||
/**
|
||||
* Tells whether or not the loader started loading a document.
|
||||
*/
|
||||
NS_IMETHOD GetIsDocumentLoading(PRBool *aIsDocumentLoading) = 0;
|
||||
|
||||
/**
|
||||
* Destroy the frame loader and everything inside it. This will
|
||||
* clear the weak owner content reference. */
|
||||
NS_IMETHOD Destroy() = 0;
|
||||
};
|
||||
|
||||
|
@ -78,6 +106,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;
|
||||
};
|
||||
|
||||
|
|
|
@ -56,8 +56,8 @@ REQUIRES = xpcom \
|
|||
imglib2 \
|
||||
gfx2 \
|
||||
uriloader \
|
||||
webbrwsr \
|
||||
webBrowser_core \
|
||||
webbrwsr \
|
||||
webBrowser_core \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
@ -99,9 +99,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 \
|
||||
|
@ -69,10 +70,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 \
|
||||
|
@ -80,7 +81,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 \
|
||||
|
@ -92,13 +93,14 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsTreeWalker.obj \
|
||||
.\$(OBJDIR)\nsXMLContentSerializer.obj \
|
||||
.\$(OBJDIR)\nsHTMLContentSerializer.obj \
|
||||
.\$(OBJDIR)\nsParserUtils.obj \
|
||||
.\$(OBJDIR)\nsPlainTextSerializer.obj \
|
||||
.\$(OBJDIR)\mozSanitizingSerializer.obj \
|
||||
.\$(OBJDIR)\nsContentUtils.obj \
|
||||
.\$(OBJDIR)\nsScriptLoader.obj \
|
||||
.\$(OBJDIR)\nsStyleLinkElement.obj \
|
||||
.\$(OBJDIR)\nsContentAreaDragDrop.obj \
|
||||
.\$(OBJDIR)\nsParserUtils.obj \
|
||||
.\$(OBJDIR)\nsPlainTextSerializer.obj \
|
||||
.\$(OBJDIR)\mozSanitizingSerializer.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 \
|
||||
|
|
|
@ -178,7 +178,7 @@ NS_IMPL_RELEASE(nsDOMStyleSheetList)
|
|||
NS_IMETHODIMP
|
||||
nsDOMStyleSheetList::GetLength(PRUint32* aLength)
|
||||
{
|
||||
if (nsnull != mDocument) {
|
||||
if (mDocument) {
|
||||
// XXX Find the number and then cache it. We'll use the
|
||||
// observer notification to figure out if new ones have
|
||||
// been added or removed.
|
||||
|
@ -473,7 +473,7 @@ NS_IMPL_RELEASE_USING_AGGREGATOR(nsXPathDocumentTearoff, mDocument)
|
|||
// ==================================================================
|
||||
|
||||
nsDocument::nsDocument() : mIsGoingAway(PR_FALSE),
|
||||
mCSSLoader(nsnull),
|
||||
mCSSLoader(nsnull), mSubDocuments(nsnull),
|
||||
mXPathDocument(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
@ -505,6 +505,7 @@ nsDocument::nsDocument() : mIsGoingAway(PR_FALSE),
|
|||
mObservers.InsertElementAt(observer, 0);
|
||||
}
|
||||
|
||||
|
||||
nsDocument::~nsDocument()
|
||||
{
|
||||
delete mXPathDocument;
|
||||
|
@ -532,11 +533,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) {
|
||||
|
@ -723,25 +725,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);
|
||||
|
@ -775,8 +780,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)
|
||||
|
@ -1211,26 +1217,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;
|
||||
}
|
||||
|
@ -1792,23 +1923,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2197,8 +2323,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;
|
||||
|
@ -3523,6 +3649,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
|
||||
|
|
|
@ -70,6 +70,8 @@
|
|||
#include "nsICSSLoader.h"
|
||||
#include "nsIDOMXPathEvaluator.h"
|
||||
|
||||
#include "pldhash.h"
|
||||
|
||||
class nsIEventListenerManager;
|
||||
class nsDOMStyleSheetList;
|
||||
class nsIOutputStream;
|
||||
|
@ -214,6 +216,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
|
||||
|
@ -369,9 +394,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.
|
||||
|
@ -494,6 +521,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
|
||||
|
@ -575,13 +604,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 8
|
||||
|
||||
|
||||
class nsFrameLoader : public nsIFrameLoader
|
||||
{
|
||||
public:
|
||||
nsFrameLoader();
|
||||
|
@ -79,26 +84,22 @@ 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 GetIsDocumentLoading(PRBool* aIsDocumentLoading);
|
||||
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;
|
||||
nsIContent *mOwnerContent; // WEAK
|
||||
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
PRBool mIsLoadStarted;
|
||||
};
|
||||
|
||||
nsresult
|
||||
|
@ -112,26 +113,22 @@ NS_NewFrameLoader(nsIFrameLoader **aFrameLoader)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsFrameLoader::nsFrameLoader()
|
||||
: mOwnerContent(nsnull), mIsLoadStarted(PR_FALSE)
|
||||
{
|
||||
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 +136,51 @@ 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));
|
||||
if (!doc) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// 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,33 +218,25 @@ 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");
|
||||
|
||||
mIsLoadStarted = NS_SUCCEEDED(rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -239,14 +252,35 @@ nsFrameLoader::GetDocShell(nsIDocShell **aDocShell)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::Destroy()
|
||||
nsFrameLoader::GetIsDocumentLoading(PRBool* aIsDocumentLoading)
|
||||
{
|
||||
*aIsDocumentLoading = mIsLoadStarted;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::HandleEvent(nsIDOMEvent *aEvent)
|
||||
nsFrameLoader::Destroy()
|
||||
{
|
||||
if (mOwnerContent) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
|
||||
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 +290,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 +319,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 =
|
||||
|
@ -305,8 +336,11 @@ nsFrameLoader::EnsureDocShell()
|
|||
while (parentAsItem) {
|
||||
++depth;
|
||||
|
||||
if (MAX_DEPTH_CONTENT_FRAMES < depth)
|
||||
if (MAX_DEPTH_CONTENT_FRAMES < depth) {
|
||||
NS_WARNING("Too many nested content frames so giving up");
|
||||
|
||||
return NS_ERROR_UNEXPECTED; // Too deep, give up! (silently?)
|
||||
}
|
||||
|
||||
// Only count depth on content, not chrome.
|
||||
// If we wanted to limit total depth, skip the following check:
|
||||
|
@ -321,32 +355,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 +374,147 @@ 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
|
||||
|
||||
|
||||
|
||||
|
||||
// string iterators!
|
||||
|
||||
|
||||
value.Left(valuePiece, 7);
|
||||
if (valuePiece.EqualsIgnoreCase("content") &&
|
||||
(value.Length() == 7 ||
|
||||
value.Mid(valuePiece, 7, 1) == 1 &&
|
||||
valuePiece.EqualsWithConversion("-"))) {
|
||||
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 (mOwnerContent->IsContentOfType(nsIContent::eXUL)) {
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// Lowercase the value, ContentShellAdded() further down relies
|
||||
// on it being lowercased.
|
||||
ToLowerCase(value);
|
||||
|
||||
nsAutoString::const_iterator start, end;
|
||||
value.BeginReading(start);
|
||||
value.EndReading(end);
|
||||
|
||||
nsAutoString::const_iterator iter(start);
|
||||
iter.advance(7);
|
||||
|
||||
const nsAString& valuePiece = Substring(start, iter);
|
||||
|
||||
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.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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1634,8 +1634,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
|
||||
|
|
|
@ -56,6 +56,9 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsPrintPreviewListener(nsIDOMEventReceiver* aEVRec);
|
||||
virtual ~nsPrintPreviewListener()
|
||||
{
|
||||
}
|
||||
|
||||
// nsIDOMContextMenuListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
|
|
@ -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 "mozSanitizingSerializer.h"
|
||||
|
@ -276,6 +277,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);
|
||||
|
@ -348,6 +350,7 @@ MAKE_CTOR(CreateSanitizingHTMLSerializer, nsIContentSerializer, NS_NewSan
|
|||
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
|
||||
|
@ -742,6 +745,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,
|
||||
|
|
|
@ -1511,7 +1511,7 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
|
|||
|
||||
rv = GetParentScrollingView(msEvent, aPresContext, newFrame,
|
||||
*getter_AddRefs(newPresContext));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_SUCCEEDED(rv) && newFrame)
|
||||
return DoWheelScroll(newPresContext, newFrame, msEvent, numLines,
|
||||
scrollPage, PR_TRUE);
|
||||
else
|
||||
|
@ -1527,41 +1527,40 @@ nsEventStateManager::GetParentScrollingView(nsMouseScrollEvent *aEvent,
|
|||
nsIFrame* &targetOuterFrame,
|
||||
nsIPresContext* &presCtxOuter)
|
||||
{
|
||||
targetOuterFrame = nsnull;
|
||||
|
||||
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,
|
||||
|
@ -1569,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 +2745,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 +2838,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 +2940,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;
|
||||
|
@ -4619,6 +4637,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));
|
||||
|
@ -4626,12 +4652,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 \
|
||||
|
|
|
@ -1237,22 +1237,19 @@ PRBool
|
|||
nsGenericHTMLElement::InNavQuirksMode(nsIDocument* aDoc)
|
||||
{
|
||||
PRBool status = PR_FALSE;
|
||||
if (aDoc) {
|
||||
nsCompatibility mode;
|
||||
// multiple shells on the same doc are out of luck
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
aDoc->GetShellAt(0, getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
shell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (presContext) {
|
||||
presContext->GetCompatibilityMode(&mode);
|
||||
if (eCompatibility_NavQuirks == mode) {
|
||||
status = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHTMLDocument> doc(do_QueryInterface(aDoc));
|
||||
|
||||
if (doc) {
|
||||
nsDTDMode mode;
|
||||
|
||||
doc->GetDTDMode(mode);
|
||||
|
||||
if (mode == eDTDMode_quirks) {
|
||||
status = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -2314,12 +2311,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;
|
||||
}
|
||||
|
||||
|
@ -3704,17 +3701,20 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(const nsIHTMLMappedAttributes*
|
|||
getter_AddRefs(docURL));
|
||||
rv = NS_MakeAbsoluteURI(absURLSpec, spec, docURL);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
aData->mColorData->mBackImage.SetStringValue(absURLSpec, eCSSUnit_URL);
|
||||
aData->mColorData->mBackImage.SetStringValue(absURLSpec,
|
||||
eCSSUnit_URL);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (aData->mPresContext) {
|
||||
// in NavQuirks mode, allow the empty string to set the background to empty
|
||||
// in NavQuirks mode, allow the empty string to set the
|
||||
// background to empty
|
||||
nsCompatibility mode;
|
||||
aData->mPresContext->GetCompatibilityMode(&mode);
|
||||
if (eCompatibility_NavQuirks == mode &&
|
||||
eHTMLUnit_Empty == value.GetUnit())
|
||||
aData->mColorData->mBackImage.SetStringValue(NS_LITERAL_STRING(""), eCSSUnit_URL);
|
||||
aData->mColorData->mBackImage.SetStringValue(NS_LITERAL_STRING(""),
|
||||
eCSSUnit_URL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4554,32 +4554,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
|
||||
|
|
|
@ -308,8 +308,8 @@ static nsGenericHTMLElement::EnumTable kCellScopeTable[] = {
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
const nsAString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
/* ignore these attributes, stored simply as strings
|
||||
abbr, axis, ch, headers
|
||||
|
@ -379,8 +379,8 @@ nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableCellElement::AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsAString& aResult) const
|
||||
const nsHTMLValue& aValue,
|
||||
nsAString& aResult) const
|
||||
{
|
||||
/* ignore these attributes, stored already as strings
|
||||
abbr, axis, ch, headers
|
||||
|
@ -409,7 +409,8 @@ nsHTMLTableCellElement::AttributeToString(nsIAtom* aAttribute,
|
|||
}
|
||||
|
||||
static
|
||||
void MapAttributesIntoRule(const nsIHTMLMappedAttributes* aAttributes, nsRuleData* aData)
|
||||
void MapAttributesIntoRule(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsRuleData* aData)
|
||||
{
|
||||
if (!aAttributes || !aData)
|
||||
return;
|
||||
|
|
|
@ -1512,7 +1512,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);
|
||||
|
||||
|
@ -1614,7 +1614,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();
|
||||
}
|
||||
|
@ -3848,43 +3849,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3892,48 +3907,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;
|
||||
|
@ -4180,7 +4196,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);
|
||||
|
|
|
@ -416,28 +416,15 @@ nsHTMLDocument::Init()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
nsresult result = nsDocument::Reset(aChannel, aLoadGroup);
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
|
||||
if (aChannel) {
|
||||
result = aChannel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
}
|
||||
|
||||
return BaseResetToURI(aURL);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup)
|
||||
{
|
||||
nsresult result = nsDocument::ResetToURI(aURI, aLoadGroup);
|
||||
|
||||
if (NS_SUCCEEDED(result))
|
||||
result = BaseResetToURI(aURI);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -469,7 +456,7 @@ nsHTMLDocument::BaseResetToURI(nsIURI *aURL)
|
|||
NS_GET_IID(nsIHTMLStyleSheet),
|
||||
(void**)&mAttrStyleSheet);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = mAttrStyleSheet->Init(aURL,this);
|
||||
result = mAttrStyleSheet->Init(aURL, this);
|
||||
if (NS_FAILED(result)) {
|
||||
NS_RELEASE(mAttrStyleSheet);
|
||||
}
|
||||
|
@ -1479,7 +1466,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
|
||||
|
@ -3777,34 +3764,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;
|
||||
|
|
|
@ -85,7 +85,6 @@ public:
|
|||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
NS_IMETHOD Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup);
|
||||
NS_IMETHOD ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup);
|
||||
|
||||
NS_IMETHOD CreateShell(nsIPresContext* aContext,
|
||||
|
|
|
@ -2637,7 +2637,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>
|
||||
|
@ -3452,6 +3459,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>
|
||||
|
@ -5811,6 +5823,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>
|
||||
|
@ -6953,6 +6972,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>
|
||||
|
@ -7286,6 +7310,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>
|
||||
<FILEREF>
|
||||
<TARGETNAME>content.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1166,6 +1166,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;
|
||||
}
|
||||
|
||||
|
@ -2449,7 +2457,6 @@ nsDocShell::Stop(PRUint32 aStopFlags)
|
|||
if (nsIWebNavigation::STOP_CONTENT & aStopFlags) {
|
||||
if (mContentViewer)
|
||||
mContentViewer->Stop();
|
||||
|
||||
}
|
||||
|
||||
if (nsIWebNavigation::STOP_NETWORK & aStopFlags) {
|
||||
|
@ -2658,7 +2665,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);
|
||||
|
@ -2843,10 +2849,17 @@ nsDocShell::GetParentWidget(nsIWidget ** parentWidget)
|
|||
NS_IMETHODIMP
|
||||
nsDocShell::SetParentWidget(nsIWidget * aParentWidget)
|
||||
{
|
||||
NS_ENSURE_STATE(!mContentViewer);
|
||||
|
||||
mParentWidget = aParentWidget;
|
||||
|
||||
if (!mParentWidget) {
|
||||
// If the parent widget is set to null we don't want to hold
|
||||
// on to the current device context any more since it is
|
||||
// associated with the parent widget we no longer own. We'll
|
||||
// need to create a new device context if one is needed again.
|
||||
|
||||
mDeviceContext = nsnull;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2914,12 +2927,22 @@ nsDocShell::GetVisibility(PRBool * aVisibility)
|
|||
nsCOMPtr<nsIDocShellTreeItem> parentItem;
|
||||
treeItem->GetParent(getter_AddRefs(parentItem));
|
||||
while (parentItem) {
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(treeItem));
|
||||
docShell->GetPresShell(getter_AddRefs(presShell));
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
presShell->GetDocument(getter_AddRefs(doc));
|
||||
|
||||
nsCOMPtr<nsIDocShell> parentDS = do_QueryInterface(parentItem);
|
||||
nsCOMPtr<nsIPresShell> pPresShell;
|
||||
parentDS->GetPresShell(getter_AddRefs(pPresShell));
|
||||
|
||||
nsCOMPtr<nsIDocument> pDoc;
|
||||
pPresShell->GetDocument(getter_AddRefs(pDoc));
|
||||
|
||||
nsCOMPtr<nsIContent> shellContent;
|
||||
nsCOMPtr<nsISupports> shellISupports = do_QueryInterface(treeItem);
|
||||
pPresShell->FindContentForShell(shellISupports, getter_AddRefs(shellContent));
|
||||
pDoc->FindContentForSubDocument(doc, getter_AddRefs(shellContent));
|
||||
NS_ASSERTION(shellContent, "subshell not in the map");
|
||||
|
||||
nsIFrame* frame;
|
||||
|
@ -4016,6 +4039,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),
|
||||
|
@ -4357,13 +4381,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");
|
||||
|
@ -4386,7 +4410,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;
|
||||
|
@ -85,6 +86,12 @@ public:
|
|||
|
||||
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;
|
||||
|
||||
NS_IMETHOD IsLoadingOrRunningTimeout(PRBool* aResult) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -229,7 +229,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
|
||||
|
@ -760,6 +761,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,
|
||||
|
@ -868,10 +901,11 @@ GlobalWindowImpl::GetPrincipal(nsIPrincipal** result)
|
|||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetDocument(nsIDOMDocument** aDocument)
|
||||
{
|
||||
/* lazily instantiate an about:blank document if necessary, and if we have
|
||||
what it takes to do so. Note that domdoc here is the same thing as
|
||||
our mDocument, but we don't have to explicitly set the member variable
|
||||
because the docshell has already called SetNewDocument(). */
|
||||
// lazily instantiate an about:blank document if necessary, and if
|
||||
// we have what it takes to do so. Note that domdoc here is the same
|
||||
// thing as our mDocument, but we don't have to explicitly set the
|
||||
// member variable because the docshell has already called
|
||||
// SetNewDocument().
|
||||
if (!mDocument && mDocShell)
|
||||
nsCOMPtr<nsIDOMDocument> domdoc(do_GetInterface(mDocShell));
|
||||
|
||||
|
@ -2984,6 +3018,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::IsLoadingOrRunningTimeout(PRBool* aResult)
|
||||
{
|
||||
|
@ -4950,6 +5031,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;
|
||||
|
|
|
@ -189,6 +189,9 @@ public:
|
|||
NS_IMETHOD ReallyCloseWindow();
|
||||
NS_IMETHOD IsLoadingOrRunningTimeout(PRBool* aResult);
|
||||
|
||||
NS_IMETHOD GetFrameElementInternal(nsIDOMElement** aFrameElement);
|
||||
NS_IMETHOD SetFrameElementInternal(nsIDOMElement* aFrameElement);
|
||||
|
||||
// nsIDOMViewCSS
|
||||
NS_DECL_NSIDOMVIEWCSS
|
||||
|
||||
|
@ -303,6 +306,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
|
||||
|
||||
|
@ -1678,13 +1658,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);
|
||||
|
||||
|
@ -5553,94 +5526,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);
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -231,19 +230,29 @@ nsHTMLFramesetFrame::nsHTMLFramesetFrame()
|
|||
|
||||
nsHTMLFramesetFrame::~nsHTMLFramesetFrame()
|
||||
{
|
||||
if (mRowSizes) delete [] mRowSizes;
|
||||
if (mRowSpecs) delete [] mRowSpecs;
|
||||
if (mColSizes) delete [] mColSizes;
|
||||
if (mColSpecs) delete [] mColSpecs;
|
||||
if (mVerBorders) delete[] mVerBorders;
|
||||
if (mHorBorders) delete[] mHorBorders;
|
||||
delete [] mRowSizes;
|
||||
delete [] mRowSpecs;
|
||||
delete [] mColSizes;
|
||||
delete [] mColSpecs;
|
||||
delete[] mVerBorders;
|
||||
delete[] mHorBorders;
|
||||
|
||||
mRowSizes = mColSizes = nsnull;
|
||||
mRowSpecs = mColSpecs = nsnull;
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch(do_QueryReferent(mPrefBranchWeakRef));
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch =
|
||||
do_QueryReferent(mPrefBranchWeakRef);
|
||||
|
||||
if (prefBranch) {
|
||||
nsresult rv = prefBranch->RemoveObserver(kFrameResizePref, this);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't remove frameset as pref branch observer");
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
prefBranch->RemoveObserver(kFrameResizePref, this);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"Can't remove frameset as pref branch observer");
|
||||
}
|
||||
|
||||
mPrefBranchWeakRef = nsnull;
|
||||
}
|
||||
|
||||
|
@ -252,7 +261,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 +336,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 +1414,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
|
||||
|
||||
|
@ -1678,13 +1658,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);
|
||||
|
||||
|
@ -5553,94 +5526,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
|
||||
|
|
|
@ -46,7 +46,8 @@ REQUIRES = xpcom \
|
|||
shistory \
|
||||
xpconnect \
|
||||
accessibility \
|
||||
webbrwsr \
|
||||
webbrwsr \
|
||||
webBrowser_core \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
|
|
@ -40,6 +40,7 @@ REQUIRES = xpcom \
|
|||
accessibility \
|
||||
gfx \
|
||||
content \
|
||||
webBrowser_core \
|
||||
$(NULL)
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -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);
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -231,19 +230,29 @@ nsHTMLFramesetFrame::nsHTMLFramesetFrame()
|
|||
|
||||
nsHTMLFramesetFrame::~nsHTMLFramesetFrame()
|
||||
{
|
||||
if (mRowSizes) delete [] mRowSizes;
|
||||
if (mRowSpecs) delete [] mRowSpecs;
|
||||
if (mColSizes) delete [] mColSizes;
|
||||
if (mColSpecs) delete [] mColSpecs;
|
||||
if (mVerBorders) delete[] mVerBorders;
|
||||
if (mHorBorders) delete[] mHorBorders;
|
||||
delete [] mRowSizes;
|
||||
delete [] mRowSpecs;
|
||||
delete [] mColSizes;
|
||||
delete [] mColSpecs;
|
||||
delete[] mVerBorders;
|
||||
delete[] mHorBorders;
|
||||
|
||||
mRowSizes = mColSizes = nsnull;
|
||||
mRowSpecs = mColSpecs = nsnull;
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch(do_QueryReferent(mPrefBranchWeakRef));
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch =
|
||||
do_QueryReferent(mPrefBranchWeakRef);
|
||||
|
||||
if (prefBranch) {
|
||||
nsresult rv = prefBranch->RemoveObserver(kFrameResizePref, this);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't remove frameset as pref branch observer");
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
prefBranch->RemoveObserver(kFrameResizePref, this);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"Can't remove frameset as pref branch observer");
|
||||
}
|
||||
|
||||
mPrefBranchWeakRef = nsnull;
|
||||
}
|
||||
|
||||
|
@ -252,7 +261,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 +336,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 +1414,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();
|
||||
|
|
|
@ -56,6 +56,9 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsPrintPreviewListener(nsIDOMEventReceiver* aEVRec);
|
||||
virtual ~nsPrintPreviewListener()
|
||||
{
|
||||
}
|
||||
|
||||
// nsIDOMContextMenuListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
|
|
@ -2637,7 +2637,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
|
||||
|
@ -87,19 +87,31 @@ nsBrowserBoxObject::~nsBrowserBoxObject()
|
|||
delete mSrcURL;
|
||||
}
|
||||
|
||||
/* void openBrowser (in boolean openFlag); */
|
||||
NS_IMETHODIMP nsBrowserBoxObject::GetDocShell(nsIDocShell** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
if (!mPresShell)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsISupports> subShell;
|
||||
mPresShell->GetSubShellFor(mContent, getter_AddRefs(subShell));
|
||||
if(!subShell)
|
||||
if (!mPresShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return CallQueryInterface(subShell, aResult); //Addref happens here.
|
||||
nsCOMPtr<nsIDocument> doc, sub_doc;
|
||||
mPresShell->GetDocument(getter_AddRefs(doc));
|
||||
|
||||
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,28 @@ 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)
|
||||
if (!mPresShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return CallQueryInterface(subShell, aResult); //Addref happens here.
|
||||
nsCOMPtr<nsIDocument> doc, sub_doc;
|
||||
mPresShell->GetDocument(getter_AddRefs(doc));
|
||||
|
||||
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,28 @@ 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)
|
||||
if (!mPresShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return CallQueryInterface(subShell, aResult); //Addref happens here.
|
||||
nsCOMPtr<nsIDocument> doc, sub_doc;
|
||||
mPresShell->GetDocument(getter_AddRefs(doc));
|
||||
|
||||
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 ///////////////////////////////////////////////////////////////////////
|
||||
|
|
Загрузка…
Ссылка в новой задаче