Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Attributes
nsContentTagTestNode Class Reference

#include <nsContentTagTestNode.h>

Inheritance diagram for nsContentTagTestNode:
Inheritance graph
[legend]
Collaboration diagram for nsContentTagTestNode:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsContentTagTestNode (InnerNode *aParent, nsConflictSet &aConflictSet, PRInt32 aContentVariable, nsIAtom *aTag)
virtual nsresult FilterInstantiations (InstantiationSet &aInstantiations, void *aClosure) const
 Given a set of instantiations, filter out any that are inconsistent with the test node's test, and append variable-to-value assignments and memory element support for those which do pass the test node's test.
virtual nsresult GetAncestorVariables (VariableSet &aVariables) const
 Retrieve the set of variables that are introduced by this node and any of its ancestors.
InnerNodeGetParent () const
 Retrieve the test node's parent.
virtual nsresult Propagate (const InstantiationSet &aInstantiations, void *aClosure)
 Calls FilterInstantiations() on the instantiation set, and if the resulting set isn't empty, propagates the new set down to each of the test node's children.
virtual nsresult Constrain (InstantiationSet &aInstantiations, void *aClosure)
 Calls FilterInstantiations() on the instantiation set, and if the resulting set isn't empty, propagates the new set up to the test node's parent.
virtual PRBool HasAncestor (const ReteNode *aNode) const
 Determine if this node has another node as its direct ancestor.
nsresult AddChild (ReteNode *aNode)
 Add another node as a child of this node.
nsresult RemoveAllChildren ()
 Remove all the children of this node.

Protected Attributes

nsConflictSetmConflictSet
PRInt32 mContentVariable
nsCOMPtr< nsIAtommTag
InnerNodemParent
ReteNodeSet mKids

Detailed Description

Definition at line 47 of file nsContentTagTestNode.h.


Constructor & Destructor Documentation

nsContentTagTestNode::nsContentTagTestNode ( InnerNode aParent,
nsConflictSet aConflictSet,
PRInt32  aContentVariable,
nsIAtom aTag 
)

Definition at line 48 of file nsContentTagTestNode.cpp.

    : TestNode(aParent),
      mConflictSet(aConflictSet),
      mContentVariable(aContentVariable),
      mTag(aTag)
{
#ifdef PR_LOGGING
    if (PR_LOG_TEST(gXULTemplateLog, PR_LOG_DEBUG)) {
        nsAutoString tag(NS_LITERAL_STRING("(none)"));
        if (mTag)
            mTag->ToString(tag);

        PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
               ("nsContentTagTestNode[%p]: parent=%p content-var=%d tag=%s",
                this, aParent, aContentVariable, NS_ConvertUCS2toUTF8(tag).get()));
    }
#endif
}

Member Function Documentation

nsresult InnerNode::AddChild ( ReteNode aNode) [inline, inherited]

Add another node as a child of this node.

Parameters:
aNodethe node to add.
Returns:
NS_OK if no errors occur.

Definition at line 973 of file nsRuleNetwork.h.

{ return mKids.Add(aNode); }

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult TestNode::Constrain ( InstantiationSet aInstantiations,
void aClosure 
) [virtual, inherited]

Calls FilterInstantiations() on the instantiation set, and if the resulting set isn't empty, propagates the new set up to the test node's parent.

Implements InnerNode.

Definition at line 1065 of file nsRuleNetwork.cpp.

{
    nsresult rv;

    PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
           ("TestNode[%p]: Constrain() begin", this));

    rv = FilterInstantiations(aInstantiations, aClosure);
    if (NS_FAILED(rv)) return rv;

    if (! aInstantiations.Empty()) {
        // if we still have instantiations, then ride 'em on up to the
        // parent to narrow them.

        PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
               ("TestNode[%p]: Constrain() passing to parent %p", this, mParent));

        rv = mParent->Constrain(aInstantiations, aClosure);
    }
    else {
        PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
               ("TestNode[%p]: Constrain() failed", this));

        rv = NS_OK;
    }

    PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
           ("TestNode[%p]: Constrain() end", this));

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsContentTagTestNode::FilterInstantiations ( InstantiationSet aInstantiations,
void aClosure 
) const [virtual]

