dom/xslt/xpath/txIXPathContext.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.

     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/. */
     6 #ifndef __TX_I_XPATH_CONTEXT
     7 #define __TX_I_XPATH_CONTEXT
     9 #include "txCore.h"
    11 class FunctionCall;
    12 class nsIAtom;
    13 class txAExprResult;
    14 class txResultRecycler;
    15 class txXPathNode;
    17 /*
    18  * txIParseContext
    19  *
    20  * This interface describes the context needed to create
    21  * XPath Expressions and XSLT Patters.
    22  * (not completely though. key() requires the ProcessorState, which is 
    23  * not part of this interface.)
    24  */
    26 class txIParseContext
    27 {
    28 public:
    29     virtual ~txIParseContext()
    30     {
    31     }
    33     /*
    34      * Return a namespaceID for a given prefix.
    35      */
    36     virtual nsresult resolveNamespacePrefix(nsIAtom* aPrefix, int32_t& aID) = 0;
    38     /*
    39      * Create a FunctionCall, needed for extension function calls and
    40      * XSLT. XPath function calls are resolved by the Parser.
    41      */
    42     virtual nsresult resolveFunctionCall(nsIAtom* aName, int32_t aID,
    43                                          FunctionCall** aFunction) = 0;
    45     /**
    46      * Should nametests parsed in this context be case-sensitive
    47      */
    48     virtual bool caseInsensitiveNameTests() = 0;
    50     /*
    51      * Callback to be used by the Parser if errors are detected.
    52      */
    53     virtual void SetErrorOffset(uint32_t aOffset) = 0;
    54 };
    56 /*
    57  * txIMatchContext
    58  *
    59  * Interface used for matching XSLT Patters.
    60  * This is the part of txIEvalContext (see below), that is independent
    61  * of the context node when evaluating a XPath expression, too.
    62  * When evaluating a XPath expression, |txIMatchContext|s are used
    63  * to transport the information from Step to Step.
    64  */
    65 class txIMatchContext
    66 {
    67 public:
    68     virtual ~txIMatchContext()
    69     {
    70     }
    72     /*
    73      * Return the ExprResult associated with the variable with the 
    74      * given namespace and local name.
    75      */
    76     virtual nsresult getVariable(int32_t aNamespace, nsIAtom* aLName,
    77                                  txAExprResult*& aResult) = 0;
    79     /*
    80      * Is whitespace stripping allowed for the given node?
    81      * See http://www.w3.org/TR/xslt#strip
    82      */
    83     virtual bool isStripSpaceAllowed(const txXPathNode& aNode) = 0;
    85     /**
    86      * Returns a pointer to the private context
    87      */
    88     virtual void* getPrivateContext() = 0;
    90     virtual txResultRecycler* recycler() = 0;
    92     /*
    93      * Callback to be used by the expression/pattern if errors are detected.
    94      */
    95     virtual void receiveError(const nsAString& aMsg, nsresult aRes) = 0;
    96 };
    98 #define TX_DECL_MATCH_CONTEXT \
    99     nsresult getVariable(int32_t aNamespace, nsIAtom* aLName, \
   100                          txAExprResult*& aResult); \
   101     bool isStripSpaceAllowed(const txXPathNode& aNode); \
   102     void* getPrivateContext(); \
   103     txResultRecycler* recycler(); \
   104     void receiveError(const nsAString& aMsg, nsresult aRes)
   106 class txIEvalContext : public txIMatchContext
   107 {
   108 public:
   109     /*
   110      * Get the context node.
   111      */
   112     virtual const txXPathNode& getContextNode() = 0;
   114     /*
   115      * Get the size of the context node set.
   116      */
   117     virtual uint32_t size() = 0;
   119     /*
   120      * Get the position of the context node in the context node set,
   121      * starting with 1.
   122      */
   123     virtual uint32_t position() = 0;
   124 };
   126 #define TX_DECL_EVAL_CONTEXT \
   127     TX_DECL_MATCH_CONTEXT; \
   128     const txXPathNode& getContextNode(); \
   129     uint32_t size(); \
   130     uint32_t position()
   132 #endif // __TX_I_XPATH_CONTEXT

mercurial