diff --git a/src/document/css/apply.c b/src/document/css/apply.c index f4b03ea6..ed606958 100644 --- a/src/document/css/apply.c +++ b/src/document/css/apply.c @@ -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, diff --git a/src/document/css/property.c b/src/document/css/property.c index 40f6fae6..06f3b450 100644 --- a/src/document/css/property.c +++ b/src/document/css/property.c @@ -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 }, diff --git a/src/document/css/property.h b/src/document/css/property.h index 66ed09ed..3679196c 100644 --- a/src/document/css/property.h +++ b/src/document/css/property.h @@ -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, diff --git a/src/document/css/value.h b/src/document/css/value.h index 83e06676..0e3af600 100644 --- a/src/document/css/value.h +++ b/src/document/css/value.h @@ -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 diff --git a/src/document/dom/util.c b/src/document/dom/util.c index 020016be..7b084b2b 100644 --- a/src/document/dom/util.c +++ b/src/document/dom/util.c @@ -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; }