XForms:Model Concurrent Changes: Difference between revisions

Revised thoughts
(Just needs to be implemented :))
(Revised thoughts)
 
Line 38: Line 38:
# should any event handling in the model defer concurrent events?
# should any event handling in the model defer concurrent events?
# how about "rogue" events, coming from script, etc.?
# how about "rogue" events, coming from script, etc.?
# at least also defer rebuild?
# also defer rebuild?


I believe the spec. only meant for option 1) to happen. It is the common use case, and is not as intrusive a change as the other options.
"Instance data changes performed by a set of actions do not result in
immediate computation dependency rebuilding, recalculation, revalidate and
form control refreshing until the termination of the outermost action handler"
[http://www.w3.org/TR/2006/REC-xforms-20060314/slice10.html#action-action Deferred Actions in the Spec]
 
Based on that, I believe:
 
# we should defer rebuild too
# both "deferred events from action" and value-changes should be deferred


== The Event-Dispatch Queue ==
== The Event-Dispatch Queue ==


The conclusion of the above is that the model should
The conclusion of the above is that the _model_ should
# be asked to perform requests for controls directly, not through events
# be asked to perform requests for controls directly, not through events
# be responsible for dispatching events on itself
# be responsible for dispatching events on itself
Line 54: Line 62:
The nsIModelPrivateElement should expose:
The nsIModelPrivateElement should expose:
<pre>
<pre>
requestRecalculate(in boolean force);
requestRebuild();
requestRevalidate(in boolean force);
requestRecalculate();
requestRefresh(in boolean force);
requestRevalidate();
requestRefresh();
</pre>
</pre>


On a call to any of these functions the following should happen
On a call to any of these functions the following should happen
<pre>
<pre>
doRequest(aRequest, aForce) {
request...() {
  if (aForce) {
    handleRequest(aRequest);
    return;
  }
   if (gDefer) {
   if (gDefer) {
     eventQ.pushBack(aRequest);
     eventQ.pushBack(the_request);
     return;
     return;
   }
   }
   gDefer = true;
   gDefer = true;
   while (aRequest) {
 
    dispatchEventFor(aRequest);
   dispatchEventFor(the_request);
    aRequest = eventQ.popFront();
 
  // Empty the queue
  req = eventQ.popFront();
  while (req) {
    dispatchEventFor(req);
   }
   }
   gDefer = false;
   gDefer = false;
Line 79: Line 88:
</pre>
</pre>


The <code>force</code> parameter is needed for action elements that need to bypass the event mechanism.
&lt;recalculate&gt; and its friends and scripts call the functions directly (exposed in nsIXFormsModelElement), which bypasses both events and the queue.


[[User:Beaufour|Beaufour]] 02:10, 16 May 2006 (PDT)
[[User:Beaufour|Beaufour]] 02:10, 16 May 2006 (PDT)
29

edits