diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2022-08-27 13:00:57 +0100 |
---|---|---|
committer | Michael Drake <mdrake.unique@gmail.com> | 2022-08-29 13:49:20 +0100 |
commit | 8d4c3080202d5c9cb1ffe0b67448c0392c53028b (patch) | |
tree | 990847a2b6afd4e8ea56dc7a5290a13436917d7c /src/select/properties/text_align.c | |
parent | 9a4646ccb841105404f153cfc5f76cfe3d61b35f (diff) | |
download | libcss-8d4c3080202d5c9cb1ffe0b67448c0392c53028b.tar.gz libcss-8d4c3080202d5c9cb1ffe0b67448c0392c53028b.tar.bz2 |
Select: Properties: Implement copy handler for complex properties
Diffstat (limited to 'src/select/properties/text_align.c')
-rw-r--r-- | src/select/properties/text_align.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/select/properties/text_align.c b/src/select/properties/text_align.c index f2ba4e6..303f8f5 100644 --- a/src/select/properties/text_align.c +++ b/src/select/properties/text_align.c @@ -66,15 +66,24 @@ css_error css__initial_text_align(css_select_state *state) return set_text_align(state->computed, CSS_TEXT_ALIGN_DEFAULT); } +css_error css__copy_text_align( + const css_computed_style *from, + css_computed_style *to) +{ + if (from == to) { + return CSS_OK; + } + + return set_text_align(to, get_text_align(from)); +} + css_error css__compose_text_align(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { uint8_t type = get_text_align(child); - if (type == CSS_TEXT_ALIGN_INHERIT) { - type = get_text_align(parent); - } else if (type == CSS_TEXT_ALIGN_INHERIT_IF_NON_MAGIC) { + if (type == CSS_TEXT_ALIGN_INHERIT_IF_NON_MAGIC) { /* This is purely for the benefit of HTML tables */ type = get_text_align(parent); @@ -83,10 +92,15 @@ css_error css__compose_text_align(const css_computed_style *parent, * 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_LIBCSS_RIGHT) { type = CSS_TEXT_ALIGN_DEFAULT; + } + + return set_text_align(result, type); } - return set_text_align(result, type); + return css__copy_text_align( + type == CSS_TEXT_ALIGN_INHERIT ? parent : child, + result); } |