diff --git a/content/base/src/nsContentList.cpp b/content/base/src/nsContentList.cpp index 40f81ba8c546..86535e702873 100644 --- a/content/base/src/nsContentList.cpp +++ b/content/base/src/nsContentList.cpp @@ -677,7 +677,7 @@ nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer, nsresult rv = ourLastDOM3Node->CompareDocumentPosition(newNode, &comparisonFlags); if (NS_SUCCEEDED(rv) && - (comparisonFlags & nsIDOMNode::DOCUMENT_POSITION_FOLLOWING)) { + (comparisonFlags & nsIDOM3Node::DOCUMENT_POSITION_FOLLOWING)) { appendToList = PR_TRUE; } } diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index fdb2bda679d1..ca6b3591b11d 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -1153,8 +1153,8 @@ nsContentUtils::ComparePositionWithAncestors(nsIDOMNode *aNode, // If there is no common container node, then the order is based upon // order between the root container of each node that is in no container. // In this case, the result is disconnected and implementation-dependent. - mask = (nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED | - nsIDOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); + mask = (nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED | + nsIDOM3Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); return mask; } @@ -1162,15 +1162,15 @@ nsContentUtils::ComparePositionWithAncestors(nsIDOMNode *aNode, nsIDOMNode* commonAncestor = nodeAncestors[0]; if (commonAncestor == aNode) { - mask = (nsIDOMNode::DOCUMENT_POSITION_IS_CONTAINED | - nsIDOMNode::DOCUMENT_POSITION_FOLLOWING); + mask = (nsIDOM3Node::DOCUMENT_POSITION_CONTAINED_BY | + nsIDOM3Node::DOCUMENT_POSITION_FOLLOWING); return mask; } if (commonAncestor == aOther) { - mask |= (nsIDOMNode::DOCUMENT_POSITION_CONTAINS | - nsIDOMNode::DOCUMENT_POSITION_PRECEDING); + mask |= (nsIDOM3Node::DOCUMENT_POSITION_CONTAINS | + nsIDOM3Node::DOCUMENT_POSITION_PRECEDING); return mask; } @@ -1198,12 +1198,12 @@ nsContentUtils::ComparePositionWithAncestors(nsIDOMNode *aNode, nsCOMPtr childNode; children->Item(i, getter_AddRefs(childNode)); if (childNode == nodeAncestor) { - mask |= nsIDOMNode::DOCUMENT_POSITION_FOLLOWING; + mask |= nsIDOM3Node::DOCUMENT_POSITION_FOLLOWING; break; } if (childNode == otherAncestor) { - mask |= nsIDOMNode::DOCUMENT_POSITION_PRECEDING; + mask |= nsIDOM3Node::DOCUMENT_POSITION_PRECEDING; break; } } @@ -1218,23 +1218,23 @@ nsContentUtils::ReverseDocumentPosition(PRUint16 aDocumentPosition) // Disconnected and implementation-specific flags cannot be reversed. // Keep them. PRUint16 reversedPosition = - aDocumentPosition & (nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED | - nsIDOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); + aDocumentPosition & (nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED | + nsIDOM3Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); // Following/preceding - if (aDocumentPosition & nsIDOMNode::DOCUMENT_POSITION_FOLLOWING) { - reversedPosition |= nsIDOMNode::DOCUMENT_POSITION_PRECEDING; + if (aDocumentPosition & nsIDOM3Node::DOCUMENT_POSITION_FOLLOWING) { + reversedPosition |= nsIDOM3Node::DOCUMENT_POSITION_PRECEDING; } - else if (aDocumentPosition & nsIDOMNode::DOCUMENT_POSITION_PRECEDING) { - reversedPosition |= nsIDOMNode::DOCUMENT_POSITION_FOLLOWING; + else if (aDocumentPosition & nsIDOM3Node::DOCUMENT_POSITION_PRECEDING) { + reversedPosition |= nsIDOM3Node::DOCUMENT_POSITION_FOLLOWING; } // Is contained/contains. - if (aDocumentPosition & nsIDOMNode::DOCUMENT_POSITION_CONTAINS) { - reversedPosition |= nsIDOMNode::DOCUMENT_POSITION_IS_CONTAINED; + if (aDocumentPosition & nsIDOM3Node::DOCUMENT_POSITION_CONTAINS) { + reversedPosition |= nsIDOM3Node::DOCUMENT_POSITION_CONTAINED_BY; } - else if (aDocumentPosition & nsIDOMNode::DOCUMENT_POSITION_IS_CONTAINED) { - reversedPosition |= nsIDOMNode::DOCUMENT_POSITION_CONTAINS; + else if (aDocumentPosition & nsIDOM3Node::DOCUMENT_POSITION_CONTAINED_BY) { + reversedPosition |= nsIDOM3Node::DOCUMENT_POSITION_CONTAINS; } return reversedPosition; diff --git a/content/base/src/nsDOMAttribute.cpp b/content/base/src/nsDOMAttribute.cpp index 704a071901d8..e3cae9ab6b87 100644 --- a/content/base/src/nsDOMAttribute.cpp +++ b/content/base/src/nsDOMAttribute.cpp @@ -516,8 +516,8 @@ nsDOMAttribute::CompareDocumentPosition(nsIDOMNode* aOther, // then based upon order between the root container of each node that // is in no container. In this case, the result is disconnected // and implementation-dependent. - mask |= (nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED | - nsIDOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); + mask |= (nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED | + nsIDOM3Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); *aReturn = mask; @@ -539,7 +539,7 @@ nsDOMAttribute::CompareDocumentPosition(nsIDOMNode* aOther, // nodeType is the same for both determining nodes, then an // implementation-dependent order between the determining nodes // is returned. - mask |= nsIDOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC; + mask |= nsIDOM3Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC; } // If the two nodes being compared are the same node, @@ -580,8 +580,8 @@ nsDOMAttribute::CompareDocumentPosition(nsIDOMNode* aOther, // Throw a party! Celebrate by returning that it is contained // and following this node. - mask |= (nsIDOMNode::DOCUMENT_POSITION_IS_CONTAINED | - nsIDOMNode::DOCUMENT_POSITION_FOLLOWING); + mask |= (nsIDOM3Node::DOCUMENT_POSITION_CONTAINED_BY | + nsIDOM3Node::DOCUMENT_POSITION_FOLLOWING); *aReturn = mask; return NS_OK; @@ -599,8 +599,8 @@ nsDOMAttribute::CompareDocumentPosition(nsIDOMNode* aOther, parent->IsSameNode(aOther, &sameNode); if (sameNode) { // If the other node contains us, then it precedes us. - mask |= (nsIDOMNode::DOCUMENT_POSITION_CONTAINS | - nsIDOMNode::DOCUMENT_POSITION_PRECEDING); + mask |= (nsIDOM3Node::DOCUMENT_POSITION_CONTAINS | + nsIDOM3Node::DOCUMENT_POSITION_PRECEDING); *aReturn = mask; return NS_OK; @@ -612,7 +612,7 @@ nsDOMAttribute::CompareDocumentPosition(nsIDOMNode* aOther, // We already established earlier that the node is not contained // by this attribute. So if it is contained by our owner element, // unset the flag. - mask |= parentMask & ~nsIDOMNode::DOCUMENT_POSITION_IS_CONTAINED; + mask |= parentMask & ~nsIDOM3Node::DOCUMENT_POSITION_CONTAINED_BY; *aReturn = mask; return NS_OK; diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 10d69dfa3f9f..6bbbbef2e346 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -3451,8 +3451,8 @@ nsDocument::CompareDocumentPosition(nsIDOMNode* aOther, PRUint16* aReturn) // is based upon order between the root container of each // node that is in no container. In this case, the result // is disconnected and implementation-dependent. - mask |= (nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED | - nsIDOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); + mask |= (nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED | + nsIDOM3Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); *aReturn = mask; return NS_OK; @@ -3463,16 +3463,16 @@ nsDocument::CompareDocumentPosition(nsIDOMNode* aOther, PRUint16* aReturn) if (this == otherDoc) { // If the node being compared is contained by our node, // then it follows it. - mask |= (nsIDOMNode::DOCUMENT_POSITION_IS_CONTAINED | - nsIDOMNode::DOCUMENT_POSITION_FOLLOWING); + mask |= (nsIDOM3Node::DOCUMENT_POSITION_CONTAINED_BY | + nsIDOM3Node::DOCUMENT_POSITION_FOLLOWING); } else { // If there is no common container node, then the order // is based upon order between the root container of each // node that is in no container. In this case, the result // is disconnected and implementation-dependent. - mask |= (nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED | - nsIDOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); + mask |= (nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED | + nsIDOM3Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); } *aReturn = mask; diff --git a/content/base/src/nsDocumentFragment.cpp b/content/base/src/nsDocumentFragment.cpp index bb53f1e5d5d0..e749c032a437 100644 --- a/content/base/src/nsDocumentFragment.cpp +++ b/content/base/src/nsDocumentFragment.cpp @@ -413,8 +413,8 @@ nsDocumentFragment::CompareDocumentPosition(nsIDOMNode* aOther, // is based upon order between the root container of each // node that is in no container. In this case, the result // is disconnected and implementation-dependent. - mask |= (nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED | - nsIDOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); + mask |= (nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED | + nsIDOM3Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); break; } @@ -429,8 +429,8 @@ nsDocumentFragment::CompareDocumentPosition(nsIDOMNode* aOther, if (NS_STATIC_CAST(nsIDOMNode*, this) == other) { // If the node being compared is contained by our node, // then it follows it. - mask |= (nsIDOMNode::DOCUMENT_POSITION_IS_CONTAINED | - nsIDOMNode::DOCUMENT_POSITION_FOLLOWING); + mask |= (nsIDOM3Node::DOCUMENT_POSITION_CONTAINED_BY | + nsIDOM3Node::DOCUMENT_POSITION_FOLLOWING); break; } } while (other); diff --git a/content/html/style/src/nsCSSLoader.cpp b/content/html/style/src/nsCSSLoader.cpp index 977d1d76e4d4..ce3ad3dcfbc2 100644 --- a/content/html/style/src/nsCSSLoader.cpp +++ b/content/html/style/src/nsCSSLoader.cpp @@ -1166,7 +1166,7 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, rv = linkingNode->CompareDocumentPosition(sheetOwner, &comparisonFlags); // If we can't get the order right, just bail... NS_ENSURE_SUCCESS(rv, rv); - NS_ASSERTION(!(comparisonFlags & nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED), + NS_ASSERTION(!(comparisonFlags & nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED), "Why are these elements in different documents?"); #ifdef DEBUG { @@ -1175,7 +1175,7 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, NS_ASSERTION(!sameNode, "Why do we still have our old sheet?"); } #endif // DEBUG - if (comparisonFlags & nsIDOMNode::DOCUMENT_POSITION_PRECEDING) { + if (comparisonFlags & nsIDOM3Node::DOCUMENT_POSITION_PRECEDING) { // The current sheet comes before us, and it better be the first // such, because now we break break; diff --git a/dom/public/idl/core/nsIDOM3Node.idl b/dom/public/idl/core/nsIDOM3Node.idl index 889efd7fbb6f..cae8105fbcbb 100644 --- a/dom/public/idl/core/nsIDOM3Node.idl +++ b/dom/public/idl/core/nsIDOM3Node.idl @@ -43,14 +43,17 @@ [scriptable, uuid(29fb2a18-1dd2-11b2-8dd9-a6fd5d5ad12f)] interface nsIDOM3Node : nsISupports { - // Introduced in DOM Level 3: readonly attribute DOMString baseURI; - // Introduced in DOM Level 3: unsigned short compareDocumentPosition(in nsIDOMNode other); - // Introduced in DOM Level 3: boolean isSameNode(in nsIDOMNode other); - // Introduced in DOM Level 3: DOMString lookupNamespacePrefix(in DOMString namespaceURI); - // Introduced in DOM Level 3: DOMString lookupNamespaceURI(in DOMString prefix); + + // DocumentPosition + const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01; + const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02; + const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04; + const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08; + const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10; + const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; }; diff --git a/dom/public/idl/core/nsIDOMNode.idl b/dom/public/idl/core/nsIDOMNode.idl index dba18d7a7f99..68f05cfe8b90 100644 --- a/dom/public/idl/core/nsIDOMNode.idl +++ b/dom/public/idl/core/nsIDOMNode.idl @@ -109,14 +109,4 @@ interface nsIDOMNode : nsISupports readonly attribute DOMString localName; // Introduced in DOM Level 2: boolean hasAttributes(); - - // Introduced in DOM Level 3: - // DocumentPosition - // XXX actual constant values await w3c feedback - const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x20; - const unsigned short DOCUMENT_POSITION_PRECEDING = 0x01; - const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x02; - const unsigned short DOCUMENT_POSITION_CONTAINS = 0x04; - const unsigned short DOCUMENT_POSITION_IS_CONTAINED = 0x08; - const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x10; }; diff --git a/dom/src/base/nsDOMClassInfo.cpp b/dom/src/base/nsDOMClassInfo.cpp index d7dfb46b0837..2d3805169442 100644 --- a/dom/src/base/nsDOMClassInfo.cpp +++ b/dom/src/base/nsDOMClassInfo.cpp @@ -3705,6 +3705,14 @@ nsWindowSH::GlobalResolve(nsISupports *native, JSContext *cx, JSObject *obj, rv = DefineInterfaceConstants(cx, class_obj, primary_iid); NS_ENSURE_SUCCESS(rv, rv); + // Special case for |Node|, which needs constants from Node3 + // too for forwards compatibility. + if (primary_iid->Equals(NS_GET_IID(nsIDOMNode))) { + rv = DefineInterfaceConstants(cx, class_obj, + &NS_GET_IID(nsIDOM3Node)); + NS_ENSURE_SUCCESS(rv, rv); + } + // Special case for |Event|, Event needs constants from NSEvent // too for backwards compatibility. if (primary_iid->Equals(NS_GET_IID(nsIDOMEvent))) { diff --git a/layout/style/nsCSSLoader.cpp b/layout/style/nsCSSLoader.cpp index 977d1d76e4d4..ce3ad3dcfbc2 100644 --- a/layout/style/nsCSSLoader.cpp +++ b/layout/style/nsCSSLoader.cpp @@ -1166,7 +1166,7 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, rv = linkingNode->CompareDocumentPosition(sheetOwner, &comparisonFlags); // If we can't get the order right, just bail... NS_ENSURE_SUCCESS(rv, rv); - NS_ASSERTION(!(comparisonFlags & nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED), + NS_ASSERTION(!(comparisonFlags & nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED), "Why are these elements in different documents?"); #ifdef DEBUG { @@ -1175,7 +1175,7 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, NS_ASSERTION(!sameNode, "Why do we still have our old sheet?"); } #endif // DEBUG - if (comparisonFlags & nsIDOMNode::DOCUMENT_POSITION_PRECEDING) { + if (comparisonFlags & nsIDOM3Node::DOCUMENT_POSITION_PRECEDING) { // The current sheet comes before us, and it better be the first // such, because now we break break;