summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-04-22 14:48:54 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-04-22 14:48:54 +0000
commitb5f94b26dc7a3fc54d2a4dbb00b1b4644b7cffba (patch)
treeba4003caa0ecbc6d3c53c8e25f277214661b5b7b
parentc737dbd5f82517eb83a9f9a0a0917a9cb264219c (diff)
downloadnetsurf-b5f94b26dc7a3fc54d2a4dbb00b1b4644b7cffba.tar.gz
netsurf-b5f94b26dc7a3fc54d2a4dbb00b1b4644b7cffba.tar.bz2
Apply same hack for :before as for :after
svn path=/trunk/netsurf/; revision=12224
-rw-r--r--render/box_construct.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/render/box_construct.c b/render/box_construct.c
index b80dbdbe6..b47405c12 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -106,8 +106,8 @@ bool box_construct_element(xmlNode *n, struct content *content,
const css_computed_style *parent_style,
struct box *parent, struct box **inline_container,
char *href, const char *target, char *title);
-void box_construct_after(xmlNode *n, struct content *content,
- struct box *box, const css_computed_style *after_style);
+void box_construct_generate(xmlNode *n, struct content *content,
+ struct box *box, const css_computed_style *style);
bool box_construct_text(xmlNode *n, struct content *content,
const css_computed_style *parent_style,
struct box *parent, struct box **inline_container,
@@ -358,6 +358,18 @@ bool box_construct_element(xmlNode *n, struct content *content,
n->parent == NULL)];
}
+ /* handle the :before pseudo element */
+
+ /* TODO: Replace with true implementation.
+ * Currently we only implement enough of this to support the
+ * 'clearfix' hack, which is in widespread use and the layout
+ * of many sites depend on. As such, only bother if box is a
+ * block for now. */
+ if (box->type == BOX_BLOCK) {
+ box_construct_generate(n, content, box,
+ box->styles->styles[CSS_PSEUDO_ELEMENT_BEFORE]);
+ }
+
/* special elements */
element = bsearch((const char *) n->name, element_table,
ELEMENT_TABLE_COUNT, sizeof(element_table[0]),
@@ -608,21 +620,20 @@ bool box_construct_element(xmlNode *n, struct content *content,
* of many sites depend on. As such, only bother if box is a
* block for now. */
if (box->type == BOX_BLOCK) {
- box_construct_after(n, content, box,
+ box_construct_generate(n, content, box,
box->styles->styles[CSS_PSEUDO_ELEMENT_AFTER]);
}
return true;
}
-
/**
- * Construct the box required for an :after pseudo element.
+ * Construct the box required for a generated element.
*
* \param n XML node of type XML_ELEMENT_NODE
* \param content content of type CONTENT_HTML that is being processed
- * \param box box which may have an :after s
- * \param after_style complete computed style for after pseudo element
+ * \param box box which may have generated content
+ * \param style complete computed style for pseudo element
*
* TODO:
* This is currently incomplete. It just does enough to support the clearfix
@@ -634,36 +645,36 @@ bool box_construct_element(xmlNode *n, struct content *content,
* We don't actually support generated content yet.
*/
-void box_construct_after(xmlNode *n, struct content *content,
- struct box *box, const css_computed_style *after_style)
+void box_construct_generate(xmlNode *n, struct content *content,
+ struct box *box, const css_computed_style *style)
{
- struct box *after = 0;
+ struct box *gen = NULL;
const css_computed_content_item *c_item;
- if (after_style == NULL ||
- css_computed_content(after_style, &c_item) ==
+ if (style == NULL ||
+ css_computed_content(style, &c_item) ==
CSS_CONTENT_NORMAL) {
/* No pseudo element */
return;
}
/* create box for this element */
- if (css_computed_display(after_style, n->parent == NULL) ==
+ if (css_computed_display(style, n->parent == NULL) ==
CSS_DISPLAY_BLOCK) {
/* currently only support block level after elements */
/** \todo Not wise to drop const from the computed style */
- after = box_create(NULL, (css_computed_style *)after_style,
+ gen = box_create(NULL, (css_computed_style *) style,
false, NULL, NULL, NULL, NULL, content);
- if (after == NULL) {
+ if (gen == NULL) {
return;
}
/* set box type from computed display */
- after->type = box_map[css_computed_display(
- after_style, n->parent == NULL)];
+ gen->type = box_map[css_computed_display(
+ style, n->parent == NULL)];
- box_add_child(box, after);
+ box_add_child(box, gen);
}
}