content/xul/templates/src/nsXULTemplateQueryProcessorXML.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 nsXULTemplateQueryProcessorXML_h__
michael@0 7 #define nsXULTemplateQueryProcessorXML_h__
michael@0 8
michael@0 9 #include "nsIXULTemplateBuilder.h"
michael@0 10 #include "nsIXULTemplateQueryProcessor.h"
michael@0 11
michael@0 12 #include "nsISimpleEnumerator.h"
michael@0 13 #include "nsString.h"
michael@0 14 #include "nsCOMArray.h"
michael@0 15 #include "nsRefPtrHashtable.h"
michael@0 16 #include "nsIDOMElement.h"
michael@0 17 #include "nsIDOMEventListener.h"
michael@0 18 #include "nsIDOMXPathExpression.h"
michael@0 19 #include "nsIDOMXPathEvaluator.h"
michael@0 20 #include "nsIDOMXPathResult.h"
michael@0 21 #include "nsXMLBinding.h"
michael@0 22 #include "nsCycleCollectionParticipant.h"
michael@0 23 #include "nsIXMLHttpRequest.h"
michael@0 24 #include "mozilla/Attributes.h"
michael@0 25
michael@0 26 class nsXULTemplateQueryProcessorXML;
michael@0 27
michael@0 28 #define NS_IXMLQUERY_IID \
michael@0 29 {0x0358d692, 0xccce, 0x4a97, \
michael@0 30 { 0xb2, 0x51, 0xba, 0x8f, 0x17, 0x0f, 0x3b, 0x6f }}
michael@0 31
michael@0 32 class nsXMLQuery MOZ_FINAL : public nsISupports
michael@0 33 {
michael@0 34 public:
michael@0 35 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IXMLQUERY_IID)
michael@0 36
michael@0 37 NS_DECL_ISUPPORTS
michael@0 38
michael@0 39 // return a weak reference to the processor the query was created from
michael@0 40 nsXULTemplateQueryProcessorXML* Processor() { return mProcessor; }
michael@0 41
michael@0 42 // return a weak reference t the member variable for the query
michael@0 43 nsIAtom* GetMemberVariable() { return mMemberVariable; }
michael@0 44
michael@0 45 // return a weak reference to the expression used to generate results
michael@0 46 nsIDOMXPathExpression* GetResultsExpression() { return mResultsExpr; }
michael@0 47
michael@0 48 // return a weak reference to the additional required bindings
michael@0 49 nsXMLBindingSet* GetBindingSet() { return mRequiredBindings; }
michael@0 50
michael@0 51 // add a required binding for the query
michael@0 52 nsresult
michael@0 53 AddBinding(nsIAtom* aVar, nsIDOMXPathExpression* aExpr)
michael@0 54 {
michael@0 55 if (!mRequiredBindings) {
michael@0 56 mRequiredBindings = new nsXMLBindingSet();
michael@0 57 NS_ENSURE_TRUE(mRequiredBindings, NS_ERROR_OUT_OF_MEMORY);
michael@0 58 }
michael@0 59
michael@0 60 return mRequiredBindings->AddBinding(aVar, aExpr);
michael@0 61 }
michael@0 62
michael@0 63 nsXMLQuery(nsXULTemplateQueryProcessorXML* aProcessor,
michael@0 64 nsIAtom* aMemberVariable,
michael@0 65 nsIDOMXPathExpression* aResultsExpr)
michael@0 66 : mProcessor(aProcessor),
michael@0 67 mMemberVariable(aMemberVariable),
michael@0 68 mResultsExpr(aResultsExpr)
michael@0 69 { }
michael@0 70
michael@0 71 protected:
michael@0 72 nsXULTemplateQueryProcessorXML* mProcessor;
michael@0 73
michael@0 74 nsCOMPtr<nsIAtom> mMemberVariable;
michael@0 75
michael@0 76 nsCOMPtr<nsIDOMXPathExpression> mResultsExpr;
michael@0 77
michael@0 78 nsRefPtr<nsXMLBindingSet> mRequiredBindings;
michael@0 79 };
michael@0 80
michael@0 81 NS_DEFINE_STATIC_IID_ACCESSOR(nsXMLQuery, NS_IXMLQUERY_IID)
michael@0 82
michael@0 83 class nsXULTemplateResultSetXML MOZ_FINAL : public nsISimpleEnumerator
michael@0 84 {
michael@0 85 private:
michael@0 86
michael@0 87 // reference back to the query
michael@0 88 nsCOMPtr<nsXMLQuery> mQuery;
michael@0 89
michael@0 90 // the binding set created from <assign> nodes
michael@0 91 nsRefPtr<nsXMLBindingSet> mBindingSet;
michael@0 92
michael@0 93 // set of results contained in this enumerator
michael@0 94 nsCOMPtr<nsIDOMXPathResult> mResults;
michael@0 95
michael@0 96 // current position within the list of results
michael@0 97 uint32_t mPosition;
michael@0 98
michael@0 99 public:
michael@0 100
michael@0 101 // nsISupports interface
michael@0 102 NS_DECL_ISUPPORTS
michael@0 103
michael@0 104 // nsISimpleEnumerator interface
michael@0 105 NS_DECL_NSISIMPLEENUMERATOR
michael@0 106
michael@0 107 nsXULTemplateResultSetXML(nsXMLQuery* aQuery,
michael@0 108 nsIDOMXPathResult* aResults,
michael@0 109 nsXMLBindingSet* aBindingSet)
michael@0 110 : mQuery(aQuery),
michael@0 111 mBindingSet(aBindingSet),
michael@0 112 mResults(aResults),
michael@0 113 mPosition(0)
michael@0 114 {}
michael@0 115 };
michael@0 116
michael@0 117 class nsXULTemplateQueryProcessorXML MOZ_FINAL : public nsIXULTemplateQueryProcessor,
michael@0 118 public nsIDOMEventListener
michael@0 119 {
michael@0 120 public:
michael@0 121
michael@0 122 nsXULTemplateQueryProcessorXML()
michael@0 123 : mGenerationStarted(false)
michael@0 124 {}
michael@0 125
michael@0 126 // nsISupports interface
michael@0 127 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 128 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsXULTemplateQueryProcessorXML,
michael@0 129 nsIXULTemplateQueryProcessor)
michael@0 130
michael@0 131 // nsIXULTemplateQueryProcessor interface
michael@0 132 NS_DECL_NSIXULTEMPLATEQUERYPROCESSOR
michael@0 133
michael@0 134 // nsIDOMEventListener interface
michael@0 135 NS_DECL_NSIDOMEVENTLISTENER
michael@0 136
michael@0 137 nsXMLBindingSet*
michael@0 138 GetOptionalBindingsForRule(nsIDOMNode* aRuleNode);
michael@0 139
michael@0 140 // create an XPath expression from aExpr, using aNode for
michael@0 141 // resolving namespaces
michael@0 142 nsresult
michael@0 143 CreateExpression(const nsAString& aExpr,
michael@0 144 nsIDOMNode* aNode,
michael@0 145 nsIDOMXPathExpression** aCompiledExpr);
michael@0 146
michael@0 147 private:
michael@0 148
michael@0 149 bool mGenerationStarted;
michael@0 150
michael@0 151 nsRefPtrHashtable<nsISupportsHashKey, nsXMLBindingSet> mRuleToBindingsMap;
michael@0 152
michael@0 153 nsCOMPtr<nsIDOMElement> mRoot;
michael@0 154
michael@0 155 nsCOMPtr<nsIDOMXPathEvaluator> mEvaluator;
michael@0 156
michael@0 157 nsCOMPtr<nsIXULTemplateBuilder> mTemplateBuilder;
michael@0 158
michael@0 159 nsCOMPtr<nsIXMLHttpRequest> mRequest;
michael@0 160 };
michael@0 161
michael@0 162
michael@0 163 #endif // nsXULTemplateQueryProcessorXML_h__

mercurial