summaryrefslogtreecommitdiff
path: root/render/box_construct.c
diff options
context:
space:
mode:
Diffstat (limited to 'render/box_construct.c')
-rw-r--r--render/box_construct.c59
1 files changed, 58 insertions, 1 deletions
diff --git a/render/box_construct.c b/render/box_construct.c
index 69b681760..4c847289a 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -205,7 +205,7 @@ static const box_type box_map[] = {
0, /*CSS_DISPLAY_INHERIT,*/
BOX_INLINE, /*CSS_DISPLAY_INLINE,*/
BOX_BLOCK, /*CSS_DISPLAY_BLOCK,*/
- BOX_BLOCK, /*CSS_DISPLAY_LIST_ITEM,*/
+ BOX_LIST_ITEM, /*CSS_DISPLAY_LIST_ITEM,*/
BOX_INLINE, /*CSS_DISPLAY_RUN_IN,*/
BOX_INLINE_BLOCK, /*CSS_DISPLAY_INLINE_BLOCK,*/
BOX_TABLE, /*CSS_DISPLAY_TABLE,*/
@@ -350,6 +350,10 @@ bool box_construct_element(xmlNode *n, struct content *content,
return true;
}
+ /* if this is a list item, then reset the box type */
+ if (style->display == CSS_DISPLAY_LIST_ITEM)
+ box->type = BOX_LIST_ITEM;
+
if (!*inline_container &&
(box->type == BOX_INLINE ||
box->type == BOX_BR ||
@@ -394,6 +398,59 @@ bool box_construct_element(xmlNode *n, struct content *content,
&inline_container_c,
href, target, title))
return false;
+ } else if (box->type == BOX_LIST_ITEM) {
+ /* list item: create marker box and recurse */
+ struct box *list_item;
+ struct box *marker;
+
+ /* create container box */
+ list_item = box_create(0, href, target, title, 0, content);
+ if (!list_item)
+ return false;
+ list_item->type = BOX_LIST_ITEM;
+
+ /* create marker - effectively a single INLINE */
+ /* marker style information is contained in PRINCIPAL box */
+ marker = box_create(box->style, href, target, title, 0,
+ content);
+ if (!marker)
+ return false;
+ marker->type = BOX_LIST_MARKER;
+ marker->clone = 1;
+
+ /** \todo marker content (list-style-type)
+ * need to traverse up the tree to find containing BOX_LIST,
+ * which contains the counter information */
+ marker->text = talloc_strdup(content, "1.");
+ if (!marker->text)
+ return false;
+ marker->space = 1;
+ marker->length = 2;
+
+ if (style->list_style_image.type ==
+ CSS_LIST_STYLE_IMAGE_URI) {
+ if (!html_fetch_object(content,
+ style->list_style_image.uri, marker,
+ 0, content->available_width, 1000,
+ false))
+ return false;
+ }
+
+ /* make box into principal block for list */
+ box->type = BOX_LIST_PRINCIPAL;
+
+ box_add_child(parent, list_item);
+ box_add_child(list_item, marker);
+ box_add_child(list_item, box);
+
+ /* and recurse */
+ inline_container_c = 0;
+ for (c = n->children; convert_children && c; c = c->next) {
+ if (!convert_xml_to_box(c, content, style,
+ box, &inline_container_c,
+ href, target, title))
+ return false;
+ }
} else {
if (style->float_ == CSS_FLOAT_LEFT ||
style->float_ == CSS_FLOAT_RIGHT) {