Bug 682420 - Rename nsINode::GetOwnerDoc to nsINode::OwnerDoc, part 2, r=jst

--HG--
extra : rebase_source : 53dc2ec386f6e4147587e6be3c53d297ad71d57a
This commit is contained in:
Olli Pettay 2011-10-18 14:19:44 +03:00
parent a86b1a4d43
commit e5b7e8ee46
67 changed files with 295 additions and 710 deletions

View File

@ -465,10 +465,8 @@ nsAccessNode::GetLanguage(nsAString& aLanguage)
nsCoreUtils::GetLanguageFor(mContent, nsnull, aLanguage); nsCoreUtils::GetLanguageFor(mContent, nsnull, aLanguage);
if (aLanguage.IsEmpty()) { // Nothing found, so use document's language if (aLanguage.IsEmpty()) { // Nothing found, so use document's language
nsIDocument *doc = mContent->OwnerDoc(); mContent->OwnerDoc()->GetHeaderData(nsGkAtoms::headerContentLanguage,
if (doc) { aLanguage);
doc->GetHeaderData(nsGkAtoms::headerContentLanguage, aLanguage);
}
} }
return NS_OK; return NS_OK;

View File

@ -386,11 +386,7 @@ nsCaretAccessible::GetSelectionControllerForNode(nsIContent *aContent)
if (!aContent) if (!aContent)
return nsnull; return nsnull;
nsIDocument *document = aContent->OwnerDoc(); nsIPresShell *presShell = aContent->OwnerDoc()->GetShell();
if (!document)
return nsnull;
nsIPresShell *presShell = document->GetShell();
if (!presShell) if (!presShell)
return nsnull; return nsnull;

View File

