txUnionNodeTest.cpp (1563B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "mozilla/FloatingPoint.h" 8 #include "txExpr.h" 9 #include "txExprResult.h" 10 #include "txSingleNodeContext.h" 11 12 #ifdef TX_TO_STRING 13 # include "nsReadableUtils.h" 14 #endif 15 16 nsresult txUnionNodeTest::matches(const txXPathNode& aNode, 17 txIMatchContext* aContext, bool& aMatched) { 18 uint32_t i, len = mNodeTests.Length(); 19 for (i = 0; i < len; ++i) { 20 nsresult rv = mNodeTests[i]->matches(aNode, aContext, aMatched); 21 NS_ENSURE_SUCCESS(rv, rv); 22 23 if (aMatched) { 24 return NS_OK; 25 } 26 } 27 28 aMatched = false; 29 return NS_OK; 30 } 31 32 double txUnionNodeTest::getDefaultPriority() { 33 NS_ERROR("Don't call getDefaultPriority on txUnionPattern"); 34 return mozilla::UnspecifiedNaN<double>(); 35 } 36 37 bool txUnionNodeTest::isSensitiveTo(Expr::ContextSensitivity aContext) { 38 uint32_t i, len = mNodeTests.Length(); 39 for (i = 0; i < len; ++i) { 40 if (mNodeTests[i]->isSensitiveTo(aContext)) { 41 return true; 42 } 43 } 44 45 return false; 46 } 47 48 #ifdef TX_TO_STRING 49 void txUnionNodeTest::toString(nsAString& aDest) { 50 aDest.Append('('); 51 52 StringJoinAppend( 53 aDest, u" | "_ns, mNodeTests, 54 [](nsAString& dest, txNodeTest* nodeTest) { nodeTest->toString(dest); }); 55 56 aDest.Append(')'); 57 } 58 #endif