mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-02-05 00:54:06 +03:00
[project @ 2004-08-01 21:56:47 by jmb]
Rationalise top, bottom, right and left property handling svn path=/import/netsurf/; revision=1174
This commit is contained in:
parent
dcb72507b2
commit
6103e3f0cd
162
css/css.c
162
css/css.c
@ -3,6 +3,7 @@
|
||||
* Licensed under the GNU General Public License,
|
||||
* http://www.opensource.org/licenses/gpl-license
|
||||
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2004 John M Bell <jmb202@ecs.soton.ac.uk>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
@ -120,7 +121,6 @@ const struct css_style css_base_style = {
|
||||
CSS_BORDER_COLLAPSE_SEPARATE,
|
||||
{ CSS_BORDER_SPACING_LENGTH,
|
||||
{ 0, CSS_UNIT_PX }, { 0, CSS_UNIT_PX } },
|
||||
{ CSS_BOTTOM_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
CSS_CAPTION_SIDE_TOP,
|
||||
CSS_CLEAR_NONE,
|
||||
{ CSS_CLIP_AUTO, { { CSS_CLIP_RECT_AUTO, { 0, CSS_UNIT_PX } },
|
||||
@ -139,7 +139,6 @@ const struct css_style css_base_style = {
|
||||
CSS_FONT_VARIANT_NORMAL,
|
||||
CSS_FONT_WEIGHT_NORMAL,
|
||||
{ CSS_HEIGHT_AUTO, { 1, CSS_UNIT_EM } },
|
||||
{ CSS_LEFT_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
{ CSS_LETTER_SPACING_NORMAL, { 0, CSS_UNIT_PX } },
|
||||
{ CSS_LINE_HEIGHT_ABSOLUTE, { 1.3 } },
|
||||
{ CSS_LIST_STYLE_IMAGE_NONE, 0 },
|
||||
@ -165,14 +164,16 @@ const struct css_style css_base_style = {
|
||||
CSS_PAGE_BREAK_AFTER_AUTO,
|
||||
CSS_PAGE_BREAK_BEFORE_AUTO,
|
||||
CSS_PAGE_BREAK_INSIDE_AUTO,
|
||||
{ { CSS_POS_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
{ CSS_POS_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
{ CSS_POS_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
{ CSS_POS_AUTO, { { 0, CSS_UNIT_PX } } } },
|
||||
CSS_POSITION_STATIC,
|
||||
{ CSS_RIGHT_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
CSS_TABLE_LAYOUT_AUTO,
|
||||
CSS_TEXT_ALIGN_LEFT,
|
||||
CSS_TEXT_DECORATION_NONE,
|
||||
{ CSS_TEXT_INDENT_LENGTH, { { 0, CSS_UNIT_EM } } },
|
||||
CSS_TEXT_TRANSFORM_NONE,
|
||||
{ CSS_TOP_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
CSS_UNICODE_BIDI_NORMAL,
|
||||
{ CSS_VERTICAL_ALIGN_BASELINE, { { 0, CSS_UNIT_PX } } },
|
||||
CSS_VISIBILITY_VISIBLE,
|
||||
@ -202,7 +203,6 @@ const struct css_style css_empty_style = {
|
||||
CSS_BORDER_COLLAPSE_INHERIT,
|
||||
{ CSS_BORDER_SPACING_INHERIT,
|
||||
{ 0, CSS_UNIT_PX }, { 0, CSS_UNIT_PX } },
|
||||
{ CSS_BOTTOM_INHERIT, { { 0, CSS_UNIT_PX } } },
|
||||
CSS_CAPTION_SIDE_INHERIT,
|
||||
CSS_CLEAR_INHERIT,
|
||||
{ CSS_CLIP_INHERIT, { { CSS_CLIP_RECT_AUTO, { 0, CSS_UNIT_PX } },
|
||||
@ -221,7 +221,6 @@ const struct css_style css_empty_style = {
|
||||
CSS_FONT_VARIANT_INHERIT,
|
||||
CSS_FONT_WEIGHT_INHERIT,
|
||||
{ CSS_HEIGHT_INHERIT, { 1, CSS_UNIT_EM } },
|
||||
{ CSS_LEFT_INHERIT, { { 0, CSS_UNIT_PX } } },
|
||||
{ CSS_LETTER_SPACING_INHERIT, { 0, CSS_UNIT_PX } },
|
||||
{ CSS_LINE_HEIGHT_INHERIT, { 1.3 } },
|
||||
{ CSS_LIST_STYLE_IMAGE_INHERIT, 0 },
|
||||
@ -247,14 +246,16 @@ const struct css_style css_empty_style = {
|
||||
CSS_PAGE_BREAK_AFTER_INHERIT,
|
||||
CSS_PAGE_BREAK_BEFORE_INHERIT,
|
||||
CSS_PAGE_BREAK_INSIDE_INHERIT,
|
||||
{ { CSS_POS_INHERIT, { { 0, CSS_UNIT_PX } } },
|
||||
{ CSS_POS_INHERIT, { { 0, CSS_UNIT_PX } } },
|
||||
{ CSS_POS_INHERIT, { { 0, CSS_UNIT_PX } } },
|
||||
{ CSS_POS_INHERIT, { { 0, CSS_UNIT_PX } } } },
|
||||
CSS_POSITION_INHERIT,
|
||||
{ CSS_RIGHT_INHERIT, { { 0, CSS_UNIT_PX } } },
|
||||
CSS_TABLE_LAYOUT_INHERIT,
|
||||
CSS_TEXT_ALIGN_INHERIT,
|
||||
CSS_TEXT_DECORATION_INHERIT,
|
||||
{ CSS_TEXT_INDENT_INHERIT, { { 0, CSS_UNIT_EM } } },
|
||||
CSS_TEXT_TRANSFORM_INHERIT,
|
||||
{ CSS_TOP_INHERIT, { { 0, CSS_UNIT_PX } } },
|
||||
CSS_UNICODE_BIDI_INHERIT,
|
||||
{ CSS_VERTICAL_ALIGN_INHERIT, { { 0, CSS_UNIT_PX } } },
|
||||
CSS_VISIBILITY_INHERIT,
|
||||
@ -285,7 +286,6 @@ const struct css_style css_blank_style = {
|
||||
CSS_BORDER_COLLAPSE_INHERIT,
|
||||
{ CSS_BORDER_SPACING_INHERIT,
|
||||
{ 0, CSS_UNIT_PX }, { 0, CSS_UNIT_PX } },
|
||||
{ CSS_BOTTOM_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
CSS_CAPTION_SIDE_INHERIT,
|
||||
CSS_CLEAR_NONE,
|
||||
{ CSS_CLIP_AUTO, { { CSS_CLIP_RECT_AUTO, { 0, CSS_UNIT_PX } },
|
||||
@ -304,7 +304,6 @@ const struct css_style css_blank_style = {
|
||||
CSS_FONT_VARIANT_INHERIT,
|
||||
CSS_FONT_WEIGHT_INHERIT,
|
||||
{ CSS_HEIGHT_AUTO, { 1, CSS_UNIT_EM } },
|
||||
{ CSS_LEFT_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
{ CSS_LETTER_SPACING_INHERIT, { 0, CSS_UNIT_PX } },
|
||||
{ CSS_LINE_HEIGHT_INHERIT, { 1.3 } },
|
||||
{ CSS_LIST_STYLE_IMAGE_INHERIT, 0 },
|
||||
@ -330,14 +329,16 @@ const struct css_style css_blank_style = {
|
||||
CSS_PAGE_BREAK_AFTER_AUTO,
|
||||
CSS_PAGE_BREAK_BEFORE_AUTO,
|
||||
CSS_PAGE_BREAK_INSIDE_INHERIT,
|
||||
{ { CSS_POS_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
{ CSS_POS_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
{ CSS_POS_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
{ CSS_POS_AUTO, { { 0, CSS_UNIT_PX } } } },
|
||||
CSS_POSITION_STATIC,
|
||||
{ CSS_RIGHT_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
CSS_TABLE_LAYOUT_AUTO,
|
||||
CSS_TEXT_ALIGN_INHERIT,
|
||||
CSS_TEXT_DECORATION_INHERIT,
|
||||
{ CSS_TEXT_INDENT_INHERIT, { { 0, CSS_UNIT_EM } } },
|
||||
CSS_TEXT_TRANSFORM_INHERIT,
|
||||
{ CSS_TOP_AUTO, { { 0, CSS_UNIT_PX } } },
|
||||
CSS_UNICODE_BIDI_NORMAL,
|
||||
{ CSS_VERTICAL_ALIGN_BASELINE, { { 0, CSS_UNIT_PX } } },
|
||||
CSS_VISIBILITY_INHERIT,
|
||||
@ -1271,25 +1272,7 @@ void css_dump_style(const struct css_style * const style)
|
||||
css_dump_length(&style->border_spacing.vert);
|
||||
fprintf(stderr, "; ");
|
||||
}
|
||||
if (style->bottom.bottom != css_empty_style.bottom.bottom) {
|
||||
fprintf(stderr, "bottom: ");
|
||||
switch (style->bottom.bottom) {
|
||||
case CSS_BOTTOM_INHERIT:
|
||||
fprintf(stderr, "inherit");
|
||||
break;
|
||||
case CSS_BOTTOM_AUTO:
|
||||
fprintf(stderr, "auto");
|
||||
break;
|
||||
case CSS_BOTTOM_PERCENT:
|
||||
fprintf(stderr, "%g%%",
|
||||
style->bottom.value.percent);
|
||||
break;
|
||||
case CSS_BOTTOM_LENGTH:
|
||||
css_dump_length(&style->bottom.value.length);
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "; ");
|
||||
}
|
||||
|
||||
DUMP_KEYWORD(caption_side, "caption-side", css_caption_side_name);
|
||||
DUMP_KEYWORD(clear, "clear", css_clear_name);
|
||||
|
||||
@ -1398,26 +1381,6 @@ void css_dump_style(const struct css_style * const style)
|
||||
fprintf(stderr, "; ");
|
||||
}
|
||||
|
||||
if (style->left.left != css_empty_style.left.left) {
|
||||
fprintf(stderr, "left: ");
|
||||
switch (style->left.left) {
|
||||
case CSS_LEFT_INHERIT:
|
||||
fprintf(stderr, "inherit");
|
||||
break;
|
||||
case CSS_LEFT_AUTO:
|
||||
fprintf(stderr, "auto");
|
||||
break;
|
||||
case CSS_LEFT_PERCENT:
|
||||
fprintf(stderr, "%g%%",
|
||||
style->left.value.percent);
|
||||
break;
|
||||
case CSS_LEFT_LENGTH:
|
||||
css_dump_length(&style->left.value.length);
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "; ");
|
||||
}
|
||||
|
||||
if (style->letter_spacing.letter_spacing != css_empty_style.letter_spacing.letter_spacing) {
|
||||
fprintf(stderr, "letter-spacing: ");
|
||||
switch (style->letter_spacing.letter_spacing) {
|
||||
@ -1639,27 +1602,42 @@ void css_dump_style(const struct css_style * const style)
|
||||
DUMP_KEYWORD(page_break_after, "page-break-after", css_page_break_after_name);
|
||||
DUMP_KEYWORD(page_break_before, "page-break-before", css_page_break_before_name);
|
||||
DUMP_KEYWORD(page_break_inside, "page-break-inside", css_page_break_inside_name);
|
||||
DUMP_KEYWORD(position, "position", css_position_name);
|
||||
|
||||
if (style->right.right != css_empty_style.right.right) {
|
||||
fprintf(stderr, "right: ");
|
||||
switch (style->right.right) {
|
||||
case CSS_RIGHT_INHERIT:
|
||||
fprintf(stderr, "inherit");
|
||||
break;
|
||||
case CSS_RIGHT_AUTO:
|
||||
fprintf(stderr, "auto");
|
||||
break;
|
||||
case CSS_RIGHT_PERCENT:
|
||||
fprintf(stderr, "%g%%",
|
||||
style->right.value.percent);
|
||||
break;
|
||||
case CSS_RIGHT_LENGTH:
|
||||
css_dump_length(&style->right.value.length);
|
||||
break;
|
||||
for (i = 0; i != 4; i++) {
|
||||
if (style->pos[i].pos != css_empty_style.pos[i].pos) {
|
||||
switch (i) {
|
||||
case TOP:
|
||||
fprintf(stderr, "top: ");
|
||||
break;
|
||||
case RIGHT:
|
||||
fprintf(stderr, "right: ");
|
||||
break;
|
||||
case BOTTOM:
|
||||
fprintf(stderr, "bottom: ");
|
||||
break;
|
||||
case LEFT:
|
||||
fprintf(stderr, "left: ");
|
||||
break;
|
||||
}
|
||||
switch (style->pos[i].pos) {
|
||||
case CSS_POS_INHERIT:
|
||||
fprintf(stderr, "inherit");
|
||||
break;
|
||||
case CSS_POS_AUTO:
|
||||
fprintf(stderr, "auto");
|
||||
break;
|
||||
case CSS_POS_PERCENT:
|
||||
fprintf(stderr, "%g%%",
|
||||
style->pos[i].value.percent);
|
||||
break;
|
||||
case CSS_POS_LENGTH:
|
||||
css_dump_length(&style->pos[i].value.length);
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "; ");
|
||||
}
|
||||
fprintf(stderr, "; ");
|
||||
}
|
||||
DUMP_KEYWORD(position, "position", css_position_name);
|
||||
|
||||
DUMP_KEYWORD(table_layout, "table-layout", css_table_layout_name);
|
||||
DUMP_KEYWORD(text_align, "text-align", css_text_align_name);
|
||||
@ -1703,26 +1681,6 @@ void css_dump_style(const struct css_style * const style)
|
||||
|
||||
DUMP_KEYWORD(text_transform, "text-transform", css_text_transform_name);
|
||||
|
||||
if (style->top.top != css_empty_style.top.top) {
|
||||
fprintf(stderr, "top: ");
|
||||
switch (style->top.top) {
|
||||
case CSS_TOP_INHERIT:
|
||||
fprintf(stderr, "inherit");
|
||||
break;
|
||||
case CSS_TOP_AUTO:
|
||||
fprintf(stderr, "auto");
|
||||
break;
|
||||
case CSS_TOP_PERCENT:
|
||||
fprintf(stderr, "%g%%",
|
||||
style->top.value.percent);
|
||||
break;
|
||||
case CSS_TOP_LENGTH:
|
||||
css_dump_length(&style->top.value.length);
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "; ");
|
||||
}
|
||||
|
||||
DUMP_KEYWORD(unicode_bidi, "unicode-bidi", css_unicode_bidi_name);
|
||||
|
||||
if (style->vertical_align.type != css_empty_style.vertical_align.type) {
|
||||
@ -1980,8 +1938,6 @@ void css_cascade(struct css_style * const style,
|
||||
style->border_collapse = apply->border_collapse;
|
||||
if (apply->border_spacing.border_spacing != CSS_BORDER_SPACING_INHERIT)
|
||||
style->border_spacing = apply->border_spacing;
|
||||
if (apply->bottom.bottom != CSS_BOTTOM_INHERIT)
|
||||
style->bottom = apply->bottom;
|
||||
if (apply->caption_side != CSS_CAPTION_SIDE_INHERIT)
|
||||
style->caption_side = apply->caption_side;
|
||||
if (apply->clear != CSS_CLEAR_INHERIT)
|
||||
@ -2008,8 +1964,6 @@ void css_cascade(struct css_style * const style,
|
||||
style->font_weight = apply->font_weight;
|
||||
if (apply->height.height != CSS_HEIGHT_INHERIT)
|
||||
style->height = apply->height;
|
||||
if (apply->left.left != CSS_LEFT_INHERIT)
|
||||
style->left = apply->left;
|
||||
if (apply->letter_spacing.letter_spacing != CSS_LETTER_SPACING_INHERIT)
|
||||
style->letter_spacing = apply->letter_spacing;
|
||||
if (apply->line_height.size != CSS_LINE_HEIGHT_INHERIT)
|
||||
@ -2040,8 +1994,6 @@ void css_cascade(struct css_style * const style,
|
||||
style->page_break_inside = apply->page_break_inside;
|
||||
if (apply->position != CSS_POSITION_INHERIT)
|
||||
style->position = apply->position;
|
||||
if (apply->right.right != CSS_RIGHT_INHERIT)
|
||||
style->right = apply->right;
|
||||
if (apply->table_layout != CSS_TABLE_LAYOUT_INHERIT)
|
||||
style->table_layout = apply->table_layout;
|
||||
if (apply->text_align != CSS_TEXT_ALIGN_INHERIT)
|
||||
@ -2053,8 +2005,6 @@ void css_cascade(struct css_style * const style,
|
||||
style->text_indent = apply->text_indent;
|
||||
if (apply->text_transform != CSS_TEXT_TRANSFORM_INHERIT)
|
||||
style->text_transform = apply->text_transform;
|
||||
if (apply->top.top != CSS_TOP_INHERIT)
|
||||
style->top = apply->top;
|
||||
if (apply->unicode_bidi != CSS_UNICODE_BIDI_INHERIT)
|
||||
style->unicode_bidi = apply->unicode_bidi;
|
||||
if (apply->vertical_align.type != CSS_VERTICAL_ALIGN_INHERIT)
|
||||
@ -2135,7 +2085,7 @@ void css_cascade(struct css_style * const style,
|
||||
if (apply->outline.style != CSS_BORDER_STYLE_INHERIT)
|
||||
style->outline.style = apply->outline.style;
|
||||
|
||||
/* borders, margins and padding */
|
||||
/* borders, margins, padding and box position */
|
||||
for (i = 0; i != 4; i++) {
|
||||
if (apply->border[i].color != CSS_COLOR_INHERIT)
|
||||
style->border[i].color = apply->border[i].color;
|
||||
@ -2149,6 +2099,9 @@ void css_cascade(struct css_style * const style,
|
||||
|
||||
if (apply->padding[i].padding != CSS_PADDING_INHERIT)
|
||||
style->padding[i] = apply->padding[i];
|
||||
|
||||
if (apply->pos[i].pos != CSS_POS_INHERIT)
|
||||
style->pos[i] = apply->pos[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -2180,8 +2133,6 @@ void css_merge(struct css_style * const style,
|
||||
style->border_collapse = apply->border_collapse;
|
||||
if (apply->border_spacing.border_spacing != CSS_BORDER_SPACING_INHERIT)
|
||||
style->border_spacing = apply->border_spacing;
|
||||
if (apply->bottom.bottom != CSS_BOTTOM_INHERIT)
|
||||
style->bottom = apply->bottom;
|
||||
if (apply->caption_side != CSS_CAPTION_SIDE_INHERIT)
|
||||
style->caption_side = apply->caption_side;
|
||||
if (apply->clear != CSS_CLEAR_INHERIT)
|
||||
@ -2210,8 +2161,6 @@ void css_merge(struct css_style * const style,
|
||||
style->font_weight = apply->font_weight;
|
||||
if (apply->height.height != CSS_HEIGHT_INHERIT)
|
||||
style->height = apply->height;
|
||||
if (apply->left.left != CSS_LEFT_INHERIT)
|
||||
style->left = apply->left;
|
||||
if (apply->letter_spacing.letter_spacing != CSS_LETTER_SPACING_INHERIT)
|
||||
style->letter_spacing = apply->letter_spacing;
|
||||
if (apply->line_height.size != CSS_LINE_HEIGHT_INHERIT)
|
||||
@ -2242,8 +2191,6 @@ void css_merge(struct css_style * const style,
|
||||
style->page_break_inside = apply->page_break_inside;
|
||||
if (apply->position != CSS_POSITION_INHERIT)
|
||||
style->position = apply->position;
|
||||
if (apply->right.right != CSS_RIGHT_INHERIT)
|
||||
style->right = apply->right;
|
||||
if (apply->table_layout != CSS_TABLE_LAYOUT_INHERIT)
|
||||
style->table_layout = apply->table_layout;
|
||||
if (apply->text_align != CSS_TEXT_ALIGN_INHERIT)
|
||||
@ -2255,8 +2202,6 @@ void css_merge(struct css_style * const style,
|
||||
style->text_indent = apply->text_indent;
|
||||
if (apply->text_transform != CSS_TEXT_TRANSFORM_INHERIT)
|
||||
style->text_transform = apply->text_transform;
|
||||
if (apply->top.top != CSS_TOP_INHERIT)
|
||||
style->top = apply->top;
|
||||
if (apply->unicode_bidi != CSS_UNICODE_BIDI_INHERIT)
|
||||
style->unicode_bidi = apply->unicode_bidi;
|
||||
if (apply->vertical_align.type != CSS_VERTICAL_ALIGN_INHERIT)
|
||||
@ -2298,7 +2243,7 @@ void css_merge(struct css_style * const style,
|
||||
if (apply->outline.style != CSS_BORDER_STYLE_INHERIT)
|
||||
style->outline.style = apply->outline.style;
|
||||
|
||||
/* borders, margins and padding */
|
||||
/* borders, margins, padding and box position */
|
||||
for (i = 0; i != 4; i++) {
|
||||
if (apply->border[i].color != CSS_COLOR_INHERIT)
|
||||
style->border[i].color = apply->border[i].color;
|
||||
@ -2312,6 +2257,9 @@ void css_merge(struct css_style * const style,
|
||||
|
||||
if (apply->padding[i].padding != CSS_PADDING_INHERIT)
|
||||
style->padding[i] = apply->padding[i];
|
||||
|
||||
if (apply->pos[i].pos != CSS_POS_INHERIT)
|
||||
style->pos[i] = apply->pos[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
52
css/css.h
52
css/css.h
@ -3,6 +3,7 @@
|
||||
* Licensed under the GNU General Public License,
|
||||
* http://www.opensource.org/licenses/gpl-license
|
||||
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2004 John M Bell <jmb202@ecs.soton.ac.uk>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
@ -134,17 +135,6 @@ struct css_style {
|
||||
struct css_length vert;
|
||||
} border_spacing;
|
||||
|
||||
struct {
|
||||
enum { CSS_BOTTOM_INHERIT,
|
||||
CSS_BOTTOM_AUTO,
|
||||
CSS_BOTTOM_PERCENT,
|
||||
CSS_BOTTOM_LENGTH } bottom;
|
||||
union {
|
||||
struct css_length length;
|
||||
float percent;
|
||||
} value;
|
||||
} bottom;
|
||||
|
||||
css_caption_side caption_side;
|
||||
css_clear clear;
|
||||
|
||||
@ -193,17 +183,6 @@ struct css_style {
|
||||
struct css_length length;
|
||||
} height;
|
||||
|
||||
struct {
|
||||
enum { CSS_LEFT_INHERIT,
|
||||
CSS_LEFT_AUTO,
|
||||
CSS_LEFT_PERCENT,
|
||||
CSS_LEFT_LENGTH } left;
|
||||
union {
|
||||
struct css_length length;
|
||||
float percent;
|
||||
} value;
|
||||
} left;
|
||||
|
||||
struct {
|
||||
enum { CSS_LETTER_SPACING_INHERIT,
|
||||
CSS_LETTER_SPACING_NORMAL,
|
||||
@ -315,20 +294,20 @@ struct css_style {
|
||||
css_page_break_before page_break_before;
|
||||
css_page_break_inside page_break_inside;
|
||||
|
||||
css_position position;
|
||||
|
||||
/** \todo quotes */
|
||||
|
||||
struct {
|
||||
enum { CSS_RIGHT_INHERIT,
|
||||
CSS_RIGHT_AUTO,
|
||||
CSS_RIGHT_PERCENT,
|
||||
CSS_RIGHT_LENGTH } right;
|
||||
enum { CSS_POS_INHERIT,
|
||||
CSS_POS_AUTO,
|
||||
CSS_POS_PERCENT,
|
||||
CSS_POS_LENGTH } pos;
|
||||
union {
|
||||
struct css_length length;
|
||||
float percent;
|
||||
} value;
|
||||
} right;
|
||||
} pos[4]; /**< top, right, bottom, left */
|
||||
|
||||
css_position position;
|
||||
|
||||
/** \todo quotes */
|
||||
|
||||
css_table_layout table_layout;
|
||||
|
||||
@ -346,17 +325,6 @@ struct css_style {
|
||||
} text_indent;
|
||||
css_text_transform text_transform;
|
||||
|
||||
struct {
|
||||
enum { CSS_TOP_INHERIT,
|
||||
CSS_TOP_AUTO,
|
||||
CSS_TOP_PERCENT,
|
||||
CSS_TOP_LENGTH } top;
|
||||
union {
|
||||
struct css_length length;
|
||||
float percent;
|
||||
} value;
|
||||
} top;
|
||||
|
||||
css_unicode_bidi unicode_bidi;
|
||||
|
||||
struct {
|
||||
|
128
css/ruleset.c
128
css/ruleset.c
@ -3,6 +3,7 @@
|
||||
* Licensed under the GNU General Public License,
|
||||
* http://www.opensource.org/licenses/gpl-license
|
||||
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2004 John M Bell <jmb202@ecs.soton.ac.uk>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
@ -138,6 +139,7 @@ static void parse_padding_side(struct css_style * const s, const struct css_node
|
||||
static void parse_page_break_after(struct css_style * const s, const struct css_node * v);
|
||||
static void parse_page_break_before(struct css_style * const s, const struct css_node * v);
|
||||
static void parse_page_break_inside(struct css_style * const s, const struct css_node * v);
|
||||
static void parse_pos(struct css_style * const s, const struct css_node * v, unsigned int i);
|
||||
static void parse_position(struct css_style * const s, const struct css_node * v);
|
||||
static void parse_right(struct css_style * const s, const struct css_node * v);
|
||||
static void parse_table_layout(struct css_style * const s, const struct css_node * v);
|
||||
@ -1355,34 +1357,6 @@ void parse_border_spacing(struct css_style * const s, const struct css_node * v)
|
||||
}
|
||||
}
|
||||
|
||||
void parse_bottom(struct css_style * const s, const struct css_node * v)
|
||||
{
|
||||
if (v->next != 0)
|
||||
return;
|
||||
|
||||
switch (v->type) {
|
||||
case CSS_NODE_IDENT:
|
||||
if (v->data_length == 7 &&
|
||||
strncasecmp(v->data, "inherit", 7) == 0)
|
||||
s->bottom.bottom = CSS_BOTTOM_INHERIT;
|
||||
else if (v->data_length == 4 &&
|
||||
strncasecmp(v->data, "auto", 4) == 0)
|
||||
s->bottom.bottom = CSS_BOTTOM_AUTO;
|
||||
break;
|
||||
case CSS_NODE_DIMENSION:
|
||||
case CSS_NODE_NUMBER:
|
||||
if (parse_length(&s->bottom.value.length, v, false) == 0)
|
||||
s->bottom.bottom = CSS_BOTTOM_LENGTH;
|
||||
break;
|
||||
case CSS_NODE_PERCENTAGE:
|
||||
s->bottom.bottom = CSS_BOTTOM_PERCENT;
|
||||
s->bottom.value.percent = atof(v->data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void parse_caption_side(struct css_style * const s, const struct css_node * v)
|
||||
{
|
||||
css_caption_side z;
|
||||
@ -1695,34 +1669,6 @@ void parse_height(struct css_style * const s, const struct css_node * const v)
|
||||
s->height.height = CSS_HEIGHT_LENGTH;
|
||||
}
|
||||
|
||||
void parse_left(struct css_style * const s, const struct css_node * v)
|
||||
{
|
||||
if (v->next != 0)
|
||||
return;
|
||||
|
||||
switch (v->type) {
|
||||
case CSS_NODE_IDENT:
|
||||
if (v->data_length == 7 &&
|
||||
strncasecmp(v->data, "inherit", 7) == 0)
|
||||
s->left.left = CSS_LEFT_INHERIT;
|
||||
else if (v->data_length == 4 &&
|
||||
strncasecmp(v->data, "auto", 4) == 0)
|
||||
s->left.left = CSS_LEFT_AUTO;
|
||||
break;
|
||||
case CSS_NODE_DIMENSION:
|
||||
case CSS_NODE_NUMBER:
|
||||
if (parse_length(&s->left.value.length, v, false) == 0)
|
||||
s->left.left = CSS_LEFT_LENGTH;
|
||||
break;
|
||||
case CSS_NODE_PERCENTAGE:
|
||||
s->left.left = CSS_LEFT_PERCENT;
|
||||
s->left.value.percent = atof(v->data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void parse_letter_spacing(struct css_style * const s, const struct css_node * v)
|
||||
{
|
||||
if (v->next != 0)
|
||||
@ -2381,17 +2327,19 @@ void parse_page_break_inside(struct css_style * const s, const struct css_node *
|
||||
s->page_break_inside = z;
|
||||
}
|
||||
|
||||
void parse_position(struct css_style * const s, const struct css_node * v)
|
||||
{
|
||||
css_position z;
|
||||
if (v->type != CSS_NODE_IDENT || v->next != 0)
|
||||
return;
|
||||
z = css_position_parse(v->data, v->data_length);
|
||||
if (z != CSS_POSITION_UNKNOWN)
|
||||
s->position = z;
|
||||
#define PARSE_POS(side, z) \
|
||||
void parse_ ## side(struct css_style * const s, \
|
||||
const struct css_node * const v) \
|
||||
{ \
|
||||
parse_pos(s, v, z); \
|
||||
}
|
||||
|
||||
void parse_right(struct css_style * const s, const struct css_node * v)
|
||||
PARSE_POS(top, TOP)
|
||||
PARSE_POS(right, RIGHT)
|
||||
PARSE_POS(bottom, BOTTOM)
|
||||
PARSE_POS(left, LEFT)
|
||||
|
||||
void parse_pos(struct css_style * const s, const struct css_node * v, unsigned int i)
|
||||
{
|
||||
if (v->next != 0)
|
||||
return;
|
||||
@ -2400,25 +2348,35 @@ void parse_right(struct css_style * const s, const struct css_node * v)
|
||||
case CSS_NODE_IDENT:
|
||||
if (v->data_length == 7 &&
|
||||
strncasecmp(v->data, "inherit", 7) == 0)
|
||||
s->right.right = CSS_RIGHT_INHERIT;
|
||||
s->pos[i].pos = CSS_POS_INHERIT;
|
||||
else if (v->data_length == 4 &&
|
||||
strncasecmp(v->data, "auto", 4) == 0)
|
||||
s->right.right = CSS_RIGHT_AUTO;
|
||||
s->pos[i].pos = CSS_POS_AUTO;
|
||||
break;
|
||||
case CSS_NODE_DIMENSION:
|
||||
case CSS_NODE_NUMBER:
|
||||
if (parse_length(&s->right.value.length, v, false) == 0)
|
||||
s->right.right = CSS_RIGHT_LENGTH;
|
||||
if (parse_length(&s->pos[i].value.length, v, false) == 0)
|
||||
s->pos[i].pos = CSS_POS_LENGTH;
|
||||
break;
|
||||
case CSS_NODE_PERCENTAGE:
|
||||
s->right.right = CSS_RIGHT_PERCENT;
|
||||
s->right.value.percent = atof(v->data);
|
||||
s->pos[i].pos = CSS_POS_PERCENT;
|
||||
s->pos[i].value.percent = atof(v->data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void parse_position(struct css_style * const s, const struct css_node * v)
|
||||
{
|
||||
css_position z;
|
||||
if (v->type != CSS_NODE_IDENT || v->next != 0)
|
||||
return;
|
||||
z = css_position_parse(v->data, v->data_length);
|
||||
if (z != CSS_POSITION_UNKNOWN)
|
||||
s->position = z;
|
||||
}
|
||||
|
||||
void parse_table_layout(struct css_style * const s, const struct css_node * v)
|
||||
{
|
||||
css_table_layout z;
|
||||
@ -2483,34 +2441,6 @@ void parse_text_transform(struct css_style * const s, const struct css_node * co
|
||||
s->text_transform = z;
|
||||
}
|
||||
|
||||
void parse_top(struct css_style * const s, const struct css_node * v)
|
||||
{
|
||||
if (v->next != 0)
|
||||
return;
|
||||
|
||||
switch (v->type) {
|
||||
case CSS_NODE_IDENT:
|
||||
if (v->data_length == 7 &&
|
||||
strncasecmp(v->data, "inherit", 7) == 0)
|
||||
s->top.top = CSS_TOP_INHERIT;
|
||||
else if (v->data_length == 4 &&
|
||||
strncasecmp(v->data, "auto", 4) == 0)
|
||||
s->top.top = CSS_TOP_AUTO;
|
||||
break;
|
||||
case CSS_NODE_DIMENSION:
|
||||
case CSS_NODE_NUMBER:
|
||||
if (parse_length(&s->top.value.length, v, false) == 0)
|
||||
s->top.top = CSS_TOP_LENGTH;
|
||||
break;
|
||||
case CSS_NODE_PERCENTAGE:
|
||||
s->top.top = CSS_TOP_PERCENT;
|
||||
s->top.value.percent = atof(v->data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void parse_unicode_bidi(struct css_style * const s, const struct css_node * const v)
|
||||
{
|
||||
css_unicode_bidi z;
|
||||
|
Loading…
x
Reference in New Issue
Block a user