txRootExpr.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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/. */
  5. #include "txExpr.h"
  6. #include "txNodeSet.h"
  7. #include "txIXPathContext.h"
  8. #include "txXPathTreeWalker.h"
  9. /**
  10. * Evaluates this Expr based on the given context node and processor state
  11. * @param context the context node for evaluation of this Expr
  12. * @param ps the ContextState containing the stack information needed
  13. * for evaluation
  14. * @return the result of the evaluation
  15. **/
  16. nsresult
  17. RootExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
  18. {
  19. txXPathTreeWalker walker(aContext->getContextNode());
  20. walker.moveToRoot();
  21. return aContext->recycler()->getNodeSet(walker.getCurrentPosition(),
  22. aResult);
  23. }
  24. TX_IMPL_EXPR_STUBS_0(RootExpr, NODESET_RESULT)
  25. bool
  26. RootExpr::isSensitiveTo(ContextSensitivity aContext)
  27. {
  28. return !!(aContext & NODE_CONTEXT);
  29. }
  30. #ifdef TX_TO_STRING
  31. void
  32. RootExpr::toString(nsAString& dest)
  33. {
  34. if (mSerialize)
  35. dest.Append(char16_t('/'));
  36. }
  37. #endif