dom/xslt/xpath/txExprParser.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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 * ExprParser
michael@0 8 * This class is used to parse XSL Expressions
michael@0 9 * @see ExprLexer
michael@0 10 **/
michael@0 11
michael@0 12 #ifndef MITREXSL_EXPRPARSER_H
michael@0 13 #define MITREXSL_EXPRPARSER_H
michael@0 14
michael@0 15 #include "txCore.h"
michael@0 16 #include "nsAutoPtr.h"
michael@0 17 #include "nsString.h"
michael@0 18
michael@0 19 class AttributeValueTemplate;
michael@0 20 class Expr;
michael@0 21 class txExprLexer;
michael@0 22 class FunctionCall;
michael@0 23 class LocationStep;
michael@0 24 class nsIAtom;
michael@0 25 class PredicateList;
michael@0 26 class Token;
michael@0 27 class txIParseContext;
michael@0 28 class txNodeTest;
michael@0 29 class txNodeTypeTest;
michael@0 30
michael@0 31 class txExprParser
michael@0 32 {
michael@0 33 public:
michael@0 34
michael@0 35 static nsresult createExpr(const nsSubstring& aExpression,
michael@0 36 txIParseContext* aContext, Expr** aExpr)
michael@0 37 {
michael@0 38 return createExprInternal(aExpression, 0, aContext, aExpr);
michael@0 39 }
michael@0 40
michael@0 41 /**
michael@0 42 * Creates an Attribute Value Template using the given value
michael@0 43 */
michael@0 44 static nsresult createAVT(const nsSubstring& aAttrValue,
michael@0 45 txIParseContext* aContext,
michael@0 46 Expr** aResult);
michael@0 47
michael@0 48
michael@0 49 protected:
michael@0 50 static nsresult createExprInternal(const nsSubstring& aExpression,
michael@0 51 uint32_t aSubStringPos,
michael@0 52 txIParseContext* aContext,
michael@0 53 Expr** aExpr);
michael@0 54 /**
michael@0 55 * Using nsAutoPtr& to optimize passing the ownership to the
michael@0 56 * created binary expression objects.
michael@0 57 */
michael@0 58 static nsresult createBinaryExpr(nsAutoPtr<Expr>& left,
michael@0 59 nsAutoPtr<Expr>& right, Token* op,
michael@0 60 Expr** aResult);
michael@0 61 static nsresult createExpr(txExprLexer& lexer, txIParseContext* aContext,
michael@0 62 Expr** aResult);
michael@0 63 static nsresult createFilterOrStep(txExprLexer& lexer,
michael@0 64 txIParseContext* aContext,
michael@0 65 Expr** aResult);
michael@0 66 static nsresult createFunctionCall(txExprLexer& lexer,
michael@0 67 txIParseContext* aContext,
michael@0 68 Expr** aResult);
michael@0 69 static nsresult createLocationStep(txExprLexer& lexer,
michael@0 70 txIParseContext* aContext,
michael@0 71 Expr** aResult);
michael@0 72 static nsresult createNodeTypeTest(txExprLexer& lexer,
michael@0 73 txNodeTest** aResult);
michael@0 74 static nsresult createPathExpr(txExprLexer& lexer,
michael@0 75 txIParseContext* aContext,
michael@0 76 Expr** aResult);
michael@0 77 static nsresult createUnionExpr(txExprLexer& lexer,
michael@0 78 txIParseContext* aContext,
michael@0 79 Expr** aResult);
michael@0 80
michael@0 81 static bool isLocationStepToken(Token* aToken);
michael@0 82
michael@0 83 static short precedence(Token* aToken);
michael@0 84
michael@0 85 /**
michael@0 86 * Resolve a QName, given the mContext parse context.
michael@0 87 * Returns prefix and localName as well as namespace ID
michael@0 88 */
michael@0 89 static nsresult resolveQName(const nsAString& aQName, nsIAtom** aPrefix,
michael@0 90 txIParseContext* aContext,
michael@0 91 nsIAtom** aLocalName, int32_t& aNamespace,
michael@0 92 bool aIsNameTest = false);
michael@0 93
michael@0 94 /**
michael@0 95 * Using the given lexer, parses the tokens if they represent a
michael@0 96 * predicate list
michael@0 97 * If an error occurs a non-zero String pointer will be returned
michael@0 98 * containing the error message.
michael@0 99 * @param predicateList, the PredicateList to add predicate expressions to
michael@0 100 * @param lexer the ExprLexer to use for parsing tokens
michael@0 101 * @return 0 if successful, or a String pointer to the error message
michael@0 102 */
michael@0 103 static nsresult parsePredicates(PredicateList* aPredicateList,
michael@0 104 txExprLexer& lexer,
michael@0 105 txIParseContext* aContext);
michael@0 106 static nsresult parseParameters(FunctionCall* aFnCall, txExprLexer& lexer,
michael@0 107 txIParseContext* aContext);
michael@0 108
michael@0 109 };
michael@0 110
michael@0 111 #endif

mercurial