summaryrefslogtreecommitdiff
path: root/content/handlers
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2021-02-09 20:50:01 +0000
committerMichael Drake <michael.drake@codethink.co.uk>2021-02-09 21:33:06 +0000
commit64680a8edbebcfbcb5f2f2ddcce9a998aeef19f3 (patch)
tree5e92cbc512ef301a907a559636e2cb57765227e6 /content/handlers
parent41a0c21812ed1fb59bf75cbe26a8b8c5e19e71a0 (diff)
downloadnetsurf-64680a8edbebcfbcb5f2f2ddcce9a998aeef19f3.tar.gz
netsurf-64680a8edbebcfbcb5f2f2ddcce9a998aeef19f3.tar.bz2
layout: Add support for list item value attribute.
Diffstat (limited to 'content/handlers')
-rw-r--r--content/handlers/html/layout.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/content/handlers/html/layout.c b/content/handlers/html/layout.c
index 2f222b9c9..b46b8a592 100644
--- a/content/handlers/html/layout.c
+++ b/content/handlers/html/layout.c
@@ -4439,6 +4439,48 @@ layout__check_element_type(
/**
+ * Helper to get attribute value from a LI node.
+ *
+ * \param[in] li_node DOM node for the LI element;
+ * \param[out] value_out Returns the value on success.
+ * \return true if node has value, otherwise false.
+ */
+static bool
+layout__get_li_value(dom_node *li_node, dom_long *value_out)
+{
+ dom_exception exc;
+ dom_long value;
+ bool has_value;
+
+ /** \todo
+ * dom_html_li_element_get_value() is rubbish and we can't tell
+ * a lack of value attribute or invalid value from a perfectly
+ * valid '-1'.
+ *
+ * This helps for the common case of no value. However we should
+ * fix libdom to have some kind of sane interface to get numerical
+ * attributes.
+ */
+ exc = dom_element_has_attribute(li_node,
+ corestring_dom_value,
+ &has_value);
+ if (exc != DOM_NO_ERR || has_value == false) {
+ return false;
+ }
+
+ exc = dom_html_li_element_get_value(
+ (dom_html_li_element *)li_node,
+ &value);
+ if (exc != DOM_NO_ERR) {
+ return false;
+ }
+
+ *value_out = value;
+ return true;
+}
+
+
+/**
* Handle list item counting, if this is a list owner box.
*
* \param[in] box Box to do list item counting for.
@@ -4451,6 +4493,7 @@ layout__ordered_list_count(
dom_exception exc;
dom_node *child;
unsigned count;
+ unsigned next;
if (box->node == NULL) {
return;
@@ -4472,6 +4515,7 @@ layout__ordered_list_count(
}
count = 1;
+ next = 1;
while (child != NULL) {
dom_node *temp_node;
@@ -4488,7 +4532,14 @@ layout__ordered_list_count(
if (child_box != NULL &&
child_box->list_marker != NULL) {
- child_box->list_marker->rows = count;
+ dom_long value;
+ if (layout__get_li_value(child, &value)) {
+ child_box->list_marker->rows = value;
+ next = value + 1;
+ } else {
+ child_box->list_marker->rows = next;
+ next++;
+ }
count++;
}
}