1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/xslt/xpath/txIXPathContext.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,132 @@ 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 +#ifndef __TX_I_XPATH_CONTEXT 1.10 +#define __TX_I_XPATH_CONTEXT 1.11 + 1.12 +#include "txCore.h" 1.13 + 1.14 +class FunctionCall; 1.15 +class nsIAtom; 1.16 +class txAExprResult; 1.17 +class txResultRecycler; 1.18 +class txXPathNode; 1.19 + 1.20 +/* 1.21 + * txIParseContext 1.22 + * 1.23 + * This interface describes the context needed to create 1.24 + * XPath Expressions and XSLT Patters. 1.25 + * (not completely though. key() requires the ProcessorState, which is 1.26 + * not part of this interface.) 1.27 + */ 1.28 + 1.29 +class txIParseContext 1.30 +{ 1.31 +public: 1.32 + virtual ~txIParseContext() 1.33 + { 1.34 + } 1.35 + 1.36 + /* 1.37 + * Return a namespaceID for a given prefix. 1.38 + */ 1.39 + virtual nsresult resolveNamespacePrefix(nsIAtom* aPrefix, int32_t& aID) = 0; 1.40 + 1.41 + /* 1.42 + * Create a FunctionCall, needed for extension function calls and 1.43 + * XSLT. XPath function calls are resolved by the Parser. 1.44 + */ 1.45 + virtual nsresult resolveFunctionCall(nsIAtom* aName, int32_t aID, 1.46 + FunctionCall** aFunction) = 0; 1.47 + 1.48 + /** 1.49 + * Should nametests parsed in this context be case-sensitive 1.50 + */ 1.51 + virtual bool caseInsensitiveNameTests() = 0; 1.52 + 1.53 + /* 1.54 + * Callback to be used by the Parser if errors are detected. 1.55 + */ 1.56 + virtual void SetErrorOffset(uint32_t aOffset) = 0; 1.57 +}; 1.58 + 1.59 +/* 1.60 + * txIMatchContext 1.61 + * 1.62 + * Interface used for matching XSLT Patters. 1.63 + * This is the part of txIEvalContext (see below), that is independent 1.64 + * of the context node when evaluating a XPath expression, too. 1.65 + * When evaluating a XPath expression, |txIMatchContext|s are used 1.66 + * to transport the information from Step to Step. 1.67 + */ 1.68 +class txIMatchContext 1.69 +{ 1.70 +public: 1.71 + virtual ~txIMatchContext() 1.72 + { 1.73 + } 1.74 + 1.75 + /* 1.76 + * Return the ExprResult associated with the variable with the 1.77 + * given namespace and local name. 1.78 + */ 1.79 + virtual nsresult getVariable(int32_t aNamespace, nsIAtom* aLName, 1.80 + txAExprResult*& aResult) = 0; 1.81 + 1.82 + /* 1.83 + * Is whitespace stripping allowed for the given node? 1.84 + * See http://www.w3.org/TR/xslt#strip 1.85 + */ 1.86 + virtual bool isStripSpaceAllowed(const txXPathNode& aNode) = 0; 1.87 + 1.88 + /** 1.89 + * Returns a pointer to the private context 1.90 + */ 1.91 + virtual void* getPrivateContext() = 0; 1.92 + 1.93 + virtual txResultRecycler* recycler() = 0; 1.94 + 1.95 + /* 1.96 + * Callback to be used by the expression/pattern if errors are detected. 1.97 + */ 1.98 + virtual void receiveError(const nsAString& aMsg, nsresult aRes) = 0; 1.99 +}; 1.100 + 1.101 +#define TX_DECL_MATCH_CONTEXT \ 1.102 + nsresult getVariable(int32_t aNamespace, nsIAtom* aLName, \ 1.103 + txAExprResult*& aResult); \ 1.104 + bool isStripSpaceAllowed(const txXPathNode& aNode); \ 1.105 + void* getPrivateContext(); \ 1.106 + txResultRecycler* recycler(); \ 1.107 + void receiveError(const nsAString& aMsg, nsresult aRes) 1.108 + 1.109 +class txIEvalContext : public txIMatchContext 1.110 +{ 1.111 +public: 1.112 + /* 1.113 + * Get the context node. 1.114 + */ 1.115 + virtual const txXPathNode& getContextNode() = 0; 1.116 + 1.117 + /* 1.118 + * Get the size of the context node set. 1.119 + */ 1.120 + virtual uint32_t size() = 0; 1.121 + 1.122 + /* 1.123 + * Get the position of the context node in the context node set, 1.124 + * starting with 1. 1.125 + */ 1.126 + virtual uint32_t position() = 0; 1.127 +}; 1.128 + 1.129 +#define TX_DECL_EVAL_CONTEXT \ 1.130 + TX_DECL_MATCH_CONTEXT; \ 1.131 + const txXPathNode& getContextNode(); \ 1.132 + uint32_t size(); \ 1.133 + uint32_t position() 1.134 + 1.135 +#endif // __TX_I_XPATH_CONTEXT