dom/xslt/xpath/txNamedAttributeStep.cpp

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

mercurial