#include <nsXFormsMDGEngine.h>
A bit about the graph: As specified in the spec., one node (nsXFormsMDGNode) is created in the graph for each of the attributes (readonly, calculate, etc.) for a nsIDOMNode. These graph nodes are owned by the mNodeToMDG hash table, which maps from a nsIDOMNode to the first node in a single-linked list (mNext) of nodes for the same nsIDOMNode.
Public Member Functions | |
| nsXFormsMDGEngine () | |
| Constructor. | |
| ~nsXFormsMDGEngine () | |
| nsresult | Init (nsXFormsModelElement *aModel) |
| Initializes the internal structures. | |
| nsresult | AddMIP (ModelItemPropName aType, nsIDOMNSXPathExpression *aExpression, nsCOMArray< nsIDOMNode > *aDependencies, PRBool aDynFunc, nsIDOMNode *aContextNode, PRInt32 aContextPos, PRInt32 aContextSize) |
| Insert new MIP (Model Item Property) into graph. | |
| nsresult | Recalculate (nsCOMArray< nsIDOMNode > *aChangedNodes) |
| Recalculate the MDG. | |
| nsresult | Revalidate (nsCOMArray< nsIDOMNode > *aNodes) |
| Revalidate nodes. | |
| nsresult | Rebuild () |
| Rebuilds the MDG. | |
| nsresult | Clear () |
| Clears all information in the MDG. | |
| nsresult | ClearDispatchFlags () |
| Clears all Dispatch flags. | |
| nsresult | MarkNodeAsChanged (nsIDOMNode *aContextNode) |
| Mark a node as changed. | |
| nsresult | SetNodeValue (nsIDOMNode *aContextNode, const nsAString &aNodeValue, PRBool *aNodeChanged=nsnull) |
| Set the value of a node -- the public version of SetNodeValueInternal(). | |
| nsresult | SetNodeContent (nsIDOMNode *aContextNode, nsIDOMNode *aContentEnvelope) |
| Set the contents of a node. | |
| const nsXFormsNodeState * | GetNodeState (nsIDOMNode *aContextNode) |
| External interface of GetNCNodeState(), returns const pointer to the node state. | |
| void | PrintDot (const char *aFile=nsnull) |
| Write MDG graph to a file in GraphViz dot format. | |
Protected Member Functions | |
| nsXFormsMDGEngine (nsXFormsMDGEngine &) | |
| Hidden copy constructor. | |
| nsXFormsNodeState * | GetNCNodeState (nsIDOMNode *aContextNode) |
| Get non-const (NC) node state for a node, create a new node state if necessary. | |
| nsresult | CreateNewChild (nsIDOMNode *aContextNode, const nsAString &aNodeValue, nsIDOMNode *aBeforeNode=nsnull) |
| Inserts a new text child for aContextNode. | |
| nsXFormsMDGNode * | GetNode (nsIDOMNode *aDomNode, ModelItemPropName aType, PRBool aCreate=PR_TRUE) |
| Retrieve a node from the graph. | |
| PRBool | AndFlags (PRUint16 aAndMask) |
| Boolean AND _all_ flags with a mask. | |
| nsresult | BooleanExpression (nsXFormsMDGNode *aNode, PRBool &aRes) |
| Evaluates the expression for the given node and returns the boolean result. | |
| nsresult | ComputeMIP (eFlag_t aStateFlag, eFlag_t aDispatchFlag, nsXFormsMDGNode *aNode, PRBool &aDidChange) |
| Compute MIP value for node types with boolean result (all except calculate). | |
| nsresult | ComputeMIPWithInheritance (eFlag_t aStateFlag, eFlag_t aDispatchFlag, eFlag_t aInheritanceFlag, nsXFormsMDGNode *aNode, nsCOMArray< nsIDOMNode > *aSet) |
| Same as ComputeMIP(), but also handles any inheritance of attributes. | |
| nsresult | AttachInheritance (nsCOMArray< nsIDOMNode > *aSet, nsIDOMNode *aSrc, PRBool aState, eFlag_t aStateFlag) |
| Attaches inheritance to all children of a given node. | |
| nsresult | Invalidate () |
| Invalidate the information, ie. | |
| nsresult | SetNodeValueInternal (nsIDOMNode *aContextNode, const nsAString &aNodeValue, PRBool aMarkNode=PR_TRUE, PRBool aIsCalculate=PR_FALSE, PRBool *aNodeChanged=nsnull) |
| Set the value of a node. | |
| nsresult | HandleMarkedNodes (nsCOMArray< nsIDOMNode > *aArray) |
| Handle nodes nodes marked as dirty, and insert into "changed nodes array". | |
Static Protected Member Functions | |
| static PLDHashOperator PR_CALLBACK | DeleteLinkedNodes (nsISupports *aKey, nsAutoPtr< nsXFormsMDGNode > &aNode, void *aArg) |
| Used by Clear() and ~ to delete the linked nodes in mNodeToMDG, the hash table itself handles the main nodes. | |
| static PLDHashOperator PR_CALLBACK | AddStartNodes (nsISupports *aKey, nsXFormsMDGNode *aNode, void *aDeque) |
| Used by Rebuild() to find the start nodes for mGraph, that is nodes where mCount == 0. | |
| static PLDHashOperator PR_CALLBACK | AndFlag (nsISupports *aKey, nsAutoPtr< nsXFormsNodeState > &aState, void *aMask) |
| Used by AndFlags() to boolean AND _all_ flags with aMask. | |
Protected Attributes | |
| nsClassHashtable < nsISupportsHashKey, nsXFormsMDGNode > | mNodeToMDG |
| Maps from nsIDOMNode to nsXFormsMDGNode. | |
| nsClassHashtable < nsISupportsHashKey, nsXFormsNodeState > | mNodeStates |
| Maps from nsIDOMNode to nsXFormsNodeState. | |
| nsXFormsNodeState | mDefaultState |
| Default node state. | |
| PRBool | mJustRebuilt |
| True when Rebuild() has been run, but not ClearDispatchFlags(). | |
| PRBool | mFirstCalculate |
| True when last Calculate() was run when mJustRebuilt was true. | |
| nsVoidArray | mGraph |
| The actual MDG. | |
| nsXFormsModelElement * | mModel |
| The model that created the MDG. | |
| nsCOMArray< nsIDOMNode > | mMarkedNodes |
| Nodes that are marked as changed, and should be included in recalculation. | |
| PRInt32 | mNodesInGraph |
| Number of nodes in the graph. | |
| nsXFormsMDGEngine::nsXFormsMDGEngine | ( | nsXFormsMDGEngine & | ) | [inline, protected] |
| nsXFormsMDGEngine::nsXFormsMDGEngine | ( | ) |
| nsXFormsMDGEngine::~nsXFormsMDGEngine | ( | ) |
| PLDHashOperator nsXFormsMDGEngine::DeleteLinkedNodes | ( | nsISupports * | aKey, | |
| nsAutoPtr< nsXFormsMDGNode > & | aNode, | |||
| void * | aArg | |||
| ) | [static, protected] |
| PLDHashOperator nsXFormsMDGEngine::AddStartNodes | ( | nsISupports * | aKey, | |
| nsXFormsMDGNode * | aNode, | |||
| void * | aDeque | |||
| ) | [static, protected] |
| PLDHashOperator nsXFormsMDGEngine::AndFlag | ( | nsISupports * | aKey, | |
| nsAutoPtr< nsXFormsNodeState > & | aState, | |||
| void * | aMask | |||
| ) | [static, protected] |
| nsXFormsNodeState * nsXFormsMDGEngine::GetNCNodeState | ( | nsIDOMNode * | aContextNode | ) | [protected] |
| aContextNode | The node to get the state for |
| nsresult nsXFormsMDGEngine::CreateNewChild | ( | nsIDOMNode * | aContextNode, | |
| const nsAString & | aNodeValue, | |||
| nsIDOMNode * | aBeforeNode = nsnull | |||
| ) | [protected] |
| aContextNode | The node to create a child for | |
| aNodeValue | The value of the new node | |
| aBeforeNode | If non-null, insert new node before this node |
| nsXFormsMDGNode * nsXFormsMDGEngine::GetNode | ( | nsIDOMNode * | aDomNode, | |
| ModelItemPropName | aType, | |||
| PRBool | aCreate = PR_TRUE | |||
| ) | [protected] |
| aDomNode | The DOM node to retrieve | |
| aType | The type to retrieve (readonly, calculate, etc) | |
| aCreate | Create the node and insert it into the graph if it does not exist? |
| aAndMask | The mask |
| nsresult nsXFormsMDGEngine::BooleanExpression | ( | nsXFormsMDGNode * | aNode, | |
| PRBool & | aRes | |||
| ) | [protected] |
| aNode | The node to evaluate | |
| aRes | The result of the evaluation |
| nsresult nsXFormsMDGEngine::ComputeMIP | ( | eFlag_t | aStateFlag, | |
| eFlag_t | aDispatchFlag, | |||
| nsXFormsMDGNode * | aNode, | |||
| PRBool & | aDidChange | |||
| ) | [protected] |
| aStateFlag | The flag for the type of MIP | |
| aDispatchFlag | The dispatch flag | |
| aNode | The context node | |
| aDidChange | Was the node changed? |
| nsresult nsXFormsMDGEngine::ComputeMIPWithInheritance | ( | eFlag_t | aStateFlag, | |
| eFlag_t | aDispatchFlag, | |||
| eFlag_t | aInheritanceFlag, | |||
| nsXFormsMDGNode * | aNode, | |||
| nsCOMArray< nsIDOMNode > * | aSet | |||
| ) | [protected] |
| aStateFlag | The flag for the type of MIP | |
| aDispatchFlag | The dispatch flag | |
| aInheritanceFlag | The inheritance flag for the type of MIP | |
| aNode | The context node | |
| aSet | Set of the nodes influenced by operation |
| nsresult nsXFormsMDGEngine::AttachInheritance | ( | nsCOMArray< nsIDOMNode > * | aSet, | |
| nsIDOMNode * | aSrc, | |||
| PRBool | aState, | |||
| eFlag_t | aStateFlag | |||
| ) | [protected] |
| aSet | Set of the nodes influenced by operation | |
| aSrc | The node | |
| aState | The state of the flag | |
| aStateFlag | The flag |
| nsresult nsXFormsMDGEngine::Invalidate | ( | ) | [protected] |
mark all nodes as dirty.
| nsresult nsXFormsMDGEngine::SetNodeValueInternal | ( | nsIDOMNode * | aContextNode, | |
| const nsAString & | aNodeValue, | |||
| PRBool | aMarkNode = PR_TRUE, |
|||
| PRBool | aIsCalculate = PR_FALSE, |
|||
| PRBool * | aNodeChanged = nsnull | |||
| ) | [protected] |
| aContextNode | The node to set the value for | |
| aNodeValue | The value | |
| aMarkNode | Whether to mark node as changed | |
| aNodeChanged | Was node changed? | |
| aIsCalculate | Is it a setting the value? |
Unsupported nodeType
| nsresult nsXFormsMDGEngine::HandleMarkedNodes | ( | nsCOMArray< nsIDOMNode > * | aArray | ) | [protected] |
| aArray | The "changed nodes array" to insert into |
| nsresult nsXFormsMDGEngine::Init | ( | nsXFormsModelElement * | aModel | ) |
Needs to be called before class is used!
| aModel | The model that created this MDGEngine instance. |
| nsresult nsXFormsMDGEngine::AddMIP | ( | ModelItemPropName | aType, | |
| nsIDOMNSXPathExpression * | aExpression, | |||
| nsCOMArray< nsIDOMNode > * | aDependencies, | |||
| PRBool | aDynFunc, | |||
| nsIDOMNode * | aContextNode, | |||
| PRInt32 | aContextPos, | |||
| PRInt32 | aContextSize | |||
| ) |
| aType | The type of MIP | |
| aExpression | The XPath expression | |
| aDependencies | Set of nodes expression depends on | |
| aDynFunc | True if expression uses dynamic functions | |
| aContextNode | The context node for aExpression | |
| aContextPos | The context positions of aExpression | |
| aContextSize | The context size for aExpression |
| nsresult nsXFormsMDGEngine::Recalculate | ( | nsCOMArray< nsIDOMNode > * | aChangedNodes | ) |
| aChangedNodes | Returns the nodes that was changed during recalculation. |
| nsresult nsXFormsMDGEngine::Revalidate | ( | nsCOMArray< nsIDOMNode > * | aNodes | ) |
| aNodes | The nodes to revalidate |
| nsresult nsXFormsMDGEngine::Rebuild | ( | ) |
| nsresult nsXFormsMDGEngine::Clear | ( | void | ) |
| nsresult nsXFormsMDGEngine::ClearDispatchFlags | ( | ) |
| nsresult nsXFormsMDGEngine::MarkNodeAsChanged | ( | nsIDOMNode * | aContextNode | ) |
| aContextNode | The node to be marked. |
| nsresult nsXFormsMDGEngine::SetNodeValue | ( | nsIDOMNode * | aContextNode, | |
| const nsAString & | aNodeValue, | |||
| PRBool * | aNodeChanged = nsnull | |||
| ) |
| aContextNode | The node to set the value for | |
| aNodeValue | The value | |
| aNodeChanged | Was node changed? |
| nsresult nsXFormsMDGEngine::SetNodeContent | ( | nsIDOMNode * | aContextNode, | |
| nsIDOMNode * | aContentEnvelope | |||
| ) |
| aContextNode | The node to set the contents of | |
| aContentEnvelope | The container of the contents that need to be moved under aContextNode |
| const nsXFormsNodeState * nsXFormsMDGEngine::GetNodeState | ( | nsIDOMNode * | aContextNode | ) |
| aContextNode | The node to get the state for |
| aFile | Filename to write to (nsnull = stdout) |
nsXFormsNodeState nsXFormsMDGEngine::mDefaultState [protected] |
PRBool nsXFormsMDGEngine::mJustRebuilt [protected] |
PRBool nsXFormsMDGEngine::mFirstCalculate [protected] |
nsVoidArray nsXFormsMDGEngine::mGraph [protected] |
nsXFormsModelElement* nsXFormsMDGEngine::mModel [protected] |
nsCOMArray<nsIDOMNode> nsXFormsMDGEngine::mMarkedNodes [protected] |
PRInt32 nsXFormsMDGEngine::mNodesInGraph [protected] |
1.5.6