summaryrefslogtreecommitdiff
path: root/css
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2005-04-09 09:47:37 +0000
committerJames Bursa <james@netsurf-browser.org>2005-04-09 09:47:37 +0000
commit2920bca14adbf145d64754b1ef8e6b888c7995ee (patch)
treedb57b9169d89bf0bc79e06c1cde68db60adf2462 /css
parent8728712699ff8ff80bfce53308e073898c958c11 (diff)
downloadnetsurf-2920bca14adbf145d64754b1ef8e6b888c7995ee.tar.gz
netsurf-2920bca14adbf145d64754b1ef8e6b888c7995ee.tar.bz2
[project @ 2005-04-09 09:47:36 by bursa]
Move HTML contents almost fully over to talloc(), simplifying code. Improvements to title attributes, broken forms, cellpadding. Reorder functions in box_construct.c. svn path=/import/netsurf/; revision=1608
Diffstat (limited to 'css')
-rw-r--r--css/css.c34
-rw-r--r--css/css.h11
-rw-r--r--css/ruleset.c27
3 files changed, 24 insertions, 48 deletions
diff --git a/css/css.c b/css/css.c
index e1d1199f0..c188e7c11 100644
--- a/css/css.c
+++ b/css/css.c
@@ -110,7 +110,6 @@ static void css_dump_selector(const struct css_selector *r);
/** Default style for a document. These are the 'Initial values' from the
* spec. */
const struct css_style css_base_style = {
- { {CSS_CELLPADDING_VALUE, 1} },
CSS_BACKGROUND_ATTACHMENT_SCROLL,
0xffffff,
{ CSS_BACKGROUND_IMAGE_NONE, 0 },
@@ -167,10 +166,10 @@ const struct css_style css_base_style = {
{ CSS_BORDER_WIDTH_LENGTH, { 2, CSS_UNIT_PX } },
CSS_BORDER_STYLE_NONE },
CSS_OVERFLOW_VISIBLE,
- { { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false },
- { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false },
- { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false },
- { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false }, },
+ { { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } },
+ { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } },
+ { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } },
+ { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } } },
CSS_PAGE_BREAK_AFTER_AUTO,
CSS_PAGE_BREAK_BEFORE_AUTO,
CSS_PAGE_BREAK_INSIDE_AUTO,
@@ -196,7 +195,6 @@ const struct css_style css_base_style = {
/** Style with no values set. */
const struct css_style css_empty_style = {
- { { CSS_CELLPADDING_NOT_SET, 0 } },
CSS_BACKGROUND_ATTACHMENT_NOT_SET,
CSS_COLOR_NOT_SET,
{ CSS_BACKGROUND_IMAGE_NOT_SET, 0 },
@@ -253,10 +251,10 @@ const struct css_style css_empty_style = {
{ CSS_BORDER_WIDTH_NOT_SET, { 0, CSS_UNIT_PX } },
CSS_BORDER_STYLE_NOT_SET },
CSS_OVERFLOW_NOT_SET,
- { { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } }, false },
- { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } }, false },
- { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } }, false },
- { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } }, false }, },
+ { { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } } },
+ { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } } },
+ { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } } },
+ { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } } } },
CSS_PAGE_BREAK_AFTER_NOT_SET,
CSS_PAGE_BREAK_BEFORE_NOT_SET,
CSS_PAGE_BREAK_INSIDE_NOT_SET,
@@ -283,7 +281,6 @@ const struct css_style css_empty_style = {
/** Default style for an element. These should be INHERIT if 'Inherited' is yes,
* and the 'Initial value' otherwise. */
const struct css_style css_blank_style = {
- { { CSS_CELLPADDING_INHERIT, 0 } },
CSS_BACKGROUND_ATTACHMENT_SCROLL,
TRANSPARENT,
{ CSS_BACKGROUND_IMAGE_NONE, 0 },
@@ -340,10 +337,10 @@ const struct css_style css_blank_style = {
{ CSS_BORDER_WIDTH_LENGTH, { 2, CSS_UNIT_PX } },
CSS_BORDER_STYLE_NONE },
CSS_OVERFLOW_VISIBLE,
- { { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false },
- { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false },
- { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false },
- { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false }, },
+ { { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } },
+ { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } },
+ { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } },
+ { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } } },
CSS_PAGE_BREAK_AFTER_AUTO,
CSS_PAGE_BREAK_BEFORE_AUTO,
CSS_PAGE_BREAK_INSIDE_INHERIT,
@@ -2383,11 +2380,6 @@ void css_cascade(struct css_style * const style,
unsigned int i;
float f;
- if (apply->html_style.cellpadding.type !=
- CSS_CELLPADDING_INHERIT &&
- apply->html_style.cellpadding.type !=
- CSS_CELLPADDING_NOT_SET)
- style->html_style.cellpadding = apply->html_style.cellpadding;
if (apply->background_attachment !=
CSS_BACKGROUND_ATTACHMENT_INHERIT &&
apply->background_attachment !=
@@ -2678,8 +2670,6 @@ void css_merge(struct css_style * const style,
{
unsigned int i;
- if (apply->html_style.cellpadding.type != CSS_CELLPADDING_NOT_SET)
- style->html_style.cellpadding = apply->html_style.cellpadding;
if (apply->background_attachment != CSS_BACKGROUND_ATTACHMENT_NOT_SET)
style->background_attachment = apply->background_attachment;
if (apply->background_color != CSS_COLOR_NOT_SET)
diff --git a/css/css.h b/css/css.h
index 99e9b4463..d9701cbbe 100644
--- a/css/css.h
+++ b/css/css.h
@@ -149,16 +149,6 @@ struct css_content {
/** Representation of a complete CSS 2 style. */
struct css_style {
- /* html styles that don't translate directly to CSS */
- struct {
- struct {
- enum { CSS_CELLPADDING_INHERIT,
- CSS_CELLPADDING_VALUE,
- CSS_CELLPADDING_NOT_SET } type;
- int value;
- } cellpadding;
- } html_style;
-
/* background properties */
css_background_attachment background_attachment;
colour background_color;
@@ -378,7 +368,6 @@ struct css_style {
struct css_length length;
float percent;
} value;
- bool override_cellpadding; /* override HTML setting */
} padding[4]; /**< top, right, bottom, left */
css_page_break_after page_break_after;
diff --git a/css/ruleset.c b/css/ruleset.c
index 54d7ff87d..a5bb20f12 100644
--- a/css/ruleset.c
+++ b/css/ruleset.c
@@ -1153,7 +1153,7 @@ bool css_background_position_parse(const struct css_node **node,
*node = w->next;
return true;
}
-
+
/* reverse specifiers such that idents are places in h, v order */
if ((v->type == CSS_NODE_IDENT && bg && bg->vertical) ||
(w->type == CSS_NODE_IDENT && bg2 && bg2->horizontal)) {
@@ -1651,7 +1651,7 @@ void parse_content(struct css_style * const s, const struct css_node * v)
struct css_content *content;
struct css_node *t;
bool first = true;
-
+
for (; v; v = v->next) {
switch (v->type) {
case CSS_NODE_STRING:
@@ -1746,18 +1746,18 @@ void parse_content(struct css_style * const s, const struct css_node * v)
}
first = false;
}
-
+
if (new_content) {
css_deep_free_content(s->content.content);
s->content.type = CSS_CONTENT_INTERPRET;
- s->content.content = new_content;
+ s->content.content = new_content;
}
}
struct css_content *parse_content_new(struct css_content **current, css_content_type_generated generated) {
struct css_content *content;
struct css_content *link;
-
+
content = (struct css_content *)calloc(1, sizeof(struct css_content));
if (!content) {
css_deep_free_content(*current);
@@ -1777,15 +1777,15 @@ struct css_content *parse_content_new(struct css_content **current, css_content_
bool parse_content_counter(struct css_content **current, struct css_node *t, bool counters) {
struct css_content *content;
css_list_style_type z;
-
+
content = parse_content_new(current, CSS_CONTENT_COUNTER);
if ((!content) || (t->type != CSS_NODE_IDENT))
return false;
-
+
content->data.counter.name = strndup(t->data, t->data_length);
content->data.counter.style = CSS_LIST_STYLE_TYPE_DECIMAL;
t = t->next;
-
+
if (counters) {
if ((!t) || (t->type != CSS_NODE_STRING)) {
css_deep_free_content(*current);
@@ -1794,7 +1794,7 @@ bool parse_content_counter(struct css_content **current, struct css_node *t, boo
content->data.counter.separator = strndup(t->data, t->data_length);
t = t->next;
}
-
+
if (!t)
return true;
@@ -1818,7 +1818,7 @@ void parse_counter_reset(struct css_style * const s, const struct css_node * v)
css_deep_free_counter_control(s->counter_reset.data);
s->counter_reset.type = CSS_COUNTER_RESET_INTERPRET;
s->counter_reset.data = counter;
- }
+ }
}
void parse_counter_increment(struct css_style * const s, const struct css_node * v) {
@@ -1836,7 +1836,7 @@ void parse_counter_increment(struct css_style * const s, const struct css_node *
bool parse_counter_control_data(struct css_counter_control **current, const struct css_node * v, int empty) {
struct css_counter_control *open = NULL;
-
+
for (; v; v = v->next) {
switch (v->type) {
case CSS_NODE_IDENT:
@@ -1869,7 +1869,7 @@ bool parse_counter_control_data(struct css_counter_control **current, const stru
struct css_counter_control *parse_counter_control_new(struct css_counter_control **current) {
struct css_counter_control *counter;
struct css_counter_control *link;
-
+
counter = (struct css_counter_control *)calloc(1, sizeof(struct css_counter_control));
if (!counter) {
css_deep_free_counter_control(*current);
@@ -2683,15 +2683,12 @@ void parse_padding_side(struct css_style * const s, const struct css_node * cons
if (v->type == CSS_NODE_IDENT && v->data_length == 7 &&
strncasecmp(v->data, "inherit", 7) == 0) {
s->padding[i].padding = CSS_PADDING_INHERIT;
- s->padding[i].override_cellpadding = true;
} else if (v->type == CSS_NODE_PERCENTAGE) {
s->padding[i].padding = CSS_PADDING_PERCENT;
s->padding[i].value.percent = atof(v->data);
- s->padding[i].override_cellpadding = true;
} else if ((v->type == CSS_NODE_DIMENSION || v->type == CSS_NODE_NUMBER) &&
parse_length(&s->padding[i].value.length, v, true) == 0) {
s->padding[i].padding = CSS_PADDING_LENGTH;
- s->padding[i].override_cellpadding = true;
}
}