summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2021-02-20 17:03:49 +0000
committerMichael Drake <michael.drake@codethink.co.uk>2021-02-20 17:03:49 +0000
commit9e3ef18255464ccf0b7e29db23a436ccdc371959 (patch)
treef176471e56a265e056ad1cd2de0f89c3f9304dc4
parent920041a13103b0b207da56d2cb9d16c9ebcaba65 (diff)
downloadnetsurf-9e3ef18255464ccf0b7e29db23a436ccdc371959.tar.gz
netsurf-9e3ef18255464ccf0b7e29db23a436ccdc371959.tar.bz2
html: layout: Cleanup dom node tag name getting with helper.
-rw-r--r--content/handlers/html/layout.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/content/handlers/html/layout.c b/content/handlers/html/layout.c
index 082e537ba..c8c0127ad 100644
--- a/content/handlers/html/layout.c
+++ b/content/handlers/html/layout.c
@@ -4411,20 +4411,17 @@ layout_block_context(struct box *block,
return true;
}
-
/**
- * Check a node's tag type.
+ * Get a dom node's element tag type.
*
- * Assumes node is an HTML element.
- *
- * \param[in] node Node to ckeck tag type of.
- * \param[in] type Tag type to test for.
- * \return true if if node has given type, false otherwise.
+ * \param[in] node Node to get tag type of.
+ * \param[in] type Returns element tag type on success.
+ * \return true if on success, false otherwise.
*/
-static inline bool
-layout__check_element_type(
+static bool
+layout__get_element_tag(
const dom_node *node,
- dom_html_element_type type)
+ dom_html_element_type *type)
{
dom_html_element_type element_type;
dom_node_type node_type;
@@ -4441,6 +4438,29 @@ layout__check_element_type(
return false;
}
+ *type = element_type;
+ return true;
+}
+
+
+/**
+ * Check a node's tag type.
+ *
+ * \param[in] node Node to check tag type of.
+ * \param[in] type Tag type to test for.
+ * \return true if if node has given type, false otherwise.
+ */
+static inline bool
+layout__check_element_type(
+ const dom_node *node,
+ dom_html_element_type type)
+{
+ dom_html_element_type element_type;
+
+ if (!layout__get_element_tag(node, &element_type)) {
+ return false;
+ }
+
return element_type == type;
}
@@ -4566,8 +4586,7 @@ layout__get_list_item_count(
return false;
}
- exc = dom_html_element_get_tag_type(list_owner, &tag_type);
- if (exc != DOM_NO_ERR) {
+ if (!layout__get_element_tag(list_owner, &tag_type)) {
return false;
}
@@ -4634,8 +4653,7 @@ layout__ordered_list_count(
return;
}
- exc = dom_html_element_get_tag_type(box->node, &tag_type);
- if (exc != DOM_NO_ERR) {
+ if (!layout__get_element_tag(box->node, &tag_type)) {
return;
}