Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Friends
nsXFormsModelElement Class Reference

Implementation of the XForms <model> element. More...

#include <nsXFormsModelElement.h>

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

List of all members.

Public Member Functions

 nsXFormsModelElement () NS_HIDDEN
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIXFORMSMODELELEMENT
NS_DECL_NSIMODELELEMENTPRIVATE
NS_DECL_NSIXFORMSNSMODELELEMENT
NS_DECL_NSISCHEMALOADLISTENER
NS_DECL_NSIWEBSERVICEERRORHANDLER
NS_DECL_NSIDOMEVENTLISTENER
NS_DECL_NSIXFORMSCONTEXTCONTROL
NS_IMETHOD 
OnDestroyed ()
NS_IMETHOD GetScriptingInterfaces (PRUint32 *aCount, nsIID ***aArray)
NS_IMETHOD WillChangeDocument (nsIDOMDocument *aNewDocument)
NS_IMETHOD DocumentChanged (nsIDOMDocument *aNewDocument)
NS_IMETHOD DoneAddingChildren ()
NS_IMETHOD HandleDefault (nsIDOMEvent *aEvent, PRBool *aHandled)
NS_IMETHOD OnCreated (nsIXTFGenericElementWrapper *aWrapper)
NS_IMETHOD Bind (PRBool *aContextChanged)
NS_IMETHOD GetOnDeferredBindList (PRBool *onList)
NS_IMETHOD SetOnDeferredBindList (PRBool putOnList)
already_AddRefed< nsIDOMElementGetDOMElement ()
 Returns the DOM element for the model.
virtual nsRepeatState GetRepeatState ()
 Get/Set the repeat state for the xforms control or action.
virtual void SetRepeatState (nsRepeatState aState)
void onCreated (in nsIXTFGenericElementWrapper wrapper)
void onDestroyed ()
void getScriptingInterfaces (out unsigned long count,[array, size_is(count), retval] out nsIIDPtr array)
void willChangeDocument (in nsIDOMDocument newDoc)
void documentChanged (in nsIDOMDocument newDoc)
void willChangeParent (in nsIDOMElement newParent)
void parentChanged (in nsIDOMElement newParent)
void willInsertChild (in nsIDOMNode child, in unsigned long index)
void childInserted (in nsIDOMNode child, in unsigned long index)
void willAppendChild (in nsIDOMNode child)
void childAppended (in nsIDOMNode child)
void willRemoveChild (in unsigned long index)
void childRemoved (in unsigned long index)
void willSetAttribute (in nsIAtom name, in AString newValue)
void attributeSet (in nsIAtom name, in AString newValue)
void willRemoveAttribute (in nsIAtom name)
void attributeRemoved (in nsIAtom name)
void beginAddingChildren ()
void doneAddingChildren ()
boolean handleDefault (in nsIDOMEvent aEvent)
void cloneState (in nsIDOMElement aElement)
void addFormControl (in nsIXFormsControl control, in nsIXFormsControl parent)
 Called by form control elements when they are bound to or unbound from this model.
void removeFormControl (in nsIXFormsControl control)
void instanceLoadStarted ()
 Notification that an instance element has started or finished loading its instance data.
void instanceLoadFinished (in boolean success, in AString uri)
nsIInstanceElementPrivate findInstanceElement (in AString id)
 Locate the instance element child with the given id.
void setNodeValue (in nsIDOMNode instanceNode, in AString nodeValue, in boolean doRefresh, out boolean nodeChanged)
 Set the value of an instance node.
void setNodeContent (in nsIDOMNode node, in nsIDOMNode content, in boolean doRebuild)
 Insert a set of nodes underneath an instance node.
PRBool validateNode (in nsIDOMNode aInstanceNode)
 Validates the instance node against the schemas loaded by the model.
unsigned short handleInstanceDataNode (in nsIDOMNode aInstanceDataNode)
 Handles an instance data node and returns one of the above 3 values.
void setStates (in nsIXFormsControl aControl, in nsIDOMNode aBoundNode)
 Set MIP states for given control bound to the given bound node.
void addInstanceElement (in nsIInstanceElementPrivate aInstanceElement)
 Add an instance element to the model's instance list.
void removeInstanceElement (in nsIInstanceElementPrivate aInstanceElement)
 Remove an instance element from the model's instance list.
void getTypeFromNode (in nsIDOMNode aInstanceData, out AString aType, out AString aNSUri)
 Retrieves the type for an instance data node.
void messageLoadFinished ()
 Notification that all of the external message loads have finished loading.
void requestRebuild ()
 Request an xforms-rebuild.
void requestRecalculate ()
 Request an xforms-recalculate.
void requestRevalidate ()
 Request an xforms-revalidate.
void requestRefresh ()
 Request an xforms-refresh.
void forceRebind (in nsIXFormsControl control)
 Force rebinding (and refreshing) of a control.
nsISchemaType getTypeForNode (in nsIDOMNode node)
 Determine the type for a form control based on the schema included by this model.
nsISchemaType getTypeForControl (in nsIXFormsControl control)
 Determine the type for a form control based on the schema included by this model.
AString getBuiltinTypeNameForControl (in nsIXFormsControl control)
 Return builtin type name for a form control based on the schema included by this model.
void getTypeAndNSFromNode (in nsIDOMNode instancenode, out AString type, out AString namespaceURI)
 This function takes an instance data node, finds the type bound to it, and returns the separated out type and namespace URI.
void getDerivedTypeList (in AString aType, in AString aNamespace, out AString aTypeList)
 Retrieves the list of datatypes that the original type is derived from or is an extension of.
void GetRootBuiltinType (in nsISchemaType aType, out unsigned short aBuiltinType)
 Retrieves the primative builtin type that the original type derives from.
nsIDOMDocument getInstanceDocument (in DOMString instanceID)
void rebuild ()
void recalculate ()
void revalidate ()
void refresh ()
nsIDOMNodeList getInstanceDocuments ()
void onLoad (in nsISchema schema)
void onError (in nsresult status, in AString statusMessage)
void handleEvent (in nsIDOMEvent event)
 This method is called whenever an event occurs of the type for which the EventListener interface was registered.
