content/xul/templates/src/nsXULContentUtils.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 /*
michael@0 7
michael@0 8 A package of routines shared by the XUL content code.
michael@0 9
michael@0 10 */
michael@0 11
michael@0 12 #ifndef nsXULContentUtils_h__
michael@0 13 #define nsXULContentUtils_h__
michael@0 14
michael@0 15 #include "nsISupports.h"
michael@0 16
michael@0 17 class nsIAtom;
michael@0 18 class nsIContent;
michael@0 19 class nsIDocument;
michael@0 20 class nsIDOMNodeList;
michael@0 21 class nsIRDFNode;
michael@0 22 class nsCString;
michael@0 23 class nsString;
michael@0 24 class nsIRDFResource;
michael@0 25 class nsIRDFLiteral;
michael@0 26 class nsIRDFService;
michael@0 27 class nsIDateTimeFormat;
michael@0 28 class nsICollation;
michael@0 29
michael@0 30 // errors to pass to LogTemplateError
michael@0 31 #define ERROR_TEMPLATE_INVALID_QUERYPROCESSOR \
michael@0 32 "querytype attribute doesn't specify a valid query processor"
michael@0 33 #define ERROR_TEMPLATE_INVALID_QUERYSET \
michael@0 34 "unexpected <queryset> element"
michael@0 35 #define ERROR_TEMPLATE_NO_MEMBERVAR \
michael@0 36 "no member variable found. Action body should have an element with uri attribute"
michael@0 37 #define ERROR_TEMPLATE_WHERE_NO_SUBJECT \
michael@0 38 "<where> element is missing a subject attribute"
michael@0 39 #define ERROR_TEMPLATE_WHERE_NO_RELATION \
michael@0 40 "<where> element is missing a rel attribute"
michael@0 41 #define ERROR_TEMPLATE_WHERE_NO_VALUE \
michael@0 42 "<where> element is missing a value attribute"
michael@0 43 #define ERROR_TEMPLATE_WHERE_NO_VAR \
michael@0 44 "<where> element must have at least one variable as a subject or value"
michael@0 45 #define ERROR_TEMPLATE_BINDING_BAD_SUBJECT \
michael@0 46 "<binding> requires a variable for its subject attribute"
michael@0 47 #define ERROR_TEMPLATE_BINDING_BAD_PREDICATE \
michael@0 48 "<binding> element is missing a predicate attribute"
michael@0 49 #define ERROR_TEMPLATE_BINDING_BAD_OBJECT \
michael@0 50 "<binding> requires a variable for its object attribute"
michael@0 51 #define ERROR_TEMPLATE_CONTENT_NOT_FIRST \
michael@0 52 "expected <content> to be first"
michael@0 53 #define ERROR_TEMPLATE_MEMBER_NOCONTAINERVAR \
michael@0 54 "<member> requires a variable for its container attribute"
michael@0 55 #define ERROR_TEMPLATE_MEMBER_NOCHILDVAR \
michael@0 56 "<member> requires a variable for its child attribute"
michael@0 57 #define ERROR_TEMPLATE_TRIPLE_NO_VAR \
michael@0 58 "<triple> should have at least one variable as a subject or object"
michael@0 59 #define ERROR_TEMPLATE_TRIPLE_BAD_SUBJECT \
michael@0 60 "<triple> requires a variable for its subject attribute"
michael@0 61 #define ERROR_TEMPLATE_TRIPLE_BAD_PREDICATE \
michael@0 62 "<triple> should have a non-variable value as a predicate"
michael@0 63 #define ERROR_TEMPLATE_TRIPLE_BAD_OBJECT \
michael@0 64 "<triple> requires a variable for its object attribute"
michael@0 65 #define ERROR_TEMPLATE_MEMBER_UNBOUND \
michael@0 66 "neither container or child variables of <member> has a value"
michael@0 67 #define ERROR_TEMPLATE_TRIPLE_UNBOUND \
michael@0 68 "neither subject or object variables of <triple> has a value"
michael@0 69 #define ERROR_TEMPLATE_BAD_XPATH \
michael@0 70 "XPath expression in query could not be parsed"
michael@0 71 #define ERROR_TEMPLATE_BAD_ASSIGN_XPATH \
michael@0 72 "XPath expression in <assign> could not be parsed"
michael@0 73 #define ERROR_TEMPLATE_BAD_BINDING_XPATH \
michael@0 74 "XPath expression in <binding> could not be parsed"
michael@0 75 #define ERROR_TEMPLATE_STORAGE_BAD_URI \
michael@0 76 "only profile: or file URI are allowed"
michael@0 77 #define ERROR_TEMPLATE_STORAGE_CANNOT_OPEN_DATABASE \
michael@0 78 "cannot open given database"
michael@0 79 #define ERROR_TEMPLATE_STORAGE_BAD_QUERY \
michael@0 80 "syntax error in the SQL query"
michael@0 81 #define ERROR_TEMPLATE_STORAGE_UNKNOWN_QUERY_PARAMETER \
michael@0 82 "the given named parameter is unknown in the SQL query"
michael@0 83 #define ERROR_TEMPLATE_STORAGE_WRONG_TYPE_QUERY_PARAMETER \
michael@0 84 "the type of a query parameter is wrong"
michael@0 85 #define ERROR_TEMPLATE_STORAGE_QUERY_PARAMETER_NOT_BOUND \
michael@0 86 "a query parameter cannot be bound to the SQL query"
michael@0 87
michael@0 88 class nsXULContentUtils
michael@0 89 {
michael@0 90 protected:
michael@0 91 static nsIRDFService* gRDF;
michael@0 92 static nsIDateTimeFormat* gFormat;
michael@0 93 static nsICollation *gCollation;
michael@0 94
michael@0 95 static bool gDisableXULCache;
michael@0 96
michael@0 97 static int
michael@0 98 DisableXULCacheChangedCallback(const char* aPrefName, void* aClosure);
michael@0 99
michael@0 100 public:
michael@0 101 static nsresult
michael@0 102 Init();
michael@0 103
michael@0 104 static nsresult
michael@0 105 Finish();
michael@0 106
michael@0 107 static nsresult
michael@0 108 FindChildByTag(nsIContent *aElement,
michael@0 109 int32_t aNameSpaceID,
michael@0 110 nsIAtom* aTag,
michael@0 111 nsIContent **aResult);
michael@0 112
michael@0 113 static nsresult
michael@0 114 FindChildByResource(nsIContent* aElement,
michael@0 115 nsIRDFResource* aResource,
michael@0 116 nsIContent** aResult);
michael@0 117
michael@0 118 static nsresult
michael@0 119 GetElementResource(nsIContent* aElement, nsIRDFResource** aResult);
michael@0 120
michael@0 121 static nsresult
michael@0 122 GetTextForNode(nsIRDFNode* aNode, nsAString& aResult);
michael@0 123
michael@0 124 /**
michael@0 125 * Construct a URI from the element ID given. This uses aElement as the
michael@0 126 * ref and aDocument's document URI as the base. If aDocument's document
michael@0 127 * URI does not support refs, this will throw NS_ERROR_NOT_AVAILABLE.
michael@0 128 */
michael@0 129 static nsresult
michael@0 130 MakeElementURI(nsIDocument* aDocument, const nsAString& aElementID, nsCString& aURI);
michael@0 131
michael@0 132 static nsresult
michael@0 133 MakeElementResource(nsIDocument* aDocument, const nsAString& aElementID, nsIRDFResource** aResult);
michael@0 134
michael@0 135 /**
michael@0 136 * Extract the element ID from aURI. Note that aURI must be an absolute
michael@0 137 * URI string in UTF8; the element ID is the ref from the URI. If the
michael@0 138 * scheme does not support refs, then the ID will be empty.
michael@0 139 */
michael@0 140 static nsresult
michael@0 141 MakeElementID(nsIDocument* aDocument, const nsACString& aURI, nsAString& aElementID);
michael@0 142
michael@0 143 static nsresult
michael@0 144 GetResource(int32_t aNameSpaceID, nsIAtom* aAttribute, nsIRDFResource** aResult);
michael@0 145
michael@0 146 static nsresult
michael@0 147 GetResource(int32_t aNameSpaceID, const nsAString& aAttribute, nsIRDFResource** aResult);
michael@0 148
michael@0 149 static nsresult
michael@0 150 SetCommandUpdater(nsIDocument* aDocument, nsIContent* aElement);
michael@0 151
michael@0 152 /**
michael@0 153 * Log a message to the error console
michael@0 154 */
michael@0 155 static void
michael@0 156 LogTemplateError(const char* aMsg);
michael@0 157
michael@0 158 static nsIRDFService*
michael@0 159 RDFService()
michael@0 160 {
michael@0 161 return gRDF;
michael@0 162 }
michael@0 163
michael@0 164 static nsICollation*
michael@0 165 GetCollation();
michael@0 166
michael@0 167 #define XUL_RESOURCE(ident, uri) static nsIRDFResource* ident
michael@0 168 #define XUL_LITERAL(ident, val) static nsIRDFLiteral* ident
michael@0 169 #include "nsXULResourceList.h"
michael@0 170 #undef XUL_RESOURCE
michael@0 171 #undef XUL_LITERAL
michael@0 172 };
michael@0 173
michael@0 174 #endif // nsXULContentUtils_h__

mercurial