W3C home > Mailing lists > Public > www-voice@w3.org > January to March 2013

Adding history states with recorded history

From: Gavin Kistner <phrogz@me.com>
Date: Tue, 12 Feb 2013 19:45:58 -0700
Message-id: <9FD91A42-93EE-48E8-8BDF-717D728142D7@me.com>
To: "www-voice@w3.org" <www-voice@w3.org>
I believe that this pseudo-code from the top oc addStatesToEnter() is incorrect:

    if isHistoryState(state):
      if historyValue[state.id]:
        for s in historyValue[state.id]:
          addStatesToEnter(s,statesToEnter,statesForDefaultEntry)
          for anc in getProperAncestors(s,state):
            statesToEnter.add(anc)

Specifically, the second-to-last line. The proper ancestors of the states recorded by a <history> will never include the <history> itself (noted by "state" above), and so the line is equivalent to calling `getProperAncestors(s,null)`. Consequently, every ancestor of a recorded node is added to the entry set, *including the root <scxml> node itself*.

Here's a simple example machine:

    <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="HistoryTest">
      <initial><transition target="universe">
        <raise event="modal.on" />
        <raise event="modal.off" />
      </transition></initial>
      <state id="universe">
        <transition event="modal.on" target="modal" />
        <state id="s1" />
        <history id="h"><transition target="s1"/></history>
      </state>
      <state id="modal"><transition event="modal.off" target="h"/></state>
    </scxml>

The machine enters 'universe/s1', then exits these states (recording 's1' in the history for 'h') and enters 'modal'. When the machine processes the 'modal.off' event, enterStates() calls addStatesToEnter(), passing along the <history> node.

I believe that the second-to-last line in the quoted code above should perhaps instead read:
          for anc in getProperAncestors(s,state.parent):
Received on Wednesday, 13 February 2013 02:46:35 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 13 February 2013 02:46:38 GMT