void getContext (out AString aModelID, out nsIDOMNode aContextNode, out long aContextPosition, out long aContextSize)
 Used by children to retrieve the context of their parent.
void setContext (in nsIDOMNode aContextNode, in long aContextPosition, in long aContextSize)
 Used by parents to set the context for children.
void addRemoveAbortedControl (in nsIXFormsControl aControl, in boolean aAddControl)
 Each context control maintains an 'aborted bind' list.
boolean bind ()
 This tells the form control to update its node binding based on the current instance data.
void refresh ()
 This tells the form control to update its state based on the current instance data.

Static Public Member Functions

static NS_HIDDEN_ (void) Startup()
static NS_HIDDEN_ (nsresult) DeferElementBind(nsIXFormsControl *aControl)
 The models are not ready for binding, so defer the binding of the control by storing it as a property on the document.
static nsresult NeedsPostRefresh (nsIXFormsControl *aControl)
static PRBool ContainerNeedsPostRefresh (nsIXFormsControl *aControl)
static void CancelPostRefresh (nsIXFormsControl *aControl)

Public Attributes

const unsigned long ELEMENT_TYPE_GENERIC_ELEMENT = 0
const unsigned long ELEMENT_TYPE_SVG_VISUAL = 1
const unsigned long ELEMENT_TYPE_XML_VISUAL = 2
const unsigned long ELEMENT_TYPE_XUL_VISUAL = 3
const unsigned long ELEMENT_TYPE_BINDABLE = 4
readonly attribute unsigned long elementType
readonly attribute boolean isAttributeHandler
const unsigned long NOTIFY_WILL_CHANGE_DOCUMENT = 0x00000001
const unsigned long NOTIFY_DOCUMENT_CHANGED = 0x00000002
const unsigned long NOTIFY_WILL_CHANGE_PARENT = 0x00000004
const unsigned long NOTIFY_PARENT_CHANGED = 0x00000008
const unsigned long NOTIFY_WILL_INSERT_CHILD = 0x00000010
const unsigned long NOTIFY_CHILD_INSERTED = 0x00000020
const unsigned long NOTIFY_WILL_APPEND_CHILD = 0x00000040
const unsigned long NOTIFY_CHILD_APPENDED = 0x00000080
const unsigned long NOTIFY_WILL_REMOVE_CHILD = 0x00000100
const unsigned long NOTIFY_CHILD_REMOVED = 0x00000200
const unsigned long NOTIFY_WILL_SET_ATTRIBUTE = 0x00000400
const unsigned long NOTIFY_ATTRIBUTE_SET = 0x00000800
const unsigned long NOTIFY_WILL_REMOVE_ATTRIBUTE = 0x00001000
const unsigned long NOTIFY_ATTRIBUTE_REMOVED = 0x00002000
const unsigned long NOTIFY_BEGIN_ADDING_CHILDREN = 0x00004000
const unsigned long NOTIFY_DONE_ADDING_CHILDREN = 0x00008000
const unsigned long NOTIFY_HANDLE_DEFAULT = 0x00010000
const unsigned short SUBMIT_SERIALIZE_NODE = 1
const unsigned short SUBMIT_SKIP_NODE = 2
const unsigned short SUBMIT_ABORT_SUBMISSION = 3
readonly attribute boolean lazyAuthored
 This attribute is set when the model's instance was lazy authored.
readonly attribute boolean isReady
 This attribute is set when the model handled xforms-ready event.
readonly attribute boolean hasDOMContentFired
 Returns true when the model has been notified that the DOMContentLoaded event has been fired on the XForms document.
attribute boolean onDeferredBindList
 Determines whether this control is already on the deferred bind list.

Protected Member Functions

virtual nsRepeatState UpdateRepeatState (nsIDOMNode *aParent)
 This is processed when an XForms control or XForms action has been inserted under a parent node AND has been inserted into a document.

Protected Attributes

nsRepeatState mRepeatState
PRPackedBool mHasParent
 State that tells whether control has a parent or not.
PRPackedBool mHasDoc
 State that tells whether control has a document or not.

