Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef __TX_I_XPATH_CONTEXT |
michael@0 | 7 | #define __TX_I_XPATH_CONTEXT |
michael@0 | 8 | |
michael@0 | 9 | #include "txCore.h" |
michael@0 | 10 | |
michael@0 | 11 | class FunctionCall; |
michael@0 | 12 | class nsIAtom; |
michael@0 | 13 | class txAExprResult; |
michael@0 | 14 | class txResultRecycler; |
michael@0 | 15 | class txXPathNode; |
michael@0 | 16 | |
michael@0 | 17 | /* |
michael@0 | 18 | * txIParseContext |
michael@0 | 19 | * |
michael@0 | 20 | * This interface describes the context needed to create |
michael@0 | 21 | * XPath Expressions and XSLT Patters. |
michael@0 | 22 | * (not completely though. key() requires the ProcessorState, which is |
michael@0 | 23 | * not part of this interface.) |
michael@0 | 24 | */ |
michael@0 | 25 | |
michael@0 | 26 | class txIParseContext |
michael@0 | 27 | { |
michael@0 | 28 | public: |
michael@0 | 29 | virtual ~txIParseContext() |
michael@0 | 30 | { |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | /* |
michael@0 | 34 | * Return a namespaceID for a given prefix. |
michael@0 | 35 | */ |
michael@0 | 36 | virtual nsresult resolveNamespacePrefix(nsIAtom* aPrefix, int32_t& aID) = 0; |
michael@0 | 37 | |
michael@0 | 38 | /* |
michael@0 | 39 | * Create a FunctionCall, needed for extension function calls and |
michael@0 | 40 | * XSLT. XPath function calls are resolved by the Parser. |
michael@0 | 41 | */ |
michael@0 | 42 | virtual nsresult resolveFunctionCall(nsIAtom* aName, int32_t aID, |
michael@0 | 43 | FunctionCall** aFunction) = 0; |
michael@0 | 44 | |
michael@0 | 45 | /** |
michael@0 | 46 | * Should nametests parsed in this context be case-sensitive |
michael@0 | 47 | */ |
michael@0 | 48 | virtual bool caseInsensitiveNameTests() = 0; |
michael@0 | 49 | |
michael@0 | 50 | /* |
michael@0 | 51 | * Callback to be used by the Parser if errors are detected. |
michael@0 | 52 | */ |
michael@0 | 53 | virtual void SetErrorOffset(uint32_t aOffset) = 0; |
michael@0 | 54 | }; |
michael@0 | 55 | |
michael@0 | 56 | /* |
michael@0 | 57 | * txIMatchContext |
michael@0 | 58 | * |
michael@0 | 59 | * Interface used for matching XSLT Patters. |
michael@0 | 60 | * This is the part of txIEvalContext (see below), that is independent |
michael@0 | 61 | * of the context node when evaluating a XPath expression, too. |
michael@0 | 62 | * When evaluating a XPath expression, |txIMatchContext|s are used |
michael@0 | 63 | * to transport the information from Step to Step. |
michael@0 | 64 | */ |
michael@0 | 65 | class txIMatchContext |
michael@0 | 66 | { |
michael@0 | 67 | public: |
michael@0 | 68 | virtual ~txIMatchContext() |
michael@0 | 69 | { |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | /* |
michael@0 | 73 | * Return the ExprResult associated with the variable with the |
michael@0 | 74 | * given namespace and local name. |
michael@0 | 75 | */ |
michael@0 | 76 | virtual nsresult getVariable(int32_t aNamespace, nsIAtom* aLName, |
michael@0 | 77 | txAExprResult*& aResult) = 0; |
michael@0 | 78 | |
michael@0 | 79 | /* |
michael@0 | 80 | * Is whitespace stripping allowed for the given node? |
michael@0 | 81 | * See http://www.w3.org/TR/xslt#strip |
michael@0 | 82 | */ |
michael@0 | 83 | virtual bool isStripSpaceAllowed(const txXPathNode& aNode) = 0; |
michael@0 | 84 | |
michael@0 | 85 | /** |
michael@0 | 86 | * Returns a pointer to the private context |
michael@0 | 87 | */ |
michael@0 | 88 | virtual void* getPrivateContext() = 0; |
michael@0 | 89 | |
michael@0 | 90 | virtual txResultRecycler* recycler() = 0; |
michael@0 | 91 | |
michael@0 | 92 | /* |
michael@0 | 93 | * Callback to be used by the expression/pattern if errors are detected. |
michael@0 | 94 | */ |
michael@0 | 95 | virtual void receiveError(const nsAString& aMsg, nsresult aRes) = 0; |
michael@0 | 96 | }; |
michael@0 | 97 | |
michael@0 | 98 | #define TX_DECL_MATCH_CONTEXT \ |
michael@0 | 99 | nsresult getVariable(int32_t aNamespace, nsIAtom* aLName, \ |
michael@0 | 100 | txAExprResult*& aResult); \ |
michael@0 | 101 | bool isStripSpaceAllowed(const txXPathNode& aNode); \ |
michael@0 | 102 | void* getPrivateContext(); \ |
michael@0 | 103 | txResultRecycler* recycler(); \ |
michael@0 | 104 | void receiveError(const nsAString& aMsg, nsresult aRes) |
michael@0 | 105 | |
michael@0 | 106 | class txIEvalContext : public txIMatchContext |
michael@0 | 107 | { |
michael@0 | 108 | public: |
michael@0 | 109 | /* |
michael@0 | 110 | * Get the context node. |
michael@0 | 111 | */ |
michael@0 | 112 | virtual const txXPathNode& getContextNode() = 0; |
michael@0 | 113 | |
michael@0 | 114 | /* |
michael@0 | 115 | * Get the size of the context node set. |
michael@0 | 116 | */ |
michael@0 | 117 | virtual uint32_t size() = 0; |
michael@0 | 118 | |
michael@0 | 119 | /* |
michael@0 | 120 | * Get the position of the context node in the context node set, |
michael@0 | 121 | * starting with 1. |
michael@0 | 122 | */ |
michael@0 | 123 | virtual uint32_t position() = 0; |
michael@0 | 124 | }; |
michael@0 | 125 | |
michael@0 | 126 | #define TX_DECL_EVAL_CONTEXT \ |
michael@0 | 127 | TX_DECL_MATCH_CONTEXT; \ |
michael@0 | 128 | const txXPathNode& getContextNode(); \ |
michael@0 | 129 | uint32_t size(); \ |
michael@0 | 130 | uint32_t position() |
michael@0 | 131 | |
michael@0 | 132 | #endif // __TX_I_XPATH_CONTEXT |