fix list index overflow
This is visible on https://en.wikipedia.org/wiki/Obama, which has an ordered list with more than 256 items
This commit is contained in:
parent
63014557d7
commit
9e34db38f2
@ -14,17 +14,17 @@ int litehtml::el_li::render(int x, int y, int max_width, bool second_pass)
|
||||
{
|
||||
const auto hasStart = p->get_attr(_t("start"));
|
||||
const int start = hasStart ? t_atoi(hasStart) : 1;
|
||||
tchar_t val[2] = { (tchar_t)start, 0 };
|
||||
int val = start;
|
||||
for (int i = 0, n = (int)p->get_children_count(); i < n; ++i)
|
||||
{
|
||||
auto child = p->get_child(i);
|
||||
if (child.get() == this)
|
||||
{
|
||||
set_attr(_t("list_index"), val);
|
||||
set_attr(_t("list_index"), t_to_string(val).c_str());
|
||||
break;
|
||||
}
|
||||
else if (!t_strcmp(child->get_tagName(), _t("li")))
|
||||
++val[0];
|
||||
++val;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2969,7 +2969,7 @@ void litehtml::html_tag::draw_list_marker( uint_ptr hdc, const position &pos )
|
||||
{
|
||||
lm.pos.y = pos.y;
|
||||
lm.pos.height = pos.height;
|
||||
lm.index = (unsigned char) get_attr(_t("list_index"), _t(""))[0];
|
||||
lm.index = t_atoi(get_attr(_t("list_index"), _t("0")));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user