nsresult TestNode::Propagate(InstantiationSet& aInstantiations, bool aIsUpdate, bool& aTakenInstantiations) { MOZ_LOG(gXULTemplateLog, LogLevel::Debug, ("TestNode[%p]: Propagate() begin", this)); aTakenInstantiations = false; nsresult rv = FilterInstantiations(aInstantiations, nullptr); if (NS_FAILED(rv)) return rv; // if there is more than one child, each will need to be supplied with the // original set of instantiations from this node, so create a copy in this // case. If there is only one child, optimize and just pass the // instantiations along to the child without copying bool shouldCopy = (mKids.Count() > 1); // See the header file for details about how instantiation ownership works. if (! aInstantiations.Empty()) { ReteNodeSet::Iterator last = mKids.Last(); for (ReteNodeSet::Iterator kid = mKids.First(); kid != last; ++kid) { MOZ_LOG(gXULTemplateLog, LogLevel::Debug, ("TestNode[%p]: Propagate() passing to child %p", this, kid.operator->())); // create a copy of the instantiations if (shouldCopy) { bool owned = false; InstantiationSet* instantiations = new InstantiationSet(aInstantiations); if (!instantiations) return NS_ERROR_OUT_OF_MEMORY; rv = kid->Propagate(*instantiations, aIsUpdate, owned); if (!owned) delete instantiations; if (NS_FAILED(rv)) return rv; } else { rv = kid->Propagate(aInstantiations, aIsUpdate, aTakenInstantiations); if (NS_FAILED(rv)) return rv; } } } MOZ_LOG(gXULTemplateLog, LogLevel::Debug, ("TestNode[%p]: Propagate() end", this)); return NS_OK; }
nsresult TestNode::Constrain(InstantiationSet& aInstantiations) { nsresult rv; MOZ_LOG(gXULTemplateLog, LogLevel::Debug, ("TestNode[%p]: Constrain() begin", this)); // if the cantHandleYet flag is set by FilterInstantiations, // there isn't enough information yet available to fill in. // For this, continue the constrain all the way to the top // and then call FilterInstantiations again afterwards. This // should fill in any missing information. bool cantHandleYet = false; rv = FilterInstantiations(aInstantiations, &cantHandleYet); if (NS_FAILED(rv)) return rv; if (mParent && (!aInstantiations.Empty() || cantHandleYet)) { // if we still have instantiations, or if the instantiations // could not be filled in yet, then ride 'em on up to the // parent to narrow them. MOZ_LOG(gXULTemplateLog, LogLevel::Debug, ("TestNode[%p]: Constrain() passing to parent %p", this, mParent)); rv = mParent->Constrain(aInstantiations); if (NS_SUCCEEDED(rv) && cantHandleYet) rv = FilterInstantiations(aInstantiations, nullptr); } else { MOZ_LOG(gXULTemplateLog, LogLevel::Debug, ("TestNode[%p]: Constrain() failed", this)); rv = NS_OK; } MOZ_LOG(gXULTemplateLog, LogLevel::Debug, ("TestNode[%p]: Constrain() end", this)); return rv; }