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.c52
1 files changed, 32 insertions, 20 deletions
diff --git a/render/box_construct.c b/render/box_construct.c
index d0ffd9d83..1aa99e2d1 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -46,6 +46,7 @@
#include "content/content_protected.h"
#include "css/hints.h"
#include "css/select.h"
+#include "css/utils.h"
#include "desktop/gui_internal.h"
#include "render/box.h"
@@ -103,7 +104,8 @@ static bool box_construct_element(struct box_construct_ctx *ctx,
static void box_construct_element_after(dom_node *n, html_content *content);
static bool box_construct_text(struct box_construct_ctx *ctx);
static css_select_results * box_get_style(html_content *c,
- const css_computed_style *parent_style, dom_node *n);
+ const css_computed_style *parent_style,
+ const css_computed_style *root_style, dom_node *n);
static void box_text_transform(char *s, unsigned int len,
enum css_text_transform_e tt);
#define BOX_SPECIAL_PARAMS dom_node *n, html_content *content, \
@@ -428,7 +430,8 @@ void convert_xml_to_box(struct box_construct_ctx *ctx)
root.children->parent = &root;
/** \todo Remove box_normalise_block */
- if (box_normalise_block(&root, ctx->content) == false) {
+ if (box_normalise_block(&root, ctx->root_box,
+ ctx->content) == false) {
ctx->cb(ctx->content, false);
} else {
ctx->content->layout = root.children;
@@ -612,7 +615,7 @@ static void box_construct_generate(dom_node *n, html_content *content,
}
/* create box for this element */
- computed_display = css_computed_display(style, box_is_root(n));
+ computed_display = ns_computed_display(style, box_is_root(n));
if (computed_display == CSS_DISPLAY_BLOCK ||
computed_display == CSS_DISPLAY_TABLE) {
/* currently only support block level boxes */
@@ -625,7 +628,7 @@ static void box_construct_generate(dom_node *n, html_content *content,
}
/* set box type from computed display */
- gen->type = box_map[css_computed_display(
+ gen->type = box_map[ns_computed_display(
style, box_is_root(n))];
box_add_child(box, gen);
@@ -740,6 +743,7 @@ bool box_construct_element(struct box_construct_ctx *ctx,
lwc_string *bgimage_uri;
dom_exception err;
struct box_construct_props props;
+ const css_computed_style *root_style = NULL;
assert(ctx->n != NULL);
@@ -752,7 +756,12 @@ bool box_construct_element(struct box_construct_ctx *ctx,
props.containing_block->flags &= ~PRE_STRIP;
}
- styles = box_get_style(ctx->content, props.parent_style, ctx->n);
+ if (props.node_is_root == false) {
+ root_style = ctx->root_box->style;
+ }
+
+ styles = box_get_style(ctx->content, props.parent_style, root_style,
+ ctx->n);
if (styles == NULL)
return false;
@@ -831,11 +840,11 @@ bool box_construct_element(struct box_construct_ctx *ctx,
if ((css_computed_position(box->style) == CSS_POSITION_ABSOLUTE ||
css_computed_position(box->style) ==
CSS_POSITION_FIXED) &&
- (css_computed_display_static(box->style) ==
+ (ns_computed_display_static(box->style) ==
CSS_DISPLAY_INLINE ||
- css_computed_display_static(box->style) ==
+ ns_computed_display_static(box->style) ==
CSS_DISPLAY_INLINE_BLOCK ||
- css_computed_display_static(box->style) ==
+ ns_computed_display_static(box->style) ==
CSS_DISPLAY_INLINE_TABLE)) {
/* Special case for absolute positioning: make absolute inlines
* into inline block so that the boxes are constructed in an
@@ -848,7 +857,7 @@ bool box_construct_element(struct box_construct_ctx *ctx,
box->type = BOX_BLOCK;
} else {
/* Normal mapping */
- box->type = box_map[css_computed_display(box->style,
+ box->type = box_map[ns_computed_display(box->style,
props.node_is_root)];
}
@@ -876,7 +885,7 @@ bool box_construct_element(struct box_construct_ctx *ctx,
box->styles->styles[CSS_PSEUDO_ELEMENT_BEFORE]);
}
- if (box->type == BOX_NONE || (css_computed_display(box->style,
+ if (box->type == BOX_NONE || (ns_computed_display(box->style,
props.node_is_root) == CSS_DISPLAY_NONE &&
props.node_is_root == false)) {
css_select_results_destroy(styles);
@@ -968,7 +977,7 @@ bool box_construct_element(struct box_construct_ctx *ctx,
box_add_child(props.inline_container, box);
} else {
- if (css_computed_display(box->style, props.node_is_root) ==
+ if (ns_computed_display(box->style, props.node_is_root) ==
CSS_DISPLAY_LIST_ITEM) {
/* List item: compute marker */
if (box_construct_marker(box, props.title, ctx,
@@ -1320,13 +1329,15 @@ bool box_construct_text(struct box_construct_ctx *ctx)
/**
* Get the style for an element.
*
- * \param c content of type CONTENT_HTML that is being processed
+ * \param c content of type CONTENT_HTML that is being processed
* \param parent_style style at this point in xml tree, or NULL for root
- * \param n node in xml tree
+ * \param root_style root node's style, or NULL for root
+ * \param n node in xml tree
* \return the new style, or NULL on memory exhaustion
*/
css_select_results *box_get_style(html_content *c,
- const css_computed_style *parent_style, dom_node *n)
+ const css_computed_style *parent_style,
+ const css_computed_style *root_style, dom_node *n)
{
dom_string *s;
dom_exception err;
@@ -1358,6 +1369,7 @@ css_select_results *box_get_style(html_content *c,
ctx.quirks = (c->quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL);
ctx.base_url = c->base_url;
ctx.universal = c->universal;
+ ctx.root_style = root_style;
ctx.parent_style = parent_style;
/* Select style for element */
@@ -1559,7 +1571,7 @@ bool box_image(BOX_SPECIAL_PARAMS)
css_unit wunit = CSS_UNIT_PX;
css_unit hunit = CSS_UNIT_PX;
- if (box->style && css_computed_display(box->style,
+ if (box->style && ns_computed_display(box->style,
box_is_root(n)) == CSS_DISPLAY_NONE)
return true;
@@ -1666,7 +1678,7 @@ bool box_object(BOX_SPECIAL_PARAMS)
dom_node *c;
dom_exception err;
- if (box->style && css_computed_display(box->style,
+ if (box->style && ns_computed_display(box->style,
box_is_root(n)) == CSS_DISPLAY_NONE)
return true;
@@ -1900,7 +1912,7 @@ bool box_frameset(BOX_SPECIAL_PARAMS)
bool ok;
if (content->frameset) {
- LOG("Error: multiple framesets in document.");
+ NSLOG(netsurf, INFO, "Error: multiple framesets in document.");
/* Don't convert children */
if (convert_children)
*convert_children = false;
@@ -2316,7 +2328,7 @@ bool box_iframe(BOX_SPECIAL_PARAMS)
struct content_html_iframe *iframe;
int i;
- if (box->style && css_computed_display(box->style,
+ if (box->style && ns_computed_display(box->style,
box_is_root(n)) == CSS_DISPLAY_NONE)
return true;
@@ -2551,7 +2563,7 @@ bool box_input(BOX_SPECIAL_PARAMS)
corestring_lwc_image)) {
gadget->type = GADGET_IMAGE;
- if (box->style && css_computed_display(box->style,
+ if (box->style && ns_computed_display(box->style,
box_is_root(n)) != CSS_DISPLAY_NONE &&
nsoption_bool(foreground_images) == true) {
dom_string *s;
@@ -2887,7 +2899,7 @@ bool box_embed(BOX_SPECIAL_PARAMS)
dom_string *src;
dom_exception err;
- if (box->style && css_computed_display(box->style,
+ if (box->style && ns_computed_display(box->style,
box_is_root(n)) == CSS_DISPLAY_NONE)
return true;