html: store the current insertion mode in the parser
html: store the current insertion mode in the parser

Currently, the state transition functions in the HTML parser
return the next insertion mode and whether the token is consumed.
This works well except for when one insertion mode needs to use
the rules for another insertion mode. Then the useTheRulesFor
function needs to patch things up. This requires comparing functions
for equality, which is going to stop working.

Adding a field to the parser structure to store the current
insertion mode eliminates the need for useTheRulesFor;
one insertion mode function can now just call the other
directly. The insertion mode will be changed only if it needs to be.

This CL is an alternative to CL 5372078.

R=nigeltao, rsc
CC=golang-dev
http://codereview.appspot.com/5372079

Committer: Nigel Tao <58ae08b3356928ff9c67562b4719487d54fe8348@golang.org>

webfd/go-zh,webfd/go-zh,scirelli/scirelli-go,rdp/rogerpack2005-golang,bryanxu/go-zh,sanjosh/sanjos100-tipc,Triskite/willstone-goclone,mhennings/marcohennings-go,glycerine/jeaten-go-arrayof-structof,rdp/rogerpack2005-golang,Triskite/willstone-goclone,webfd/go-zh,sanjosh/sanjos100-tipc,webfd/go-zh,bryanxu/go-zh,webfd/go-zh,rflanagan/reginaldflanagan-project1,mhennings/marcohennings-go,bryanxu/go-zh,sanjosh/sanjos100-tipc,mhennings/marcohennings-go,bryanxu/go-zh,sanjosh/sanjos100-tipc,glycerine/jeaten-go-arrayof-structof,webfd/go-zh,rdp/rogerpack2005-golang,d0f/go-zh,glycerine/jeaten-go-arrayof-structof,scirelli/scirelli-go,Triskite/willstone-goclone,bryanxu/go-zh,Triskite/willstone-goclone,d0f/go-zh,mhennings/marcohennings-go,rdp/rogerpack2005-golang,rflanagan/reginaldflanagan-project1,bryanxu/go-zh,glycerine/jeaten-go-arrayof-structof,glycerine/jeaten-go-arrayof-structof,Triskite/willstone-goclone,rflanagan/reginaldflanagan-project1,rflanagan/reginaldflanagan-project1,d0f/go-zh,rflanagan/reginaldflanagan-project1,d0f/go-zh,sanjosh/sanjos100-tipc,sanjosh/sanjos100-tipc,Triskite/willstone-goclone,scirelli/scirelli-go,rdp/rogerpack2005-golang,glycerine/jeaten-go-arrayof-structof,bryanxu/go-zh,scirelli/scirelli-go,d0f/go-zh,glycerine/jeaten-go-arrayof-structof,webfd/go-zh,scirelli/scirelli-go,rflanagan/reginaldflanagan-project1,rflanagan/reginaldflanagan-project1,webfd/go-zh,mhennings/marcohennings-go,mhennings/marcohennings-go,mhennings/marcohennings-go,Triskite/willstone-goclone,sanjosh/sanjos100-tipc,d0f/go-zh,rdp/rogerpack2005-golang,scirelli/scirelli-go,rdp/rogerpack2005-golang,rdp/rogerpack2005-golang,Triskite/willstone-goclone,rflanagan/reginaldflanagan-project1,d0f/go-zh,glycerine/jeaten-go-arrayof-structof,bryanxu/go-zh,scirelli/scirelli-go,scirelli/scirelli-go,sanjosh/sanjos100-tipc,d0f/go-zh,mhennings/marcohennings-go