mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-02 12:32:55 +00:00
Bug 1018658 - Convert XPathNSResolver to WebIDL bindings, switch XPathNSResolver to WebIDL. r=bz.
--HG-- extra : rebase_source : 5edb613061b8d0dcb533ae6e1c3a5244e43dd545
This commit is contained in:
parent
269a880293
commit
643250e37e
@ -125,6 +125,7 @@ class TreeWalker;
|
||||
class UndoManager;
|
||||
class XPathEvaluator;
|
||||
class XPathExpression;
|
||||
class XPathNSResolver;
|
||||
class XPathResult;
|
||||
template<typename> class OwningNonNull;
|
||||
template<typename> class Sequence;
|
||||
@ -135,8 +136,8 @@ typedef CallbackObjectHolder<NodeFilter, nsIDOMNodeFilter> NodeFilterHolder;
|
||||
} // namespace mozilla
|
||||
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0x42a263db, 0x6ac6, 0x40ff, \
|
||||
{ 0x89, 0xe2, 0x25, 0x12, 0xe4, 0xbc, 0x2d, 0x2d } }
|
||||
{ 0xbab5b447, 0x7e23, 0x4cdd, \
|
||||
{ 0xac, 0xe5, 0xaa, 0x04, 0x26, 0x87, 0x2b, 0x97 } }
|
||||
|
||||
// Enum for requesting a particular type of document when creating a doc
|
||||
enum DocumentFlavor {
|
||||
@ -2318,13 +2319,12 @@ public:
|
||||
void LoadBindingDocument(const nsAString& aURI, mozilla::ErrorResult& rv);
|
||||
mozilla::dom::XPathExpression*
|
||||
CreateExpression(const nsAString& aExpression,
|
||||
nsIDOMXPathNSResolver* aResolver,
|
||||
mozilla::dom::XPathNSResolver* aResolver,
|
||||
mozilla::ErrorResult& rv);
|
||||
already_AddRefed<nsIDOMXPathNSResolver>
|
||||
CreateNSResolver(nsINode* aNodeResolver, mozilla::ErrorResult& rv);
|
||||
nsINode* CreateNSResolver(nsINode& aNodeResolver);
|
||||
already_AddRefed<mozilla::dom::XPathResult>
|
||||
Evaluate(JSContext* aCx, const nsAString& aExpression, nsINode* aContextNode,
|
||||
nsIDOMXPathNSResolver* aResolver, uint16_t aType,
|
||||
mozilla::dom::XPathNSResolver* aResolver, uint16_t aType,
|
||||
JS::Handle<JSObject*> aResult, mozilla::ErrorResult& rv);
|
||||
// Touch event handlers already on nsINode
|
||||
already_AddRefed<mozilla::dom::Touch>
|
||||
|
@ -210,6 +210,7 @@
|
||||
#include "nsISecurityConsoleMessage.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "mozilla/dom/XPathEvaluator.h"
|
||||
#include "mozilla/dom/XPathNSResolverBinding.h"
|
||||
#include "mozilla/dom/XPathResult.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsIDocumentActivity.h"
|
||||
@ -12314,22 +12315,21 @@ nsIDocument::Constructor(const GlobalObject& aGlobal,
|
||||
|
||||
XPathExpression*
|
||||
nsIDocument::CreateExpression(const nsAString& aExpression,
|
||||
nsIDOMXPathNSResolver* aResolver,
|
||||
XPathNSResolver* aResolver,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
return XPathEvaluator()->CreateExpression(aExpression, aResolver, rv);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMXPathNSResolver>
|
||||
nsIDocument::CreateNSResolver(nsINode* aNodeResolver,
|
||||
ErrorResult& rv)
|
||||
nsINode*
|
||||
nsIDocument::CreateNSResolver(nsINode& aNodeResolver)
|
||||
{
|
||||
return XPathEvaluator()->CreateNSResolver(aNodeResolver, rv);
|
||||
return XPathEvaluator()->CreateNSResolver(aNodeResolver);
|
||||
}
|
||||
|
||||
already_AddRefed<XPathResult>
|
||||
nsIDocument::Evaluate(JSContext* aCx, const nsAString& aExpression,
|
||||
nsINode* aContextNode, nsIDOMXPathNSResolver* aResolver,
|
||||
nsINode* aContextNode, XPathNSResolver* aResolver,
|
||||
uint16_t aType, JS::Handle<JSObject*> aResult,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
@ -12346,7 +12346,7 @@ nsDocument::CreateNSResolver(nsIDOMNode* aNodeResolver,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::Evaluate(const nsAString& aExpression, nsIDOMNode* aContextNode,
|
||||
nsIDOMXPathNSResolver* aResolver, uint16_t aType,
|
||||
nsIDOMNode* aResolver, uint16_t aType,
|
||||
nsISupports* aInResult, nsISupports** aResult)
|
||||
{
|
||||
return XPathEvaluator()->Evaluate(aExpression, aContextNode, aResolver, aType,
|
||||
|
@ -1863,5 +1863,4 @@ addExternalIface('StackFrame', nativeType='nsIStackFrame',
|
||||
headerFile='nsIException.h', notflattened=True)
|
||||
addExternalIface('URI', nativeType='nsIURI', headerFile='nsIURI.h',
|
||||
notflattened=True)
|
||||
addExternalIface('XPathNSResolver')
|
||||
addExternalIface('XULCommandDispatcher')
|
||||
|
@ -12,13 +12,13 @@
|
||||
interface nsIDOMXPathNSResolver;
|
||||
interface XPathException;
|
||||
|
||||
[uuid(89a0fe71-c1d9-46bd-b76b-47f51fd935ff)]
|
||||
[uuid(55e1a327-ad12-4b1d-a839-ddafa477f6c1)]
|
||||
interface nsIDOMXPathEvaluator : nsISupports
|
||||
{
|
||||
nsIDOMXPathNSResolver createNSResolver(in nsIDOMNode nodeResolver);
|
||||
nsISupports evaluate(in DOMString expression,
|
||||
in nsIDOMNode contextNode,
|
||||
in nsIDOMXPathNSResolver resolver,
|
||||
in nsIDOMNode resolver,
|
||||
in unsigned short type,
|
||||
in nsISupports result)
|
||||
raises(XPathException,
|
||||
|
@ -1301,8 +1301,6 @@ var interfaceNamesInGlobalScope =
|
||||
"XPathEvaluator",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"XPathExpression",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"XPathNSResolver",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"XPathResult",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
@ -4,16 +4,14 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
interface XPathNSResolver;
|
||||
|
||||
[Constructor]
|
||||
interface XPathEvaluator {
|
||||
// Based on nsIDOMXPathEvaluator
|
||||
[NewObject, Throws]
|
||||
XPathExpression createExpression(DOMString expression,
|
||||
XPathNSResolver? resolver);
|
||||
[NewObject, Throws]
|
||||
XPathNSResolver createNSResolver(Node? nodeResolver);
|
||||
[Pure]
|
||||
Node createNSResolver(Node nodeResolver);
|
||||
[Throws]
|
||||
XPathResult evaluate(DOMString expression, Node? contextNode,
|
||||
XPathNSResolver? resolver, unsigned short type,
|
||||
|
10
dom/webidl/XPathNSResolver.webidl
Normal file
10
dom/webidl/XPathNSResolver.webidl
Normal file
@ -0,0 +1,10 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
callback interface XPathNSResolver
|
||||
{
|
||||
DOMString? lookupNamespaceURI(DOMString? prefix);
|
||||
};
|
@ -537,6 +537,7 @@ WEBIDL_FILES = [
|
||||
'XMLStylesheetProcessingInstruction.webidl',
|
||||
'XPathEvaluator.webidl',
|
||||
'XPathExpression.webidl',
|
||||
'XPathNSResolver.webidl',
|
||||
'XPathResult.webidl',
|
||||
'XSLTProcessor.webidl',
|
||||
'XULCommandEvent.webidl',
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "txIXPathContext.h"
|
||||
#include "mozilla/dom/XPathEvaluatorBinding.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/XPathNSResolverBinding.h"
|
||||
|
||||
extern nsresult
|
||||
TX_ResolveFunctionCallXPCOM(const nsCString &aContractID, int32_t aNamespaceID,
|
||||
@ -36,7 +37,7 @@ namespace dom {
|
||||
class XPathEvaluatorParseContext : public txIParseContext
|
||||
{
|
||||
public:
|
||||
XPathEvaluatorParseContext(nsIDOMXPathNSResolver* aResolver,
|
||||
XPathEvaluatorParseContext(XPathNSResolver* aResolver,
|
||||
bool aIsCaseSensitive)
|
||||
: mResolver(aResolver),
|
||||
mResolverNode(nullptr),
|
||||
@ -65,7 +66,7 @@ public:
|
||||
void SetErrorOffset(uint32_t aOffset);
|
||||
|
||||
private:
|
||||
nsIDOMXPathNSResolver* mResolver;
|
||||
XPathNSResolver* mResolver;
|
||||
nsINode* mResolverNode;
|
||||
nsresult mLastError;
|
||||
bool mIsCaseSensitive;
|
||||
@ -100,14 +101,15 @@ XPathEvaluator::CreateNSResolver(nsIDOMNode *aNodeResolver,
|
||||
NS_IMETHODIMP
|
||||
XPathEvaluator::Evaluate(const nsAString & aExpression,
|
||||
nsIDOMNode *aContextNode,
|
||||
nsIDOMXPathNSResolver *aResolver,
|
||||
nsIDOMNode *aResolver,
|
||||
uint16_t aType,
|
||||
nsISupports *aInResult,
|
||||
nsISupports **aResult)
|
||||
{
|
||||
nsCOMPtr<nsINode> resolver = do_QueryInterface(aResolver);
|
||||
ErrorResult rv;
|
||||
nsAutoPtr<XPathExpression> expression(CreateExpression(aExpression,
|
||||
aResolver, rv));
|
||||
resolver, rv));
|
||||
if (rv.Failed()) {
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
@ -132,7 +134,7 @@ XPathEvaluator::Evaluate(const nsAString & aExpression,
|
||||
|
||||
XPathExpression*
|
||||
XPathEvaluator::CreateExpression(const nsAString& aExpression,
|
||||
nsIDOMXPathNSResolver* aResolver, ErrorResult& aRv)
|
||||
XPathNSResolver* aResolver, ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
|
||||
XPathEvaluatorParseContext pContext(aResolver, !(doc && doc->IsHTML()));
|
||||
@ -187,34 +189,24 @@ XPathEvaluator::Constructor(const GlobalObject& aGlobal,
|
||||
return newObj.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMXPathNSResolver>
|
||||
XPathEvaluator::CreateNSResolver(nsINode* aNodeResolver,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> nodeResolver = do_QueryInterface(aNodeResolver);
|
||||
nsCOMPtr<nsIDOMXPathNSResolver> res;
|
||||
rv = CreateNSResolver(nodeResolver, getter_AddRefs(res));
|
||||
return res.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<XPathResult>
|
||||
XPathEvaluator::Evaluate(JSContext* aCx, const nsAString& aExpression,
|
||||
nsINode* aContextNode,
|
||||
nsIDOMXPathNSResolver* aResolver, uint16_t aType,
|
||||
XPathNSResolver* aResolver, uint16_t aType,
|
||||
JS::Handle<JSObject*> aResult, ErrorResult& rv)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> contextNode = do_QueryInterface(aContextNode);
|
||||
nsCOMPtr<nsISupports> res;
|
||||
rv = Evaluate(aExpression, contextNode, aResolver, aType,
|
||||
aResult ? UnwrapDOMObjectToISupports(aResult) : nullptr,
|
||||
getter_AddRefs(res));
|
||||
return res.forget().downcast<nsIXPathResult>().downcast<XPathResult>();
|
||||
nsAutoPtr<XPathExpression> expression(CreateExpression(aExpression,
|
||||
aResolver, rv));
|
||||
if (rv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
return expression->Evaluate(aCx, *aContextNode, aType, aResult, rv);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Implementation of txIParseContext private to XPathEvaluator, based on a
|
||||
* nsIDOMXPathNSResolver
|
||||
* XPathNSResolver
|
||||
*/
|
||||
|
||||
nsresult XPathEvaluatorParseContext::resolveNamespacePrefix
|
||||
@ -233,10 +225,17 @@ nsresult XPathEvaluatorParseContext::resolveNamespacePrefix
|
||||
|
||||
nsVoidableString ns;
|
||||
if (mResolver) {
|
||||
nsresult rv = mResolver->LookupNamespaceURI(prefix, ns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ErrorResult rv;
|
||||
mResolver->LookupNamespaceURI(prefix, ns, rv);
|
||||
if (rv.Failed()) {
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
} else {
|
||||
mResolverNode->LookupNamespaceURI(prefix, ns);
|
||||
if (aPrefix == nsGkAtoms::xml) {
|
||||
ns.AssignLiteral("http://www.w3.org/XML/1998/namespace");
|
||||
} else {
|
||||
mResolverNode->LookupNamespaceURI(prefix, ns);
|
||||
}
|
||||
}
|
||||
|
||||
if (DOMStringIsNull(ns)) {
|
||||
|
@ -23,6 +23,7 @@ namespace dom {
|
||||
|
||||
class GlobalObject;
|
||||
class XPathExpression;
|
||||
class XPathNSResolver;
|
||||
class XPathResult;
|
||||
|
||||
/**
|
||||
@ -51,17 +52,19 @@ public:
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& rv);
|
||||
XPathExpression*
|
||||
CreateExpression(const nsAString& aExpression,
|
||||
nsIDOMXPathNSResolver* aResolver,
|
||||
XPathNSResolver* aResolver,
|
||||
ErrorResult& rv);
|
||||
already_AddRefed<nsIDOMXPathNSResolver>
|
||||
CreateNSResolver(nsINode* aNodeResolver, ErrorResult& rv);
|
||||
XPathExpression*
|
||||
CreateExpression(const nsAString& aExpression,
|
||||
nsINode* aResolver,
|
||||
ErrorResult& aRv);
|
||||
nsINode* CreateNSResolver(nsINode& aNodeResolver)
|
||||
{
|
||||
return &aNodeResolver;
|
||||
}
|
||||
already_AddRefed<XPathResult>
|
||||
Evaluate(JSContext* aCx, const nsAString& aExpression,
|
||||
nsINode* aContextNode, nsIDOMXPathNSResolver* aResolver,
|
||||
nsINode* aContextNode, XPathNSResolver* aResolver,
|
||||
uint16_t aType, JS::Handle<JSObject*> aResult,
|
||||
ErrorResult& rv);
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user