summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2016-02-09 16:42:28 +0000
committerMichael Drake <michael.drake@codethink.co.uk>2016-02-09 16:42:28 +0000
commit3bee7b7e127be7b378a90569c63b82cde9fb20bc (patch)
tree5ec29fb0816765ec69fd458a26f349f833c068cf /render
parent3af77eabd8b818629bc86e8bd7e29da2cdb621ff (diff)
downloadnetsurf-3bee7b7e127be7b378a90569c63b82cde9fb20bc.tar.gz
netsurf-3bee7b7e127be7b378a90569c63b82cde9fb20bc.tar.bz2
Layout: Don't generate :before and :after boxes for replaced elements.
In CSS 2.1 this was undefined. CSS 2.1 -- 12.1 The :before and :after pseudo-elements Note. This specification does not fully define the interaction of :before and :after with replaced elements (such as IMG in HTML). This will be defined in more detail in a future specification. -- https://www.w3.org/TR/CSS21/generate.html#before-after-content In CSS 3 the :before and :after generated content boxes are not allowed on replaced elements. CSS 3 Generated and Replaced Content Module 12. Replaced content The box model defines different rules for the layout of replaced elements than normal elements. Replaced elements do not have '::before' and '::after' pseudo-elements; the 'content' property in the case of replaced content replaces the entire contents of the element's box. -- https://www.w3.org/TR/css3-content/#replacedContent
Diffstat (limited to 'render')
-rw-r--r--render/box.h3
-rw-r--r--render/box_construct.c20
2 files changed, 17 insertions, 6 deletions
diff --git a/render/box.h b/render/box.h
index 1f35adad9..4ac3453aa 100644
--- a/render/box.h
+++ b/render/box.h
@@ -132,7 +132,8 @@ typedef enum {
NEED_MIN = 1 << 8, /* minimum width is required for layout */
REPLACE_DIM = 1 << 9, /* replaced element has given dimensions */
IFRAME = 1 << 10, /* box contains an iframe */
- CONVERT_CHILDREN = 1 << 11 /* wanted children converting */
+ CONVERT_CHILDREN = 1 << 11, /* wanted children converting */
+ IS_REPLACED = 1 << 12 /* box is a replaced element */
} box_flags;
/* Sides of a box */
diff --git a/render/box_construct.c b/render/box_construct.c
index b3fc8f156..adb450946 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -852,10 +852,6 @@ bool box_construct_element(struct box_construct_ctx *ctx,
props.node_is_root)];
}
- /* Handle the :before pseudo element */
- box_construct_generate(ctx->n, ctx->content, box,
- box->styles->styles[CSS_PSEUDO_ELEMENT_BEFORE]);
-
err = dom_node_get_node_name(ctx->n, &s);
if (err != DOM_NO_ERR || s == NULL)
return false;
@@ -874,6 +870,12 @@ bool box_construct_element(struct box_construct_ctx *ctx,
return false;
}
+ /* Handle the :before pseudo element */
+ if (!(box->flags & IS_REPLACED)) {
+ box_construct_generate(ctx->n, ctx->content, box,
+ box->styles->styles[CSS_PSEUDO_ELEMENT_BEFORE]);
+ }
+
if (box->type == BOX_NONE || (css_computed_display(box->style,
props.node_is_root) == CSS_DISPLAY_NONE &&
props.node_is_root == false)) {
@@ -1065,7 +1067,7 @@ void box_construct_element_after(dom_node *n, html_content *content)
box->inline_end = inline_end;
inline_end->inline_end = box;
}
- } else {
+ } else if (!(box->flags & IS_REPLACED)) {
/* Handle the :after pseudo element */
box_construct_generate(n, content, box,
box->styles->styles[CSS_PSEUDO_ELEMENT_AFTER]);
@@ -1603,6 +1605,7 @@ bool box_image(BOX_SPECIAL_PARAMS)
return true;
/* start fetch */
+ box->flags |= IS_REPLACED;
ok = html_fetch_object(content, url, box, image_types,
content->base.available_width, 1000, false);
nsurl_unref(url);
@@ -1879,6 +1882,7 @@ bool box_object(BOX_SPECIAL_PARAMS)
box->object_params = params;
/* start fetch (MIME type is ok or not specified) */
+ box->flags |= IS_REPLACED;
if (!html_fetch_object(content,
params->data ? params->data : params->classid,
box, CONTENT_ANY, content->base.available_width, 1000,
@@ -2357,6 +2361,7 @@ bool box_iframe(BOX_SPECIAL_PARAMS)
/* box */
assert(box->style);
box->flags |= IFRAME;
+ box->flags |= IS_REPLACED;
/* Showing iframe, so don't show alternate content */
if (convert_children)
@@ -2415,6 +2420,7 @@ bool box_input(BOX_SPECIAL_PARAMS)
if (gadget == NULL)
goto no_memory;
box->gadget = gadget;
+ box->flags |= IS_REPLACED;
gadget->box = box;
gadget->html = content;
@@ -2554,6 +2560,7 @@ bool box_button(BOX_SPECIAL_PARAMS)
gadget->html = content;
box->gadget = gadget;
+ box->flags |= IS_REPLACED;
gadget->box = box;
box->type = BOX_INLINE_BLOCK;
@@ -2676,6 +2683,7 @@ bool box_select(BOX_SPECIAL_PARAMS)
box->type = BOX_INLINE_BLOCK;
box->gadget = gadget;
+ box->flags |= IS_REPLACED;
gadget->box = box;
inline_container = box_create(NULL, 0, false, 0, 0, 0, 0, content->bctx);
@@ -2797,6 +2805,7 @@ bool box_textarea(BOX_SPECIAL_PARAMS)
if (box->gadget == NULL)
return false;
+ box->flags |= IS_REPLACED;
box->gadget->html = content;
box->gadget->box = box;
@@ -2930,6 +2939,7 @@ bool box_embed(BOX_SPECIAL_PARAMS)
box->object_params = params;
/* start fetch */
+ box->flags |= IS_REPLACED;
return html_fetch_object(content, params->data, box, CONTENT_ANY,
content->base.available_width, 1000, false);
}