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