Fixed: Move tr elements directly under table into tbody

--HG--
branch : html-improvements
hg/feature/html-improvements
Nimetu 5 years ago
parent 379a7f0e98
commit 72b6d1e4c5

@ -1143,8 +1143,10 @@ namespace NLGUI
case HTML_STRONG: renderPseudoElement(":before", elm); break;
case HTML_STYLE: htmlSTYLE(elm); break;
case HTML_TABLE: htmlTABLE(elm); break;
case HTML_TBODY: renderPseudoElement(":before", elm); break;
case HTML_TD: htmlTD(elm); break;
case HTML_TEXTAREA: htmlTEXTAREA(elm); break;
case HTML_TFOOT: renderPseudoElement(":before", elm); break;
case HTML_TH: htmlTH(elm); break;
case HTML_TITLE: htmlTITLE(elm); break;
case HTML_TR: htmlTR(elm); break;
@ -1205,7 +1207,9 @@ namespace NLGUI
case HTML_STYLE: htmlSTYLEend(elm); break;
case HTML_TABLE: htmlTABLEend(elm); break;
case HTML_TD: htmlTDend(elm); break;
case HTML_TBODY: renderPseudoElement(":after", elm); break;
case HTML_TEXTAREA: htmlTEXTAREAend(elm); break;
case HTML_TFOOT: renderPseudoElement(":after", elm); break;
case HTML_TH: htmlTHend(elm); break;
case HTML_TITLE: htmlTITLEend(elm); break;
case HTML_TR: htmlTRend(elm); break;

@ -190,6 +190,35 @@ namespace NLGUI
elm.reindexChilds();
parent.reindexChilds();
}
// move all <tr> directly under <table> to its own <tbody> ("table > tbody > tr" selector).
// TODO: move first real <thead> to front, move first real <tfoot> at the end
if (elm.ID == HTML_TABLE)
{
std::list<CHtmlElement>::iterator it = elm.Children.begin();
std::list<CHtmlElement>::iterator tbody = elm.Children.end();
for(it = elm.Children.begin(); it != elm.Children.end(); ++it)
{
if (it->ID == HTML_TR)
{
if (tbody == elm.Children.end())
{
tbody = elm.Children.insert(it, CHtmlElement(CHtmlElement::ELEMENT_NODE, "tbody"));
tbody->ID = HTML_TBODY;
tbody->parent = &elm;
}
tbody->Children.splice(tbody->Children.end(), elm.Children, it);
it = tbody;
}
else if (tbody != elm.Children.end())
{
tbody->reindexChilds();
tbody = elm.Children.end();
}
}
elm.reindexChilds();
}
}
}

Loading…
Cancel
Save