|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef __TX_XPATH_SINGLENODE_CONTEXT |
|
7 #define __TX_XPATH_SINGLENODE_CONTEXT |
|
8 |
|
9 #include "mozilla/Attributes.h" |
|
10 #include "txIXPathContext.h" |
|
11 |
|
12 class txSingleNodeContext : public txIEvalContext |
|
13 { |
|
14 public: |
|
15 txSingleNodeContext(const txXPathNode& aContextNode, |
|
16 txIMatchContext* aContext) |
|
17 : mNode(aContextNode), |
|
18 mInner(aContext) |
|
19 { |
|
20 NS_ASSERTION(aContext, "txIMatchContext must be given"); |
|
21 } |
|
22 |
|
23 nsresult getVariable(int32_t aNamespace, nsIAtom* aLName, |
|
24 txAExprResult*& aResult) MOZ_OVERRIDE |
|
25 { |
|
26 NS_ASSERTION(mInner, "mInner is null!!!"); |
|
27 return mInner->getVariable(aNamespace, aLName, aResult); |
|
28 } |
|
29 |
|
30 bool isStripSpaceAllowed(const txXPathNode& aNode) MOZ_OVERRIDE |
|
31 { |
|
32 NS_ASSERTION(mInner, "mInner is null!!!"); |
|
33 return mInner->isStripSpaceAllowed(aNode); |
|
34 } |
|
35 |
|
36 void* getPrivateContext() MOZ_OVERRIDE |
|
37 { |
|
38 NS_ASSERTION(mInner, "mInner is null!!!"); |
|
39 return mInner->getPrivateContext(); |
|
40 } |
|
41 |
|
42 txResultRecycler* recycler() MOZ_OVERRIDE |
|
43 { |
|
44 NS_ASSERTION(mInner, "mInner is null!!!"); |
|
45 return mInner->recycler(); |
|
46 } |
|
47 |
|
48 void receiveError(const nsAString& aMsg, nsresult aRes) MOZ_OVERRIDE |
|
49 { |
|
50 NS_ASSERTION(mInner, "mInner is null!!!"); |
|
51 #ifdef DEBUG |
|
52 nsAutoString error(NS_LITERAL_STRING("forwarded error: ")); |
|
53 error.Append(aMsg); |
|
54 mInner->receiveError(error, aRes); |
|
55 #else |
|
56 mInner->receiveError(aMsg, aRes); |
|
57 #endif |
|
58 } |
|
59 |
|
60 const txXPathNode& getContextNode() MOZ_OVERRIDE |
|
61 { |
|
62 return mNode; |
|
63 } |
|
64 |
|
65 uint32_t size() MOZ_OVERRIDE |
|
66 { |
|
67 return 1; |
|
68 } |
|
69 |
|
70 uint32_t position() MOZ_OVERRIDE |
|
71 { |
|
72 return 1; |
|
73 } |
|
74 |
|
75 private: |
|
76 const txXPathNode& mNode; |
|
77 txIMatchContext* mInner; |
|
78 }; |
|
79 |
|
80 #endif // __TX_XPATH_SINGLENODE_CONTEXT |