1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/xslt/xpath/nsXPathNSResolver.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsXPathNSResolver.h" 1.10 +#include "nsDOMClassInfoID.h" 1.11 +#include "nsDOMString.h" 1.12 + 1.13 +NS_IMPL_CYCLE_COLLECTION(nsXPathNSResolver, mNode) 1.14 + 1.15 +NS_IMPL_CYCLE_COLLECTING_ADDREF(nsXPathNSResolver) 1.16 +NS_IMPL_CYCLE_COLLECTING_RELEASE(nsXPathNSResolver) 1.17 + 1.18 +DOMCI_DATA(XPathNSResolver, nsXPathNSResolver) 1.19 + 1.20 +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXPathNSResolver) 1.21 + NS_INTERFACE_MAP_ENTRY(nsIDOMXPathNSResolver) 1.22 + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMXPathNSResolver) 1.23 + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XPathNSResolver) 1.24 +NS_INTERFACE_MAP_END 1.25 + 1.26 +nsXPathNSResolver::nsXPathNSResolver(nsIDOMNode* aNode) 1.27 + : mNode(aNode) 1.28 +{ 1.29 + NS_ASSERTION(mNode, "Need a node to resolve namespaces."); 1.30 +} 1.31 + 1.32 +NS_IMETHODIMP 1.33 +nsXPathNSResolver::LookupNamespaceURI(const nsAString & aPrefix, 1.34 + nsAString & aResult) 1.35 +{ 1.36 + if (aPrefix.EqualsLiteral("xml")) { 1.37 + aResult.AssignLiteral("http://www.w3.org/XML/1998/namespace"); 1.38 + 1.39 + return NS_OK; 1.40 + } 1.41 + 1.42 + if (!mNode) { 1.43 + SetDOMStringToNull(aResult); 1.44 + 1.45 + return NS_OK; 1.46 + } 1.47 + 1.48 + return mNode->LookupNamespaceURI(aPrefix, aResult); 1.49 +}