nsTemplateMatch.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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 "nsTemplateMatch.h"
  6. #include "nsTemplateRule.h"
  7. // static
  8. void
  9. nsTemplateMatch::Destroy(nsTemplateMatch*& aMatch, bool aRemoveResult)
  10. {
  11. if (aRemoveResult && aMatch->mResult)
  12. aMatch->mResult->HasBeenRemoved();
  13. ::delete aMatch;
  14. aMatch = nullptr;
  15. }
  16. nsresult
  17. nsTemplateMatch::RuleMatched(nsTemplateQuerySet* aQuerySet,
  18. nsTemplateRule* aRule,
  19. int16_t aRuleIndex,
  20. nsIXULTemplateResult* aResult)
  21. {
  22. // assign the rule index, used to indicate that a match is active, and
  23. // so the tree builder can get the right action body to generate
  24. mRuleIndex = aRuleIndex;
  25. nsCOMPtr<nsIDOMNode> rulenode;
  26. aRule->GetRuleNode(getter_AddRefs(rulenode));
  27. if (rulenode)
  28. return aResult->RuleMatched(aQuerySet->mCompiledQuery, rulenode);
  29. return NS_OK;
  30. }