@ -207,11 +207,7 @@ nsCoreUtils::GetAccessKeyFor(nsIContent *aContent)
if (!aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::accesskey)) if (!aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::accesskey))
return 0; return 0;
nsCOMPtr<nsIDocument> doc = aContent->OwnerDoc(); nsCOMPtr<nsIPresShell> presShell = aContent->OwnerDoc()->GetShell();
if (!doc)
return 0;
nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
if (!presShell) if (!presShell)
return 0; return 0;
@ -439,11 +435,7 @@ nsCoreUtils::GetDocShellTreeItemFor(nsINode *aNode)
if (!aNode) if (!aNode)
return nsnull; return nsnull;
nsIDocument *doc = aNode->OwnerDoc(); nsCOMPtr<nsISupports> container = aNode->OwnerDoc()->GetContainer();
NS_ASSERTION(doc, "No document for node passed in");
NS_ENSURE_TRUE(doc, nsnull);
nsCOMPtr<nsISupports> container = doc->GetContainer();
nsIDocShellTreeItem *docShellTreeItem = nsnull; nsIDocShellTreeItem *docShellTreeItem = nsnull;
if (container) if (container)
CallQueryInterface(container, &docShellTreeItem); CallQueryInterface(container, &docShellTreeItem);
@ -603,11 +595,8 @@ nsCoreUtils::GetComputedStyleDeclaration(const nsAString& aPseudoElt,
return nsnull; return nsnull;
// Returns number of items in style declaration // Returns number of items in style declaration
nsIDocument* document = content->OwnerDoc(); nsCOMPtr<nsIDOMWindow> window =
if (!document) do_QueryInterface(content->OwnerDoc()->GetWindow());
return nsnull;
nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(document->GetWindow());
if (!window) if (!window)
return nsnull; return nsnull;

View File

@ -254,8 +254,7 @@ public:
*/ */
static nsIPresShell *GetPresShellFor(nsINode *aNode) static nsIPresShell *GetPresShellFor(nsINode *aNode)
{ {
nsIDocument *document = aNode->OwnerDoc(); return aNode->OwnerDoc()->GetShell();
return document ? document->GetShell() : nsnull;
} }
static already_AddRefed<nsIWeakReference> GetWeakShellFor(nsINode *aNode) static already_AddRefed<nsIWeakReference> GetWeakShellFor(nsINode *aNode)
{ {

View File

@ -463,11 +463,7 @@ nsXULMenuitemAccessible::KeyboardShortcut() const
if (keyElmId.IsEmpty()) if (keyElmId.IsEmpty())
return KeyBinding(); return KeyBinding();
nsIDocument* document = mContent->OwnerDoc(); nsIContent* keyElm = mContent->OwnerDoc()->GetElementById(keyElmId);
if (!document)
return KeyBinding();
nsIContent* keyElm = document->GetElementById(keyElmId);
if (!keyElm) if (!keyElm)
return KeyBinding(); return KeyBinding();

View File

@ -204,11 +204,7 @@ nsXULSliderAccessible::GetSliderNode()
return nsnull; return nsnull;
if (!mSliderNode) { if (!mSliderNode) {
nsIDocument* document = mContent->OwnerDoc(); nsCOMPtr<nsIDOMDocumentXBL> xblDoc(do_QueryInterface(mContent->OwnerDoc()));
if (!document)
return nsnull;
nsCOMPtr<nsIDOMDocumentXBL> xblDoc(do_QueryInterface(document));
if (!xblDoc) if (!xblDoc)
return nsnull; return nsnull;

View File

@ -261,7 +261,7 @@ nsXULLinkAccessible::AnchorURIAt(PRUint32 aAnchorIndex)
nsIURI* anchorURI = nsnull; nsIURI* anchorURI = nsnull;
NS_NewURI(&anchorURI, href, NS_NewURI(&anchorURI, href,
document ? document->GetDocumentCharacterSet().get() : nsnull, document->GetDocumentCharacterSet().get(),
baseURI); baseURI);
return anchorURI; return anchorURI;

View File

@ -174,12 +174,8 @@ nsMacShellService::SetDesktopBackground(nsIDOMElement* aElement,
// We need the referer URI for nsIWebBrowserPersist::saveURI // We need the referer URI for nsIWebBrowserPersist::saveURI
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement, &rv); nsCOMPtr<nsIContent> content = do_QueryInterface(aElement, &rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc;
doc = content->OwnerDoc();
if (!doc)
return NS_ERROR_FAILURE;
nsIURI *docURI = doc->GetDocumentURI(); nsIURI *docURI = content->OwnerDoc()->GetDocumentURI();
if (!docURI) if (!docURI)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

View File

@ -278,9 +278,7 @@ public:
*/ */
inline bool IsInHTMLDocument() const inline bool IsInHTMLDocument() const
{ {
nsIDocument* doc = OwnerDoc(); return OwnerDoc()->IsHTML();
return doc && // XXX clean up after bug 335998 lands
doc->IsHTML();
} }
/** /**

View File

@ -847,9 +847,8 @@ nsContentList::Match(Element *aElement)
if (toReturn) if (toReturn)
return toReturn; return toReturn;
nsIDocument* doc = aElement->OwnerDoc();
bool matchHTML = aElement->GetNameSpaceID() == kNameSpaceID_XHTML && bool matchHTML = aElement->GetNameSpaceID() == kNameSpaceID_XHTML &&
doc && doc->IsHTML(); aElement->OwnerDoc()->IsHTML();
if (unknown) { if (unknown) {
return matchHTML ? ni->QualifiedNameEquals(mHTMLMatchAtom) : return matchHTML ? ni->QualifiedNameEquals(mHTMLMatchAtom) :

View File

@ -3248,9 +3248,6 @@ nsContentUtils::HasMutationListeners(nsINode* aNode,
nsINode* aTargetForSubtreeModified) nsINode* aTargetForSubtreeModified)
{ {
nsIDocument* doc = aNode->OwnerDoc(); nsIDocument* doc = aNode->OwnerDoc();
if (!doc) {
return false;
}
// global object will be null for documents that don't have windows. // global object will be null for documents that don't have windows.
nsPIDOMWindow* window = doc->GetInnerWindow(); nsPIDOMWindow* window = doc->GetInnerWindow();
@ -3494,8 +3491,6 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
// If we don't have a document here, we can't get the right security context // If we don't have a document here, we can't get the right security context
// for compiling event handlers... so just bail out. // for compiling event handlers... so just bail out.
nsCOMPtr<nsIDocument> document = aContextNode->OwnerDoc(); nsCOMPtr<nsIDocument> document = aContextNode->OwnerDoc();
NS_ENSURE_TRUE(document, NS_ERROR_NOT_AVAILABLE);
bool isHTML = document->IsHTML(); bool isHTML = document->IsHTML();
#ifdef DEBUG #ifdef DEBUG
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document); nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document);
@ -4736,15 +4731,9 @@ nsContentUtils::GetContextForEventHandlers(nsINode* aNode,
nsresult* aRv) nsresult* aRv)
{ {
*aRv = NS_OK; *aRv = NS_OK;
nsIDocument* ownerDoc = aNode->OwnerDoc();
if (!ownerDoc) {
*aRv = NS_ERROR_UNEXPECTED;
return nsnull;
}
bool hasHadScriptObject = true; bool hasHadScriptObject = true;
nsIScriptGlobalObject* sgo = nsIScriptGlobalObject* sgo =
ownerDoc->GetScriptHandlingObject(hasHadScriptObject); aNode->OwnerDoc()->GetScriptHandlingObject(hasHadScriptObject);
// It is bad if the document doesn't have event handling context, // It is bad if the document doesn't have event handling context,
// but it used to have one. // but it used to have one.
if (!sgo && hasHadScriptObject) { if (!sgo && hasHadScriptObject) {
@ -5354,7 +5343,6 @@ AllocClassMatchingInfo(nsINode* aRootNode,
} }
info->mCaseTreatment = info->mCaseTreatment =
aRootNode->OwnerDoc() &&
aRootNode->OwnerDoc()->GetCompatibilityMode() == eCompatibility_NavQuirks ? aRootNode->OwnerDoc()->GetCompatibilityMode() == eCompatibility_NavQuirks ?
eIgnoreCase : eCaseMatters; eIgnoreCase : eCaseMatters;
return info; return info;

View File

@ -181,9 +181,7 @@ nsDOMAttribute::SetOwnerDocument(nsIDocument* aDocument)
nsIDocument *doc = OwnerDoc(); nsIDocument *doc = OwnerDoc();
NS_ASSERTION(doc != aDocument, "bad call to nsDOMAttribute::SetOwnerDocument"); NS_ASSERTION(doc != aDocument, "bad call to nsDOMAttribute::SetOwnerDocument");
if (doc) { doc->DeleteAllPropertiesFor(this);
doc->DeleteAllPropertiesFor(this);
}
nsCOMPtr<nsINodeInfo> newNodeInfo; nsCOMPtr<nsINodeInfo> newNodeInfo;
newNodeInfo = aDocument->NodeInfoManager()-> newNodeInfo = aDocument->NodeInfoManager()->
@ -275,10 +273,8 @@ NS_IMETHODIMP
nsDOMAttribute::GetSpecified(bool* aSpecified) nsDOMAttribute::GetSpecified(bool* aSpecified)
{ {
NS_ENSURE_ARG_POINTER(aSpecified); NS_ENSURE_ARG_POINTER(aSpecified);
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eSpecified);
if (document) {
document->WarnOnceAbout(nsIDocument::eSpecified);
}
*aSpecified = true; *aSpecified = true;
return NS_OK; return NS_OK;
} }
@ -287,11 +283,7 @@ NS_IMETHODIMP
nsDOMAttribute::GetOwnerElement(nsIDOMElement** aOwnerElement) nsDOMAttribute::GetOwnerElement(nsIDOMElement** aOwnerElement)
{ {
NS_ENSURE_ARG_POINTER(aOwnerElement); NS_ENSURE_ARG_POINTER(aOwnerElement);
OwnerDoc()->WarnOnceAbout(nsIDocument::eOwnerElement);
nsIDocument* document = OwnerDoc();
if (document) {
document->WarnOnceAbout(nsIDocument::eOwnerElement);
}
nsIContent* content = GetContentInternal(); nsIContent* content = GetContentInternal();
if (content) { if (content) {
@ -306,10 +298,7 @@ nsDOMAttribute::GetOwnerElement(nsIDOMElement** aOwnerElement)
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::GetNodeName(nsAString& aNodeName) nsDOMAttribute::GetNodeName(nsAString& aNodeName)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eNodeName);
if (document) {
document->WarnOnceAbout(nsIDocument::eNodeName);
}
return GetName(aNodeName); return GetName(aNodeName);
} }
@ -317,10 +306,7 @@ nsDOMAttribute::GetNodeName(nsAString& aNodeName)
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::GetNodeValue(nsAString& aNodeValue) nsDOMAttribute::GetNodeValue(nsAString& aNodeValue)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eNodeValue);
if (document) {
document->WarnOnceAbout(nsIDocument::eNodeValue);
}
return GetValue(aNodeValue); return GetValue(aNodeValue);
} }
@ -328,10 +314,7 @@ nsDOMAttribute::GetNodeValue(nsAString& aNodeValue)
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::SetNodeValue(const nsAString& aNodeValue) nsDOMAttribute::SetNodeValue(const nsAString& aNodeValue)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eNodeValue);
if (document) {
document->WarnOnceAbout(nsIDocument::eNodeValue);
}
return SetValue(aNodeValue); return SetValue(aNodeValue);
} }
@ -340,11 +323,7 @@ NS_IMETHODIMP
nsDOMAttribute::GetNodeType(PRUint16* aNodeType) nsDOMAttribute::GetNodeType(PRUint16* aNodeType)
{ {
NS_ENSURE_ARG_POINTER(aNodeType); NS_ENSURE_ARG_POINTER(aNodeType);
OwnerDoc()->WarnOnceAbout(nsIDocument::eNodeType);
nsIDocument* document = OwnerDoc();
if (document) {
document->WarnOnceAbout(nsIDocument::eNodeType);
}
*aNodeType = (PRUint16)nsIDOMNode::ATTRIBUTE_NODE; *aNodeType = (PRUint16)nsIDOMNode::ATTRIBUTE_NODE;
return NS_OK; return NS_OK;
@ -354,11 +333,7 @@ NS_IMETHODIMP
nsDOMAttribute::GetParentNode(nsIDOMNode** aParentNode) nsDOMAttribute::GetParentNode(nsIDOMNode** aParentNode)
{ {
NS_ENSURE_ARG_POINTER(aParentNode); NS_ENSURE_ARG_POINTER(aParentNode);
OwnerDoc()->WarnOnceAbout(nsIDocument::eParentNode);
nsIDocument* document = OwnerDoc();
if (document) {
document->WarnOnceAbout(nsIDocument::eParentNode);
}
*aParentNode = nsnull; *aParentNode = nsnull;
return NS_OK; return NS_OK;
@ -374,10 +349,7 @@ nsDOMAttribute::GetParentElement(nsIDOMElement** aParentElement)
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::GetChildNodes(nsIDOMNodeList** aChildNodes) nsDOMAttribute::GetChildNodes(nsIDOMNodeList** aChildNodes)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eChildNodes);
if (document) {
document->WarnOnceAbout(nsIDocument::eChildNodes);
}
return nsINode::GetChildNodes(aChildNodes); return nsINode::GetChildNodes(aChildNodes);
} }
@ -385,10 +357,7 @@ nsDOMAttribute::GetChildNodes(nsIDOMNodeList** aChildNodes)
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::HasChildNodes(bool* aHasChildNodes) nsDOMAttribute::HasChildNodes(bool* aHasChildNodes)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eHasChildNodes);
if (document) {
document->WarnOnceAbout(nsIDocument::eHasChildNodes);
}
*aHasChildNodes = mFirstChild != nsnull; *aHasChildNodes = mFirstChild != nsnull;
@ -399,11 +368,7 @@ NS_IMETHODIMP
nsDOMAttribute::HasAttributes(bool* aHasAttributes) nsDOMAttribute::HasAttributes(bool* aHasAttributes)
{ {
NS_ENSURE_ARG_POINTER(aHasAttributes); NS_ENSURE_ARG_POINTER(aHasAttributes);
OwnerDoc()->WarnOnceAbout(nsIDocument::eHasAttributes);
nsIDocument* document = OwnerDoc();
if (document) {
document->WarnOnceAbout(nsIDocument::eHasAttributes);
}
*aHasAttributes = false; *aHasAttributes = false;
@ -415,10 +380,7 @@ nsDOMAttribute::GetFirstChild(nsIDOMNode** aFirstChild)
{ {
*aFirstChild = nsnull; *aFirstChild = nsnull;
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eFirstChild);
if (document) {
document->WarnOnceAbout(nsIDocument::eFirstChild);
}
if (mFirstChild) { if (mFirstChild) {
CallQueryInterface(mFirstChild, aFirstChild); CallQueryInterface(mFirstChild, aFirstChild);
@ -430,10 +392,8 @@ nsDOMAttribute::GetFirstChild(nsIDOMNode** aFirstChild)
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::GetLastChild(nsIDOMNode** aLastChild) nsDOMAttribute::GetLastChild(nsIDOMNode** aLastChild)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eLastChild);
if (document) {
document->WarnOnceAbout(nsIDocument::eLastChild);
}
return GetFirstChild(aLastChild); return GetFirstChild(aLastChild);
} }
@ -442,10 +402,7 @@ nsDOMAttribute::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
{ {
NS_ENSURE_ARG_POINTER(aPreviousSibling); NS_ENSURE_ARG_POINTER(aPreviousSibling);
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::ePreviousSibling);
if (document) {
document->WarnOnceAbout(nsIDocument::ePreviousSibling);
}
*aPreviousSibling = nsnull; *aPreviousSibling = nsnull;
return NS_OK; return NS_OK;
@ -456,10 +413,7 @@ nsDOMAttribute::GetNextSibling(nsIDOMNode** aNextSibling)
{ {
NS_ENSURE_ARG_POINTER(aNextSibling); NS_ENSURE_ARG_POINTER(aNextSibling);
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eNextSibling);
if (document) {
document->WarnOnceAbout(nsIDocument::eNextSibling);
}
*aNextSibling = nsnull; *aNextSibling = nsnull;
return NS_OK; return NS_OK;
@ -470,10 +424,7 @@ nsDOMAttribute::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
{ {
NS_ENSURE_ARG_POINTER(aAttributes); NS_ENSURE_ARG_POINTER(aAttributes);
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eAttributes);
if (document) {
document->WarnOnceAbout(nsIDocument::eAttributes);
}
*aAttributes = nsnull; *aAttributes = nsnull;
return NS_OK; return NS_OK;
@ -482,10 +433,7 @@ nsDOMAttribute::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn) nsDOMAttribute::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eInsertBefore);
if (document) {
document->WarnOnceAbout(nsIDocument::eInsertBefore);
}
return ReplaceOrInsertBefore(false, aNewChild, aRefChild, aReturn); return ReplaceOrInsertBefore(false, aNewChild, aRefChild, aReturn);
} }
@ -493,10 +441,7 @@ nsDOMAttribute::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDO
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn) nsDOMAttribute::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eReplaceChild);
if (document) {
document->WarnOnceAbout(nsIDocument::eReplaceChild);
}
return ReplaceOrInsertBefore(true, aNewChild, aOldChild, aReturn); return ReplaceOrInsertBefore(true, aNewChild, aOldChild, aReturn);
} }
@ -504,10 +449,7 @@ nsDOMAttribute::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDO
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) nsDOMAttribute::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eRemoveChild);
if (document) {
document->WarnOnceAbout(nsIDocument::eRemoveChild);
}
return nsINode::RemoveChild(aOldChild, aReturn); return nsINode::RemoveChild(aOldChild, aReturn);
} }
@ -515,10 +457,7 @@ nsDOMAttribute::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn) nsDOMAttribute::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eAppendChild);
if (document) {
document->WarnOnceAbout(nsIDocument::eAppendChild);
}
return InsertBefore(aNewChild, nsnull, aReturn); return InsertBefore(aNewChild, nsnull, aReturn);
} }
@ -543,10 +482,7 @@ nsDOMAttribute::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::CloneNode(bool aDeep, nsIDOMNode** aResult) nsDOMAttribute::CloneNode(bool aDeep, nsIDOMNode** aResult)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eCloneNode);
if (document) {
document->WarnOnceAbout(nsIDocument::eCloneNode);
}
return nsNodeUtils::CloneNodeImpl(this, aDeep, true, aResult); return nsNodeUtils::CloneNodeImpl(this, aDeep, true, aResult);
} }
@ -554,10 +490,7 @@ nsDOMAttribute::CloneNode(bool aDeep, nsIDOMNode** aResult)
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument) nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eOwnerDocument);
if (document) {
document->WarnOnceAbout(nsIDocument::eOwnerDocument);
}
return nsINode::GetOwnerDocument(aOwnerDocument); return nsINode::GetOwnerDocument(aOwnerDocument);
} }
@ -585,10 +518,7 @@ nsDOMAttribute::GetLocalName(nsAString& aLocalName)
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::Normalize() nsDOMAttribute::Normalize()
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eNormalize);
if (document) {
document->WarnOnceAbout(nsIDocument::eNormalize);
}
// Nothing to do here // Nothing to do here
return NS_OK; return NS_OK;
@ -599,10 +529,8 @@ nsDOMAttribute::IsSupported(const nsAString& aFeature,
const nsAString& aVersion, const nsAString& aVersion,
bool* aReturn) bool* aReturn)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eIsSupported);
if (document) {
document->WarnOnceAbout(nsIDocument::eIsSupported);
}
return nsGenericElement::InternalIsSupported(static_cast<nsIDOMAttr*>(this), return nsGenericElement::InternalIsSupported(static_cast<nsIDOMAttr*>(this),
aFeature, aVersion, aReturn); aFeature, aVersion, aReturn);
} }
@ -631,40 +559,31 @@ nsDOMAttribute::CompareDocumentPosition(nsIDOMNode *other,
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::IsEqualNode(nsIDOMNode* aOther, bool* aResult) nsDOMAttribute::IsEqualNode(nsIDOMNode* aOther, bool* aResult)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eIsEqualNode);
if (document) {
document->WarnOnceAbout(nsIDocument::eIsEqualNode);
}
return nsINode::IsEqualNode(aOther, aResult); return nsINode::IsEqualNode(aOther, aResult);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::GetTextContent(nsAString &aTextContent) nsDOMAttribute::GetTextContent(nsAString &aTextContent)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eTextContent);
if (document) {
document->WarnOnceAbout(nsIDocument::eTextContent);
}
return GetNodeValue(aTextContent); return GetNodeValue(aTextContent);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::SetTextContent(const nsAString& aTextContent) nsDOMAttribute::SetTextContent(const nsAString& aTextContent)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eTextContent);
if (document) {
document->WarnOnceAbout(nsIDocument::eTextContent);
}
return SetNodeValue(aTextContent); return SetNodeValue(aTextContent);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMAttribute::IsSameNode(nsIDOMNode *other, bool *aResult) nsDOMAttribute::IsSameNode(nsIDOMNode *other, bool *aResult)
{ {
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eIsSameNode);
if (document) {
document->WarnOnceAbout(nsIDocument::eIsSameNode);
}
*aResult = other == this; *aResult = other == this;
return NS_OK; return NS_OK;

View File

@ -400,8 +400,7 @@ nsIdentifierMapEntry::RemoveIdElement(Element* aElement)
// This could fire in OOM situations // This could fire in OOM situations
// Only assert this in HTML documents for now as XUL does all sorts of weird // Only assert this in HTML documents for now as XUL does all sorts of weird
// crap. // crap.
NS_ASSERTION(!aElement->OwnerDoc() || NS_ASSERTION(!aElement->OwnerDoc()->IsHTML() ||
!aElement->OwnerDoc()->IsHTML() ||
mIdContentList.IndexOf(aElement) >= 0, mIdContentList.IndexOf(aElement) >= 0,
"Removing id entry that doesn't exist"); "Removing id entry that doesn't exist");
@ -1129,9 +1128,6 @@ nsExternalResourceMap::PendingLoad::StartLoad(nsIURI* aURI,
} }
nsIDocument* doc = aRequestingNode->OwnerDoc(); nsIDocument* doc = aRequestingNode->OwnerDoc();
if (!doc) {
return NS_ERROR_NOT_AVAILABLE;
}
nsCOMPtr<nsIInterfaceRequestor> req = nsContentUtils::GetSameOriginChecker(); nsCOMPtr<nsIInterfaceRequestor> req = nsContentUtils::GetSameOriginChecker();
NS_ENSURE_TRUE(req, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(req, NS_ERROR_OUT_OF_MEMORY);
@ -4816,12 +4812,10 @@ nsDocument::ImportNode(nsIDOMNode* aImportedNode,
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsIDocument *ownerDoc = imported->OwnerDoc(); nsIDocument *ownerDoc = imported->OwnerDoc();
if (ownerDoc) { rv = nsNodeUtils::CallUserDataHandlers(nodesWithProperties, ownerDoc,
rv = nsNodeUtils::CallUserDataHandlers(nodesWithProperties, ownerDoc, nsIDOMUserDataHandler::NODE_IMPORTED,
nsIDOMUserDataHandler::NODE_IMPORTED, true);
true); NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS(rv, rv);
}
newNode.swap(*aResult); newNode.swap(*aResult);

View File

@ -340,7 +340,7 @@ nsFrameLoader::Create(Element* aOwner, bool aNetworkCreated)
{ {
NS_ENSURE_TRUE(aOwner, nsnull); NS_ENSURE_TRUE(aOwner, nsnull);
nsIDocument* doc = aOwner->OwnerDoc(); nsIDocument* doc = aOwner->OwnerDoc();
NS_ENSURE_TRUE(doc && !doc->GetDisplayDocument() && NS_ENSURE_TRUE(!doc->GetDisplayDocument() &&
((!doc->IsLoadedAsData() && aOwner->GetCurrentDoc()) || ((!doc->IsLoadedAsData() && aOwner->GetCurrentDoc()) ||
doc->IsStaticDocument()), doc->IsStaticDocument()),
nsnull); nsnull);
@ -363,7 +363,7 @@ nsFrameLoader::LoadFrame()
} }
nsIDocument* doc = mOwnerContent->OwnerDoc(); nsIDocument* doc = mOwnerContent->OwnerDoc();
if (!doc || doc->IsStaticDocument()) { if (doc->IsStaticDocument()) {
return NS_OK; return NS_OK;
} }
@ -412,9 +412,6 @@ nsFrameLoader::LoadURI(nsIURI* aURI)
NS_ENSURE_STATE(!mDestroyCalled && mOwnerContent); NS_ENSURE_STATE(!mDestroyCalled && mOwnerContent);
nsCOMPtr<nsIDocument> doc = mOwnerContent->OwnerDoc(); nsCOMPtr<nsIDocument> doc = mOwnerContent->OwnerDoc();
if (!doc) {
return NS_OK;
}
nsresult rv = CheckURILoad(aURI); nsresult rv = CheckURILoad(aURI);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -1275,11 +1272,8 @@ nsFrameLoader::Destroy()
bool dynamicSubframeRemoval = false; bool dynamicSubframeRemoval = false;
if (mOwnerContent) { if (mOwnerContent) {
doc = mOwnerContent->OwnerDoc(); doc = mOwnerContent->OwnerDoc();
dynamicSubframeRemoval = !mIsTopLevelContent && !doc->InUnlinkOrDeletion();
if (doc) { doc->SetSubDocumentFor(mOwnerContent, nsnull);
dynamicSubframeRemoval = !mIsTopLevelContent && !doc->InUnlinkOrDeletion();
doc->SetSubDocumentFor(mOwnerContent, nsnull);
}
SetOwnerContent(nsnull); SetOwnerContent(nsnull);
} }
@ -1383,7 +1377,7 @@ nsFrameLoader::MaybeCreateDocShell()
// XXXbz this is such a total hack.... We really need to have a // XXXbz this is such a total hack.... We really need to have a
// better setup for doing this. // better setup for doing this.
nsIDocument* doc = mOwnerContent->OwnerDoc(); nsIDocument* doc = mOwnerContent->OwnerDoc();
if (!doc || !(doc->IsStaticDocument() || mOwnerContent->IsInDoc())) { if (!(doc->IsStaticDocument() || mOwnerContent->IsInDoc())) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }

View File

@ -106,10 +106,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsGenericDOMDataNode)
return NS_SUCCESS_INTERRUPTED_TRAVERSE; return NS_SUCCESS_INTERRUPTED_TRAVERSE;
} }
nsIDocument* ownerDoc = tmp->OwnerDoc(); tmp->OwnerDoc()->BindingManager()->Traverse(tmp, cb);
if (ownerDoc) {
ownerDoc->BindingManager()->Traverse(tmp, cb);
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGenericDOMDataNode) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGenericDOMDataNode)

View File

@ -217,12 +217,8 @@ void*
nsINode::GetProperty(PRUint16 aCategory, nsIAtom *aPropertyName, nsINode::GetProperty(PRUint16 aCategory, nsIAtom *aPropertyName,
nsresult *aStatus) const nsresult *aStatus) const
{ {
nsIDocument *doc = OwnerDoc(); return OwnerDoc()->PropertyTable(aCategory)->GetProperty(this, aPropertyName,
if (!doc) aStatus);
return nsnull;
return doc->PropertyTable(aCategory)->GetProperty(this, aPropertyName,
aStatus);
} }
nsresult nsresult
@ -230,13 +226,12 @@ nsINode::SetProperty(PRUint16 aCategory, nsIAtom *aPropertyName, void *aValue,
NSPropertyDtorFunc aDtor, bool aTransfer, NSPropertyDtorFunc aDtor, bool aTransfer,
void **aOldValue) void **aOldValue)
{ {
nsIDocument *doc = OwnerDoc(); nsresult rv = OwnerDoc()->PropertyTable(aCategory)->SetProperty(this,
if (!doc) aPropertyName,
return NS_ERROR_FAILURE; aValue, aDtor,
nsnull,
nsresult rv = doc->PropertyTable(aCategory)->SetProperty(this, aTransfer,
aPropertyName, aValue, aDtor, aOldValue);
nsnull, aTransfer, aOldValue);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
SetFlags(NODE_HAS_PROPERTIES); SetFlags(NODE_HAS_PROPERTIES);
} }
@ -247,21 +242,16 @@ nsINode::SetProperty(PRUint16 aCategory, nsIAtom *aPropertyName, void *aValue,
void void
nsINode::DeleteProperty(PRUint16 aCategory, nsIAtom *aPropertyName) nsINode::DeleteProperty(PRUint16 aCategory, nsIAtom *aPropertyName)
{ {
nsIDocument *doc = OwnerDoc(); OwnerDoc()->PropertyTable(aCategory)->DeleteProperty(this, aPropertyName);
if (doc)
doc->PropertyTable(aCategory)->DeleteProperty(this, aPropertyName);
} }
void* void*
nsINode::UnsetProperty(PRUint16 aCategory, nsIAtom *aPropertyName, nsINode::UnsetProperty(PRUint16 aCategory, nsIAtom *aPropertyName,
nsresult *aStatus) nsresult *aStatus)
{ {
nsIDocument *doc = OwnerDoc(); return OwnerDoc()->PropertyTable(aCategory)->UnsetProperty(this,
if (!doc) aPropertyName,
return nsnull; aStatus);
return doc->PropertyTable(aCategory)->UnsetProperty(this, aPropertyName,
aStatus);
} }
nsINode::nsSlots* nsINode::nsSlots*
@ -1345,12 +1335,10 @@ nsIContent::GetFlattenedTreeParent() const
nsIContent *parent = GetParent(); nsIContent *parent = GetParent();
if (parent && parent->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) { if (parent && parent->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
nsIDocument *doc = parent->OwnerDoc(); nsIDocument *doc = parent->OwnerDoc();
if (doc) { nsIContent* insertionElement =
nsIContent* insertionElement = doc->BindingManager()->GetNestedInsertionPoint(parent, this);
doc->BindingManager()->GetNestedInsertionPoint(parent, this); if (insertionElement) {
if (insertionElement) { parent = insertionElement;
parent = insertionElement;
}
} }
} }
return parent; return parent;
@ -1463,13 +1451,6 @@ already_AddRefed<nsIURI>
nsIContent::GetBaseURI() const nsIContent::GetBaseURI() const
{ {
nsIDocument* doc = OwnerDoc(); nsIDocument* doc = OwnerDoc();
if (!doc) {
// We won't be able to do security checks, etc. So don't go any
// further. That said, this really shouldn't happen...
NS_ERROR("Element without owner document");
return nsnull;
}
// Start with document base // Start with document base
nsCOMPtr<nsIURI> base = doc->GetDocBaseURI(); nsCOMPtr<nsIURI> base = doc->GetDocBaseURI();
@ -1486,18 +1467,15 @@ nsIContent::GetBaseURI() const
if (elem->IsSVG()) { if (elem->IsSVG()) {
nsIContent* bindingParent = elem->GetBindingParent(); nsIContent* bindingParent = elem->GetBindingParent();
if (bindingParent) { if (bindingParent) {
nsIDocument* bindingDoc = bindingParent->OwnerDoc(); nsXBLBinding* binding =
if (bindingDoc) { bindingParent->OwnerDoc()->BindingManager()->GetBinding(bindingParent);
nsXBLBinding* binding = if (binding) {
bindingDoc->BindingManager()->GetBinding(bindingParent); // XXX sXBL/XBL2 issue
if (binding) { // If this is an anonymous XBL element use the binding
// XXX sXBL/XBL2 issue // document for the base URI.
// If this is an anonymous XBL element use the binding // XXX Will fail with xml:base
// document for the base URI. base = binding->PrototypeBinding()->DocURI();
// XXX Will fail with xml:base break;
base = binding->PrototypeBinding()->DocURI();
break;
}
} }
} }
} }
@ -2640,10 +2618,7 @@ nsGenericElement::SetAttributeNode(nsIDOMAttr* aAttribute,
*aReturn = nsnull; *aReturn = nsnull;
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eSetAttributeNode);
if (document) {
document->WarnOnceAbout(nsIDocument::eSetAttributeNode);
}
nsCOMPtr<nsIDOMNamedNodeMap> map; nsCOMPtr<nsIDOMNamedNodeMap> map;
nsresult rv = GetAttributes(getter_AddRefs(map)); nsresult rv = GetAttributes(getter_AddRefs(map));
@ -2669,10 +2644,7 @@ nsGenericElement::RemoveAttributeNode(nsIDOMAttr* aAttribute,
*aReturn = nsnull; *aReturn = nsnull;
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eRemoveAttributeNode);
if (document) {
document->WarnOnceAbout(nsIDocument::eRemoveAttributeNode);
}
nsCOMPtr<nsIDOMNamedNodeMap> map; nsCOMPtr<nsIDOMNamedNodeMap> map;
nsresult rv = GetAttributes(getter_AddRefs(map)); nsresult rv = GetAttributes(getter_AddRefs(map));
@ -2771,10 +2743,7 @@ nsGenericElement::GetAttributeNodeNS(const nsAString& aNamespaceURI,
NS_ENSURE_ARG_POINTER(aReturn); NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull; *aReturn = nsnull;
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eGetAttributeNodeNS);
if (document) {
document->WarnOnceAbout(nsIDocument::eGetAttributeNodeNS);
}
nsCOMPtr<nsIDOMNamedNodeMap> map; nsCOMPtr<nsIDOMNamedNodeMap> map;
nsresult rv = GetAttributes(getter_AddRefs(map)); nsresult rv = GetAttributes(getter_AddRefs(map));
@ -2798,10 +2767,7 @@ nsGenericElement::SetAttributeNodeNS(nsIDOMAttr* aNewAttr,
NS_ENSURE_ARG_POINTER(aNewAttr); NS_ENSURE_ARG_POINTER(aNewAttr);
*aReturn = nsnull; *aReturn = nsnull;
nsIDocument* document = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eSetAttributeNodeNS);
if (document) {
document->WarnOnceAbout(nsIDocument::eSetAttributeNodeNS);
}
nsCOMPtr<nsIDOMNamedNodeMap> map; nsCOMPtr<nsIDOMNamedNodeMap> map;
nsresult rv = GetAttributes(getter_AddRefs(map)); nsresult rv = GetAttributes(getter_AddRefs(map));
@ -3034,37 +3000,34 @@ nsGenericElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
// that also need to be told that they are moving. // that also need to be told that they are moving.
nsresult rv; nsresult rv;
if (hadForceXBL) { if (hadForceXBL) {
nsIDocument* ownerDoc = OwnerDoc(); nsBindingManager* bmgr = OwnerDoc()->BindingManager();
if (ownerDoc) {
nsBindingManager* bmgr = ownerDoc->BindingManager();
// First check if we have a binding... // First check if we have a binding...
nsXBLBinding* contBinding = nsXBLBinding* contBinding =
GetFirstBindingWithContent(bmgr, this); GetFirstBindingWithContent(bmgr, this);
if (contBinding) { if (contBinding) {
nsCOMPtr<nsIContent> anonRoot = contBinding->GetAnonymousContent(); nsCOMPtr<nsIContent> anonRoot = contBinding->GetAnonymousContent();
bool allowScripts = contBinding->AllowScripts(); bool allowScripts = contBinding->AllowScripts();
for (nsCOMPtr<nsIContent> child = anonRoot->GetFirstChild(); for (nsCOMPtr<nsIContent> child = anonRoot->GetFirstChild();
child; child;
child = child->GetNextSibling()) { child = child->GetNextSibling()) {
rv = child->BindToTree(aDocument, this, this, allowScripts); rv = child->BindToTree(aDocument, this, this, allowScripts);
NS_ENSURE_SUCCESS(rv, rv);
}
// ...then check if we have content in insertion points that are
// direct children of the <content>
rv = BindNodesInInsertPoints(contBinding, this, aDocument);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }
// ...and finally check if we're in a binding where we have content in // ...then check if we have content in insertion points that are
// insertion points. // direct children of the <content>
if (aBindingParent) { rv = BindNodesInInsertPoints(contBinding, this, aDocument);
nsXBLBinding* binding = bmgr->GetBinding(aBindingParent); NS_ENSURE_SUCCESS(rv, rv);
if (binding) { }
rv = BindNodesInInsertPoints(binding, this, aDocument);
NS_ENSURE_SUCCESS(rv, rv); // ...and finally check if we're in a binding where we have content in
} // insertion points.
if (aBindingParent) {
nsXBLBinding* binding = bmgr->GetBinding(aBindingParent);
if (binding) {
rv = BindNodesInInsertPoints(binding, this, aDocument);
NS_ENSURE_SUCCESS(rv, rv);
} }
} }
} }
@ -3192,18 +3155,14 @@ nsGenericElement::GetChildren(PRUint32 aFilter)
nsINodeList *childList = nsnull; nsINodeList *childList = nsnull;
nsIDocument* document = OwnerDoc(); nsIDocument* document = OwnerDoc();
if (document) { if (!(aFilter & eAllButXBL)) {
if (!(aFilter & eAllButXBL)) { childList = document->BindingManager()->GetXBLChildNodesFor(this);
childList = document->BindingManager()->GetXBLChildNodesFor(this); if (!childList) {
if (!childList) { childList = GetChildNodesList();
childList = GetChildNodesList();
}
} else {
childList = document->BindingManager()->GetContentListFor(this);
} }
} else { } else {
childList = GetChildNodesList(); childList = document->BindingManager()->GetContentListFor(this);
} }
if (childList) { if (childList) {
@ -3351,16 +3310,13 @@ nsIContent::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
// check for an anonymous parent // check for an anonymous parent
// XXX XBL2/sXBL issue // XXX XBL2/sXBL issue
if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) { if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
nsIDocument* ownerDoc = OwnerDoc(); nsIContent* insertionParent = OwnerDoc()->BindingManager()->
if (ownerDoc) { GetInsertionParent(this);
nsIContent* insertionParent = ownerDoc->BindingManager()-> NS_ASSERTION(!(aVisitor.mEventTargetAtParent && insertionParent &&
GetInsertionParent(this); aVisitor.mEventTargetAtParent != insertionParent),
NS_ASSERTION(!(aVisitor.mEventTargetAtParent && insertionParent && "Retargeting and having insertion parent!");
aVisitor.mEventTargetAtParent != insertionParent), if (insertionParent) {
"Retargeting and having insertion parent!"); parent = insertionParent;
if (insertionParent) {
parent = insertionParent;
}
} }
} }
@ -3823,10 +3779,8 @@ void
nsGenericElement::DestroyContent() nsGenericElement::DestroyContent()
{ {
nsIDocument *document = OwnerDoc(); nsIDocument *document = OwnerDoc();
if (document) { document->BindingManager()->RemovedFromDocument(this, document);
document->BindingManager()->RemovedFromDocument(this, document); document->ClearBoxObjectFor(this);
document->ClearBoxObjectFor(this);
}
// XXX We really should let cycle collection do this, but that currently still // XXX We really should let cycle collection do this, but that currently still
// leaks (see https://bugzilla.mozilla.org/show_bug.cgi?id=406684). // leaks (see https://bugzilla.mozilla.org/show_bug.cgi?id=406684).
@ -4245,10 +4199,8 @@ nsINode::IsEqualNode(nsIDOMNode* aOther, bool* aReturn)
nsresult nsresult
nsINode::IsSameNode(nsIDOMNode* aOther, bool* aReturn) nsINode::IsSameNode(nsIDOMNode* aOther, bool* aReturn)
{ {
nsIDocument* owner = OwnerDoc(); OwnerDoc()->WarnOnceAbout(nsIDocument::eIsSameNode);
if (owner) {
owner->WarnOnceAbout(nsIDocument::eIsSameNode);
}
nsCOMPtr<nsINode> other = do_QueryInterface(aOther); nsCOMPtr<nsINode> other = do_QueryInterface(aOther);
*aReturn = other == this; *aReturn = other == this;
return NS_OK; return NS_OK;
@ -4347,10 +4299,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGenericElement)
return NS_SUCCESS_INTERRUPTED_TRAVERSE; return NS_SUCCESS_INTERRUPTED_TRAVERSE;
} }
nsIDocument* ownerDoc = tmp->OwnerDoc(); tmp->OwnerDoc()->BindingManager()->Traverse(tmp, cb);
if (ownerDoc) {
ownerDoc->BindingManager()->Traverse(tmp, cb);
}
if (tmp->HasProperties() && tmp->IsXUL()) { if (tmp->HasProperties() && tmp->IsXUL()) {
nsISupports* property = nsISupports* property =
@ -4423,14 +4372,8 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_DESTROY(nsGenericElement,
nsresult nsresult
nsGenericElement::PostQueryInterface(REFNSIID aIID, void** aInstancePtr) nsGenericElement::PostQueryInterface(REFNSIID aIID, void** aInstancePtr)
{ {
nsIDocument *document = OwnerDoc(); return OwnerDoc()->BindingManager()->GetBindingImplementation(this, aIID,
if (document) {
return document->BindingManager()->GetBindingImplementation(this, aIID,
aInstancePtr); aInstancePtr);
}
*aInstancePtr = nsnull;
return NS_ERROR_NO_INTERFACE;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -4451,7 +4394,7 @@ nsGenericElement::AddScriptEventListener(nsIAtom* aEventName,
bool aDefer) bool aDefer)
{ {
nsIDocument *ownerDoc = OwnerDoc(); nsIDocument *ownerDoc = OwnerDoc();
if (!ownerDoc || ownerDoc->IsLoadedAsData()) { if (ownerDoc->IsLoadedAsData()) {
// Make this a no-op rather than throwing an error to avoid // Make this a no-op rather than throwing an error to avoid
// the error causing problems setting the attribute. // the error causing problems setting the attribute.
return NS_OK; return NS_OK;
@ -4664,13 +4607,10 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (document || HasFlag(NODE_FORCE_XBL_BINDINGS)) { if (document || HasFlag(NODE_FORCE_XBL_BINDINGS)) {
nsIDocument* ownerDoc = OwnerDoc(); nsRefPtr<nsXBLBinding> binding =
if (ownerDoc) { OwnerDoc()->BindingManager()->GetBinding(this);
nsRefPtr<nsXBLBinding> binding = if (binding) {
ownerDoc->BindingManager()->GetBinding(this); binding->AttributeChanged(aName, aNamespaceID, false, aNotify);
if (binding) {
binding->AttributeChanged(aName, aNamespaceID, false, aNotify);
}
} }
} }
@ -4894,13 +4834,10 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (document || HasFlag(NODE_FORCE_XBL_BINDINGS)) { if (document || HasFlag(NODE_FORCE_XBL_BINDINGS)) {
nsIDocument* ownerDoc = OwnerDoc(); nsRefPtr<nsXBLBinding> binding =
if (ownerDoc) { OwnerDoc()->BindingManager()->GetBinding(this);
nsRefPtr<nsXBLBinding> binding = if (binding) {
ownerDoc->BindingManager()->GetBinding(this); binding->AttributeChanged(aName, aNameSpaceID, true, aNotify);
if (binding) {
binding->AttributeChanged(aName, aNameSpaceID, true, aNotify);
}
} }
} }
@ -5058,56 +4995,55 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent,
// XXX sXBL/XBL2 issue! Owner or current document? // XXX sXBL/XBL2 issue! Owner or current document?
nsIDocument *document = OwnerDoc(); nsIDocument *document = OwnerDoc();
if (document) {
// Note: not listing nsIAnonymousContentCreator-created content...
nsBindingManager* bindingManager = document->BindingManager(); // Note: not listing nsIAnonymousContentCreator-created content...
nsCOMPtr<nsIDOMNodeList> anonymousChildren;
bindingManager->GetAnonymousNodesFor(nonConstThis,
getter_AddRefs(anonymousChildren));
if (anonymousChildren) { nsBindingManager* bindingManager = document->BindingManager();
PRUint32 length; nsCOMPtr<nsIDOMNodeList> anonymousChildren;
anonymousChildren->GetLength(&length); bindingManager->GetAnonymousNodesFor(nonConstThis,
if (length > 0) { getter_AddRefs(anonymousChildren));
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fputs("anonymous-children<\n", out);
for (PRUint32 i = 0; i < length; ++i) { if (anonymousChildren) {
nsCOMPtr<nsIDOMNode> node; PRUint32 length;
anonymousChildren->Item(i, getter_AddRefs(node)); anonymousChildren->GetLength(&length);
nsCOMPtr<nsIContent> child = do_QueryInterface(node); if (length > 0) {
child->List(out, aIndent + 1); for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
} fputs("anonymous-children<\n", out);
for (indent = aIndent; --indent >= 0; ) fputs(" ", out); for (PRUint32 i = 0; i < length; ++i) {
fputs(">\n", out); nsCOMPtr<nsIDOMNode> node;
anonymousChildren->Item(i, getter_AddRefs(node));
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
child->List(out, aIndent + 1);
} }
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fputs(">\n", out);
} }
}
if (bindingManager->HasContentListFor(nonConstThis)) { if (bindingManager->HasContentListFor(nonConstThis)) {
nsCOMPtr<nsIDOMNodeList> contentList; nsCOMPtr<nsIDOMNodeList> contentList;
bindingManager->GetContentListFor(nonConstThis, bindingManager->GetContentListFor(nonConstThis,
getter_AddRefs(contentList)); getter_AddRefs(contentList));
NS_ASSERTION(contentList != nsnull, "oops, binding manager lied"); NS_ASSERTION(contentList != nsnull, "oops, binding manager lied");
PRUint32 length; PRUint32 length;
contentList->GetLength(&length); contentList->GetLength(&length);
if (length > 0) { if (length > 0) {
for (indent = aIndent; --indent >= 0; ) fputs(" ", out); for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fputs("content-list<\n", out); fputs("content-list<\n", out);
for (PRUint32 i = 0; i < length; ++i) { for (PRUint32 i = 0; i < length; ++i) {
nsCOMPtr<nsIDOMNode> node; nsCOMPtr<nsIDOMNode> node;
contentList->Item(i, getter_AddRefs(node)); contentList->Item(i, getter_AddRefs(node));
nsCOMPtr<nsIContent> child = do_QueryInterface(node); nsCOMPtr<nsIContent> child = do_QueryInterface(node);
child->List(out, aIndent + 1); child->List(out, aIndent + 1);
}
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fputs(">\n", out);
} }
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fputs(">\n", out);
} }
} }
} }
@ -5399,8 +5335,6 @@ ParseSelectorList(nsINode* aNode,
NS_ENSURE_ARG(aNode); NS_ENSURE_ARG(aNode);
nsIDocument* doc = aNode->OwnerDoc(); nsIDocument* doc = aNode->OwnerDoc();
NS_ENSURE_STATE(doc);
nsCSSParser parser(doc->CSSLoader()); nsCSSParser parser(doc->CSSLoader());
nsCSSSelectorList* selectorList; nsCSSSelectorList* selectorList;

View File

@ -903,16 +903,10 @@ protected:
} }
void RegisterFreezableElement() { void RegisterFreezableElement() {
nsIDocument* doc = OwnerDoc(); OwnerDoc()->RegisterFreezableElement(this);
if (doc) {
doc->RegisterFreezableElement(this);
}
} }
void UnregisterFreezableElement() { void UnregisterFreezableElement() {
nsIDocument* doc = OwnerDoc(); OwnerDoc()->UnregisterFreezableElement(this);
if (doc) {
doc->UnregisterFreezableElement(this);
}
} }
/** /**

View File

@ -268,9 +268,7 @@ nsNodeUtils::LastRelease(nsINode* aNode)
// Strong reference to the document so that deleting properties can't // Strong reference to the document so that deleting properties can't
// delete the document. // delete the document.
nsCOMPtr<nsIDocument> document = aNode->OwnerDoc(); nsCOMPtr<nsIDocument> document = aNode->OwnerDoc();
if (document) { document->DeleteAllPropertiesFor(aNode);
document->DeleteAllPropertiesFor(aNode);
}
} }
// I wonder whether it's faster to do the HasFlag check first.... // I wonder whether it's faster to do the HasFlag check first....
@ -302,12 +300,9 @@ nsNodeUtils::LastRelease(nsINode* aNode)
if (aNode->IsElement()) { if (aNode->IsElement()) {
nsIDocument* ownerDoc = aNode->OwnerDoc(); nsIDocument* ownerDoc = aNode->OwnerDoc();
Element* elem = aNode->AsElement(); Element* elem = aNode->AsElement();
if (ownerDoc) { ownerDoc->ClearBoxObjectFor(elem);
ownerDoc->ClearBoxObjectFor(elem);
}
NS_ASSERTION(aNode->HasFlag(NODE_FORCE_XBL_BINDINGS) || NS_ASSERTION(aNode->HasFlag(NODE_FORCE_XBL_BINDINGS) ||
!ownerDoc ||
!ownerDoc->BindingManager() || !ownerDoc->BindingManager() ||
!ownerDoc->BindingManager()->GetBinding(elem), !ownerDoc->BindingManager()->GetBinding(elem),
"Non-forced node has binding on destruction"); "Non-forced node has binding on destruction");
@ -315,7 +310,7 @@ nsNodeUtils::LastRelease(nsINode* aNode)
// if NODE_FORCE_XBL_BINDINGS is set, the node might still have a binding // if NODE_FORCE_XBL_BINDINGS is set, the node might still have a binding
// attached // attached
if (aNode->HasFlag(NODE_FORCE_XBL_BINDINGS) && if (aNode->HasFlag(NODE_FORCE_XBL_BINDINGS) &&
ownerDoc && ownerDoc->BindingManager()) { ownerDoc->BindingManager()) {
ownerDoc->BindingManager()->RemovedFromDocument(elem, ownerDoc); ownerDoc->BindingManager()->RemovedFromDocument(elem, ownerDoc);
} }
} }
@ -416,10 +411,6 @@ nsNodeUtils::TraverseUserData(nsINode* aNode,
nsCycleCollectionTraversalCallback &aCb) nsCycleCollectionTraversalCallback &aCb)
{ {
nsIDocument* ownerDoc = aNode->OwnerDoc(); nsIDocument* ownerDoc = aNode->OwnerDoc();
if (!ownerDoc) {
return;
}
ownerDoc->PropertyTable(DOM_USER_DATA)->Enumerate(aNode, NoteUserData, &aCb); ownerDoc->PropertyTable(DOM_USER_DATA)->Enumerate(aNode, NoteUserData, &aCb);
ownerDoc->PropertyTable(DOM_USER_DATA_HANDLER)->Enumerate(aNode, NoteUserData, &aCb); ownerDoc->PropertyTable(DOM_USER_DATA_HANDLER)->Enumerate(aNode, NoteUserData, &aCb);
} }
@ -438,9 +429,8 @@ nsNodeUtils::CloneNodeImpl(nsINode *aNode, bool aDeep,
getter_AddRefs(newNode)); getter_AddRefs(newNode));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsIDocument *ownerDoc = aNode->OwnerDoc(); if (aCallUserDataHandlers) {
if (ownerDoc && aCallUserDataHandlers) { rv = CallUserDataHandlers(nodesWithProperties, aNode->OwnerDoc(),
rv = CallUserDataHandlers(nodesWithProperties, ownerDoc,
nsIDOMUserDataHandler::NODE_CLONED, true); nsIDOMUserDataHandler::NODE_CLONED, true);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }
@ -493,8 +483,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
if (!newDoc->GetScriptHandlingObject(hasHadScriptHandlingObject) && if (!newDoc->GetScriptHandlingObject(hasHadScriptHandlingObject) &&
!hasHadScriptHandlingObject) { !hasHadScriptHandlingObject) {
nsIDocument* currentDoc = aNode->OwnerDoc(); nsIDocument* currentDoc = aNode->OwnerDoc();
NS_ENSURE_STATE(currentDoc && NS_ENSURE_STATE((nsContentUtils::IsChromeDoc(currentDoc) ||
(nsContentUtils::IsChromeDoc(currentDoc) ||
(!currentDoc->GetScriptHandlingObject(hasHadScriptHandlingObject) && (!currentDoc->GetScriptHandlingObject(hasHadScriptHandlingObject) &&
!hasHadScriptHandlingObject))); !hasHadScriptHandlingObject)));
} }
@ -535,7 +524,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
else if (nodeInfoManager) { else if (nodeInfoManager) {
nsIDocument* oldDoc = aNode->OwnerDoc(); nsIDocument* oldDoc = aNode->OwnerDoc();
bool wasRegistered = false; bool wasRegistered = false;
if (oldDoc && aNode->IsElement()) { if (aNode->IsElement()) {
Element* element = aNode->AsElement(); Element* element = aNode->AsElement();
oldDoc->ClearBoxObjectFor(element); oldDoc->ClearBoxObjectFor(element);
wasRegistered = oldDoc->UnregisterFreezableElement(element); wasRegistered = oldDoc->UnregisterFreezableElement(element);
@ -717,8 +706,6 @@ nsNodeUtils::UnlinkUserData(nsINode *aNode)
// Strong reference to the document so that deleting properties can't // Strong reference to the document so that deleting properties can't
// delete the document. // delete the document.
nsCOMPtr<nsIDocument> document = aNode->OwnerDoc(); nsCOMPtr<nsIDocument> document = aNode->OwnerDoc();
if (document) { document->PropertyTable(DOM_USER_DATA)->DeleteAllPropertiesFor(aNode);
document->PropertyTable(DOM_USER_DATA)->DeleteAllPropertiesFor(aNode); document->PropertyTable(DOM_USER_DATA_HANDLER)->DeleteAllPropertiesFor(aNode);
document->PropertyTable(DOM_USER_DATA_HANDLER)->DeleteAllPropertiesFor(aNode);
}
} }

View File

@ -604,10 +604,6 @@ nsObjectLoadingContent::OnStartRequest(nsIRequest *aRequest,
NS_ASSERTION(thisContent, "must be a content"); NS_ASSERTION(thisContent, "must be a content");
nsIDocument* doc = thisContent->OwnerDoc(); nsIDocument* doc = thisContent->OwnerDoc();
if (!doc) {
Fallback(false);
return NS_BINDING_ABORTED;
}
PRInt16 shouldProcess = nsIContentPolicy::ACCEPT; PRInt16 shouldProcess = nsIContentPolicy::ACCEPT;
rv = rv =
@ -946,7 +942,7 @@ nsObjectLoadingContent::HasNewFrame(nsIObjectFrame* aFrame)
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this)); do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
NS_ASSERTION(thisContent, "must be a content"); NS_ASSERTION(thisContent, "must be a content");
nsIDocument* doc = thisContent->OwnerDoc(); nsIDocument* doc = thisContent->OwnerDoc();
if (!doc || doc->IsStaticDocument() || doc->IsBeingUsedAsImage()) { if (doc->IsStaticDocument() || doc->IsBeingUsedAsImage()) {
return NS_OK; return NS_OK;
} }
@ -1200,7 +1196,7 @@ nsObjectLoadingContent::LoadObject(nsIURI* aURI,
NS_ASSERTION(thisContent, "must be a content"); NS_ASSERTION(thisContent, "must be a content");
nsIDocument* doc = thisContent->OwnerDoc(); nsIDocument* doc = thisContent->OwnerDoc();
if (!doc || doc->IsBeingUsedAsImage()) { if (doc->IsBeingUsedAsImage()) {
return NS_OK; return NS_OK;
} }

View File

@ -1295,9 +1295,7 @@ nsresult nsRange::CutContents(nsIDOMDocumentFragment** aFragment)
nsresult rv; nsresult rv;
nsCOMPtr<nsIDocument> doc = nsCOMPtr<nsIDocument> doc = mStartParent->OwnerDoc();
do_QueryInterface(mStartParent->OwnerDoc());
if (!doc) return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIDOMNode> commonAncestor; nsCOMPtr<nsIDOMNode> commonAncestor;
rv = GetCommonAncestorContainer(getter_AddRefs(commonAncestor)); rv = GetCommonAncestorContainer(getter_AddRefs(commonAncestor));

View File

@ -312,9 +312,9 @@ nsStyledElementNotElementCSSInlineStyle::ParseStyleAttribute(const nsAString& aV
{ {
nsIDocument* doc = OwnerDoc(); nsIDocument* doc = OwnerDoc();
if (doc && (aForceInDataDoc || if (aForceInDataDoc ||
!doc->IsLoadedAsData() || !doc->IsLoadedAsData() ||
doc->IsStaticDocument())) { doc->IsStaticDocument()) {
bool isCSS = true; // assume CSS until proven otherwise bool isCSS = true; // assume CSS until proven otherwise
if (!IsInNativeAnonymousSubtree()) { // native anonymous content if (!IsInNativeAnonymousSubtree()) { // native anonymous content

View File

@ -619,8 +619,7 @@ protected:
nsIPresShell *GetPresShell() { nsIPresShell *GetPresShell() {
nsCOMPtr<nsIContent> content = do_QueryObject(mCanvasElement); nsCOMPtr<nsIContent> content = do_QueryObject(mCanvasElement);
if (content) { if (content) {
nsIDocument* ownerDoc = content->OwnerDoc(); return content->OwnerDoc()->GetShell();
return ownerDoc ? ownerDoc->GetShell() : nsnull;
} }
if (mDocShell) { if (mDocShell) {
nsCOMPtr<nsIPresShell> shell; nsCOMPtr<nsIPresShell> shell;

View File

@ -610,8 +610,7 @@ protected:
nsIPresShell *GetPresShell() { nsIPresShell *GetPresShell() {
nsCOMPtr<nsIContent> content = do_QueryObject(mCanvasElement); nsCOMPtr<nsIContent> content = do_QueryObject(mCanvasElement);
if (content) { if (content) {
nsIDocument* ownerDoc = content->OwnerDoc(); return content->OwnerDoc()->GetShell();
return ownerDoc ? ownerDoc->GetShell() : nsnull;
} }
if (mDocShell) { if (mDocShell) {
nsCOMPtr<nsIPresShell> shell; nsCOMPtr<nsIPresShell> shell;

View File

@ -196,9 +196,7 @@ nsEventListenerManager::GetInnerWindowForTarget()
if (node) { if (node) {
// XXX sXBL/XBL2 issue -- do we really want the owner here? What // XXX sXBL/XBL2 issue -- do we really want the owner here? What
// if that's the XBL document? // if that's the XBL document?
nsIDocument* document = node->OwnerDoc(); return node->OwnerDoc()->GetInnerWindow();
if (document)
return document->GetInnerWindow();
} }
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mTarget); nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mTarget);
@ -467,9 +465,7 @@ nsEventListenerManager::AddScriptEventListener(nsIAtom *aName,
// Try to get context from doc // Try to get context from doc
// XXX sXBL/XBL2 issue -- do we really want the owner here? What // XXX sXBL/XBL2 issue -- do we really want the owner here? What
// if that's the XBL document? // if that's the XBL document?
doc = node->OwnerDoc(); global = node->OwnerDoc()->GetScriptGlobalObject();
if (doc)
global = doc->GetScriptGlobalObject();
} else { } else {
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(mTarget)); nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(mTarget));
if (win) { if (win) {

View File

@ -70,14 +70,12 @@ NS_IMETHODIMP nsPLDOMEvent::Run()
target->DispatchEvent(mEvent, &defaultActionEnabled); target->DispatchEvent(mEvent, &defaultActionEnabled);
} else { } else {
nsIDocument* doc = mEventNode->OwnerDoc(); nsIDocument* doc = mEventNode->OwnerDoc();
if (doc) { if (mDispatchChromeOnly) {
if (mDispatchChromeOnly) { nsContentUtils::DispatchChromeEvent(doc, mEventNode, mEventType,
nsContentUtils::DispatchChromeEvent(doc, mEventNode, mEventType, mBubbles, false);
mBubbles, false); } else {
} else { nsContentUtils::DispatchTrustedEvent(doc, mEventNode, mEventType,
nsContentUtils::DispatchTrustedEvent(doc, mEventNode, mEventType, mBubbles, false);
mBubbles, false);
}
} }
} }

View File

@ -200,9 +200,6 @@ public:
} }
nsIDocument* document = mElement->OwnerDoc(); nsIDocument* document = mElement->OwnerDoc();
if (!document) {
return NS_OK;
}
nsPIDOMWindow* window = document->GetWindow(); nsPIDOMWindow* window = document->GetWindow();
if (!window) { if (!window) {
@ -678,9 +675,6 @@ nsGenericHTMLElement::GetInnerHTML(nsAString& aInnerHTML)
aInnerHTML.Truncate(); aInnerHTML.Truncate();
nsIDocument* doc = OwnerDoc(); nsIDocument* doc = OwnerDoc();
if (!doc) {
return NS_OK; // We rely on the document for doing HTML conversion
}
nsresult rv = NS_OK; nsresult rv = NS_OK;
@ -749,7 +743,6 @@ nsresult
nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML) nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML)
{ {
nsIDocument* doc = OwnerDoc(); nsIDocument* doc = OwnerDoc();
NS_ENSURE_STATE(doc);
nsresult rv = NS_OK; nsresult rv = NS_OK;
@ -835,7 +828,6 @@ nsGenericHTMLElement::InsertAdjacentHTML(const nsAString& aPosition,
} }
nsIDocument* doc = OwnerDoc(); nsIDocument* doc = OwnerDoc();
NS_ENSURE_STATE(doc);
// Needed when insertAdjacentHTML is used in combination with contenteditable // Needed when insertAdjacentHTML is used in combination with contenteditable
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, true); mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, true);
@ -1272,8 +1264,7 @@ nsGenericHTMLElement::GetEventListenerManagerForAttr(nsIAtom* aAttrName,
// bail if it does. See similar code in nsHTMLBodyElement and // bail if it does. See similar code in nsHTMLBodyElement and
// nsHTMLFramesetElement // nsHTMLFramesetElement
*aDefer = false; *aDefer = false;
if (document && if ((win = document->GetInnerWindow()) && win->IsInnerWindow()) {
(win = document->GetInnerWindow()) && win->IsInnerWindow()) {
nsCOMPtr<nsIDOMEventTarget> piTarget(do_QueryInterface(win)); nsCOMPtr<nsIDOMEventTarget> piTarget(do_QueryInterface(win));
return piTarget->GetListenerManager(true); return piTarget->GetListenerManager(true);
@ -1378,12 +1369,7 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
void void
nsGenericHTMLElement::GetBaseTarget(nsAString& aBaseTarget) const nsGenericHTMLElement::GetBaseTarget(nsAString& aBaseTarget) const
{ {
nsIDocument* ownerDoc = OwnerDoc(); OwnerDoc()->GetBaseTarget(aBaseTarget);
if (ownerDoc) {
ownerDoc->GetBaseTarget(aBaseTarget);
} else {
aBaseTarget.Truncate();
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -3427,7 +3413,6 @@ nsresult nsGenericHTMLElement::MozRequestFullScreen()
} }
nsIDocument* doc = OwnerDoc(); nsIDocument* doc = OwnerDoc();
NS_ENSURE_STATE(doc);
nsCOMPtr<nsIDOMDocument> domDocument(do_QueryInterface(doc)); nsCOMPtr<nsIDOMDocument> domDocument(do_QueryInterface(doc));
NS_ENSURE_STATE(domDocument); NS_ENSURE_STATE(domDocument);
bool fullScreenEnabled; bool fullScreenEnabled;

View File

@ -292,7 +292,7 @@ nsHTMLDNSPrefetch::nsDeferrals::SubmitQueue()
while (mHead != mTail) { while (mHead != mTail) {
nsCOMPtr<nsIContent> content = do_QueryReferent(mEntries[mTail].mElement); nsCOMPtr<nsIContent> content = do_QueryReferent(mEntries[mTail].mElement);
if (content && content->OwnerDoc()) { if (content) {
nsCOMPtr<Link> link = do_QueryInterface(content); nsCOMPtr<Link> link = do_QueryInterface(content);
nsCOMPtr<nsIURI> hrefURI(link ? link->GetURI() : nsnull); nsCOMPtr<nsIURI> hrefURI(link ? link->GetURI() : nsnull);
if (hrefURI) if (hrefURI)

View File

@ -447,7 +447,7 @@ nsHTMLImageElement::IsHTMLFocusable(bool aWithMouse,
// XXXbz which document should this be using? sXBL/XBL2 issue! I // XXXbz which document should this be using? sXBL/XBL2 issue! I
// think that OwnerDoc() is right, since we don't want to // think that OwnerDoc() is right, since we don't want to
// assume stuff about the document we're bound to. // assume stuff about the document we're bound to.
if (OwnerDoc() && OwnerDoc()->FindImageMap(usemap)) { if (OwnerDoc()->FindImageMap(usemap)) {
if (aTabIndex) { if (aTabIndex) {
// Use tab index on individual map areas // Use tab index on individual map areas
*aTabIndex = (sTabFocusModel & eTabFocus_linksMask)? 0 : -1; *aTabIndex = (sTabFocusModel & eTabFocus_linksMask)? 0 : -1;

View File

@ -241,11 +241,9 @@ public:
AsyncClickHandler(nsHTMLInputElement* aInput) AsyncClickHandler(nsHTMLInputElement* aInput)
: mInput(aInput) { : mInput(aInput) {
nsIDocument* doc = aInput->OwnerDoc(); nsPIDOMWindow* win = aInput->OwnerDoc()->GetWindow();
if (doc) { if (win) {
nsPIDOMWindow* win = doc->GetWindow(); mPopupControlState = win->GetPopupControlState();
if (win)
mPopupControlState = win->GetPopupControlState();
} }
}; };
@ -263,8 +261,6 @@ AsyncClickHandler::Run()
// Get parent nsPIDOMWindow object. // Get parent nsPIDOMWindow object.
nsCOMPtr<nsIDocument> doc = mInput->OwnerDoc(); nsCOMPtr<nsIDocument> doc = mInput->OwnerDoc();
if (!doc)
return NS_ERROR_FAILURE;
nsPIDOMWindow* win = doc->GetWindow(); nsPIDOMWindow* win = doc->GetWindow();
if (!win) { if (!win) {
@ -3738,9 +3734,6 @@ nsHTMLInputElement::HasPatternMismatch() const
} }
nsIDocument* doc = OwnerDoc(); nsIDocument* doc = OwnerDoc();
if (!doc) {
return false;
}
return !nsContentUtils::IsPatternMatching(value, pattern, doc); return !nsContentUtils::IsPatternMatching(value, pattern, doc);
} }

View File

@ -1911,9 +1911,6 @@ nsresult nsHTMLMediaElement::NewURIFromString(const nsAutoString& aURISpec, nsIU
*aURI = nsnull; *aURI = nsnull;
nsCOMPtr<nsIDocument> doc = OwnerDoc(); nsCOMPtr<nsIDocument> doc = OwnerDoc();
if (!doc) {
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
nsCOMPtr<nsIURI> baseURI = GetBaseURI(); nsCOMPtr<nsIURI> baseURI = GetBaseURI();
nsresult rv = nsContentUtils::NewURIWithDocumentCharset(aURI, nsresult rv = nsContentUtils::NewURIWithDocumentCharset(aURI,
@ -2377,7 +2374,7 @@ void nsHTMLMediaElement::NotifyOwnerDocumentActivityChanged()
// Don't pause if we have no ownerDoc. Something native must have created // Don't pause if we have no ownerDoc. Something native must have created
// us and be expecting us to work without a document. // us and be expecting us to work without a document.
bool pauseForInactiveDocument = bool pauseForInactiveDocument =
ownerDoc && (!ownerDoc->IsActive() || !ownerDoc->IsVisible()); !ownerDoc->IsActive() || !ownerDoc->IsVisible();
if (pauseForInactiveDocument != mPausedForInactiveDocument) { if (pauseForInactiveDocument != mPausedForInactiveDocument) {
mPausedForInactiveDocument = pauseForInactiveDocument; mPausedForInactiveDocument = pauseForInactiveDocument;
@ -2410,7 +2407,7 @@ void nsHTMLMediaElement::AddRemoveSelfReference()
// See the comment at the top of this file for the explanation of this // See the comment at the top of this file for the explanation of this
// boolean expression. // boolean expression.
bool needSelfReference = !mShuttingDown && bool needSelfReference = !mShuttingDown &&
(!ownerDoc || ownerDoc->IsActive()) && ownerDoc->IsActive() &&
(mDelayingLoadEvent || (mDelayingLoadEvent ||
(!mPaused && mDecoder && !mDecoder->IsEnded()) || (!mPaused && mDecoder && !mDecoder->IsEnded()) ||
(mDecoder && mDecoder->IsSeeking()) || (mDecoder && mDecoder->IsSeeking()) ||
@ -2565,8 +2562,7 @@ void nsHTMLMediaElement::ChangeDelayLoadStatus(bool aDelay) {
already_AddRefed<nsILoadGroup> nsHTMLMediaElement::GetDocumentLoadGroup() already_AddRefed<nsILoadGroup> nsHTMLMediaElement::GetDocumentLoadGroup()
{ {
nsIDocument* doc = OwnerDoc(); return OwnerDoc()->GetDocumentLoadGroup();
return doc ? doc->GetDocumentLoadGroup() : nsnull;
} }
nsresult nsresult
@ -2627,10 +2623,7 @@ void nsHTMLMediaElement::SetRequestHeaders(nsIHttpChannel* aChannel)
NS_LITERAL_CSTRING(""), false); NS_LITERAL_CSTRING(""), false);
// Set the Referer header // Set the Referer header
nsIDocument* doc = OwnerDoc(); aChannel->SetReferrer(OwnerDoc()->GetDocumentURI());
if (doc) {
aChannel->SetReferrer(doc->GetDocumentURI());
}
} }
void nsHTMLMediaElement::FireTimeUpdate(bool aPeriodic) void nsHTMLMediaElement::FireTimeUpdate(bool aPeriodic)

View File

@ -208,9 +208,6 @@ nsHTMLMenuElement::CanLoadIcon(nsIContent* aContent, const nsAString& aIcon)
} }
nsIDocument* doc = aContent->OwnerDoc(); nsIDocument* doc = aContent->OwnerDoc();
if (!doc) {
return false;
}
nsCOMPtr<nsIURI> baseURI = aContent->GetBaseURI(); nsCOMPtr<nsIURI> baseURI = aContent->GetBaseURI();
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;

View File

@ -235,10 +235,9 @@ nsHTMLSharedElement::GetHref(nsAString& aValue)
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
nsIDocument* doc = OwnerDoc(); nsIDocument* doc = OwnerDoc();
if (doc) { nsContentUtils::NewURIWithDocumentCharset(
nsContentUtils::NewURIWithDocumentCharset( getter_AddRefs(uri), href, doc, doc->GetDocumentURI());
getter_AddRefs(uri), href, doc, doc->GetDocumentURI());
}
if (!uri) { if (!uri) {
aValue = href; aValue = href;
return NS_OK; return NS_OK;

View File

@ -612,10 +612,7 @@ nsMathMLElement::GetLinkTarget(nsAString& aTarget)
case 1: case 1:
return; return;
} }
nsIDocument* ownerDoc = OwnerDoc(); OwnerDoc()->GetBaseTarget(aTarget);
if (ownerDoc) {
ownerDoc->GetBaseTarget(aTarget);
}
} }
} }

View File

@ -310,12 +310,9 @@ nsSVGAnimationElement::BindToTree(nsIDocument* aDocument,
void void
nsSVGAnimationElement::UnbindFromTree(bool aDeep, bool aNullParent) nsSVGAnimationElement::UnbindFromTree(bool aDeep, bool aNullParent)
{ {
nsIDocument *doc = OwnerDoc(); nsSMILAnimationController *controller = OwnerDoc()->GetAnimationController();
if (doc) { if (controller) {
nsSMILAnimationController *controller = doc->GetAnimationController(); controller->UnregisterAnimationElement(this);
if (controller) {
controller->UnregisterAnimationElement(this);
}
} }
mHrefTarget.Unlink(); mHrefTarget.Unlink();

View File

@ -813,29 +813,26 @@ nsSVGElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
// in nsHTMLCSSStyleSheet::RulesMatching(), where we determine whether to // in nsHTMLCSSStyleSheet::RulesMatching(), where we determine whether to
// apply the SMILOverrideStyle.) // apply the SMILOverrideStyle.)
nsIDocument* doc = OwnerDoc(); nsIDocument* doc = OwnerDoc();
NS_ASSERTION(doc, "SVG element without doc"); nsIPresShell* shell = doc->GetShell();
if (doc) { nsPresContext* context = shell ? shell->GetPresContext() : nsnull;
nsIPresShell* shell = doc->GetShell(); if (context && context->IsProcessingRestyles() &&
nsPresContext* context = shell ? shell->GetPresContext() : nsnull; !context->IsProcessingAnimationStyleChange()) {
if (context && context->IsProcessingRestyles() && // Any style changes right now could trigger CSS Transitions. We don't
!context->IsProcessingAnimationStyleChange()) { // want that to happen from SMIL-animated value of mapped attrs, so
// Any style changes right now could trigger CSS Transitions. We don't // ignore animated value for now, and request an animation restyle to
// want that to happen from SMIL-animated value of mapped attrs, so // get our animated value noticed.
// ignore animated value for now, and request an animation restyle to shell->RestyleForAnimation(this, eRestyle_Self);
// get our animated value noticed. } else {
shell->RestyleForAnimation(this, eRestyle_Self); // Ok, this is an animation restyle -- go ahead and update/walk the
} else { // animated content style rule.
// Ok, this is an animation restyle -- go ahead and update/walk the css::StyleRule* animContentStyleRule = GetAnimatedContentStyleRule();
// animated content style rule. if (!animContentStyleRule) {
css::StyleRule* animContentStyleRule = GetAnimatedContentStyleRule(); UpdateAnimatedContentStyleRule();
if (!animContentStyleRule) { animContentStyleRule = GetAnimatedContentStyleRule();
UpdateAnimatedContentStyleRule(); }
animContentStyleRule = GetAnimatedContentStyleRule(); if (animContentStyleRule) {
} animContentStyleRule->RuleMatched();
if (animContentStyleRule) { aRuleWalker->Forward(animContentStyleRule);
animContentStyleRule->RuleMatched();
aRuleWalker->Forward(animContentStyleRule);
}
} }
} }
#endif // MOZ_SMIL #endif // MOZ_SMIL
@ -1130,11 +1127,6 @@ nsSVGElement::UpdateContentStyleRule()
} }
nsIDocument* doc = OwnerDoc(); nsIDocument* doc = OwnerDoc();
if (!doc) {
NS_ERROR("SVG element without owner document");
return;
}
MappedAttrParser mappedAttrParser(doc->CSSLoader(), doc->GetDocumentURI(), MappedAttrParser mappedAttrParser(doc->CSSLoader(), doc->GetDocumentURI(),
GetBaseURI(), NodePrincipal()); GetBaseURI(), NodePrincipal());

View File

@ -5438,14 +5438,12 @@ nsSVGFEImageElement::LoadSVGImage(bool aForce, bool aNotify)
// Make sure we don't get in a recursive death-spiral // Make sure we don't get in a recursive death-spiral
nsIDocument* doc = OwnerDoc(); nsIDocument* doc = OwnerDoc();
if (doc) { nsCOMPtr<nsIURI> hrefAsURI;
nsCOMPtr<nsIURI> hrefAsURI; if (NS_SUCCEEDED(StringToURI(href, doc, getter_AddRefs(hrefAsURI)))) {
if (NS_SUCCEEDED(StringToURI(href, doc, getter_AddRefs(hrefAsURI)))) { bool isEqual;
bool isEqual; if (NS_SUCCEEDED(hrefAsURI->Equals(baseURI, &isEqual)) && isEqual) {
if (NS_SUCCEEDED(hrefAsURI->Equals(baseURI, &isEqual)) && isEqual) { // Image URI matches our URI exactly! Bail out.
// Image URI matches our URI exactly! Bail out. return NS_OK;
return NS_OK;
}
} }
} }

View File

@ -118,13 +118,9 @@ nsSVGStylableElement::DidAnimateClass()
} }
mClassAnimAttr->ParseAtomArray(src); mClassAnimAttr->ParseAtomArray(src);
nsIDocument* doc = OwnerDoc(); nsIPresShell* shell = OwnerDoc()->GetShell();
NS_ASSERTION(doc, "If we're animating we should have an owner"); if (shell) {
if (doc) { shell->RestyleForAnimation(this, eRestyle_Self);
nsIPresShell* shell = doc->GetShell();
if (shell) {
shell->RestyleForAnimation(this, eRestyle_Self);
}
} }
nsSVGStylableElementBase::DidAnimateClass(); nsSVGStylableElementBase::DidAnimateClass();

View File

@ -933,7 +933,6 @@ nsBindingManager::RemoveLayeredBinding(nsIContent* aContent, nsIURI* aURL)
// currentdoc too? What's the one that should be passed to // currentdoc too? What's the one that should be passed to
// ChangeDocument? // ChangeDocument?
nsCOMPtr<nsIDocument> doc = aContent->OwnerDoc(); nsCOMPtr<nsIDocument> doc = aContent->OwnerDoc();
NS_ASSERTION(doc, "No owner document?");
// Finally remove the binding... // Finally remove the binding...
// XXXbz this doesn't remove the implementation! Should fix! Until // XXXbz this doesn't remove the implementation! Should fix! Until
@ -1252,8 +1251,6 @@ nsBindingManager::GetBindingImplementation(nsIContent* aContent, REFNSIID aIID,
// Create an XPC wrapper for the script object and hand it back. // Create an XPC wrapper for the script object and hand it back.
nsIDocument* doc = aContent->OwnerDoc(); nsIDocument* doc = aContent->OwnerDoc();
if (!doc)
return NS_NOINTERFACE;
nsIScriptGlobalObject *global = doc->GetScriptGlobalObject(); nsIScriptGlobalObject *global = doc->GetScriptGlobalObject();
if (!global) if (!global)

View File

@ -179,9 +179,6 @@ XBLResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
// This mirrors code in nsXBLProtoImpl::InstallImplementation // This mirrors code in nsXBLProtoImpl::InstallImplementation
nsIDocument* doc = content->OwnerDoc(); nsIDocument* doc = content->OwnerDoc();
if (!doc) {
return JS_TRUE;
}
nsIScriptGlobalObject* global = doc->GetScriptGlobalObject(); nsIScriptGlobalObject* global = doc->GetScriptGlobalObject();
if (!global) { if (!global) {
@ -554,11 +551,6 @@ RealizeDefaultContent(nsISupports* aKey,
return PL_DHASH_STOP; return PL_DHASH_STOP;
} }
nsIDocument *document = insParent->OwnerDoc(); nsIDocument *document = insParent->OwnerDoc();
if (!document) {
data->mRv = NS_ERROR_FAILURE;
return PL_DHASH_STOP;
}
nsCOMPtr<nsIDOMNode> clonedNode; nsCOMPtr<nsIDOMNode> clonedNode;
nsCOMArray<nsINode> nodesWithProperties; nsCOMArray<nsINode> nodesWithProperties;
nsNodeUtils::Clone(defContent, true, document->NodeInfoManager(), nsNodeUtils::Clone(defContent, true, document->NodeInfoManager(),
@ -642,10 +634,6 @@ nsXBLBinding::GenerateAnonymousContent()
if (hasContent || hasInsertionPoints) { if (hasContent || hasInsertionPoints) {
nsIDocument* doc = mBoundElement->OwnerDoc(); nsIDocument* doc = mBoundElement->OwnerDoc();
// XXX doc will be null if we're in the midst of paint suppression.
if (! doc)
return;
nsBindingManager *bindingManager = doc->BindingManager(); nsBindingManager *bindingManager = doc->BindingManager();

View File

@ -82,8 +82,7 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aBinding, nsIConten
// If the way this gets the script context changes, fix // If the way this gets the script context changes, fix
// nsXBLProtoImplAnonymousMethod::Execute // nsXBLProtoImplAnonymousMethod::Execute
nsIDocument* document = aBoundElement->OwnerDoc(); nsIDocument* document = aBoundElement->OwnerDoc();
if (!document) return NS_OK;
nsIScriptGlobalObject *global = document->GetScopeObject(); nsIScriptGlobalObject *global = document->GetScopeObject();
if (!global) return NS_OK; if (!global) return NS_OK;
@ -141,7 +140,7 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
nsIDocument *ownerDoc = aBoundElement->OwnerDoc(); nsIDocument *ownerDoc = aBoundElement->OwnerDoc();
nsIScriptGlobalObject *sgo; nsIScriptGlobalObject *sgo;
if (!ownerDoc || !(sgo = ownerDoc->GetScopeObject())) { if (!(sgo = ownerDoc->GetScopeObject())) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }

View File

@ -133,7 +133,7 @@ nsXBLProtoImplMethod::InstallMember(nsIScriptContext* aContext,
nsIDocument *ownerDoc = aBoundElement->OwnerDoc(); nsIDocument *ownerDoc = aBoundElement->OwnerDoc();
nsIScriptGlobalObject *sgo; nsIScriptGlobalObject *sgo;
if (!ownerDoc || !(sgo = ownerDoc->GetScopeObject())) { if (!(sgo = ownerDoc->GetScopeObject())) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
@ -280,9 +280,6 @@ nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement)
// Get the script context the same way // Get the script context the same way
// nsXBLProtoImpl::InstallImplementation does. // nsXBLProtoImpl::InstallImplementation does.
nsIDocument* document = aBoundElement->OwnerDoc(); nsIDocument* document = aBoundElement->OwnerDoc();
if (!document) {
return NS_OK;
}
nsIScriptGlobalObject* global = document->GetScriptGlobalObject(); nsIScriptGlobalObject* global = document->GetScriptGlobalObject();
if (!global) { if (!global) {

View File

@ -160,7 +160,7 @@ nsXBLProtoImplProperty::InstallMember(nsIScriptContext* aContext,
nsIDocument *ownerDoc = aBoundElement->OwnerDoc(); nsIDocument *ownerDoc = aBoundElement->OwnerDoc();
nsIScriptGlobalObject *sgo; nsIScriptGlobalObject *sgo;
if (!ownerDoc || !(sgo = ownerDoc->GetScopeObject())) { if (!(sgo = ownerDoc->GetScopeObject())) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }

View File

@ -293,8 +293,6 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventTarget* aTarget,
if (!content) if (!content)
return NS_OK; return NS_OK;
boundDocument = content->OwnerDoc(); boundDocument = content->OwnerDoc();
if (!boundDocument)
return NS_OK;
} }
boundGlobal = boundDocument->GetScopeObject(); boundGlobal = boundDocument->GetScopeObject();

View File

@ -549,10 +549,6 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL,
nsCOMPtr<nsIDocument> document = aContent->OwnerDoc(); nsCOMPtr<nsIDocument> document = aContent->OwnerDoc();
// XXX document may be null if we're in the midst of paint suppression
if (!document)
return NS_OK;
nsCAutoString urlspec; nsCAutoString urlspec;
if (nsContentUtils::GetWrapperSafeScriptFilename(document, aURL, urlspec)) { if (nsContentUtils::GetWrapperSafeScriptFilename(document, aURL, urlspec)) {
// Block an attempt to load a binding that has special wrapper // Block an attempt to load a binding that has special wrapper
@ -659,10 +655,6 @@ nsXBLService::FlushStyleBindings(nsIContent* aContent)
{ {
nsCOMPtr<nsIDocument> document = aContent->OwnerDoc(); nsCOMPtr<nsIDocument> document = aContent->OwnerDoc();
// XXX doc will be null if we're in the midst of paint suppression.
if (! document)
return NS_OK;
nsBindingManager *bindingManager = document->BindingManager(); nsBindingManager *bindingManager = document->BindingManager();
nsXBLBinding *binding = bindingManager->GetBinding(aContent); nsXBLBinding *binding = bindingManager->GetBinding(aContent);
@ -687,14 +679,8 @@ nsXBLService::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID,
nsIAtom** aResult) nsIAtom** aResult)
{ {
nsIDocument* document = aContent->OwnerDoc(); nsIDocument* document = aContent->OwnerDoc();
if (document) { *aResult = document->BindingManager()->ResolveTag(aContent, aNameSpaceID);
*aResult = document->BindingManager()->ResolveTag(aContent, aNameSpaceID); NS_IF_ADDREF(*aResult);
NS_IF_ADDREF(*aResult);
}
else {
*aNameSpaceID = aContent->GetNameSpaceID();
NS_ADDREF(*aResult = aContent->Tag());
}
return NS_OK; return NS_OK;
} }

View File

@ -180,14 +180,10 @@ nsXMLStylesheetPI::GetStyleSheetURL(bool* aIsInline)
nsIURI *baseURL; nsIURI *baseURL;
nsCAutoString charset; nsCAutoString charset;
nsIDocument *document = OwnerDoc(); nsIDocument *document = OwnerDoc();
if (document) { baseURL = mOverriddenBaseURI ?
baseURL = mOverriddenBaseURI ? mOverriddenBaseURI.get() :
mOverriddenBaseURI.get() : document->GetDocBaseURI();
document->GetDocBaseURI(); charset = document->GetDocumentCharacterSet();
charset = document->GetDocumentCharacterSet();
} else {
baseURL = mOverriddenBaseURI;
}
nsCOMPtr<nsIURI> aURI; nsCOMPtr<nsIURI> aURI;
NS_NewURI(getter_AddRefs(aURI), href, charset.get(), baseURL); NS_NewURI(getter_AddRefs(aURI), href, charset.get(), baseURL);

View File

@ -88,13 +88,6 @@ URIUtils::ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode)
} }
nsCOMPtr<nsIDocument> sourceDoc = node->OwnerDoc(); nsCOMPtr<nsIDocument> sourceDoc = node->OwnerDoc();
if (!sourceDoc) {
NS_ERROR("no source document found");
// XXXbz passing nsnull as the first arg to Reset is illegal
aNewDoc->Reset(nsnull, nsnull);
return;
}
nsIPrincipal* sourcePrincipal = sourceDoc->NodePrincipal(); nsIPrincipal* sourcePrincipal = sourceDoc->NodePrincipal();
// Copy the channel and loadgroup from the source document. // Copy the channel and loadgroup from the source document.

View File

@ -574,8 +574,7 @@ txXPathNodeUtils::getDocument(const txXPathNode& aNode)
txXPathNode* txXPathNode*
txXPathNodeUtils::getOwnerDocument(const txXPathNode& aNode) txXPathNodeUtils::getOwnerDocument(const txXPathNode& aNode)
{ {
nsIDocument* document = aNode.mNode->OwnerDoc(); return new txXPathNode(aNode.mNode->OwnerDoc());
return document ? new txXPathNode(document) : nsnull;
} }
#ifndef HAVE_64BIT_OS #ifndef HAVE_64BIT_OS

View File

@ -721,7 +721,6 @@ TX_CompileStylesheet(nsINode* aNode, txMozillaXSLTProcessor* aProcessor,
{ {
// If we move GetBaseURI to nsINode this can be simplified. // If we move GetBaseURI to nsINode this can be simplified.
nsCOMPtr<nsIDocument> doc = aNode->OwnerDoc(); nsCOMPtr<nsIDocument> doc = aNode->OwnerDoc();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
if (aNode->IsNodeOfType(nsINode::eCONTENT)) { if (aNode->IsNodeOfType(nsINode::eCONTENT)) {

View File

@ -118,12 +118,7 @@ txMozillaXMLOutput::txMozillaXMLOutput(txOutputFormat* aFormat,
mCurrentNode = do_QueryInterface(aFragment); mCurrentNode = do_QueryInterface(aFragment);
mDocument = mCurrentNode->OwnerDoc(); mDocument = mCurrentNode->OwnerDoc();
if (mDocument) { mNodeInfoManager = mDocument->NodeInfoManager();
mNodeInfoManager = mDocument->NodeInfoManager();
}
else {
mCurrentNode = nsnull;
}
} }
txMozillaXMLOutput::~txMozillaXMLOutput() txMozillaXMLOutput::~txMozillaXMLOutput()

View File

@ -515,8 +515,6 @@ nsXULElement::GetEventListenerManagerForAttr(nsIAtom* aAttrName, bool* aDefer)
// here, override BindToTree for those classes and munge event // here, override BindToTree for those classes and munge event
// listeners there? // listeners there?
nsIDocument* doc = OwnerDoc(); nsIDocument* doc = OwnerDoc();
if (!doc)
return nsnull; // XXX
nsPIDOMWindow *window; nsPIDOMWindow *window;
Element *root = doc->GetRootElement(); Element *root = doc->GetRootElement();
@ -1855,9 +1853,7 @@ nsXULElement::GetBoxObject(nsIBoxObject** aResult)
*aResult = nsnull; *aResult = nsnull;
// XXX sXBL/XBL2 issue! Owner or current document? // XXX sXBL/XBL2 issue! Owner or current document?
nsIDocument* nsDoc = OwnerDoc(); return OwnerDoc()->GetBoxObjectFor(this, aResult);
return nsDoc ? nsDoc->GetBoxObjectFor(this, aResult) : NS_ERROR_FAILURE;
} }
// Methods for setting/getting attributes from nsIDOMXULElement // Methods for setting/getting attributes from nsIDOMXULElement

View File

@ -4441,7 +4441,6 @@ nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild,
if (!posStr.IsEmpty()) { if (!posStr.IsEmpty()) {
nsIDocument *document = aParent->OwnerDoc(); nsIDocument *document = aParent->OwnerDoc();
if (!document) return NS_ERROR_FAILURE;
nsIContent *content = nsnull; nsIContent *content = nsnull;

View File

@ -390,8 +390,6 @@ ForEachPing(nsIContent *content, ForEachPingCallback callback, void *closure)
return; return;
nsIDocument *doc = content->OwnerDoc(); nsIDocument *doc = content->OwnerDoc();
if (!doc)
return;
// value contains relative URIs split on spaces (U+0020) // value contains relative URIs split on spaces (U+0020)
const PRUnichar *start = value.BeginReading(); const PRUnichar *start = value.BeginReading();
@ -551,8 +549,6 @@ SendPing(void *closure, nsIContent *content, nsIURI *uri, nsIIOService *ios)
} }
nsIDocument *doc = content->OwnerDoc(); nsIDocument *doc = content->OwnerDoc();
if (!doc)
return;
nsCOMPtr<nsIChannel> chan; nsCOMPtr<nsIChannel> chan;
ios->NewChannelFromURI(uri, getter_AddRefs(chan)); ios->NewChannelFromURI(uri, getter_AddRefs(chan));

View File

@ -7257,16 +7257,6 @@ nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj,
// See http://bugzilla.mozilla.org/show_bug.cgi?id=227417 // See http://bugzilla.mozilla.org/show_bug.cgi?id=227417
nsIDocument* doc = node->OwnerDoc(); nsIDocument* doc = node->OwnerDoc();
if (!doc) {
// No document reachable from nativeObj, use the global object
// that was passed to this method.
*parentObj = globalObj;
return node->IsInNativeAnonymousSubtree() ?
NS_SUCCESS_CHROME_ACCESS_ONLY : NS_OK;
}
// If we have a document, make sure one of these is true // If we have a document, make sure one of these is true
// (1) it has a script handling object, // (1) it has a script handling object,
// (2) has had one, or has been marked to have had one, // (2) has had one, or has been marked to have had one,
@ -7619,10 +7609,6 @@ nsElementSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);
nsIDocument* doc = content->OwnerDoc(); nsIDocument* doc = content->OwnerDoc();
if (!doc) {
// Nothing else to do here
return NS_OK;
}
nsRefPtr<nsXBLBinding> binding = doc->BindingManager()->GetBinding(content); nsRefPtr<nsXBLBinding> binding = doc->BindingManager()->GetBinding(content);
if (!binding) { if (!binding) {
@ -8160,7 +8146,6 @@ nsDOMStringMapSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
nsDOMStringMap* dataset = static_cast<nsDOMStringMap*>(nativeObj); nsDOMStringMap* dataset = static_cast<nsDOMStringMap*>(nativeObj);
nsIDocument* document = dataset->GetElement()->OwnerDoc(); nsIDocument* document = dataset->GetElement()->OwnerDoc();
NS_ENSURE_TRUE(document, NS_OK);
nsCOMPtr<nsIScriptGlobalObject> sgo = nsCOMPtr<nsIScriptGlobalObject> sgo =
do_GetInterface(document->GetScopeObject()); do_GetInterface(document->GetScopeObject());

View File

@ -618,18 +618,15 @@ TabParent::RecvGetWidgetNativeData(WindowsHandle* aValue)
{ {
nsCOMPtr<nsIContent> content = do_QueryInterface(mFrameElement); nsCOMPtr<nsIContent> content = do_QueryInterface(mFrameElement);
if (content) { if (content) {
nsIDocument* document = content->OwnerDoc(); nsIPresShell* shell = content->OwnerDoc()->GetShell();
if (document) { if (shell) {
nsIPresShell* shell = document->GetShell(); nsIViewManager* vm = shell->GetViewManager();
if (shell) { nsCOMPtr<nsIWidget> widget;
nsIViewManager* vm = shell->GetViewManager(); vm->GetRootWidget(getter_AddRefs(widget));
nsCOMPtr<nsIWidget> widget; if (widget) {
vm->GetRootWidget(getter_AddRefs(widget)); *aValue = reinterpret_cast<WindowsHandle>(
if (widget) { widget->GetNativeData(NS_NATIVE_SHAREABLE_WINDOW));
*aValue = reinterpret_cast<WindowsHandle>( return true;
widget->GetNativeData(NS_NATIVE_SHAREABLE_WINDOW));
return true;
}
} }
} }
} }

View File

@ -2053,9 +2053,6 @@ nsJSNPRuntime::OnPluginDestroy(NPP npp)
} }
nsIDocument* doc = content->OwnerDoc(); nsIDocument* doc = content->OwnerDoc();
if (!doc) {
return;
}
nsIScriptGlobalObject* sgo = doc->GetScriptGlobalObject(); nsIScriptGlobalObject* sgo = doc->GetScriptGlobalObject();
if (!sgo) { if (!sgo) {

View File

@ -969,15 +969,12 @@ nsCSSRendering::FindBackgroundStyleFrame(nsIFrame* aForFrame)
nsIContent* content = aForFrame->GetContent(); nsIContent* content = aForFrame->GetContent();
// The root element content can't be null. We wouldn't know what // The root element content can't be null. We wouldn't know what
// frame to create for aFrame. // frame to create for aFrame.
// Use |GetOwnerDoc| so it works during destruction. // Use |OwnerDoc| so it works during destruction.
if (!content) { if (!content) {
return aForFrame; return aForFrame;
} }
nsIDocument* document = content->OwnerDoc(); nsIDocument* document = content->OwnerDoc();
if (!document) {
return aForFrame;
}
dom::Element* bodyContent = document->GetBodyElement(); dom::Element* bodyContent = document->GetBodyElement();
// We need to null check the body node (bug 118829) since // We need to null check the body node (bug 118829) since
@ -1059,8 +1056,6 @@ FindElementBackground(nsIFrame* aForFrame, nsIFrame* aRootElementFrame,
// We should only look at the <html> background if we're in an HTML document // We should only look at the <html> background if we're in an HTML document
nsIDocument* document = content->OwnerDoc(); nsIDocument* document = content->OwnerDoc();
if (!document)
return true;
dom::Element* bodyContent = document->GetBodyElement(); dom::Element* bodyContent = document->GetBodyElement();
if (bodyContent != content) if (bodyContent != content)

View File

@ -59,9 +59,6 @@ ChildIterator::Init(nsIContent* aContent,
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
nsIDocument* doc = aContent->OwnerDoc(); nsIDocument* doc = aContent->OwnerDoc();
NS_ASSERTION(doc, "element not in the document");
if (! doc)
return NS_ERROR_FAILURE;
// If this node has XBL children, then use them. Otherwise, just use // If this node has XBL children, then use them. Otherwise, just use
// the vanilla content APIs. // the vanilla content APIs.

View File

@ -259,13 +259,11 @@ inDOMUtils::GetBindingURLs(nsIDOMElement *aElement, nsIArray **_retval)
NS_ASSERTION(content, "elements must implement nsIContent"); NS_ASSERTION(content, "elements must implement nsIContent");
nsIDocument *ownerDoc = content->OwnerDoc(); nsIDocument *ownerDoc = content->OwnerDoc();
if (ownerDoc) { nsXBLBinding *binding = ownerDoc->BindingManager()->GetBinding(content);
nsXBLBinding *binding = ownerDoc->BindingManager()->GetBinding(content);
while (binding) { while (binding) {
urls->AppendElement(binding->PrototypeBinding()->BindingURI(), false); urls->AppendElement(binding->PrototypeBinding()->BindingURI(), false);
binding = binding->GetBaseBinding(); binding = binding->GetBaseBinding();
}
} }
NS_ADDREF(*_retval = urls); NS_ADDREF(*_retval = urls);

View File

@ -1257,10 +1257,7 @@ nsCSSStyleSheet::FindOwningWindowInnerID() const
if (windowID == 0 && mOwningNode) { if (windowID == 0 && mOwningNode) {
nsCOMPtr<nsIContent> node = do_QueryInterface(mOwningNode); nsCOMPtr<nsIContent> node = do_QueryInterface(mOwningNode);
if (node) { if (node) {
nsIDocument* doc = node->OwnerDoc(); windowID = node->OwnerDoc()->InnerWindowID();
if (doc) {
windowID = doc->InnerWindowID();
}
} }
} }

View File

@ -176,12 +176,6 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(CSSParsingEnvironment& aC
NS_ASSERTION(mElement, "Something is severely broken -- there should be an Element here!"); NS_ASSERTION(mElement, "Something is severely broken -- there should be an Element here!");
nsIDocument* doc = mElement->OwnerDoc(); nsIDocument* doc = mElement->OwnerDoc();
if (!doc) {
// document has been destroyed
aCSSParseEnv.mPrincipal = nsnull;
return;
}
aCSSParseEnv.mSheetURI = doc->GetDocumentURI(); aCSSParseEnv.mSheetURI = doc->GetDocumentURI();
aCSSParseEnv.mBaseURI = mElement->GetBaseURI(); aCSSParseEnv.mBaseURI = mElement->GetBaseURI();
aCSSParseEnv.mPrincipal = mElement->NodePrincipal(); aCSSParseEnv.mPrincipal = mElement->NodePrincipal();

View File

@ -101,12 +101,7 @@ private:
NS_IMETHODIMP NS_IMETHODIMP
nsImageBoxFrameEvent::Run() nsImageBoxFrameEvent::Run()
{ {
nsIDocument* doc = mContent->OwnerDoc(); nsIPresShell *pres_shell = mContent->OwnerDoc()->GetShell();
if (!doc) {
return NS_OK;
}
nsIPresShell *pres_shell = doc->GetShell();
if (!pres_shell) { if (!pres_shell) {
return NS_OK; return NS_OK;
} }

View File

@ -167,15 +167,13 @@ nsMenuPopupFrame::Init(nsIContent* aContent,
mPopupType = ePopupTypePanel; mPopupType = ePopupTypePanel;
nsIDocument* doc = aContent->OwnerDoc(); nsIDocument* doc = aContent->OwnerDoc();
if (doc) { PRInt32 namespaceID;
PRInt32 namespaceID; nsCOMPtr<nsIAtom> tag = doc->BindingManager()->ResolveTag(aContent, &namespaceID);
nsCOMPtr<nsIAtom> tag = doc->BindingManager()->ResolveTag(aContent, &namespaceID); if (namespaceID == kNameSpaceID_XUL) {
if (namespaceID == kNameSpaceID_XUL) { if (tag == nsGkAtoms::menupopup || tag == nsGkAtoms::popup)
if (tag == nsGkAtoms::menupopup || tag == nsGkAtoms::popup) mPopupType = ePopupTypeMenu;
mPopupType = ePopupTypeMenu; else if (tag == nsGkAtoms::tooltip)
else if (tag == nsGkAtoms::tooltip) mPopupType = ePopupTypeTooltip;
mPopupType = ePopupTypeTooltip;
}
} }
if (mPopupType == ePopupTypePanel && if (mPopupType == ePopupTypePanel &&

View File

@ -703,13 +703,8 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
{ {
nsIContent* content = childBox->GetContent(); nsIContent* content = childBox->GetContent();
nsIDocument* doc = content->OwnerDoc(); nsIDocument* doc = content->OwnerDoc();
nsIAtom* atom; PRInt32 dummy;
if (doc) { nsIAtom* atom = doc->BindingManager()->ResolveTag(content, &dummy);
PRInt32 dummy;
atom = doc->BindingManager()->ResolveTag(content, &dummy);
} else {
atom = content->Tag();
}
// skip over any splitters // skip over any splitters
if (atom != nsGkAtoms::splitter) { if (atom != nsGkAtoms::splitter) {

View File

@ -503,7 +503,6 @@ nsHtml5Parser::ParseHtml5Fragment(const nsAString& aSourceBuffer,
NS_ENSURE_TRUE(aSourceBuffer.Length() <= PR_INT32_MAX, NS_ENSURE_TRUE(aSourceBuffer.Length() <= PR_INT32_MAX,
NS_ERROR_OUT_OF_MEMORY); NS_ERROR_OUT_OF_MEMORY);
nsIDocument* doc = aTargetNode->OwnerDoc(); nsIDocument* doc = aTargetNode->OwnerDoc();
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_AVAILABLE);
nsIURI* uri = doc->GetDocumentURI(); nsIURI* uri = doc->GetDocumentURI();
NS_ENSURE_TRUE(uri, NS_ERROR_NOT_AVAILABLE); NS_ENSURE_TRUE(uri, NS_ERROR_NOT_AVAILABLE);

View File

@ -308,7 +308,6 @@ nsMenuItemIconX::LoadIcon(nsIURI* aIconURI)
if (!mContent) return NS_ERROR_FAILURE; if (!mContent) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocument> document = mContent->OwnerDoc(); nsCOMPtr<nsIDocument> document = mContent->OwnerDoc();
if (!document) return NS_ERROR_FAILURE;
nsCOMPtr<nsILoadGroup> loadGroup = document->GetDocumentLoadGroup(); nsCOMPtr<nsILoadGroup> loadGroup = document->GetDocumentLoadGroup();
if (!loadGroup) return NS_ERROR_FAILURE; if (!loadGroup) return NS_ERROR_FAILURE;

View File

@ -204,10 +204,6 @@ nsresult nsMenuItemX::DispatchDOMEvent(const nsString &eventName, bool *preventD
// get owner document for content // get owner document for content
nsCOMPtr<nsIDocument> parentDoc = mContent->OwnerDoc(); nsCOMPtr<nsIDocument> parentDoc = mContent->OwnerDoc();
if (!parentDoc) {
NS_WARNING("Failed to get owner nsIDocument for menu item content");
return NS_ERROR_FAILURE;
}
// get interface for creating DOM events from content owner document // get interface for creating DOM events from content owner document
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(parentDoc); nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(parentDoc);

View File

@ -124,11 +124,9 @@ nsNativeTheme::GetContentState(nsIFrame* aFrame, PRUint8 aWidgetType)
#endif #endif
#if defined(XP_MACOSX) || defined(XP_WIN) #if defined(XP_MACOSX) || defined(XP_WIN)
nsIDocument* doc = aFrame->GetContent()->OwnerDoc(); nsIDocument* doc = aFrame->GetContent()->OwnerDoc();
if (doc) { nsPIDOMWindow* window = doc->GetWindow();
nsPIDOMWindow* window = doc->GetWindow(); if (window && !window->ShouldShowFocusRing())
if (window && !window->ShouldShowFocusRing()) flags &= ~NS_EVENT_STATE_FOCUS;
flags &= ~NS_EVENT_STATE_FOCUS;
}
#endif #endif
return flags; return flags;