1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-27 01:25:34 +00:00

CSS: add support for margin-left and margin-right

This commit is contained in:
Jonas Fonseca 2007-09-06 23:26:54 +02:00
parent 7d6cb2bb53
commit 146c6e650d
5 changed files with 32 additions and 0 deletions

View File

@ -154,6 +154,25 @@ css_apply_text_align(struct html_context *html_context,
element->parattr.align = prop->value.text_align;
}
void
css_apply_margin(struct html_context *html_context,
struct html_element *element,
struct css_property *prop)
{
struct par_attrib *parattr = &element->parattr;
assert(prop->value_type == CSS_VT_LENGTH);
if (prop->type == CSS_PT_MARGIN_LEFT) {
parattr->leftmargin = length_absolute(parattr->leftmargin,
&prop->value.length);
} else if (prop->type == CSS_PT_MARGIN_RIGHT) {
parattr->rightmargin = length_absolute(parattr->rightmargin,
&prop->value.length);
}
}
/*! XXX: Sort like the css_property_type */
static const css_applier_T css_appliers[CSS_PT_LAST] = {
/* CSS_PT_NONE */ NULL,
@ -164,6 +183,8 @@ static const css_applier_T css_appliers[CSS_PT_LAST] = {
/* CSS_PT_DISPLAY */ css_apply_display,
/* CSS_PT_FONT_STYLE */ css_apply_font_attribute,
/* CSS_PT_FONT_WEIGHT */ css_apply_font_attribute,
/* CSS_PT_MARGIN_LEFT */ css_apply_margin,
/* CSS_PT_MARGIN_RIGHT */ css_apply_margin,
/* CSS_PT_TEXT_ALIGN */ css_apply_text_align,
/* CSS_PT_TEXT_DECORATION */ css_apply_font_attribute,
/* CSS_PT_WHITE_SPACE */ css_apply_font_attribute,

View File

@ -23,6 +23,8 @@ struct css_property_info css_property_info[CSS_PT_LAST] = {
{ "display", CSS_PT_DISPLAY, CSS_VT_DISPLAY, css_parse_display_value },
{ "font-style", CSS_PT_FONT_STYLE, CSS_VT_FONT_ATTRIBUTE, css_parse_font_style_value },
{ "font-weight", CSS_PT_FONT_WEIGHT, CSS_VT_FONT_ATTRIBUTE, css_parse_font_weight_value },
{ "margin-left", CSS_PT_MARGIN_LEFT, CSS_VT_LENGTH, css_parse_length_value },
{ "margin-right", CSS_PT_MARGIN_RIGHT, CSS_VT_LENGTH, css_parse_length_value },
{ "text-align", CSS_PT_TEXT_ALIGN, CSS_VT_TEXT_ALIGN, css_parse_text_align_value },
{ "text-decoration", CSS_PT_TEXT_DECORATION, CSS_VT_FONT_ATTRIBUTE, css_parse_text_decoration_value },
{ "white-space", CSS_PT_WHITE_SPACE, CSS_VT_FONT_ATTRIBUTE, css_parse_white_space_value },

View File

@ -24,6 +24,8 @@ struct css_property {
CSS_PT_DISPLAY,
CSS_PT_FONT_STYLE,
CSS_PT_FONT_WEIGHT,
CSS_PT_MARGIN_LEFT,
CSS_PT_MARGIN_RIGHT,
CSS_PT_TEXT_ALIGN,
CSS_PT_TEXT_DECORATION,
CSS_PT_WHITE_SPACE,

View File

@ -67,4 +67,9 @@ int css_parse_length_value(struct css_property_info *propinfo,
union css_property_value *value,
struct scanner *scanner);
/*! Takes no parser_data. */
int css_parse_margin(struct css_property_info *propinfo,
union css_property_value *value,
struct scanner *scanner);
#endif

View File

@ -65,6 +65,8 @@ init_template_by_style(struct screen_char *template, struct document_options *op
case CSS_PT_TEXT_ALIGN:
case CSS_PT_WHITE_SPACE:
case CSS_PT_FONT_SIZE:
case CSS_PT_MARGIN_LEFT:
case CSS_PT_MARGIN_RIGHT:
case CSS_PT_LAST:
break;
}