content/xul/templates/src/nsTemplateMatch.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/xul/templates/src/nsTemplateMatch.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,40 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsTemplateMatch.h"
    1.10 +#include "nsTemplateRule.h"
    1.11 +
    1.12 +#ifdef NEED_CPP_UNUSED_IMPLEMENTATIONS
    1.13 +nsTemplateMatch::nsTemplateMatch(const nsTemplateMatch& aMatch) {}
    1.14 +void nsTemplateMatch::operator=(const nsTemplateMatch& aMatch) {}
    1.15 +#endif
    1.16 +
    1.17 +// static
    1.18 +void
    1.19 +nsTemplateMatch::Destroy(nsTemplateMatch*& aMatch, bool aRemoveResult)
    1.20 +{
    1.21 +    if (aRemoveResult && aMatch->mResult)
    1.22 +        aMatch->mResult->HasBeenRemoved();
    1.23 +    ::delete aMatch;
    1.24 +    aMatch = nullptr;
    1.25 +}
    1.26 +
    1.27 +nsresult
    1.28 +nsTemplateMatch::RuleMatched(nsTemplateQuerySet* aQuerySet,
    1.29 +                             nsTemplateRule* aRule,
    1.30 +                             int16_t aRuleIndex,
    1.31 +                             nsIXULTemplateResult* aResult)
    1.32 +{
    1.33 +    // assign the rule index, used to indicate that a match is active, and
    1.34 +    // so the tree builder can get the right action body to generate
    1.35 +    mRuleIndex = aRuleIndex;
    1.36 +
    1.37 +    nsCOMPtr<nsIDOMNode> rulenode;
    1.38 +    aRule->GetRuleNode(getter_AddRefs(rulenode));
    1.39 +    if (rulenode)
    1.40 +        return aResult->RuleMatched(aQuerySet->mCompiledQuery, rulenode);
    1.41 +
    1.42 +    return NS_OK;
    1.43 +}

mercurial