Private Member Functions

 FindInstanceDocument (const nsAString &aID)
 NS_HIDDEN_ (void) Reset()
 NS_HIDDEN_ (void) BackupOrRestoreInstanceData(PRBool restore)
 NS_HIDDEN_ (nsresult) InitializeControls()
 Initializes the MIPs on all form controls.
 NS_HIDDEN_ (nsresult) InitializeInstances()
 NS_HIDDEN_ (nsresult) ProcessBindElements()
 NS_HIDDEN_ (nsresult) FinishConstruction()
 NS_HIDDEN_ (nsresult) ConstructDone()
 NS_HIDDEN_ (void) MaybeNotifyCompletion()
 NS_HIDDEN_ (nsresult) ProcessBind(nsIXFormsXPathEvaluator *aEvaluator
 NS_HIDDEN_ (void) RemoveModelFromDocument()
 NS_HIDDEN_ (void) SetSingleState(nsIDOMElement *aElement
 Sets the state of a specific state.
PRBool IsComplete () const
 NS_HIDDEN_ (nsresult) HandleLoad(nsIDOMEvent *aEvent)
 Called by HandleEvent.
 NS_HIDDEN_ (nsresult) HandleUnload(nsIDOMEvent *aEvent)
 Called by HandleEvent.
 NS_HIDDEN_ (nsresult) RefreshSubTree(nsXFormsControlListItem *aCurrent
 NS_HIDDEN_ (nsresult) ValidateDocument(nsIDOMDocument *aInstanceDocument
 NS_HIDDEN_ (nsresult) RequestUpdateEvent(nsXFormsEvent aEvent)
 Request to send an update event to the model.
PRBool IsDuplicateSchema (nsIDOMElement *aSchemaElement)
 Returns true if a schema has already been registered to address the same namespace as aSchemaElement.
void ValidateInstanceDocuments ()
 Validate all the instance documents.
 NS_HIDDEN_ (nsresult) GetBuiltinTypeName(PRUint16 aType
 Return the name of builitn type.
 NS_HIDDEN_ (nsresult) GetBuiltinTypesNames(PRUint16 aType
 Starting with aType, walks through the builtin derived types back to the builtin primative type, appending the datatype URIs to the string array as it goes.
 NS_HIDDEN_ (nsresult) WalkTypeChainInternal(nsISchemaType *aType
 Starting from aType, walks the chain of datatype extension/derivation to gather information.
 NS_HIDDEN_ (nsresult) BuiltinTypeToPrimative(nsISchemaBuiltinType *aSchemaType
 Returns the primative type that aSchemaType is derived/extended from.
nsresult SetContextInfo (const char *aName, const nsAString &aValue)
 Set context info for events.

Static Private Member Functions

static NS_HIDDEN_ (void) ProcessDeferredBinds(nsIDOMDocument *aDoc)
 Handle controls bindings which was deferred because the model was not ready.

Private Attributes

nsIDOMNodeaContextNode
nsIDOMNode PRInt32 aContextPosition
nsIDOMNode PRInt32 PRInt32 aContextSize
nsIDOMNode PRInt32 PRInt32
nsIDOMElement
aBindElement
nsIDOMNode PRInt32 PRInt32
nsIDOMElement PRBool 
aIsOuter = PR_FALSE)
PRBool aState
PRBool nsXFormsEvent aOnEvent
PRBool aForceRebind
PRBoolaResult
nsAString & aName
nsStringArray * aNameArray
PRBool aFindRootBuiltin
PRBool PRUint16aBuiltinType
PRBool PRUint16 nsStringArray * aTypeArray = nsnull)
PRUint16aPrimType
nsIDOMElementmElement
nsCOMPtr< nsISchemaLoadermSchemas
nsStringArray mPendingInlineSchemas
nsXFormsControlListItem mFormControls
nsRefPtrHashtable
< nsISupportsHashKey,
nsXFormsControlListItem
mControlListHash
PRInt32 mSchemaCount
PRInt32 mSchemaTotal
PRInt32 mPendingInstanceCount
nsXFormsMDGEngine mMDG
 The MDG for this model.
nsCOMArray< nsIDOMNodemChangedNodes
 List of changed nodes, ie.
PRPackedBool mDocumentLoaded
 This flag indicates whether or not the document has fired DOMContentLoaded.
PRPackedBool mRebindAllControls
 Indicates whether all controls should be refreshed on the next Refresh() run.
PRPackedBool mInstancesInitialized
 Indicates whether instance elements have been initialized.
PRPackedBool mReadyHandled
 Indicates whether the model has handled the xforms-ready event.
PRPackedBool mLazyModel
 Indicates whether the model's instance was built by lazy authoring.
PRPackedBool mConstructDoneHandled
 Indicates whether the model has handled the xforms-model-construct-done event.
PRPackedBool mProcessingUpdateEvent
 Indicates whether the model is currently processing an update event, ie.
nsVoidArray mUpdateEventQueue
 A list of update events that have been queued, because they were requested while another update was running.
PRInt32 mLoopMax
 The maximum allowed number of iterations of queued event dispatching in RequestUpdateEvent(), before there is believe to be a loop, and processing stops.
nsRefPtr
< nsXFormsModelInstanceDocuments
mInstanceDocuments
 All instance documents contained by this model, including lazy-authored instance documents.
nsClassHashtable
< nsISupportsHashKey, nsString
mNodeToType
 Type information for nodes, with their type set through <xforms:bind>.
nsClassHashtable
< nsISupportsHashKey, nsString
mNodeToP3PType
 P3P type information for nodes, with their type set through <xforms:bind>.
nsCOMArray< nsIXFormsContextInfomContextInfo

Friends

class Updating

Detailed Description

Implementation of the XForms <model> element.

This includes all of the code for loading the model's external resources and initializing the model and its controls.

See also:
http://www.w3.org/TR/xforms/slice3.html#structure-model

Definition at line 259 of file nsXFormsModelElement.h.


Constructor & Destructor Documentation


Member Function Documentation

Called by form control elements when they are bound to or unbound from this model.

These form controls will be refreshed when refresh() is called on the model.

Add an instance element to the model's instance list.

Parameters:
aInstanceElementThe instance element to add to the list

Each context control maintains an 'aborted bind' list.

This list is used to track xforms controls that this context control contains which have tried to bind but couldn't because this context control wasn't bound yet, either.

Parameters:
aControlThe XForms control that couldn't bind because this context control wasn't ready.
addControlIf true, aControl is added to the list. If false aControl will be removed from the list and also aControl will lose its link to this control.
void nsIXTFElement::attributeSet ( in nsIAtom  name,
in AString  newValue 
) [inherited]

This tells the form control to update its node binding based on the current instance data.

Returns:
Did the binding change the context?
NS_IMETHOD nsXFormsModelElement::Bind ( PRBool aContextChanged) [inline]

Definition at line 288 of file nsXFormsModelElement.h.

                                           {
    // dummy method, so does nothing
    return NS_OK;
  };

Definition at line 636 of file nsXFormsModelElement.cpp.

{
  if (sPostRefreshList)
    sPostRefreshList->RemoveElement(aControl);

  if (sContainerPostRefreshList)
    sContainerPostRefreshList->RemoveElement(aControl);
}

Here is the caller graph for this function:

void nsIXTFElement::childInserted ( in nsIDOMNode  child,
in unsigned long  index 
) [inherited]
void nsIXTFElement::childRemoved ( in unsigned long  index) [inherited]
void nsIXTFElement::cloneState ( in nsIDOMElement  aElement) [inherited]

Definition at line 607 of file nsXFormsModelElement.cpp.

{

  if (sRefreshing) {
    if (!sContainerPostRefreshList) {
      sContainerPostRefreshList = new nsVoidArray();
      if (!sContainerPostRefreshList) {
        return PR_FALSE;
      }
    }

    if (sContainerPostRefreshList->IndexOf(aControl) < 0) {
      sContainerPostRefreshList->AppendElement(aControl);
    }

    // return PR_TRUE to show that the control's refresh will be delayed,
    // whether as a result of this call or a previous call to this function.
    return PR_TRUE;
  }

  // Delaying the refresh doesn't make any sense.  But since this
  // function may be called from inside the control node's refresh already,
  // we shouldn't just assume that we can call the refresh here.  So
  // we'll just return PR_FALSE to signal that we couldn't delay the refresh.

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 733 of file nsXFormsModelElement.cpp.

{
  if (!aNewDocument)
    return NS_OK;

  AddToModelList(aNewDocument, this);

  nsCOMPtr<nsIDOMEventTarget> targ = do_QueryInterface(aNewDocument);
  if (targ) {
    targ->AddEventListener(NS_LITERAL_STRING("DOMContentLoaded"), this, PR_TRUE);

    nsCOMPtr<nsIDOMWindowInternal> window;
    nsXFormsUtils::GetWindowFromDocument(aNewDocument, getter_AddRefs(window));
    targ = do_QueryInterface(window);
    if (targ) {
      targ->AddEventListener(NS_LITERAL_STRING("unload"), this, PR_TRUE);
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 756 of file nsXFormsModelElement.cpp.

{
  return InitializeInstances();
}

Definition at line 2075 of file nsXFormsModelElement.cpp.

{
  nsCOMPtr<nsIInstanceElementPrivate> instance;
  nsXFormsModelElement::FindInstanceElement(aID, getter_AddRefs(instance));

  nsIDOMDocument *doc = nsnull;
  if (instance) {
    instance->GetInstanceDocument(&doc); // addrefs
  }

  return doc;
}

Here is the call graph for this function:

Locate the instance element child with the given id.

Force rebinding (and refreshing) of a control.

Also handles rebinding and refreshing of child controls, if necessary.

Parameters:
controlThe control to rebind.

Return builtin type name for a form control based on the schema included by this model.

void nsIXFormsContextControl::getContext ( out AString  aModelID,
out nsIDOMNode  aContextNode,
out long  aContextPosition,
out long  aContextSize 
) [inherited]

Used by children to retrieve the context of their parent.

Parameters:
aModelIDThe modelID
aContextNodeThe context node
aContextPositionThe context position
aContextSizeThe context size
Note:
The actual model ID must be returned. An empty |aModelID| should only be returned if the default model has an id="".
void nsIModelElementPrivate::getDerivedTypeList ( in AString  aType,
in AString  aNamespace,
out AString  aTypeList 
) [inherited]

Retrieves the list of datatypes that the original type is derived from or is an extension of.

Parameters:
aTypeThe original type
aNamespaceThe original namespace URI
aTypeListThe returned space-delimited list

Returns NS_ERROR_XFORMS_UNION_TYPE if a schema union datatype was encounterd while trying to build the type list. Will also return an error if we encounter a complex type that comes from complex content extension or restriction.

Returns the DOM element for the model.

Definition at line 3250 of file nsXFormsModelElement.cpp.

{
  nsIDOMElement* element = nsnull;
  NS_IF_ADDREF(element = mElement);
  return element;
}

Here is the caller graph for this function:

nsIDOMDocument nsIXFormsModelElement::getInstanceDocument ( in DOMString  instanceID) [inherited]

Definition at line 293 of file nsXFormsModelElement.h.

                                                   {
    // dummy method, so does nothing
    return NS_OK;
  };

Get/Set the repeat state for the xforms control or action.

The repeat state indicates whether the control or action lives inside a context container, a repeat element, an itemset or none of the above.

Definition at line 205 of file nsXFormsStubElement.cpp.

{
  return mRepeatState;
}
void nsIModelElementPrivate::GetRootBuiltinType ( in nsISchemaType  aType,
out unsigned short  aBuiltinType 
) [inherited]

Retrieves the primative builtin type that the original type derives from.

Parameters:
aTypeThe original type
aBuiltinTypeThe returned builtin type (defined in nsISchema)

Returns NS_ERROR_XFORMS_UNION_TYPE if a schema union datatype was encounterd while trying to build the type list. Will also return an error if we encounter a complex type that comes from complex content extension or restriction.

void nsIXTFElement::getScriptingInterfaces ( out unsigned long  count,
[array, size_is(count), retval] out nsIIDPtr  array 
) [inherited]

Definition at line 718 of file nsXFormsModelElement.cpp.

{
  return nsXFormsUtils::CloneScriptingInterfaces(sScriptingIIDs,
                                                 NS_ARRAY_LENGTH(sScriptingIIDs),
                                                 aCount, aArray);
}
void nsIModelElementPrivate::getTypeAndNSFromNode ( in nsIDOMNode  instancenode,
out AString  type,
out AString  namespaceURI 
) [inherited]

This function takes an instance data node, finds the type bound to it, and returns the separated out type and namespace URI.

If no type is set for the node, then it returns the defaults: "http://www.w3.org/2001/XMLSchema" and "string"

Determine the type for a form control based on the schema included by this model.

Determine the type for a form control based on the schema included by this model.

void nsIModelElementPrivate::getTypeFromNode ( in nsIDOMNode  aInstanceData,
out AString  aType,
out AString  aNSUri 
) [inherited]

Retrieves the type for an instance data node.

Parameters:
aInstanceDataThe instance data node
aTypeThe type of the node
aNSURIThe namespace of the type

Definition at line 934 of file nsXFormsModelElement.cpp.

{
  if (!nsXFormsUtils::EventHandlingAllowed(aEvent, mElement))
    return NS_OK;

  *aHandled = PR_TRUE;

  nsAutoString type;
  aEvent->GetType(type);
  nsresult rv = NS_OK;

  if (type.EqualsASCII(sXFormsEventsEntries[eEvent_Refresh].name)) {
    rv = Refresh();
  } else if (type.EqualsASCII(sXFormsEventsEntries[eEvent_Revalidate].name)) {
    rv = Revalidate();
  } else if (type.EqualsASCII(sXFormsEventsEntries[eEvent_Recalculate].name)) {
    rv = Recalculate();
  } else if (type.EqualsASCII(sXFormsEventsEntries[eEvent_Rebuild].name)) {
    rv = Rebuild();
  } else if (type.EqualsASCII(sXFormsEventsEntries[eEvent_ModelConstructDone].name)) {
    rv = ConstructDone();
    mConstructDoneHandled = PR_TRUE;
  } else if (type.EqualsASCII(sXFormsEventsEntries[eEvent_Reset].name)) {
    Reset();
  } else if (type.EqualsASCII(sXFormsEventsEntries[eEvent_BindingException].name)) {
    // we threw up a popup during the nsXFormsUtils::DispatchEvent that sent
    // this error to the model
    *aHandled = PR_TRUE;
  } else {
    *aHandled = PR_FALSE;
  }

  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
                   "nsXFormsModelElement::HandleDefault() failed!\n");

  return rv;
}

This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Parameters:
evtThe Event contains contextual information about the event. It also contains the stopPropagation and preventDefault methods which are used in determining the event's flow and default action.
unsigned short nsIModelElementPrivate::handleInstanceDataNode ( in nsIDOMNode  aInstanceDataNode) [inherited]

Handles an instance data node and returns one of the above 3 values.

void nsIModelElementPrivate::instanceLoadFinished ( in boolean  success,
in AString  uri 
) [inherited]

Notification that an instance element has started or finished loading its instance data.

Model construction cannot complete until all of the instances have loaded their data.

The 'uri' parameter for instanceLoadFinished is the uri of or on the instance element and is needed to add the uri to the context info if the link fails.

PRBool nsXFormsModelElement::IsComplete ( ) const [inline, private]

Definition at line 382 of file nsXFormsModelElement.h.

Returns true if a schema has already been registered to address the same namespace as aSchemaElement.

Per section 3.3.1 of the XForms spec: Within each XForms Model, there is a limit of one Schema per namespace declaration, including inline and linked Schemas.

Parameters:
aSchemaElementThe schema element

Definition at line 3442 of file nsXFormsModelElement.cpp.

{
  nsCOMPtr<nsISchemaCollection> schemaColl = do_QueryInterface(mSchemas);
  if (!schemaColl)
    return PR_FALSE;

  const nsAFlatString& empty = EmptyString();
  nsAutoString targetNamespace;
  aSchemaElement->GetAttributeNS(empty,
                                 NS_LITERAL_STRING("targetNamespace"),
                                 targetNamespace);
  targetNamespace.Trim(" \r\n\t");

  nsCOMPtr<nsISchema> schema;
  schemaColl->GetSchema(targetNamespace, getter_AddRefs(schema));
  if (!schema)
    return PR_FALSE;

  // A schema with the same target namespace already exists in the
  // schema collection and the first instance has already been processed.
  // Report an error to the JS console and dispatch the LinkError event,
  // but do not consider it a fatal error.
  const nsPromiseFlatString& flat = PromiseFlatString(targetNamespace);
  const PRUnichar *strings[] = { flat.get() };
  nsXFormsUtils::ReportError(NS_LITERAL_STRING("duplicateSchema"),
                             strings, 1, aSchemaElement, aSchemaElement,
                             nsnull);
  nsXFormsUtils::DispatchEvent(mElement, eEvent_LinkError);
  return PR_TRUE;
}

Here is the call graph for this function:

Notification that all of the external message loads have finished loading.

Model contstruction cannot complete until all of the external messages have loaded their data.

Definition at line 587 of file nsXFormsModelElement.cpp.

{
  if (sRefreshing) {
    if (!sPostRefreshList) {
      sPostRefreshList = new nsVoidArray();
      NS_ENSURE_TRUE(sPostRefreshList, NS_ERROR_OUT_OF_MEMORY);
    }

    if (sPostRefreshList->IndexOf(aControl) < 0) {
      sPostRefreshList->AppendElement(aControl);
    }
  } else {
    // We are not refreshing any models, so the control
    // can be refreshed immediately.
    aControl->Refresh();
  }
  return NS_OK;
}

Here is the call graph for this function:

static nsXFormsModelElement::NS_HIDDEN_ ( void  ) [static]

The models are not ready for binding, so defer the binding of the control by storing it as a property on the document.

The models will run through this list when they are ready for binding.

Parameters:
aControlXForms control waiting to be bound

Initializes the MIPs on all form controls.

Sets the state of a specific state.

Parameters:
aElementThe element to dispatch events to and set states on
aStateThe state value
aOnEventThe on event for the state.
static nsXFormsModelElement::NS_HIDDEN_ ( void  ) [static, private]

Handle controls bindings which was deferred because the model was not ready.

Note:
Only registers the controls with the model. Does not setup bindings, etc.
Parameters:
aDocDocument that contains the XForms control

Called by HandleEvent.

Event handler for the 'DOMContentLoaded' event.

Called by HandleEvent.

Event handler for the 'unload' event.

Request to send an update event to the model.

If an update is already running, the event will be queued, and sent after that. If multiple events are queued, they will be dispatched FIFO order.

Parameters:
aEventThe requested event

Return the name of builitn type.

Parameters:
aTypeThe builtin type
aNameThe name of the given type

Starting with aType, walks through the builtin derived types back to the builtin primative type, appending the datatype URIs to the string array as it goes.

Starting from aType, walks the chain of datatype extension/derivation to gather information.

Parameters:
aTypeThe type we are trying to find datatype information for
aFindRootBuiltinIf true then root builtin type will be returned only
aBuiltinTypeIf non-null, we'll return the builtin (if aFindRootBuiltin is false) or root builtin (if aFindRootBuiltin is true) type of the given type
aTypeArrayIf non-null and aFindRootBuiltin is false, we'll build a string array of datatype URIs and put them in aTypeArray.

Returns the primative type that aSchemaType is derived/extended from.

Definition at line 982 of file nsXFormsModelElement.cpp.

{
  aWrapper->SetNotificationMask(nsIXTFElement::NOTIFY_WILL_CHANGE_DOCUMENT |
                                nsIXTFElement::NOTIFY_DOCUMENT_CHANGED |
                                nsIXTFElement::NOTIFY_DONE_ADDING_CHILDREN |
                                nsIXTFElement::NOTIFY_HANDLE_DEFAULT);

  nsCOMPtr<nsIDOMElement> node;
  aWrapper->GetElementNode(getter_AddRefs(node));

  // It's ok to keep a weak pointer to mElement.  mElement will have an
  // owning reference to this object, so as long as we null out mElement in
  // OnDestroyed, it will always be valid.

  mElement = node;
  NS_ASSERTION(mElement, "Wrapper is not an nsIDOMElement, we'll crash soon");

  nsresult rv = mMDG.Init(this);
  NS_ENSURE_SUCCESS(rv, rv);

  mSchemas = do_CreateInstance(NS_SCHEMALOADER_CONTRACTID);

  mInstanceDocuments = new nsXFormsModelInstanceDocuments();
  NS_ASSERTION(mInstanceDocuments, "could not create mInstanceDocuments?!");

  // Initialize hash tables
  NS_ENSURE_TRUE(mNodeToType.Init(), NS_ERROR_OUT_OF_MEMORY);
  NS_ENSURE_TRUE(mNodeToP3PType.Init(), NS_ERROR_OUT_OF_MEMORY);


  // Get eventual user-set loop maximum. Used by RequestUpdateEvent().
  nsCOMPtr<nsIPrefBranch> pref = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
  if (NS_SUCCEEDED(rv) && pref) {
    PRInt32 val;
    if (NS_SUCCEEDED(pref->GetIntPref("xforms.modelLoopMax", &val)))
      mLoopMax = val;
  }

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 678 of file nsXFormsModelElement.cpp.

void nsIWebServiceErrorHandler::onError ( in nsresult  status,
in AString  statusMessage 
) [inherited]
void nsIXTFElement::parentChanged ( in nsIDOMElement  newParent) [inherited]

This tells the form control to update its state based on the current instance data.

Remove an instance element from the model's instance list.

Parameters:
aInstanceElementThe instance element to remove from the list

Request an xforms-rebuild.

If a previous request (of this or one of the 3 following events) is already being handled, the event will be queued, and sent after that. If multiple events are queued, they will be dispatched FIFO order.

Request an xforms-recalculate.

Request an xforms-refresh.

Request an xforms-revalidate.

void nsIXFormsContextControl::setContext ( in nsIDOMNode  aContextNode,
in long  aContextPosition,
in long  aContextSize 
) [inherited]

Used by parents to set the context for children.

Parameters:
aContextNodeThe context node
aContextPositionThe context position
aContextSizeThe context size
nsresult nsXFormsModelElement::SetContextInfo ( const char *  aName,
const nsAString &  aValue 
) [private]

Set context info for events.

Parameters:
aNameName of the context property.
aValueValue of the context property.

Definition at line 3474 of file nsXFormsModelElement.cpp.

{
  nsCOMPtr<nsXFormsContextInfo> contextInfo = new nsXFormsContextInfo(mElement);
  NS_ENSURE_TRUE(contextInfo, NS_ERROR_OUT_OF_MEMORY);
  contextInfo->SetStringValue(aName, aValue);
  mContextInfo.AppendObject(contextInfo);

  return NS_OK;
}

Here is the call graph for this function:

void nsIModelElementPrivate::setNodeContent ( in nsIDOMNode  node,
in nsIDOMNode  content,
in boolean  doRebuild 
) [inherited]

Insert a set of nodes underneath an instance node.

If doRebuild is true, the function will request xforms-rebuild, xforms-recalculate, xforms-revalidate, and xforms-refresh to be dispatched to the model.

Parameters:
nodeThe instance node
contentNode that holds the contents to insert under the instance node
doRebuildRequest rebuild event sequence
void nsIModelElementPrivate::setNodeValue ( in nsIDOMNode  instanceNode,
in AString  nodeValue,
in boolean  doRefresh,
out boolean  nodeChanged 
) [inherited]

Set the value of an instance node.

If doRefresh is true, the function will request xforms-recalculate, xforms-revalidate, and xforms-refresh to be dispatched to the model.

Parameters:
instanceNodeThe node to set the value for
nodeValueThe value to set
doRefreshRequest value-changed event sequence
nodeChangedReturn whether the node was actually changed

Definition at line 298 of file nsXFormsModelElement.h.

                                                     {
    // dummy method, so does nothing
    return NS_OK;
  };
void nsXFormsStubElement::SetRepeatState ( nsRepeatState  aState) [virtual, inherited]

Definition at line 211 of file nsXFormsStubElement.cpp.

{
  mRepeatState = aState;
  return;
}

Here is the caller graph for this function:

void nsIModelElementPrivate::setStates ( in nsIXFormsControl  aControl,
in nsIDOMNode  aBoundNode 
) [inherited]

Set MIP states for given control bound to the given bound node.

Parameters:
aControlThe control
aBoundNodeThe node the control is bound to
nsRepeatState nsXFormsStubElement::UpdateRepeatState ( nsIDOMNode aParent) [protected, virtual, inherited]

This is processed when an XForms control or XForms action has been inserted under a parent node AND has been inserted into a document.

It checks the ancestors of the element and returns an nsRepeatState depending on the element's place in the document.

Parameters:
aParentThe new parent of the XForms control

Definition at line 218 of file nsXFormsStubElement.cpp.

{
  // Walk up the parent chain looking to see if the this control is contained
  // in an item.  If it is and that item is contained in a itemset, then we
  // know that this control was generated as a clone from the itemset's
  // template.  Similarly, we'll check to see if this control lives in a
  // contextcontainer (meaning it was cloned from a repeat's template).
  // Otherwise, if neither of these are the case but it lives under a repeat
  // or an itemset, then this control must be part of a template.  A template
  // is the content of a repeat or itemset that gets cloned once for every
  // node in the bound nodeset.
  //
  // If none of this applies, we'll return eType_NotApplicable to show that this
  // control isn't bound to a repeating nodeset.
  nsRepeatState repeatState = eType_NotApplicable;

  if (!mHasDoc || !mHasParent) {
    // If we don't have a document or a parent, none of these tests will work
    // correctly so no sense doing them now.  If either of these are false the
    // repeat state for the object should already be eType_Unknown so just
    // return that now.
    return eType_Unknown;
  }

  nsCOMPtr<nsIDOMNode> parent = aParent;
  PRBool childIsItem = PR_FALSE;
  while (parent) {
    if (nsXFormsUtils::IsXFormsElement(parent,
                                       NS_LITERAL_STRING("contextcontainer"))) {
      repeatState = eType_GeneratedContent;
      break;
    }
    if (nsXFormsUtils::IsXFormsElement(parent, NS_LITERAL_STRING("repeat"))) {
      repeatState = eType_Template;
      break;
    }
    if (nsXFormsUtils::IsXFormsElement(parent, NS_LITERAL_STRING("itemset"))) {
      if (childIsItem) {
        repeatState = eType_GeneratedContent;
        break;
      }
      repeatState = eType_Template;
      break;
    }

    if (nsXFormsUtils::IsXFormsElement(parent, NS_LITERAL_STRING("item"))) {
      childIsItem = PR_TRUE;
    } else {

      nsCOMPtr<nsIDOMElement> parentEle(do_QueryInterface(parent));
      if (!parentEle) {
        // I don't know how this can possibly happen, but if it does I guess
        // we should just ignore it and coninue on our way.
        break;
      }

      // if this control is contained underneath an element that contains
      // an xforms binding attribute that introduces an anonymous xf:repeat
      // then the control is part of a template
      PRBool repeatAttr = PR_FALSE;
      parentEle->HasAttributeNS(NS_LITERAL_STRING(NS_NAMESPACE_XFORMS),
                                NS_LITERAL_STRING("repeat-bind"),
                                &repeatAttr);
      if (repeatAttr) {
        repeatState = eType_Template;
        break;
      }

      parentEle->HasAttributeNS(NS_LITERAL_STRING(NS_NAMESPACE_XFORMS),
                                NS_LITERAL_STRING("repeat-nodeset"),
                                &repeatAttr);
      if (repeatAttr) {
        repeatState = eType_Template;
        break;
      }
    }
    nsCOMPtr<nsIDOMNode> tmp;
    parent->GetParentNode(getter_AddRefs(tmp));
    parent = tmp;
  }

  SetRepeatState(repeatState);
  return repeatState;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Validate all the instance documents.

Definition at line 2282 of file nsXFormsModelElement.cpp.

{
  if (mInstanceDocuments) {
    PRUint32 instCount;
    mInstanceDocuments->GetLength(&instCount);
    if (instCount) {
      nsCOMPtr<nsIDOMDocument> document;

      for (PRUint32 i = 0; i < instCount; ++i) {
        nsIInstanceElementPrivate* instEle =
          mInstanceDocuments->GetInstanceAt(i);
        nsCOMPtr<nsIXFormsNSInstanceElement> NSInstEle(instEle);
        NSInstEle->GetInstanceDocument(getter_AddRefs(document));
        NS_ASSERTION(document,
                     "nsIXFormsNSInstanceElement::GetInstanceDocument returned null?!");

        if (document) {
          PRBool isValid = PR_FALSE;
          ValidateDocument(document, &isValid);

          if (!isValid) {
            nsCOMPtr<nsIDOMElement> instanceElement;
            instEle->GetElement(getter_AddRefs(instanceElement));

            nsXFormsUtils::ReportError(NS_LITERAL_STRING("instDocumentInvalid"),
                                       instanceElement);
          }
        }
      }
    }
  }
}

Here is the call graph for this function:

PRBool nsIModelElementPrivate::validateNode ( in nsIDOMNode  aInstanceNode) [inherited]

Validates the instance node against the schemas loaded by the model.

Definition at line 726 of file nsXFormsModelElement.cpp.

{
  RemoveModelFromDocument();
  return NS_OK;
}
void nsIXTFElement::willInsertChild ( in nsIDOMNode  child,
in unsigned long  index 
) [inherited]
void nsIXTFElement::willRemoveChild ( in unsigned long  index) [inherited]
void nsIXTFElement::willSetAttribute ( in nsIAtom  name,
in AString  newValue 
) [inherited]

Friends And Related Function Documentation

friend class Updating [friend]

Definition at line 570 of file nsXFormsModelElement.h.


Member Data Documentation

Definition at line 351 of file nsXFormsModelElement.h.

Definition at line 458 of file nsXFormsModelElement.h.

Definition at line 351 of file nsXFormsModelElement.h.

Definition at line 351 of file nsXFormsModelElement.h.

Definition at line 351 of file nsXFormsModelElement.h.

Definition at line 458 of file nsXFormsModelElement.h.

Definition at line 396 of file nsXFormsModelElement.h.

Definition at line 355 of file nsXFormsModelElement.h.

nsAString& nsXFormsModelElement::aName [private]

Definition at line 432 of file nsXFormsModelElement.h.

nsStringArray* nsXFormsModelElement::aNameArray [private]

Definition at line 440 of file nsXFormsModelElement.h.

Definition at line 367 of file nsXFormsModelElement.h.

Definition at line 465 of file nsXFormsModelElement.h.

Definition at line 399 of file nsXFormsModelElement.h.

Definition at line 367 of file nsXFormsModelElement.h.

Definition at line 460 of file nsXFormsModelElement.h.

Definition at line 72 of file nsIXTFElement.idl.

Definition at line 56 of file nsIXTFElement.idl.

Definition at line 60 of file nsIXTFElement.idl.

Definition at line 64 of file nsIXTFElement.idl.

Definition at line 68 of file nsIXTFElement.idl.

readonly attribute unsigned long nsIXTFElement::elementType [inherited]

Definition at line 78 of file nsIXTFElement.idl.

Returns true when the model has been notified that the DOMContentLoaded event has been fired on the XForms document.

Definition at line 199 of file nsIModelElementPrivate.idl.

Definition at line 86 of file nsIXTFElement.idl.

This attribute is set when the model handled xforms-ready event.

Definition at line 152 of file nsIModelElementPrivate.idl.

This attribute is set when the model's instance was lazy authored.

Definition at line 147 of file nsIModelElementPrivate.idl.

List of changed nodes, ie.

nodes that have not been informed about changes yet

Definition at line 491 of file nsXFormsModelElement.h.

Indicates whether the model has handled the xforms-model-construct-done event.

Definition at line 524 of file nsXFormsModelElement.h.

Definition at line 568 of file nsXFormsModelElement.h.

Definition at line 478 of file nsXFormsModelElement.h.

This flag indicates whether or not the document has fired DOMContentLoaded.

Definition at line 497 of file nsXFormsModelElement.h.

Definition at line 474 of file nsXFormsModelElement.h.

Definition at line 477 of file nsXFormsModelElement.h.

State that tells whether control has a document or not.

This could be false even if the control has a document. Just means that the element doesn't need to track whether it has a document or not (i.e. xf:choices)

Definition at line 109 of file nsXFormsStubElement.h.

State that tells whether control has a parent or not.

This could be false even if the control has a parent. Just means that the element doesn't need to track whether it has a parent or not (i.e. xf:choices)

Definition at line 102 of file nsXFormsStubElement.h.

All instance documents contained by this model, including lazy-authored instance documents.

Definition at line 550 of file nsXFormsModelElement.h.

Indicates whether instance elements have been initialized.

Definition at line 508 of file nsXFormsModelElement.h.

Indicates whether the model's instance was built by lazy authoring.

Definition at line 518 of file nsXFormsModelElement.h.

The maximum allowed number of iterations of queued event dispatching in RequestUpdateEvent(), before there is believe to be a loop, and processing stops.

Definition at line 544 of file nsXFormsModelElement.h.

The MDG for this model.

Definition at line 485 of file nsXFormsModelElement.h.

P3P type information for nodes, with their type set through <xforms:bind>.

See also:
http://www.w3.org/TR/xforms/slice6.html#model-prop-p3ptype

Definition at line 565 of file nsXFormsModelElement.h.

Type information for nodes, with their type set through <xforms:bind>.

See also:
http://www.w3.org/TR/xforms/slice6.html#model-prop-type

Definition at line 557 of file nsXFormsModelElement.h.

Definition at line 476 of file nsXFormsModelElement.h.

Definition at line 482 of file nsXFormsModelElement.h.

Indicates whether the model is currently processing an update event, ie.

xforms-rebuild, xforms-recalculate, xforms-revalidate, or xforms-refresh.

Definition at line 531 of file nsXFormsModelElement.h.

Indicates whether the model has handled the xforms-ready event.

Definition at line 513 of file nsXFormsModelElement.h.

Indicates whether all controls should be refreshed on the next Refresh() run.

Definition at line 503 of file nsXFormsModelElement.h.

Definition at line 95 of file nsXFormsStubElement.h.

Definition at line 480 of file nsXFormsModelElement.h.

Definition at line 475 of file nsXFormsModelElement.h.

Definition at line 481 of file nsXFormsModelElement.h.

A list of update events that have been queued, because they were requested while another update was running.

Definition at line 537 of file nsXFormsModelElement.h.

const unsigned long nsIXTFElement::NOTIFY_ATTRIBUTE_REMOVED = 0x00002000 [inherited]

Definition at line 118 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_ATTRIBUTE_SET = 0x00000800 [inherited]

Definition at line 115 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_BEGIN_ADDING_CHILDREN = 0x00004000 [inherited]

Definition at line 120 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_CHILD_APPENDED = 0x00000080 [inherited]

Definition at line 109 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_CHILD_INSERTED = 0x00000020 [inherited]

Definition at line 106 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_CHILD_REMOVED = 0x00000200 [inherited]

Definition at line 112 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_DOCUMENT_CHANGED = 0x00000002 [inherited]

Definition at line 100 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_DONE_ADDING_CHILDREN = 0x00008000 [inherited]

Definition at line 121 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_HANDLE_DEFAULT = 0x00010000 [inherited]

Definition at line 123 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_PARENT_CHANGED = 0x00000008 [inherited]

Definition at line 103 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_WILL_APPEND_CHILD = 0x00000040 [inherited]

Definition at line 108 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_WILL_CHANGE_DOCUMENT = 0x00000001 [inherited]

Definition at line 99 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_WILL_CHANGE_PARENT = 0x00000004 [inherited]

Definition at line 102 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_WILL_INSERT_CHILD = 0x00000010 [inherited]

Definition at line 105 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_WILL_REMOVE_ATTRIBUTE = 0x00001000 [inherited]

Definition at line 117 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_WILL_REMOVE_CHILD = 0x00000100 [inherited]

Definition at line 111 of file nsIXTFElement.idl.

const unsigned long nsIXTFElement::NOTIFY_WILL_SET_ATTRIBUTE = 0x00000400 [inherited]

Definition at line 114 of file nsIXTFElement.idl.

Determines whether this control is already on the deferred bind list.

Definition at line 59 of file nsIXFormsControlBase.idl.

Definition at line 118 of file nsIModelElementPrivate.idl.

const unsigned short nsIModelElementPrivate::SUBMIT_SERIALIZE_NODE = 1 [inherited]

Definition at line 116 of file nsIModelElementPrivate.idl.

const unsigned short nsIModelElementPrivate::SUBMIT_SKIP_NODE = 2 [inherited]

Definition at line 117 of file nsIModelElementPrivate.idl.


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