From 12de7c3472b69eb3640528f752f19669e5b22627 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 29 Jan 2013 17:53:52 -0500 Subject: [PATCH] Bug 835417 part 1. Mark Node.namespaceURI as not throwing, since [Constant] things aren't allowed to throw (though we were not enforcing that). r=peterv --- content/base/public/nsINode.h | 9 ++++----- content/base/public/nsINodeInfo.h | 2 +- content/base/src/nsNodeInfo.cpp | 15 ++++++++------- content/base/src/nsNodeInfo.h | 2 +- .../xul/document/src/nsXULPrototypeDocument.cpp | 5 +---- dom/webidl/Node.webidl | 2 +- 6 files changed, 16 insertions(+), 19 deletions(-) diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index 9c221d222b9b..a65505092f9d 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -1550,9 +1550,9 @@ public: already_AddRefed CloneNode(bool aDeep, mozilla::ErrorResult& aError); bool IsEqualNode(nsINode* aNode); bool IsSupported(const nsAString& aFeature, const nsAString& aVersion); - void GetNamespaceURI(nsAString& aNamespaceURI, mozilla::ErrorResult& aError) const + void GetNamespaceURI(nsAString& aNamespaceURI) const { - aError = mNodeInfo->GetNamespaceURI(aNamespaceURI); + mNodeInfo->GetNamespaceURI(aNamespaceURI); } #ifdef MOZILLA_INTERNAL_API void GetPrefix(nsAString& aPrefix) @@ -2000,9 +2000,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsINode, NS_INODE_IID) } \ NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI) __VA_ARGS__ \ { \ - mozilla::ErrorResult rv; \ - nsINode::GetNamespaceURI(aNamespaceURI, rv); \ - return rv.ErrorCode(); \ + nsINode::GetNamespaceURI(aNamespaceURI); \ + return NS_OK; \ } \ NS_IMETHOD GetPrefix(nsAString& aPrefix) __VA_ARGS__ \ { \ diff --git a/content/base/public/nsINodeInfo.h b/content/base/public/nsINodeInfo.h index dc7fbc053613..d7dc1d6db6d7 100644 --- a/content/base/public/nsINodeInfo.h +++ b/content/base/public/nsINodeInfo.h @@ -132,7 +132,7 @@ public: /* * Get the namespace URI for a node, if the node has a namespace URI. */ - virtual nsresult GetNamespaceURI(nsAString& aNameSpaceURI) const = 0; + virtual void GetNamespaceURI(nsAString& aNameSpaceURI) const = 0; /* * Get the namespace ID for a node if the node has a namespace, if not this diff --git a/content/base/src/nsNodeInfo.cpp b/content/base/src/nsNodeInfo.cpp index 78f6c8dd380c..4ff1ed65cc50 100644 --- a/content/base/src/nsNodeInfo.cpp +++ b/content/base/src/nsNodeInfo.cpp @@ -208,19 +208,20 @@ NS_INTERFACE_MAP_END // nsINodeInfo -nsresult +void nsNodeInfo::GetNamespaceURI(nsAString& aNameSpaceURI) const { - nsresult rv = NS_OK; - if (mInner.mNamespaceID > 0) { - rv = nsContentUtils::NameSpaceManager()->GetNameSpaceURI(mInner.mNamespaceID, - aNameSpaceURI); + nsresult rv = + nsContentUtils::NameSpaceManager()->GetNameSpaceURI(mInner.mNamespaceID, + aNameSpaceURI); + // How can we possibly end up with a bogus namespace ID here? + if (NS_FAILED(rv)) { + MOZ_CRASH(); + } } else { SetDOMStringToNull(aNameSpaceURI); } - - return rv; } diff --git a/content/base/src/nsNodeInfo.h b/content/base/src/nsNodeInfo.h index 0384e6896b10..4a9905d587a8 100644 --- a/content/base/src/nsNodeInfo.h +++ b/content/base/src/nsNodeInfo.h @@ -29,7 +29,7 @@ public: NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS(nsNodeInfo) // nsINodeInfo - virtual nsresult GetNamespaceURI(nsAString& aNameSpaceURI) const; + virtual void GetNamespaceURI(nsAString& aNameSpaceURI) const; virtual bool NamespaceEquals(const nsAString& aNamespaceURI) const; // nsNodeInfo diff --git a/content/xul/document/src/nsXULPrototypeDocument.cpp b/content/xul/document/src/nsXULPrototypeDocument.cpp index e480f997c3f0..cb55bc251e9c 100644 --- a/content/xul/document/src/nsXULPrototypeDocument.cpp +++ b/content/xul/document/src/nsXULPrototypeDocument.cpp @@ -478,10 +478,7 @@ nsXULPrototypeDocument::Write(nsIObjectOutputStream* aStream) NS_ENSURE_TRUE(nodeInfo, NS_ERROR_FAILURE); nsAutoString namespaceURI; - tmp = nodeInfo->GetNamespaceURI(namespaceURI); - if (NS_FAILED(tmp)) { - rv = tmp; - } + nodeInfo->GetNamespaceURI(namespaceURI); tmp = aStream->WriteWStringZ(namespaceURI.get()); if (NS_FAILED(tmp)) { rv = tmp; diff --git a/dom/webidl/Node.webidl b/dom/webidl/Node.webidl index f86c04930efd..a5300c5defe2 100644 --- a/dom/webidl/Node.webidl +++ b/dom/webidl/Node.webidl @@ -82,7 +82,7 @@ interface Node : EventTarget { readonly attribute NamedNodeMap? attributes; // If we move namespaceURI, prefix and localName to Element they should return // a non-nullable type. - [Throws, Constant] + [Constant] readonly attribute DOMString? namespaceURI; [Constant] readonly attribute DOMString? prefix;