txUnionNodeTest.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #include "mozilla/FloatingPoint.h"
  7. #include "txExpr.h"
  8. #include "txExprResult.h"
  9. #include "txSingleNodeContext.h"
  10. bool
  11. txUnionNodeTest::matches(const txXPathNode& aNode,
  12. txIMatchContext* aContext)
  13. {
  14. uint32_t i, len = mNodeTests.Length();
  15. for (i = 0; i < len; ++i) {
  16. if (mNodeTests[i]->matches(aNode, aContext)) {
  17. return true;
  18. }
  19. }
  20. return false;
  21. }
  22. double
  23. txUnionNodeTest::getDefaultPriority()
  24. {
  25. NS_ERROR("Don't call getDefaultPriority on txUnionPattern");
  26. return mozilla::UnspecifiedNaN<double>();
  27. }
  28. bool
  29. txUnionNodeTest::isSensitiveTo(Expr::ContextSensitivity aContext)
  30. {
  31. uint32_t i, len = mNodeTests.Length();
  32. for (i = 0; i < len; ++i) {
  33. if (mNodeTests[i]->isSensitiveTo(aContext)) {
  34. return true;
  35. }
  36. }
  37. return false;
  38. }
  39. #ifdef TX_TO_STRING
  40. void
  41. txUnionNodeTest::toString(nsAString& aDest)
  42. {
  43. aDest.Append('(');
  44. for (uint32_t i = 0; i < mNodeTests.Length(); ++i) {
  45. if (i != 0) {
  46. aDest.AppendLiteral(" | ");
  47. }
  48. mNodeTests[i]->toString(aDest);
  49. }
  50. aDest.Append(')');
  51. }
  52. #endif