<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7036.0">
<TITLE>RE: [whatwg] Proposed changes to the History API</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Justin Lebar wrote:</FONT>
<BR><FONT SIZE=2>> Mike Wilson wrote:</FONT>
<BR><FONT SIZE=2>> > It would be interesting to see a concrete</FONT>
<BR><FONT SIZE=2>> > example on how you intend the dynamics of your solution to</FONT>
<BR><FONT SIZE=2>> > work. It would be great if you could outline the different</FONT>
<BR><FONT SIZE=2>> > events and method calls used (in order) to save and restore</FONT>
<BR><FONT SIZE=2>> > the history state object in the following situations:</FONT>
<BR><FONT SIZE=2>> > - doing a "fresh" navigation from page#1 to page#2</FONT>
<BR><FONT SIZE=2>> > - going back in history from page#2 to page#1</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> Here's one way it could go:</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> User was at <A HREF="http://google.com">http://google.com</A>, types</FONT>
<BR><FONT SIZE=2>> <A HREF="http://mozilla.com/index.html#1">http://mozilla.com/index.html#1</A> into address bar.</FONT>
<BR><FONT SIZE=2>> * onload</FONT>
<BR><FONT SIZE=2>> * stateactivated</FONT>
<BR><FONT SIZE=2>> User clicks on link with href "#2"</FONT>
<BR><FONT SIZE=2>> * statedeactivated (until this event is complete,</FONT>
<BR><FONT SIZE=2>> document.location.hash == "#1" and the pageStorage object is </FONT>
<BR><FONT SIZE=2>> for the "#1" state)</FONT>
<BR><FONT SIZE=2>> * stateactivated (at the beginning of this event,</FONT>
<BR><FONT SIZE=2>> document.location.hash == "#2" and the pageStorage object is </FONT>
<BR><FONT SIZE=2>> for the "#2" state)</FONT>
<BR><FONT SIZE=2>> User clicks back</FONT>
<BR><FONT SIZE=2>> * statedeactivated (for #2)</FONT>
<BR><FONT SIZE=2>> * stateactivated (for #1)</FONT>
</P>
<P><FONT SIZE=2>Great, this seems to be exactly what I want too. In particular</FONT>
<BR><FONT SIZE=2>I note the following differences from the current spec:</FONT>
<BR><FONT SIZE=2>- events both when entering and leaving a history entry (I </FONT>
<BR><FONT SIZE=2> called them hashload and hashunload but I agree it is better </FONT>
<BR><FONT SIZE=2> to avoid "hash" as we also have state-only history entries)</FONT>
<BR><FONT SIZE=2>- the same processing for "fresh" (newly navigated to) history</FONT>
<BR><FONT SIZE=2> entries as for "historical" (navigated back/forward to)</FONT>
<BR><FONT SIZE=2> history entries</FONT>
<BR><FONT SIZE=2>- removal of the popstate event and exposing a read/writable </FONT>
<BR><FONT SIZE=2> state object during the whole history entry "session"</FONT>
</P>
<P><FONT SIZE=2>About "stateactivated" naming:</FONT>
<BR><FONT SIZE=2>Activated/deactivated is a bit longish. Could</FONT>
<BR><FONT SIZE=2>- stateload/stateunload</FONT>
<BR><FONT SIZE=2>- stateenter/stateleave</FONT>
<BR><FONT SIZE=2>or others be good alternatives?</FONT>
<BR><FONT SIZE=2>Is "state" the desired keyword? Or should "history" or others</FONT>
<BR><FONT SIZE=2>be considered?</FONT>
<BR><FONT SIZE=2>Or something playing on the "pageshow/pagehide" naming?</FONT>
</P>
<P><FONT SIZE=2>About "pageStorage" lifetime:</FONT>
<BR><FONT SIZE=2>Adding on to your description, assuming we are navigating from </FONT>
<BR><FONT SIZE=2>one page (/a) to another (/b) in history without bfcache, the </FONT>
<BR><FONT SIZE=2>following would be a suitable chain of events:</FONT>
<BR><FONT SIZE=2>- /a statedeactivated event</FONT>
<BR><FONT SIZE=2>- /a unload event</FONT>
<BR><FONT SIZE=2>- /a browser saves form fields, scrollpos, and history state obj</FONT>
<BR><FONT SIZE=2>- <browser swaps out /a and loads /b></FONT>
<BR><FONT SIZE=2>- /b browser restores history state obj before any script runs</FONT>
<BR><FONT SIZE=2>- /b scripts are executed and form fields and scrollpos are </FONT>
<BR><FONT SIZE=2> restored while document content is built</FONT>
<BR><FONT SIZE=2>- /b load event</FONT>
<BR><FONT SIZE=2>- /b stateactivated event</FONT>
</P>
<P><FONT SIZE=2>About "pageStorage" naming:</FONT>
<BR><FONT SIZE=2>I think "page" makes you think more of Document than of history</FONT>
<BR><FONT SIZE=2>entries. Looking at an overview of storage areas, ordered from</FONT>
<BR><FONT SIZE=2>large scopes down to fine-grained scopes may spawn some ideas:</FONT>
</P>
<P><FONT SIZE=2> CURRENTLY DISCUSSED:</FONT>
</P>
<P><FONT SIZE=2> Scope Storage area / identifier</FONT>
<BR><FONT SIZE=2> ----- -------------------------</FONT>
<BR><FONT SIZE=2> user agent window.localStorage</FONT>
<BR><FONT SIZE=2> browsing context window.sessionStorage</FONT>
<BR><FONT SIZE=2> document -</FONT>
<BR><FONT SIZE=2> history entry window.pageStorage</FONT>
</P>
<P><FONT SIZE=2>If anticipating there could be a future storage area per </FONT>
<BR><FONT SIZE=2>Document, naming could be something like this:</FONT>
</P>
<P><FONT SIZE=2> ALTERNATIVE:</FONT>
</P>
<P><FONT SIZE=2> Scope Storage area / identifier</FONT>
<BR><FONT SIZE=2> ----- -------------------------</FONT>
<BR><FONT SIZE=2> user agent window.localStorage</FONT>
<BR><FONT SIZE=2> browsing context window.sessionStorage</FONT>
<BR><FONT SIZE=2> document document.documentStorage</FONT>
<BR><FONT SIZE=2> history entry window.history.entryStorage</FONT>
</P>
<P><FONT SIZE=2>Best regards</FONT>
<BR><FONT SIZE=2>Mike</FONT>
</P>
</BODY>
</HTML>