@@ -1302,12 +1302,66 @@ class InRow(InsertionMode):
13021302 # http://www.whatwg.org/specs/web-apps/current-work/#in-row
13031303
13041304 # helper methods (XXX unify this with other table helper methods)
1305- def clearStackToTableBodyContext (self ):
1305+ def clearStackToTableRowContext (self ):
13061306 while self .parser .openElements [:- 1 ].name in ("tr" , "html" ):
13071307 self .parser .openElements .pop ()
13081308 self .parser .parseError ()
13091309
13101310 # the rest
1311+ def processStartTag (self , name , attributes ):
1312+ handlers = utils .MethodDispatcher ([
1313+ (("td" , "th" ), self .startTagTableCell ),
1314+ (("caption" , "col" , "colgroup" , "tbody" , "tfoot" , "thead" ,
1315+ "tr" ), self .startTagTableOther )
1316+ ])
1317+ handlers .setDefaultValue (self .startTagOther )
1318+ handlers [name ](name , attributes )
1319+
1320+ def startTagTableCell (name , attributes ):
1321+ self .clearStackToTableRowContext ()
1322+ self .parser .insertElement (name , attributes )
1323+ self .parser .switchInsertionMode ("inCell" )
1324+ # XXX insert marker?!
1325+
1326+ def startTagTableOther (name , attributes ):
1327+ self .endTagTr ()
1328+ # XXX check if it wasn't ignored... innerHTML case ... reprocess
1329+ # current. see also endTagTable
1330+
1331+ def startTagOther (self , name ):
1332+ self .parser .switchInsertionMode ("inTable" )
1333+ self .parser .processStartTag (self , name )
1334+
1335+ def processEndTag (self , name ):
1336+ handlers = utils .MethodDispatcher ([
1337+ ("tr" , self .endTagTr ),
1338+ ("table" , self .endTagTable ),
1339+ (("tbody" , "tfoot" , "thead" ), self .endTagTableRowGroup ),
1340+ (("body" , "caption" , "col" , "colgroup" , "html" , "td" , "th" ), \
1341+ self .endTagIgnore )
1342+ ])
1343+ handlers .setDefaultValue (self .endTagOther )
1344+ handlers [name ](name )
1345+
1346+ def endTagTr (self , name = "tr" ):
1347+ # XXX lots of checks
1348+ assert False
1349+
1350+ def endTagTable (self , name ):
1351+ self .endTagTr ()
1352+ # XXX check if it wasn't ignored... innerHTML case ... reprocess
1353+ # current. see also startTagTableOther...
1354+
1355+ def endTagTableRowGroup (self , name ):
1356+ # XXX
1357+ assert False
1358+
1359+ def endTagIgnore (self , name ):
1360+ self .parser .parseError ()
1361+
1362+ def endTagOther (self , name ):
1363+ self .parser .switchInsertionMode ("inTable" )
1364+ self .parser .processEndTag (name )
13111365
13121366class InCell (InsertionMode ): pass
13131367
0 commit comments