dom/xslt/xpath/txSingleNodeContext.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/xslt/xpath/txSingleNodeContext.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef __TX_XPATH_SINGLENODE_CONTEXT
    1.10 +#define __TX_XPATH_SINGLENODE_CONTEXT
    1.11 +
    1.12 +#include "mozilla/Attributes.h"
    1.13 +#include "txIXPathContext.h"
    1.14 +
    1.15 +class txSingleNodeContext : public txIEvalContext
    1.16 +{
    1.17 +public:
    1.18 +    txSingleNodeContext(const txXPathNode& aContextNode,
    1.19 +                        txIMatchContext* aContext)
    1.20 +        : mNode(aContextNode),
    1.21 +          mInner(aContext)
    1.22 +    {
    1.23 +        NS_ASSERTION(aContext, "txIMatchContext must be given");
    1.24 +    }
    1.25 +
    1.26 +    nsresult getVariable(int32_t aNamespace, nsIAtom* aLName,
    1.27 +                         txAExprResult*& aResult) MOZ_OVERRIDE
    1.28 +    {
    1.29 +        NS_ASSERTION(mInner, "mInner is null!!!");
    1.30 +        return mInner->getVariable(aNamespace, aLName, aResult);
    1.31 +    }
    1.32 +
    1.33 +    bool isStripSpaceAllowed(const txXPathNode& aNode) MOZ_OVERRIDE
    1.34 +    {
    1.35 +        NS_ASSERTION(mInner, "mInner is null!!!");
    1.36 +        return mInner->isStripSpaceAllowed(aNode);
    1.37 +    }
    1.38 +
    1.39 +    void* getPrivateContext() MOZ_OVERRIDE
    1.40 +    {
    1.41 +        NS_ASSERTION(mInner, "mInner is null!!!");
    1.42 +        return mInner->getPrivateContext();
    1.43 +    }
    1.44 +
    1.45 +    txResultRecycler* recycler() MOZ_OVERRIDE
    1.46 +    {
    1.47 +        NS_ASSERTION(mInner, "mInner is null!!!");
    1.48 +        return mInner->recycler();
    1.49 +    }
    1.50 +
    1.51 +    void receiveError(const nsAString& aMsg, nsresult aRes) MOZ_OVERRIDE
    1.52 +    {
    1.53 +        NS_ASSERTION(mInner, "mInner is null!!!");
    1.54 +#ifdef DEBUG
    1.55 +        nsAutoString error(NS_LITERAL_STRING("forwarded error: "));
    1.56 +        error.Append(aMsg);
    1.57 +        mInner->receiveError(error, aRes);
    1.58 +#else
    1.59 +        mInner->receiveError(aMsg, aRes);
    1.60 +#endif
    1.61 +    }
    1.62 +
    1.63 +    const txXPathNode& getContextNode() MOZ_OVERRIDE
    1.64 +    {
    1.65 +        return mNode;
    1.66 +    }
    1.67 +
    1.68 +    uint32_t size() MOZ_OVERRIDE
    1.69 +    {
    1.70 +        return 1;
    1.71 +    }
    1.72 +
    1.73 +    uint32_t position() MOZ_OVERRIDE
    1.74 +    {
    1.75 +        return 1;
    1.76 +    }
    1.77 +
    1.78 +private:
    1.79 +    const txXPathNode& mNode;
    1.80 +    txIMatchContext* mInner;
    1.81 +};
    1.82 +
    1.83 +#endif // __TX_XPATH_SINGLENODE_CONTEXT

mercurial