dom/xslt/xpath/txNamedAttributeStep.cpp

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.

     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 #include "nsIAtom.h"
     7 #include "txIXPathContext.h"
     8 #include "txNodeSet.h"
     9 #include "txExpr.h"
    10 #include "txXPathTreeWalker.h"
    12 txNamedAttributeStep::txNamedAttributeStep(int32_t aNsID,
    13                                            nsIAtom* aPrefix,
    14                                            nsIAtom* aLocalName)
    15     : mNamespace(aNsID),
    16       mPrefix(aPrefix),
    17       mLocalName(aLocalName)
    18 {
    19 }
    21 nsresult
    22 txNamedAttributeStep::evaluate(txIEvalContext* aContext,
    23                                txAExprResult** aResult)
    24 {
    25     *aResult = nullptr;
    27     nsRefPtr<txNodeSet> nodes;
    28     nsresult rv = aContext->recycler()->getNodeSet(getter_AddRefs(nodes));
    29     NS_ENSURE_SUCCESS(rv, rv);
    31     txXPathTreeWalker walker(aContext->getContextNode());
    32     if (walker.moveToNamedAttribute(mLocalName, mNamespace)) {
    33         rv = nodes->append(walker.getCurrentPosition());
    34         NS_ENSURE_SUCCESS(rv, rv);
    35     }
    36     NS_ADDREF(*aResult = nodes);
    38     return NS_OK;
    39 }
    41 TX_IMPL_EXPR_STUBS_0(txNamedAttributeStep, NODESET_RESULT)
    43 bool
    44 txNamedAttributeStep::isSensitiveTo(ContextSensitivity aContext)
    45 {
    46     return !!(aContext & NODE_CONTEXT);
    47 }
    49 #ifdef TX_TO_STRING
    50 void
    51 txNamedAttributeStep::toString(nsAString& aDest)
    52 {
    53     aDest.Append(char16_t('@'));
    54     if (mPrefix) {
    55         nsAutoString prefix;
    56         mPrefix->ToString(prefix);
    57         aDest.Append(prefix);
    58         aDest.Append(char16_t(':'));
    59     }
    60     nsAutoString localName;
    61     mLocalName->ToString(localName);
    62     aDest.Append(localName);
    63 }
    64 #endif

mercurial