diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2022-08-18 21:19:54 +0100 |
---|---|---|
committer | Michael Drake <mdrake.unique@gmail.com> | 2022-08-29 13:49:20 +0100 |
commit | 9a4646ccb841105404f153cfc5f76cfe3d61b35f (patch) | |
tree | d911d9d26b080abfd3ea253c23b398ca96f81cc9 /src/select/properties/background_position.c | |
parent | 010b9a79ece709d364dbf3930b72d2a7e0bac045 (diff) | |
download | libcss-9a4646ccb841105404f153cfc5f76cfe3d61b35f.tar.gz libcss-9a4646ccb841105404f153cfc5f76cfe3d61b35f.tar.bz2 |
Select: Properties: Add copy handler for simple properties
Diffstat (limited to 'src/select/properties/background_position.c')
-rw-r--r-- | src/select/properties/background_position.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/select/properties/background_position.c b/src/select/properties/background_position.c index 1d959d0..f3fe47c 100644 --- a/src/select/properties/background_position.c +++ b/src/select/properties/background_position.c @@ -96,6 +96,22 @@ css_error css__initial_background_position(css_select_state *state) 0, CSS_UNIT_PCT, 0, CSS_UNIT_PCT); } +css_error css__copy_background_position( + const css_computed_style *from, + css_computed_style *to) +{ + css_fixed hlength = 0, vlength = 0; + css_unit hunit = CSS_UNIT_PX, vunit = CSS_UNIT_PX; + uint8_t type = get_background_position(from, &hlength, &hunit, + &vlength, &vunit); + + if (from == to) { + return CSS_OK; + } + + return set_background_position(to, type, hlength, hunit, vlength, vunit); +} + css_error css__compose_background_position(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) @@ -105,12 +121,8 @@ css_error css__compose_background_position(const css_computed_style *parent, uint8_t type = get_background_position(child, &hlength, &hunit, &vlength, &vunit); - if (type == CSS_BACKGROUND_POSITION_INHERIT) { - type = get_background_position(parent, - &hlength, &hunit, &vlength, &vunit); - } - - return set_background_position(result, type, hlength, hunit, - vlength, vunit); + return css__copy_background_position( + type == CSS_BACKGROUND_POSITION_INHERIT ? parent : child, + result); } |