Given a set of instantiations, filter out any that are inconsistent with the test node's test, and append variable-to-value assignments and memory element support for those which do pass the test node's test.

Parameters:
aInstantiationsthe set of instantiations to be filtered
aClosureapplication-specific data that is to be passed through the network.
Returns:
NS_OK if no errors occurred.

Implements TestNode.

Definition at line 71 of file nsContentTagTestNode.cpp.

{
    nsresult rv;

    nsCOMPtr<nsISupportsArray> elements;
    rv = NS_NewISupportsArray(getter_AddRefs(elements));
    if (NS_FAILED(rv)) return rv;

    InstantiationSet::Iterator last = aInstantiations.Last();
    for (InstantiationSet::Iterator inst = aInstantiations.First(); inst != last; ++inst) {
        Value value;
        if (! inst->mAssignments.GetAssignmentFor(mContentVariable, &value)) {
           // NS_ERROR("cannot handle open-ended tag name query");
            return NS_ERROR_UNEXPECTED;
        }

        if (VALUE_TO_ICONTENT(value)->Tag() != mTag) {
            aInstantiations.Erase(inst--);
        }
    }
    
    return NS_OK;
}

Here is the call graph for this function:

Retrieve the set of variables that are introduced by this node and any of its ancestors.

To correctly implement this method, a node must add any variables that it introduces to the variable set, and then recursively call GetAncestorVariables() on its parent (or parents).

Parameters:
aVariablesThe variable set to which the callee will add its variables, and its ancestors variables.
Returns:
NS_OK if no errors occur.

Reimplemented from TestNode.

Definition at line 96 of file nsContentTagTestNode.cpp.

{
    return NS_OK;
}
InnerNode* TestNode::GetParent ( ) const [inline, inherited]

Retrieve the test node's parent.

Returns:
the test node's parent

Definition at line 1065 of file nsRuleNetwork.h.

{ return mParent; }

Here is the caller graph for this function:

PRBool TestNode::HasAncestor ( const ReteNode aNode) const [virtual, inherited]

Determine if this node has another node as its direct ancestor.

Parameters:
aNodethe node to look for.
Returns:
PR_TRUE if aNode is a direct ancestor of this node, PR_FALSE otherwise.

Implements InnerNode.

Definition at line 1106 of file nsRuleNetwork.cpp.

{
    return aNode == this ? PR_TRUE : mParent->HasAncestor(aNode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult TestNode::Propagate ( const InstantiationSet aInstantiations,
void aClosure 
) [virtual, inherited]

Calls FilterInstantiations() on the instantiation set, and if the resulting set isn't empty, propagates the new set down to each of the test node's children.

Implements ReteNode.

Definition at line 1036 of file nsRuleNetwork.cpp.

{
    nsresult rv;

    PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
           ("TestNode[%p]: Propagate() begin", this));

    InstantiationSet instantiations = aInstantiations;
    rv = FilterInstantiations(instantiations, aClosure);
    if (NS_FAILED(rv)) return rv;

    if (! instantiations.Empty()) {
        ReteNodeSet::Iterator last = mKids.Last();
        for (ReteNodeSet::Iterator kid = mKids.First(); kid != last; ++kid) {
            PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
                   ("TestNode[%p]: Propagate() passing to child %p", this, kid.operator->()));

            kid->Propagate(instantiations, aClosure);
        }
    }

    PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
           ("TestNode[%p]: Propagate() end", this));

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult InnerNode::RemoveAllChildren ( ) [inline, inherited]

Remove all the children of this node.

Returns:
NS_OK if no errors occur.

Definition at line 979 of file nsRuleNetwork.h.

{ return mKids.Clear(); }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 60 of file nsContentTagTestNode.h.

Definition at line 61 of file nsContentTagTestNode.h.

ReteNodeSet InnerNode::mKids [protected, inherited]

Definition at line 982 of file nsRuleNetwork.h.

InnerNode* TestNode::mParent [protected, inherited]

Definition at line 1100 of file nsRuleNetwork.h.

Definition at line 62 of file nsContentTagTestNode.h.


The documentation for this class was generated from the following files: