Bug 900738 - Remove HasSameOwnerDoc, r=bz

--HG--
extra : rebase_source : c4456690ffbd53fb98ad08436da2c5d884b25faf
This commit is contained in:
Olli Pettay 2013-08-02 13:24:41 +03:00
parent e9684b52e8
commit 5b5b233df0
5 changed files with 6 additions and 23 deletions

View File

@ -862,23 +862,6 @@ public:
*/
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const = 0;
/**
* Checks if a node has the same ownerDocument as this one. Note that this
* actually compares nodeinfo managers because nodes always have one, even
* when they don't have an ownerDocument. If this function returns true
* it doesn't mean that the nodes actually have an ownerDocument.
*
* @param aOther Other node to check
* @return Whether the owner documents of this node and of aOther are the
* same.
*/
bool HasSameOwnerDoc(nsINode *aOther)
{
// We compare nodeinfo managers because nodes always have one, even when
// they don't have an ownerDocument.
return mNodeInfo->NodeInfoManager() == aOther->mNodeInfo->NodeInfoManager();
}
// This class can be extended by subclasses that wish to store more
// information in the slots.
class nsSlots

View File

@ -900,7 +900,7 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
bool aCompileEventHandlers)
{
NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!");
NS_PRECONDITION(HasSameOwnerDoc(NODE_FROM(aParent, aDocument)),
NS_PRECONDITION((NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc()),
"Must have the same owner document");
NS_PRECONDITION(!aParent || aDocument == aParent->GetCurrentDoc(),
"aDocument must be current doc of aParent");

View File

@ -283,7 +283,7 @@ nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr,
}
nsresult rv;
if (!mContent->HasSameOwnerDoc(&aAttr)) {
if (mContent->OwnerDoc() != aAttr.OwnerDoc()) {
nsCOMPtr<nsINode> adoptedNode =
mContent->OwnerDoc()->AdoptNode(aAttr, aError);
if (aError.Failed()) {

View File

@ -440,7 +440,7 @@ nsGenericDOMDataNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
bool aCompileEventHandlers)
{
NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!");
NS_PRECONDITION(HasSameOwnerDoc(NODE_FROM(aParent, aDocument)),
NS_PRECONDITION(NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc(),
"Must have the same owner document");
NS_PRECONDITION(!aParent || aDocument == aParent->GetCurrentDoc(),
"aDocument must be current doc of aParent");

View File

@ -1318,7 +1318,7 @@ AdoptNodeIntoOwnerDoc(nsINode *aParent, nsINode *aNode)
NS_ASSERTION(aParent->OwnerDoc() == doc,
"ownerDoc chainged while adopting");
NS_ASSERTION(adoptedNode == node, "Uh, adopt node changed nodes?");
NS_ASSERTION(aParent->HasSameOwnerDoc(aNode),
NS_ASSERTION(aParent->OwnerDoc() == aNode->OwnerDoc(),
"ownerDocument changed again after adopting!");
return NS_OK;
@ -1340,7 +1340,7 @@ nsINode::doInsertChildAt(nsIContent* aKid, uint32_t aIndex,
nsIDocument* doc = GetCurrentDoc();
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, aNotify);
if (!HasSameOwnerDoc(aKid)) {
if (OwnerDoc() != aKid->OwnerDoc()) {
rv = AdoptNodeIntoOwnerDoc(this, aKid);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -1953,7 +1953,7 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
// DocumentType nodes are the only nodes that can have a null
// ownerDocument according to the DOM spec, and we need to allow
// inserting them w/o calling AdoptNode().
if (!HasSameOwnerDoc(newContent)) {
if (OwnerDoc() != newContent->OwnerDoc()) {
aError = AdoptNodeIntoOwnerDoc(this, aNewChild);
if (aError.Failed()) {
return nullptr;