summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
Diffstat (limited to 'render')
-rw-r--r--render/box.c18
-rw-r--r--render/box.h1
-rw-r--r--render/box_construct.c59
-rw-r--r--render/box_normalise.c24
-rw-r--r--render/html_css.c2
-rw-r--r--render/textplain.c5
6 files changed, 15 insertions, 94 deletions
diff --git a/render/box.c b/render/box.c
index e955b4303..295308b5a 100644
--- a/render/box.c
+++ b/render/box.c
@@ -54,24 +54,6 @@ static bool box_nearest_text_box(struct box *box, int bx, int by,
box->type == BOX_FLOAT_RIGHT)
/**
- * Allocator
- *
- * \param ptr Pointer to reallocate, or NULL for new allocation
- * \param size Number of bytes requires
- * \param pw Allocation context
- * \return Pointer to allocated block, or NULL on failure
- */
-void *box_style_alloc(void *ptr, size_t len, void *pw)
-{
- if (len == 0) {
- free(ptr);
- return NULL;
- }
-
- return realloc(ptr, len);
-}
-
-/**
* Destructor for box nodes which own styles
*
* \param b The box being destroyed.
diff --git a/render/box.h b/render/box.h
index 1ce26c28b..878ebc8d3 100644
--- a/render/box.h
+++ b/render/box.h
@@ -315,7 +315,6 @@ extern const char *TARGET_BLANK;
-void *box_style_alloc(void *ptr, size_t len, void *pw);
struct box * box_create(css_select_results *styles, css_computed_style *style,
bool style_owned, nsurl *href, const char *target,
const char *title, lwc_string *id, void *context);
diff --git a/render/box_construct.c b/render/box_construct.c
index 3251cc17f..a72f918f8 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -1425,8 +1425,6 @@ css_select_results *box_get_style(html_content *c,
{
dom_string *s;
dom_exception err;
- int pseudo_element;
- css_error error;
css_stylesheet *inline_style = NULL;
css_select_results *styles;
nscss_select_ctx ctx;
@@ -1442,8 +1440,7 @@ css_select_results *box_get_style(html_content *c,
dom_string_byte_length(s),
c->encoding,
nsurl_access(content_get_url(&c->base)),
- c->quirks != DOM_DOCUMENT_QUIRKS_MODE_NONE,
- box_style_alloc, NULL);
+ c->quirks != DOM_DOCUMENT_QUIRKS_MODE_NONE);
dom_string_unref(s);
@@ -1456,63 +1453,15 @@ 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.parent_style = parent_style;
- /* Select partial style for element */
- styles = nscss_get_style(&ctx, n, CSS_MEDIA_SCREEN, inline_style,
- box_style_alloc, NULL);
+ /* Select style for element */
+ styles = nscss_get_style(&ctx, n, CSS_MEDIA_SCREEN, inline_style);
/* No longer need inline style */
if (inline_style != NULL)
css_stylesheet_destroy(inline_style);
- /* Failed selecting partial style -- bail out */
- if (styles == NULL)
- return NULL;
-
- /* If there's a parent style, compose with partial to obtain
- * complete computed style for element */
- if (parent_style != NULL) {
- /* Complete the computed style, by composing with the parent
- * element's style */
- error = css_computed_style_compose(parent_style,
- styles->styles[CSS_PSEUDO_ELEMENT_NONE],
- nscss_compute_font_size, NULL,
- styles->styles[CSS_PSEUDO_ELEMENT_NONE]);
- if (error != CSS_OK) {
- css_select_results_destroy(styles);
- return NULL;
- }
- }
-
- for (pseudo_element = CSS_PSEUDO_ELEMENT_NONE + 1;
- pseudo_element < CSS_PSEUDO_ELEMENT_COUNT;
- pseudo_element++) {
-
- if (pseudo_element == CSS_PSEUDO_ELEMENT_FIRST_LETTER ||
- pseudo_element == CSS_PSEUDO_ELEMENT_FIRST_LINE)
- /* TODO: Handle first-line and first-letter pseudo
- * element computed style completion */
- continue;
-
- if (styles->styles[pseudo_element] == NULL)
- /* There were no rules concerning this pseudo element */
- continue;
-
- /* Complete the pseudo element's computed style, by composing
- * with the base element's style */
- error = css_computed_style_compose(
- styles->styles[CSS_PSEUDO_ELEMENT_NONE],
- styles->styles[pseudo_element],
- nscss_compute_font_size, NULL,
- styles->styles[pseudo_element]);
- if (error != CSS_OK) {
- /* TODO: perhaps this shouldn't be quite so
- * catastrophic? */
- css_select_results_destroy(styles);
- return NULL;
- }
- }
-
return styles;
}
diff --git a/render/box_normalise.c b/render/box_normalise.c
index 42b20cbb7..5a4b6256a 100644
--- a/render/box_normalise.c
+++ b/render/box_normalise.c
@@ -156,8 +156,7 @@ bool box_normalise_block(struct box *block, html_content *c)
ctx.base_url = c->base_url;
ctx.universal = c->universal;
- style = nscss_get_blank_style(&ctx, block->style,
- box_style_alloc, NULL);
+ style = nscss_get_blank_style(&ctx, block->style);
if (style == NULL)
return false;
@@ -258,8 +257,7 @@ bool box_normalise_table(struct box *table, html_content * c)
ctx.base_url = c->base_url;
ctx.universal = c->universal;
- style = nscss_get_blank_style(&ctx, table->style,
- box_style_alloc, NULL);
+ style = nscss_get_blank_style(&ctx, table->style);
if (style == NULL) {
free(col_info.spans);
return false;
@@ -345,8 +343,7 @@ bool box_normalise_table(struct box *table, html_content * c)
ctx.base_url = c->base_url;
ctx.universal = c->universal;
- style = nscss_get_blank_style(&ctx, table->style,
- box_style_alloc, NULL);
+ style = nscss_get_blank_style(&ctx, table->style);
if (style == NULL) {
free(col_info.spans);
return false;
@@ -361,8 +358,7 @@ bool box_normalise_table(struct box *table, html_content * c)
}
row_group->type = BOX_TABLE_ROW_GROUP;
- style = nscss_get_blank_style(&ctx, row_group->style,
- box_style_alloc, NULL);
+ style = nscss_get_blank_style(&ctx, row_group->style);
if (style == NULL) {
box_free(row_group);
free(col_info.spans);
@@ -482,8 +478,7 @@ bool box_normalise_table_spans(struct box *table, struct span_info *spans,
ctx.universal = c->universal;
style = nscss_get_blank_style(&ctx,
- table_row->style,
- box_style_alloc, NULL);
+ table_row->style);
if (style == NULL)
return false;
@@ -591,8 +586,7 @@ bool box_normalise_table_row_group(struct box *row_group,
ctx.base_url = c->base_url;
ctx.universal = c->universal;
- style = nscss_get_blank_style(&ctx, row_group->style,
- box_style_alloc, NULL);
+ style = nscss_get_blank_style(&ctx, row_group->style);
if (style == NULL)
return false;
@@ -666,8 +660,7 @@ bool box_normalise_table_row_group(struct box *row_group,
ctx.base_url = c->base_url;
ctx.universal = c->universal;
- style = nscss_get_blank_style(&ctx, row_group->style,
- box_style_alloc, NULL);
+ style = nscss_get_blank_style(&ctx, row_group->style);
if (style == NULL) {
return false;
}
@@ -736,8 +729,7 @@ bool box_normalise_table_row(struct box *row,
ctx.base_url = c->base_url;
ctx.universal = c->universal;
- style = nscss_get_blank_style(&ctx, row->style,
- box_style_alloc, NULL);
+ style = nscss_get_blank_style(&ctx, row->style);
if (style == NULL)
return false;
diff --git a/render/html_css.c b/render/html_css.c
index bf20dcf14..88c67697d 100644
--- a/render/html_css.c
+++ b/render/html_css.c
@@ -596,7 +596,7 @@ html_css_new_selection_context(html_content *c, css_select_ctx **ret_select_ctx)
}
/* Create selection context */
- css_ret = css_select_ctx_create(ns_realloc, c, &select_ctx);
+ css_ret = css_select_ctx_create(&select_ctx);
if (css_ret != CSS_OK) {
return css_error_to_nserror(css_ret);
}
diff --git a/render/textplain.c b/render/textplain.c
index 10cf16a71..892e03e57 100644
--- a/render/textplain.c
+++ b/render/textplain.c
@@ -283,12 +283,11 @@ nserror textplain_create_internal(textplain_content *c, lwc_string *encoding)
goto no_memory;
error = parserutils_inputstream_create(lwc_string_data(encoding), 0,
- textplain_charset_hack, ns_realloc, NULL, &stream);
+ textplain_charset_hack, &stream);
if (error == PARSERUTILS_BADENCODING) {
/* Fall back to Windows-1252 */
error = parserutils_inputstream_create("Windows-1252", 0,
- textplain_charset_hack, ns_realloc, NULL,
- &stream);
+ textplain_charset_hack, &stream);
}
if (error != PARSERUTILS_OK) {
free(utf8_data);