]> Cypherpunks repositories - gostls13.git/commit
html: store the current insertion mode in the parser
authorAndrew Balholm <andybalholm@gmail.com>
Sun, 13 Nov 2011 01:39:41 +0000 (12:39 +1100)
committerNigel Tao <nigeltao@golang.org>
Sun, 13 Nov 2011 01:39:41 +0000 (12:39 +1100)
commit631a575fd92b711854930f3b03b40a2bf66bbd29
treed8540620711040e0d762f2d9fa8d088456c8c2b2
parent13dc53055f7fb6e15b640cdb24284c481bd4402c
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
https://golang.org/cl/5372079
src/pkg/html/parse.go