From 4f62d5af8c93e063bf0d9a9f0eaeffb3c451f56f Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 23 Aug 2009 07:55:37 +0000 Subject: Somewhat nasty text-align magic for the benefit of HTML tables. svn path=/trunk/libcss/; revision=9405 --- include/libcss/properties.h | 17 +++++++++-------- src/select/properties.c | 11 +++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/include/libcss/properties.h b/include/libcss/properties.h index 7ec277a..91d1dab 100644 --- a/include/libcss/properties.h +++ b/include/libcss/properties.h @@ -506,14 +506,15 @@ enum css_table_layout_e { enum css_text_align_e { CSS_TEXT_ALIGN_INHERIT = 0x0, - CSS_TEXT_ALIGN_LEFT = 0x1, - CSS_TEXT_ALIGN_RIGHT = 0x2, - CSS_TEXT_ALIGN_CENTER = 0x3, - CSS_TEXT_ALIGN_JUSTIFY = 0x4, - CSS_TEXT_ALIGN_DEFAULT = 0x5, - CSS_TEXT_ALIGN_LIBCSS_LEFT = 0x6, - CSS_TEXT_ALIGN_LIBCSS_CENTER = 0x7, - CSS_TEXT_ALIGN_LIBCSS_RIGHT = 0x8 + CSS_TEXT_ALIGN_INHERIT_IF_NON_MAGIC = 0x1, + CSS_TEXT_ALIGN_LEFT = 0x2, + CSS_TEXT_ALIGN_RIGHT = 0x3, + CSS_TEXT_ALIGN_CENTER = 0x4, + CSS_TEXT_ALIGN_JUSTIFY = 0x5, + CSS_TEXT_ALIGN_DEFAULT = 0x6, + CSS_TEXT_ALIGN_LIBCSS_LEFT = 0x7, + CSS_TEXT_ALIGN_LIBCSS_CENTER = 0x8, + CSS_TEXT_ALIGN_LIBCSS_RIGHT = 0x9 }; enum css_text_decoration_e { diff --git a/src/select/properties.c b/src/select/properties.c index 9ca9d9f..3974f1e 100644 --- a/src/select/properties.c +++ b/src/select/properties.c @@ -4678,6 +4678,17 @@ css_error compose_text_align(const css_computed_style *parent, if (type == CSS_TEXT_ALIGN_INHERIT) { type = get_text_align(parent); + } else if (type == CSS_TEXT_ALIGN_INHERIT_IF_NON_MAGIC) { + /* This is purely for the benefit of HTML tables */ + type = get_text_align(parent); + + /* If the parent's text-align is a magical one, + * then reset to the default value. Otherwise, + * inherit as normal. */ + if (type == CSS_TEXT_ALIGN_LIBCSS_LEFT || + type == CSS_TEXT_ALIGN_LIBCSS_CENTER || + type == CSS_TEXT_ALIGN_LIBCSS_RIGHT) + type = CSS_TEXT_ALIGN_DEFAULT; } return set_text_align(result, type); -- cgit v1.2.3