summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2022-08-18 21:19:54 +0100
committerMichael Drake <mdrake.unique@gmail.com>2022-08-29 13:49:20 +0100
commit9a4646ccb841105404f153cfc5f76cfe3d61b35f (patch)
treed911d9d26b080abfd3ea253c23b398ca96f81cc9
parent010b9a79ece709d364dbf3930b72d2a7e0bac045 (diff)
downloadlibcss-9a4646ccb841105404f153cfc5f76cfe3d61b35f.tar.gz
libcss-9a4646ccb841105404f153cfc5f76cfe3d61b35f.tar.bz2
Select: Properties: Add copy handler for simple properties
-rw-r--r--src/select/properties/align_content.c19
-rw-r--r--src/select/properties/align_items.c19
-rw-r--r--src/select/properties/align_self.c19
-rw-r--r--src/select/properties/azimuth.c10
-rw-r--r--src/select/properties/background_attachment.c19
-rw-r--r--src/select/properties/background_color.c22
-rw-r--r--src/select/properties/background_image.c22
-rw-r--r--src/select/properties/background_position.c26
-rw-r--r--src/select/properties/background_repeat.c19
-rw-r--r--src/select/properties/border_bottom_color.c22
-rw-r--r--src/select/properties/border_bottom_style.c19
-rw-r--r--src/select/properties/border_bottom_width.c31
-rw-r--r--src/select/properties/border_collapse.c19
-rw-r--r--src/select/properties/border_left_color.c22
-rw-r--r--src/select/properties/border_left_style.c19
-rw-r--r--src/select/properties/border_left_width.c23
-rw-r--r--src/select/properties/border_right_color.c22
-rw-r--r--src/select/properties/border_right_style.c19
-rw-r--r--src/select/properties/border_right_width.c23
-rw-r--r--src/select/properties/border_spacing.c25
-rw-r--r--src/select/properties/border_top_color.c22
-rw-r--r--src/select/properties/border_top_style.c19
-rw-r--r--src/select/properties/border_top_width.c23
-rw-r--r--src/select/properties/bottom.c23
-rw-r--r--src/select/properties/box_sizing.c22
-rw-r--r--src/select/properties/break_after.c19
-rw-r--r--src/select/properties/break_before.c19
-rw-r--r--src/select/properties/break_inside.c19
-rw-r--r--src/select/properties/caption_side.c19
-rw-r--r--src/select/properties/clear.c19
-rw-r--r--src/select/properties/clip.c24
-rw-r--r--src/select/properties/color.c22
-rw-r--r--src/select/properties/column_count.c22
-rw-r--r--src/select/properties/column_fill.c19
-rw-r--r--src/select/properties/column_gap.c23
-rw-r--r--src/select/properties/column_rule_color.c22
-rw-r--r--src/select/properties/column_rule_style.c19
-rw-r--r--src/select/properties/column_rule_width.c23
-rw-r--r--src/select/properties/column_span.c19
-rw-r--r--src/select/properties/column_width.c27
-rw-r--r--src/select/properties/cue_after.c10
-rw-r--r--src/select/properties/cue_before.c10
-rw-r--r--src/select/properties/direction.c19
-rw-r--r--src/select/properties/display.c19
-rw-r--r--src/select/properties/elevation.c10
-rw-r--r--src/select/properties/empty_cells.c19
-rw-r--r--src/select/properties/flex_basis.c23
-rw-r--r--src/select/properties/flex_direction.c19
-rw-r--r--src/select/properties/flex_grow.c22
-rw-r--r--src/select/properties/flex_shrink.c22
-rw-r--r--src/select/properties/flex_wrap.c21
-rw-r--r--src/select/properties/float.c19
-rw-r--r--src/select/properties/font_size.c23
-rw-r--r--src/select/properties/font_style.c19
-rw-r--r--src/select/properties/font_variant.c19
-rw-r--r--src/select/properties/font_weight.c19
-rw-r--r--src/select/properties/height.c23
-rw-r--r--src/select/properties/justify_content.c19
-rw-r--r--src/select/properties/left.c23
-rw-r--r--src/select/properties/letter_spacing.c23
-rw-r--r--src/select/properties/line_height.c23
-rw-r--r--src/select/properties/list_style_image.c22
-rw-r--r--src/select/properties/list_style_position.c19
-rw-r--r--src/select/properties/list_style_type.c19
-rw-r--r--src/select/properties/margin_bottom.c23
-rw-r--r--src/select/properties/margin_left.c23
-rw-r--r--src/select/properties/margin_right.c23
-rw-r--r--src/select/properties/margin_top.c23
-rw-r--r--src/select/properties/max_height.c23
-rw-r--r--src/select/properties/max_width.c23
-rw-r--r--src/select/properties/min_height.c23
-rw-r--r--src/select/properties/min_width.c23
-rw-r--r--src/select/properties/opacity.c22
-rw-r--r--src/select/properties/order.c22
-rw-r--r--src/select/properties/orphans.c22
-rw-r--r--src/select/properties/outline_color.c22
-rw-r--r--src/select/properties/outline_style.c19
-rw-r--r--src/select/properties/outline_width.c23
-rw-r--r--src/select/properties/overflow_x.c19
-rw-r--r--src/select/properties/overflow_y.c19
-rw-r--r--src/select/properties/padding_bottom.c23
-rw-r--r--src/select/properties/padding_left.c23
-rw-r--r--src/select/properties/padding_right.c23
-rw-r--r--src/select/properties/padding_top.c23
-rw-r--r--src/select/properties/page_break_after.c19
-rw-r--r--src/select/properties/page_break_before.c19
-rw-r--r--src/select/properties/page_break_inside.c19
-rw-r--r--src/select/properties/pause_after.c10
-rw-r--r--src/select/properties/pause_before.c10
-rw-r--r--src/select/properties/pitch.c10
-rw-r--r--src/select/properties/pitch_range.c10
-rw-r--r--src/select/properties/play_during.c10
-rw-r--r--src/select/properties/position.c19
-rw-r--r--src/select/properties/properties.h1
-rw-r--r--src/select/properties/richness.c10
-rw-r--r--src/select/properties/right.c23
-rw-r--r--src/select/properties/speak.c10
-rw-r--r--src/select/properties/speak_header.c10
-rw-r--r--src/select/properties/speak_numeral.c10
-rw-r--r--src/select/properties/speak_punctuation.c10
-rw-r--r--src/select/properties/speech_rate.c10
-rw-r--r--src/select/properties/stress.c10
-rw-r--r--src/select/properties/table_layout.c19
-rw-r--r--src/select/properties/text_decoration.c19
-rw-r--r--src/select/properties/text_indent.c23
-rw-r--r--src/select/properties/text_transform.c19
-rw-r--r--src/select/properties/top.c23
-rw-r--r--src/select/properties/unicode_bidi.c19
-rw-r--r--src/select/properties/vertical_align.c23
-rw-r--r--src/select/properties/visibility.c19
-rw-r--r--src/select/properties/voice_family.c10
-rw-r--r--src/select/properties/volume.c10
-rw-r--r--src/select/properties/white_space.c19
-rw-r--r--src/select/properties/widows.c22
-rw-r--r--src/select/properties/width.c23
-rw-r--r--src/select/properties/word_spacing.c23
-rw-r--r--src/select/properties/writing_mode.c21
-rw-r--r--src/select/properties/z_index.c22
118 files changed, 1778 insertions, 507 deletions
diff --git a/src/select/properties/align_content.c b/src/select/properties/align_content.c
index 7d791b8..d432879 100644
--- a/src/select/properties/align_content.c
+++ b/src/select/properties/align_content.c
@@ -66,16 +66,25 @@ css_error css__initial_align_content(css_select_state *state)
return set_align_content(state->computed, CSS_ALIGN_CONTENT_STRETCH);
}
+css_error css__copy_align_content(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_align_content(to, get_align_content(from));
+}
+
css_error css__compose_align_content(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_align_content(child);
- if (type == CSS_ALIGN_CONTENT_INHERIT) {
- type = get_align_content(parent);
- }
-
- return set_align_content(result, type);
+ return css__copy_align_content(
+ type == CSS_ALIGN_CONTENT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/align_items.c b/src/select/properties/align_items.c
index 007fd70..52ca094 100644
--- a/src/select/properties/align_items.c
+++ b/src/select/properties/align_items.c
@@ -60,16 +60,25 @@ css_error css__initial_align_items(css_select_state *state)
return set_align_items(state->computed, CSS_ALIGN_ITEMS_STRETCH);
}
+css_error css__copy_align_items(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_align_items(to, get_align_items(from));
+}
+
css_error css__compose_align_items(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_align_items(child);
- if (type == CSS_ALIGN_ITEMS_INHERIT) {
- type = get_align_items(parent);
- }
-
- return set_align_items(result, type);
+ return css__copy_align_items(
+ type == CSS_ALIGN_ITEMS_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/align_self.c b/src/select/properties/align_self.c
index b8ce46d..abdb3fe 100644
--- a/src/select/properties/align_self.c
+++ b/src/select/properties/align_self.c
@@ -63,16 +63,25 @@ css_error css__initial_align_self(css_select_state *state)
return set_align_self(state->computed, CSS_ALIGN_SELF_AUTO);
}
+css_error css__copy_align_self(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_align_self(to, get_align_self(from));
+}
+
css_error css__compose_align_self(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_align_self(child);
- if (type == CSS_ALIGN_SELF_INHERIT) {
- type = get_align_self(parent);
- }
-
- return set_align_self(result, type);
+ return css__copy_align_self(
+ type == CSS_ALIGN_SELF_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/azimuth.c b/src/select/properties/azimuth.c
index 1d3e1c2..bbbb48d 100644
--- a/src/select/properties/azimuth.c
+++ b/src/select/properties/azimuth.c
@@ -70,6 +70,16 @@ css_error css__initial_azimuth(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_azimuth(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_azimuth(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/background_attachment.c b/src/select/properties/background_attachment.c
index 7e59557..49194cc 100644
--- a/src/select/properties/background_attachment.c
+++ b/src/select/properties/background_attachment.c
@@ -52,16 +52,25 @@ css_error css__initial_background_attachment(css_select_state *state)
CSS_BACKGROUND_ATTACHMENT_SCROLL);
}
+css_error css__copy_background_attachment(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_background_attachment(to, get_background_attachment(from));
+}
+
css_error css__compose_background_attachment(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_background_attachment(child);
- if (type == CSS_BACKGROUND_ATTACHMENT_INHERIT) {
- type = get_background_attachment(parent);
- }
-
- return set_background_attachment(result, type);
+ return css__copy_background_attachment(
+ type == CSS_BACKGROUND_ATTACHMENT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/background_color.c b/src/select/properties/background_color.c
index bb90604..1ab61e6 100644
--- a/src/select/properties/background_color.c
+++ b/src/select/properties/background_color.c
@@ -32,6 +32,20 @@ css_error css__initial_background_color(css_select_state *state)
CSS_BACKGROUND_COLOR_COLOR, 0);
}
+css_error css__copy_background_color(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_color color;
+ uint8_t type = get_background_color(from, &color);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_background_color(to, type, color);
+}
+
css_error css__compose_background_color(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -39,10 +53,8 @@ css_error css__compose_background_color(const css_computed_style *parent,
css_color color;
uint8_t type = get_background_color(child, &color);
- if (type == CSS_BACKGROUND_COLOR_INHERIT) {
- type = get_background_color(parent, &color);
- }
-
- return set_background_color(result, type, color);
+ return css__copy_background_color(
+ type == CSS_BACKGROUND_COLOR_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/background_image.c b/src/select/properties/background_image.c
index 96f7409..68b1e0f 100644
--- a/src/select/properties/background_image.c
+++ b/src/select/properties/background_image.c
@@ -39,6 +39,20 @@ css_error css__initial_background_image(css_select_state *state)
CSS_BACKGROUND_IMAGE_NONE, NULL);
}
+css_error css__copy_background_image(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ lwc_string *url;
+ uint8_t type = get_background_image(from, &url);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_background_image(to, type, url);
+}
+
css_error css__compose_background_image(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -46,10 +60,8 @@ css_error css__compose_background_image(const css_computed_style *parent,
lwc_string *url;
uint8_t type = get_background_image(child, &url);
- if (type == CSS_BACKGROUND_IMAGE_INHERIT) {
- type = get_background_image(parent, &url);
- }
-
- return set_background_image(result, type, url);
+ return css__copy_background_image(
+ type == CSS_BACKGROUND_IMAGE_INHERIT ? parent : child,
+ result);
}
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);
}
diff --git a/src/select/properties/background_repeat.c b/src/select/properties/background_repeat.c
index cf1b8fc..7104bfb 100644
--- a/src/select/properties/background_repeat.c
+++ b/src/select/properties/background_repeat.c
@@ -58,16 +58,25 @@ css_error css__initial_background_repeat(css_select_state *state)
CSS_BACKGROUND_REPEAT_REPEAT);
}
+css_error css__copy_background_repeat(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_background_repeat(to, get_background_repeat(from));
+}
+
css_error css__compose_background_repeat(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_background_repeat(child);
- if (type == CSS_BACKGROUND_REPEAT_INHERIT) {
- type = get_background_repeat(parent);
- }
-
- return set_background_repeat(result, type);
+ return css__copy_background_repeat(
+ type == CSS_BACKGROUND_REPEAT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_bottom_color.c b/src/select/properties/border_bottom_color.c
index bdbecb7..1996d71 100644
--- a/src/select/properties/border_bottom_color.c
+++ b/src/select/properties/border_bottom_color.c
@@ -33,6 +33,20 @@ css_error css__initial_border_bottom_color(css_select_state *state)
CSS_BORDER_COLOR_CURRENT_COLOR, 0);
}
+css_error css__copy_border_bottom_color(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_color color;
+ uint8_t type = get_border_bottom_color(from, &color);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_bottom_color(to, type, color);
+}
+
css_error css__compose_border_bottom_color(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +54,8 @@ css_error css__compose_border_bottom_color(const css_computed_style *parent,
css_color color;
uint8_t type = get_border_bottom_color(child, &color);
- if (type == CSS_BORDER_COLOR_INHERIT) {
- type = get_border_bottom_color(parent, &color);
- }
-
- return set_border_bottom_color(result, type, color);
+ return css__copy_border_bottom_color(
+ type == CSS_BORDER_COLOR_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_bottom_style.c b/src/select/properties/border_bottom_style.c
index b5caccb..3451c65 100644
--- a/src/select/properties/border_bottom_style.c
+++ b/src/select/properties/border_bottom_style.c
@@ -31,16 +31,25 @@ css_error css__initial_border_bottom_style(css_select_state *state)
return set_border_bottom_style(state->computed, CSS_BORDER_STYLE_NONE);
}
+css_error css__copy_border_bottom_style(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_bottom_style(to, get_border_bottom_style(from));
+}
+
css_error css__compose_border_bottom_style(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_border_bottom_style(child);
- if (type == CSS_BORDER_STYLE_INHERIT) {
- type = get_border_bottom_style(parent);
- }
-
- return set_border_bottom_style(result, type);
+ return css__copy_border_bottom_style(
+ type == CSS_BORDER_STYLE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_bottom_width.c b/src/select/properties/border_bottom_width.c
index b071fba..19f4304 100644
--- a/src/select/properties/border_bottom_width.c
+++ b/src/select/properties/border_bottom_width.c
@@ -14,16 +14,16 @@
#include "select/properties/properties.h"
#include "select/properties/helpers.h"
-css_error css__cascade_border_bottom_width(uint32_t opv, css_style *style,
+css_error css__cascade_border_bottom_width(uint32_t opv, css_style *width,
css_select_state *state)
{
- return css__cascade_border_width(opv, style, state, set_border_bottom_width);
+ return css__cascade_border_width(opv, width, state, set_border_bottom_width);
}
css_error css__set_border_bottom_width_from_hint(const css_hint *hint,
- css_computed_style *style)
+ css_computed_style *width)
{
- return set_border_bottom_width(style, hint->status,
+ return set_border_bottom_width(width, hint->status,
hint->data.length.value, hint->data.length.unit);
}
@@ -33,6 +33,21 @@ css_error css__initial_border_bottom_width(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_border_bottom_width(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_border_bottom_width(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_bottom_width(to, type, length, unit);
+}
+
css_error css__compose_border_bottom_width(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,10 +56,8 @@ css_error css__compose_border_bottom_width(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_border_bottom_width(child, &length, &unit);
- if (type == CSS_BORDER_WIDTH_INHERIT) {
- type = get_border_bottom_width(parent, &length, &unit);
- }
-
- return set_border_bottom_width(result, type, length, unit);
+ return css__copy_border_bottom_width(
+ type == CSS_BORDER_WIDTH_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_collapse.c b/src/select/properties/border_collapse.c
index b923de6..8868e6b 100644
--- a/src/select/properties/border_collapse.c
+++ b/src/select/properties/border_collapse.c
@@ -51,16 +51,25 @@ css_error css__initial_border_collapse(css_select_state *state)
return set_border_collapse(state->computed, CSS_BORDER_COLLAPSE_SEPARATE);
}
+css_error css__copy_border_collapse(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_collapse(to, get_border_collapse(from));
+}
+
css_error css__compose_border_collapse(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_border_collapse(child);
- if (type == CSS_BORDER_COLLAPSE_INHERIT) {
- type = get_border_collapse(parent);
- }
-
- return set_border_collapse(result, type);
+ return css__copy_border_collapse(
+ type == CSS_BORDER_COLLAPSE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_left_color.c b/src/select/properties/border_left_color.c
index 2880751..60b81ae 100644
--- a/src/select/properties/border_left_color.c
+++ b/src/select/properties/border_left_color.c
@@ -33,6 +33,20 @@ css_error css__initial_border_left_color(css_select_state *state)
CSS_BORDER_COLOR_CURRENT_COLOR, 0);
}
+css_error css__copy_border_left_color(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_color color;
+ uint8_t type = get_border_left_color(from, &color);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_left_color(to, type, color);
+}
+
css_error css__compose_border_left_color(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +54,8 @@ css_error css__compose_border_left_color(const css_computed_style *parent,
css_color color;
uint8_t type = get_border_left_color(child, &color);
- if (type == CSS_BORDER_COLOR_INHERIT) {
- type = get_border_left_color(parent, &color);
- }
-
- return set_border_left_color(result, type, color);
+ return css__copy_border_left_color(
+ type == CSS_BORDER_COLOR_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_left_style.c b/src/select/properties/border_left_style.c
index e6472b3..99b5494 100644
--- a/src/select/properties/border_left_style.c
+++ b/src/select/properties/border_left_style.c
@@ -31,16 +31,25 @@ css_error css__initial_border_left_style(css_select_state *state)
return set_border_left_style(state->computed, CSS_BORDER_STYLE_NONE);
}
+css_error css__copy_border_left_style(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_left_style(to, get_border_left_style(from));
+}
+
css_error css__compose_border_left_style(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_border_left_style(child);
- if (type == CSS_BORDER_STYLE_INHERIT) {
- type = get_border_left_style(parent);
- }
-
- return set_border_left_style(result, type);
+ return css__copy_border_left_style(
+ type == CSS_BORDER_STYLE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_left_width.c b/src/select/properties/border_left_width.c
index 1278fa9..e1fc822 100644
--- a/src/select/properties/border_left_width.c
+++ b/src/select/properties/border_left_width.c
@@ -33,6 +33,21 @@ css_error css__initial_border_left_width(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_border_left_width(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_border_left_width(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_left_width(to, type, length, unit);
+}
+
css_error css__compose_border_left_width(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,10 +56,8 @@ css_error css__compose_border_left_width(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_border_left_width(child, &length, &unit);
- if (type == CSS_BORDER_WIDTH_INHERIT) {
- type = get_border_left_width(parent, &length, &unit);
- }
-
- return set_border_left_width(result, type, length, unit);
+ return css__copy_border_left_width(
+ type == CSS_BORDER_WIDTH_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_right_color.c b/src/select/properties/border_right_color.c
index b8563e6..815ca9c 100644
--- a/src/select/properties/border_right_color.c
+++ b/src/select/properties/border_right_color.c
@@ -33,6 +33,20 @@ css_error css__initial_border_right_color(css_select_state *state)
CSS_BORDER_COLOR_CURRENT_COLOR, 0);
}
+css_error css__copy_border_right_color(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_color color;
+ uint8_t type = get_border_right_color(from, &color);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_right_color(to, type, color);
+}
+
css_error css__compose_border_right_color(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +54,8 @@ css_error css__compose_border_right_color(const css_computed_style *parent,
css_color color;
uint8_t type = get_border_right_color(child, &color);
- if (type == CSS_BORDER_COLOR_INHERIT) {
- type = get_border_right_color(parent, &color);
- }
-
- return set_border_right_color(result, type, color);
+ return css__copy_border_right_color(
+ type == CSS_BORDER_COLOR_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_right_style.c b/src/select/properties/border_right_style.c
index d75a99e..d14fbfb 100644
--- a/src/select/properties/border_right_style.c
+++ b/src/select/properties/border_right_style.c
@@ -31,16 +31,25 @@ css_error css__initial_border_right_style(css_select_state *state)
return set_border_right_style(state->computed, CSS_BORDER_STYLE_NONE);
}
+css_error css__copy_border_right_style(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_right_style(to, get_border_right_style(from));
+}
+
css_error css__compose_border_right_style(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_border_right_style(child);
- if (type == CSS_BORDER_STYLE_INHERIT) {
- type = get_border_right_style(parent);
- }
-
- return set_border_right_style(result, type);
+ return css__copy_border_right_style(
+ type == CSS_BORDER_STYLE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_right_width.c b/src/select/properties/border_right_width.c
index 18cacd2..93e8f19 100644
--- a/src/select/properties/border_right_width.c
+++ b/src/select/properties/border_right_width.c
@@ -33,6 +33,21 @@ css_error css__initial_border_right_width(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_border_right_width(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_border_right_width(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_right_width(to, type, length, unit);
+}
+
css_error css__compose_border_right_width(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,10 +56,8 @@ css_error css__compose_border_right_width(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_border_right_width(child, &length, &unit);
- if (type == CSS_BORDER_WIDTH_INHERIT) {
- type = get_border_right_width(parent, &length, &unit);
- }
-
- return set_border_right_width(result, type, length, unit);
+ return css__copy_border_right_width(
+ type == CSS_BORDER_WIDTH_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_spacing.c b/src/select/properties/border_spacing.c
index 8eb01cb..1f70aff 100644
--- a/src/select/properties/border_spacing.c
+++ b/src/select/properties/border_spacing.c
@@ -62,6 +62,22 @@ css_error css__initial_border_spacing(css_select_state *state)
0, CSS_UNIT_PX, 0, CSS_UNIT_PX);
}
+css_error css__copy_border_spacing(
+ 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_border_spacing(from, &hlength, &hunit,
+ &vlength, &vunit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_spacing(to, type, hlength, hunit, vlength, vunit);
+}
+
css_error css__compose_border_spacing(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -71,10 +87,7 @@ css_error css__compose_border_spacing(const css_computed_style *parent,
uint8_t type = get_border_spacing(child, &hlength, &hunit,
&vlength, &vunit);
- if (type == CSS_BORDER_SPACING_INHERIT) {
- type = get_border_spacing(parent,
- &hlength, &hunit, &vlength, &vunit);
- }
-
- return set_border_spacing(result, type, hlength, hunit, vlength, vunit);
+ return css__copy_border_spacing(
+ type == CSS_BORDER_SPACING_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_top_color.c b/src/select/properties/border_top_color.c
index fd2ced4..ee3feb1 100644
--- a/src/select/properties/border_top_color.c
+++ b/src/select/properties/border_top_color.c
@@ -31,6 +31,20 @@ css_error css__initial_border_top_color(css_select_state *state)
return set_border_top_color(state->computed, CSS_BORDER_COLOR_CURRENT_COLOR, 0);
}
+css_error css__copy_border_top_color(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_color color;
+ uint8_t type = get_border_top_color(from, &color);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_top_color(to, type, color);
+}
+
css_error css__compose_border_top_color(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -38,10 +52,8 @@ css_error css__compose_border_top_color(const css_computed_style *parent,
css_color color;
uint8_t type = get_border_top_color(child, &color);
- if (type == CSS_BORDER_COLOR_INHERIT) {
- type = get_border_top_color(parent, &color);
- }
-
- return set_border_top_color(result, type, color);
+ return css__copy_border_top_color(
+ type == CSS_BORDER_COLOR_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_top_style.c b/src/select/properties/border_top_style.c
index 48d6b6d..1d2dc91 100644
--- a/src/select/properties/border_top_style.c
+++ b/src/select/properties/border_top_style.c
@@ -31,16 +31,25 @@ css_error css__initial_border_top_style(css_select_state *state)
return set_border_top_style(state->computed, CSS_BORDER_STYLE_NONE);
}
+css_error css__copy_border_top_style(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_top_style(to, get_border_top_style(from));
+}
+
css_error css__compose_border_top_style(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_border_top_style(child);
- if (type == CSS_BORDER_STYLE_INHERIT) {
- type = get_border_top_style(parent);
- }
-
- return set_border_top_style(result, type);
+ return css__copy_border_top_style(
+ type == CSS_BORDER_STYLE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/border_top_width.c b/src/select/properties/border_top_width.c
index c0fb7da..18e60cb 100644
--- a/src/select/properties/border_top_width.c
+++ b/src/select/properties/border_top_width.c
@@ -33,6 +33,21 @@ css_error css__initial_border_top_width(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_border_top_width(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_border_top_width(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_border_top_width(to, type, length, unit);
+}
+
css_error css__compose_border_top_width(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,10 +56,8 @@ css_error css__compose_border_top_width(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_border_top_width(child, &length, &unit);
- if (type == CSS_BORDER_WIDTH_INHERIT) {
- type = get_border_top_width(parent, &length, &unit);
- }
-
- return set_border_top_width(result, type, length, unit);
+ return css__copy_border_top_width(
+ type == CSS_BORDER_WIDTH_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/bottom.c b/src/select/properties/bottom.c
index 82754f1..fd65ed3 100644
--- a/src/select/properties/bottom.c
+++ b/src/select/properties/bottom.c
@@ -32,6 +32,21 @@ css_error css__initial_bottom(css_select_state *state)
return set_bottom(state->computed, CSS_BOTTOM_AUTO, 0, CSS_UNIT_PX);
}
+css_error css__copy_bottom(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_bottom(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_bottom(to, type, length, unit);
+}
+
css_error css__compose_bottom(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +55,8 @@ css_error css__compose_bottom(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_bottom(child, &length, &unit);
- if (type == CSS_BOTTOM_INHERIT) {
- type = get_bottom(parent, &length, &unit);
- }
-
- return set_bottom(result, type, length, unit);
+ return css__copy_bottom(
+ type == CSS_BOTTOM_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/box_sizing.c b/src/select/properties/box_sizing.c
index 5bfb43e..471f8a7 100644
--- a/src/select/properties/box_sizing.c
+++ b/src/select/properties/box_sizing.c
@@ -51,17 +51,25 @@ css_error css__initial_box_sizing(css_select_state *state)
return set_box_sizing(state->computed, CSS_BOX_SIZING_CONTENT_BOX);
}
-css_error css__compose_box_sizing(
- const css_computed_style *parent,
+css_error css__copy_box_sizing(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_box_sizing(to, get_box_sizing(from));
+}
+
+css_error css__compose_box_sizing(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_box_sizing(child);
- if (type == CSS_BOX_SIZING_INHERIT) {
- type = get_box_sizing(parent);
- }
-
- return set_box_sizing(result, type);
+ return css__copy_box_sizing(
+ type == CSS_BOX_SIZING_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/break_after.c b/src/select/properties/break_after.c
index 1f253aa..cb382e0 100644
--- a/src/select/properties/break_after.c
+++ b/src/select/properties/break_after.c
@@ -32,16 +32,25 @@ css_error css__initial_break_after(css_select_state *state)
return set_break_after(state->computed, CSS_BREAK_AFTER_AUTO);
}
+css_error css__copy_break_after(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_break_after(to, get_break_after(from));
+}
+
css_error css__compose_break_after(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_break_after(child);
- if (type == CSS_BREAK_AFTER_INHERIT) {
- type = get_break_after(parent);
- }
-
- return set_break_after(result, type);
+ return css__copy_break_after(
+ type == CSS_BREAK_AFTER_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/break_before.c b/src/select/properties/break_before.c
index 3dcda76..91b0612 100644
--- a/src/select/properties/break_before.c
+++ b/src/select/properties/break_before.c
@@ -32,16 +32,25 @@ css_error css__initial_break_before(css_select_state *state)
return set_break_before(state->computed, CSS_BREAK_BEFORE_AUTO);
}
+css_error css__copy_break_before(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_break_before(to, get_break_before(from));
+}
+
css_error css__compose_break_before(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_break_before(child);
- if (type == CSS_BREAK_BEFORE_INHERIT) {
- type = get_break_before(parent);
- }
-
- return set_break_before(result, type);
+ return css__copy_break_before(
+ type == CSS_BREAK_BEFORE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/break_inside.c b/src/select/properties/break_inside.c
index 58ba25e..d5b8aef 100644
--- a/src/select/properties/break_inside.c
+++ b/src/select/properties/break_inside.c
@@ -57,16 +57,25 @@ css_error css__initial_break_inside(css_select_state *state)
return set_break_inside(state->computed, CSS_BREAK_INSIDE_AUTO);
}
+css_error css__copy_break_inside(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_break_inside(to, get_break_inside(from));
+}
+
css_error css__compose_break_inside(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_break_inside(child);
- if (type == CSS_BREAK_INSIDE_INHERIT) {
- type = get_break_inside(parent);
- }
-
- return set_break_inside(result, type);
+ return css__copy_break_inside(
+ type == CSS_BREAK_INSIDE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/caption_side.c b/src/select/properties/caption_side.c
index e1b7930..f0e7693 100644
--- a/src/select/properties/caption_side.c
+++ b/src/select/properties/caption_side.c
@@ -51,16 +51,25 @@ css_error css__initial_caption_side(css_select_state *state)
return set_caption_side(state->computed, CSS_CAPTION_SIDE_TOP);
}
+css_error css__copy_caption_side(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_caption_side(to, get_caption_side(from));
+}
+
css_error css__compose_caption_side(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_caption_side(child);
- if (type == CSS_CAPTION_SIDE_INHERIT) {
- type = get_caption_side(parent);
- }
-
- return set_caption_side(result, type);
+ return css__copy_caption_side(
+ type == CSS_CAPTION_SIDE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/clear.c b/src/select/properties/clear.c
index a753218..1fbc48e 100644
--- a/src/select/properties/clear.c
+++ b/src/select/properties/clear.c
@@ -57,16 +57,25 @@ css_error css__initial_clear(css_select_state *state)
return set_clear(state->computed, CSS_CLEAR_NONE);
}
+css_error css__copy_clear(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_clear(to, get_clear(from));
+}
+
css_error css__compose_clear(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_clear(child);
- if (type == CSS_CLEAR_INHERIT) {
- type = get_clear(parent);
- }
-
- return set_clear(result, type);
+ return css__copy_clear(
+ type == CSS_CLEAR_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/clip.c b/src/select/properties/clip.c
index c82c1af..c0b9c2b 100644
--- a/src/select/properties/clip.c
+++ b/src/select/properties/clip.c
@@ -93,6 +93,22 @@ css_error css__initial_clip(css_select_state *state)
return set_clip(state->computed, CSS_CLIP_AUTO, &rect);
}
+css_error css__copy_clip(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_computed_clip_rect rect = { 0, 0, 0, 0,
+ CSS_UNIT_PX, CSS_UNIT_PX, CSS_UNIT_PX, CSS_UNIT_PX,
+ false, false, false, false };
+ uint8_t type = get_clip(from, &rect);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_clip(to, type, &rect);
+}
+
css_error css__compose_clip(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -102,9 +118,7 @@ css_error css__compose_clip(const css_computed_style *parent,
false, false, false, false };
uint8_t type = get_clip(child, &rect);
- if (type == CSS_CLIP_INHERIT) {
- type = get_clip(parent, &rect);
- }
-
- return set_clip(result, type, &rect);
+ return css__copy_clip(
+ type == CSS_CLIP_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/color.c b/src/select/properties/color.c
index c455fb9..6424436 100644
--- a/src/select/properties/color.c
+++ b/src/select/properties/color.c
@@ -66,6 +66,20 @@ css_error css__initial_color(css_select_state *state)
return css__set_color_from_hint(&hint, state->computed);
}
+css_error css__copy_color(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_color color;
+ uint8_t type = get_color(from, &color);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_color(to, type, color);
+}
+
css_error css__compose_color(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -73,10 +87,8 @@ css_error css__compose_color(const css_computed_style *parent,
css_color color;
uint8_t type = get_color(child, &color);
- if (type == CSS_COLOR_INHERIT) {
- type = get_color(parent, &color);
- }
-
- return set_color(result, type, color);
+ return css__copy_color(
+ type == CSS_COLOR_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/column_count.c b/src/select/properties/column_count.c
index 3fdd43a..4adadd6 100644
--- a/src/select/properties/column_count.c
+++ b/src/select/properties/column_count.c
@@ -52,6 +52,20 @@ css_error css__initial_column_count(css_select_state *state)
return set_column_count(state->computed, CSS_COLUMN_COUNT_AUTO, 0);
}
+css_error css__copy_column_count(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ int32_t count = 0;
+ uint8_t type = get_column_count(from, &count);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_column_count(to, type, count);
+}
+
css_error css__compose_column_count(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -59,9 +73,7 @@ css_error css__compose_column_count(const css_computed_style *parent,
int32_t count = 0;
uint8_t type = get_column_count(child, &count);
- if (type == CSS_COLUMN_COUNT_INHERIT) {
- type = get_column_count(parent, &count);
- }
-
- return set_column_count(result, type, count);
+ return css__copy_column_count(
+ type == CSS_COLUMN_COUNT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/column_fill.c b/src/select/properties/column_fill.c
index c4c23c3..f49946c 100644
--- a/src/select/properties/column_fill.c
+++ b/src/select/properties/column_fill.c
@@ -51,16 +51,25 @@ css_error css__initial_column_fill(css_select_state *state)
return set_column_fill(state->computed, CSS_COLUMN_FILL_BALANCE);
}
+css_error css__copy_column_fill(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_column_fill(to, get_column_fill(from));
+}
+
css_error css__compose_column_fill(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_column_fill(child);
- if (type == CSS_COLUMN_FILL_INHERIT) {
- type = get_column_fill(parent);
- }
-
- return set_column_fill(result, type);
+ return css__copy_column_fill(
+ type == CSS_COLUMN_FILL_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/column_gap.c b/src/select/properties/column_gap.c
index 087eb0f..5776dc9 100644
--- a/src/select/properties/column_gap.c
+++ b/src/select/properties/column_gap.c
@@ -33,6 +33,21 @@ css_error css__initial_column_gap(css_select_state *state)
INTTOFIX(1), CSS_UNIT_EM);
}
+css_error css__copy_column_gap(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = INTTOFIX(1);
+ css_unit unit = CSS_UNIT_EM;
+ uint8_t type = get_column_gap(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_column_gap(to, type, length, unit);
+}
+
css_error css__compose_column_gap(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,9 +56,7 @@ css_error css__compose_column_gap(const css_computed_style *parent,
css_unit unit = CSS_UNIT_EM;
uint8_t type = get_column_gap(child, &length, &unit);
- if (type == CSS_COLUMN_GAP_INHERIT) {
- type = get_column_gap(parent, &length, &unit);
- }
-
- return set_column_gap(result, type, length, unit);
+ return css__copy_column_gap(
+ type == CSS_COLUMN_GAP_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/column_rule_color.c b/src/select/properties/column_rule_color.c
index 047cef9..0b7ec9d 100644
--- a/src/select/properties/column_rule_color.c
+++ b/src/select/properties/column_rule_color.c
@@ -58,6 +58,20 @@ css_error css__initial_column_rule_color(css_select_state *state)
CSS_COLUMN_RULE_COLOR_CURRENT_COLOR, 0);
}
+css_error css__copy_column_rule_color(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_color color;
+ uint8_t type = get_column_rule_color(from, &color);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_column_rule_color(to, type, color);
+}
+
css_error css__compose_column_rule_color(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -65,10 +79,8 @@ css_error css__compose_column_rule_color(const css_computed_style *parent,
css_color color;
uint8_t type = get_column_rule_color(child, &color);
- if (type == CSS_COLUMN_RULE_COLOR_INHERIT) {
- type = get_column_rule_color(parent, &color);
- }
-
- return set_column_rule_color(result, type, color);
+ return css__copy_column_rule_color(
+ type == CSS_COLUMN_RULE_COLOR_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/column_rule_style.c b/src/select/properties/column_rule_style.c
index 1d9a41e..be9579c 100644
--- a/src/select/properties/column_rule_style.c
+++ b/src/select/properties/column_rule_style.c
@@ -33,16 +33,25 @@ css_error css__initial_column_rule_style(css_select_state *state)
CSS_COLUMN_RULE_STYLE_NONE);
}
+css_error css__copy_column_rule_style(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_column_rule_style(to, get_column_rule_style(from));
+}
+
css_error css__compose_column_rule_style(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_column_rule_style(child);
- if (type == CSS_COLUMN_RULE_STYLE_INHERIT) {
- type = get_column_rule_style(parent);
- }
-
- return set_column_rule_style(result, type);
+ return css__copy_column_rule_style(
+ type == CSS_COLUMN_RULE_STYLE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/column_rule_width.c b/src/select/properties/column_rule_width.c
index 3ca9367..c18f26c 100644
--- a/src/select/properties/column_rule_width.c
+++ b/src/select/properties/column_rule_width.c
@@ -34,6 +34,21 @@ css_error css__initial_column_rule_width(css_select_state *state)
CSS_COLUMN_RULE_WIDTH_MEDIUM, 0, CSS_UNIT_PX);
}
+css_error css__copy_column_rule_width(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_column_rule_width(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_column_rule_width(to, type, length, unit);
+}
+
css_error css__compose_column_rule_width(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -42,10 +57,8 @@ css_error css__compose_column_rule_width(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_column_rule_width(child, &length, &unit);
- if (type == CSS_COLUMN_RULE_WIDTH_INHERIT) {
- type = get_column_rule_width(parent, &length, &unit);
- }
-
- return set_column_rule_width(result, type, length, unit);
+ return css__copy_column_rule_width(
+ type == CSS_COLUMN_RULE_WIDTH_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/column_span.c b/src/select/properties/column_span.c
index d17b3ed..340150f 100644
--- a/src/select/properties/column_span.c
+++ b/src/select/properties/column_span.c
@@ -51,16 +51,25 @@ css_error css__initial_column_span(css_select_state *state)
return set_column_span(state->computed, CSS_COLUMN_SPAN_NONE);
}
+css_error css__copy_column_span(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_column_span(to, get_column_span(from));
+}
+
css_error css__compose_column_span(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_column_span(child);
- if (type == CSS_COLUMN_SPAN_INHERIT) {
- type = get_column_span(parent);
- }
-
- return set_column_span(result, type);
+ return css__copy_column_span(
+ type == CSS_COLUMN_SPAN_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/column_width.c b/src/select/properties/column_width.c
index e739ade..d88d022 100644
--- a/src/select/properties/column_width.c
+++ b/src/select/properties/column_width.c
@@ -33,17 +33,30 @@ css_error css__initial_column_width(css_select_state *state)
INTTOFIX(1), CSS_UNIT_EM);
}
+css_error css__copy_column_width(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_column_width(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_column_width(to, type, length, unit);
+}
+
css_error css__compose_column_width(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- css_fixed length = INTTOFIX(1);
- css_unit unit = CSS_UNIT_EM;
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
uint8_t type = get_column_width(child, &length, &unit);
- if (type == CSS_COLUMN_WIDTH_INHERIT) {
- type = get_column_width(parent, &length, &unit);
- }
-
- return set_column_width(result, type, length, unit);
+ return css__copy_column_width(
+ type == CSS_COLUMN_WIDTH_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/cue_after.c b/src/select/properties/cue_after.c
index e1c09e8..67a2c73 100644
--- a/src/select/properties/cue_after.c
+++ b/src/select/properties/cue_after.c
@@ -37,6 +37,16 @@ css_error css__initial_cue_after(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_cue_after(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_cue_after(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/cue_before.c b/src/select/properties/cue_before.c
index d562b3b..7c24822 100644
--- a/src/select/properties/cue_before.c
+++ b/src/select/properties/cue_before.c
@@ -37,6 +37,16 @@ css_error css__initial_cue_before(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_cue_before(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_cue_before(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/direction.c b/src/select/properties/direction.c
index 6baa58b..32bd31e 100644
--- a/src/select/properties/direction.c
+++ b/src/select/properties/direction.c
@@ -51,16 +51,25 @@ css_error css__initial_direction(css_select_state *state)
return set_direction(state->computed, CSS_DIRECTION_LTR);
}
+css_error css__copy_direction(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_direction(to, get_direction(from));
+}
+
css_error css__compose_direction(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_direction(child);
- if (type == CSS_DIRECTION_INHERIT) {
- type = get_direction(parent);
- }
-
- return set_direction(result, type);
+ return css__copy_direction(
+ type == CSS_DIRECTION_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/display.c b/src/select/properties/display.c
index 3e15d5f..bfe0a5f 100644
--- a/src/select/properties/display.c
+++ b/src/select/properties/display.c
@@ -99,16 +99,25 @@ css_error css__initial_display(css_select_state *state)
return set_display(state->computed, CSS_DISPLAY_INLINE);
}
+css_error css__copy_display(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_display(to, get_display(from));
+}
+
css_error css__compose_display(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_display(child);
- if (type == CSS_DISPLAY_INHERIT) {
- type = get_display(parent);
- }
-
- return set_display(result, type);
+ return css__copy_display(
+ type == CSS_DISPLAY_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/elevation.c b/src/select/properties/elevation.c
index 2df207a..1368ef8 100644
--- a/src/select/properties/elevation.c
+++ b/src/select/properties/elevation.c
@@ -65,6 +65,16 @@ css_error css__initial_elevation(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_elevation(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_elevation(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/empty_cells.c b/src/select/properties/empty_cells.c
index cd46b3f..559fbde 100644
--- a/src/select/properties/empty_cells.c
+++ b/src/select/properties/empty_cells.c
@@ -51,16 +51,25 @@ css_error css__initial_empty_cells(css_select_state *state)
return set_empty_cells(state->computed, CSS_EMPTY_CELLS_SHOW);
}
+css_error css__copy_empty_cells(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_empty_cells(to, get_empty_cells(from));
+}
+
css_error css__compose_empty_cells(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_empty_cells(child);
- if (type == CSS_EMPTY_CELLS_INHERIT) {
- type = get_empty_cells(parent);
- }
-
- return set_empty_cells(result, type);
+ return css__copy_empty_cells(
+ type == CSS_EMPTY_CELLS_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/flex_basis.c b/src/select/properties/flex_basis.c
index e5acb3c..a3141bc 100644
--- a/src/select/properties/flex_basis.c
+++ b/src/select/properties/flex_basis.c
@@ -62,6 +62,21 @@ css_error css__initial_flex_basis(css_select_state *state)
CSS_UNIT_PX);
}
+css_error css__copy_flex_basis(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_flex_basis(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_flex_basis(to, type, length, unit);
+}
+
css_error css__compose_flex_basis(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -70,10 +85,8 @@ css_error css__compose_flex_basis(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_flex_basis(child, &length, &unit);
- if (type == CSS_FLEX_BASIS_INHERIT) {
- type = get_flex_basis(parent, &length, &unit);
- }
-
- return set_flex_basis(result, type, length, unit);
+ return css__copy_flex_basis(
+ type == CSS_FLEX_BASIS_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/flex_direction.c b/src/select/properties/flex_direction.c
index 7dc46db..1d979be 100644
--- a/src/select/properties/flex_direction.c
+++ b/src/select/properties/flex_direction.c
@@ -57,16 +57,25 @@ css_error css__initial_flex_direction(css_select_state *state)
return set_flex_direction(state->computed, CSS_FLEX_DIRECTION_ROW);
}
+css_error css__copy_flex_direction(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_flex_direction(to, get_flex_direction(from));
+}
+
css_error css__compose_flex_direction(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_flex_direction(child);
- if (type == CSS_FLEX_DIRECTION_INHERIT) {
- type = get_flex_direction(parent);
- }
-
- return set_flex_direction(result, type);
+ return css__copy_flex_direction(
+ type == CSS_FLEX_DIRECTION_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/flex_grow.c b/src/select/properties/flex_grow.c
index fe4fa4d..4650cef 100644
--- a/src/select/properties/flex_grow.c
+++ b/src/select/properties/flex_grow.c
@@ -46,6 +46,20 @@ css_error css__initial_flex_grow(css_select_state *state)
return set_flex_grow(state->computed, CSS_FLEX_GROW_SET, INTTOFIX(0));
}
+css_error css__copy_flex_grow(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed flex_grow = 0;
+ uint8_t type = get_flex_grow(from, &flex_grow);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_flex_grow(to, type, flex_grow);
+}
+
css_error css__compose_flex_grow(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -53,10 +67,8 @@ css_error css__compose_flex_grow(const css_computed_style *parent,
css_fixed flex_grow = 0;
uint8_t type = get_flex_grow(child, &flex_grow);
- if (type == CSS_FLEX_GROW_INHERIT) {
- type = get_flex_grow(parent, &flex_grow);
- }
-
- return set_flex_grow(result, type, flex_grow);
+ return css__copy_flex_grow(
+ type == CSS_FLEX_GROW_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/flex_shrink.c b/src/select/properties/flex_shrink.c
index 26aaa8f..9b39ed0 100644
--- a/src/select/properties/flex_shrink.c
+++ b/src/select/properties/flex_shrink.c
@@ -46,6 +46,20 @@ css_error css__initial_flex_shrink(css_select_state *state)
return set_flex_shrink(state->computed, CSS_FLEX_SHRINK_SET, INTTOFIX(1));
}
+css_error css__copy_flex_shrink(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed flex_shrink = 0;
+ uint8_t type = get_flex_shrink(from, &flex_shrink);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_flex_shrink(to, type, flex_shrink);
+}
+
css_error css__compose_flex_shrink(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -53,10 +67,8 @@ css_error css__compose_flex_shrink(const css_computed_style *parent,
css_fixed flex_shrink = 0;
uint8_t type = get_flex_shrink(child, &flex_shrink);
- if (type == CSS_FLEX_SHRINK_INHERIT) {
- type = get_flex_shrink(parent, &flex_shrink);
- }
-
- return set_flex_shrink(result, type, flex_shrink);
+ return css__copy_flex_shrink(
+ type == CSS_FLEX_SHRINK_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/flex_wrap.c b/src/select/properties/flex_wrap.c
index 55034d7..3ca9b74 100644
--- a/src/select/properties/flex_wrap.c
+++ b/src/select/properties/flex_wrap.c
@@ -54,16 +54,27 @@ css_error css__initial_flex_wrap(css_select_state *state)
return set_flex_wrap(state->computed, CSS_FLEX_WRAP_NOWRAP);
}
+css_error css__copy_flex_wrap(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ uint8_t type = get_flex_wrap(from);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_flex_wrap(to, type);
+}
+
css_error css__compose_flex_wrap(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_flex_wrap(child);
- if (type == CSS_FLEX_WRAP_INHERIT) {
- type = get_flex_wrap(parent);
- }
-
- return set_flex_wrap(result, type);
+ return css__copy_flex_wrap(
+ type == CSS_FLEX_WRAP_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/float.c b/src/select/properties/float.c
index 87732f6..6d009bb 100644
--- a/src/select/properties/float.c
+++ b/src/select/properties/float.c
@@ -54,16 +54,25 @@ css_error css__initial_float(css_select_state *state)
return set_float(state->computed, CSS_FLOAT_NONE);
}
+css_error css__copy_float(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_float(to, get_float(from));
+}
+
css_error css__compose_float(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_float(child);
- if (type == CSS_FLOAT_INHERIT) {
- type = get_float(parent);
- }
-
- return set_float(result, type);
+ return css__copy_float(
+ type == CSS_FLOAT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/font_size.c b/src/select/properties/font_size.c
index a361ee0..3ee9ce0 100644
--- a/src/select/properties/font_size.c
+++ b/src/select/properties/font_size.c
@@ -85,6 +85,21 @@ css_error css__initial_font_size(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_font_size(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed size = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_font_size(from, &size, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_font_size(to, type, size, unit);
+}
+
css_error css__compose_font_size(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -93,10 +108,8 @@ css_error css__compose_font_size(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_font_size(child, &size, &unit);
- if (type == CSS_FONT_SIZE_INHERIT) {
- type = get_font_size(parent, &size, &unit);
- }
-
- return set_font_size(result, type, size, unit);
+ return css__copy_font_size(
+ type == CSS_FONT_SIZE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/font_style.c b/src/select/properties/font_style.c
index 6c240ec..fe605b8 100644
--- a/src/select/properties/font_style.c
+++ b/src/select/properties/font_style.c
@@ -54,16 +54,25 @@ css_error css__initial_font_style(css_select_state *state)
return set_font_style(state->computed, CSS_FONT_STYLE_NORMAL);
}
+css_error css__copy_font_style(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_font_style(to, get_font_style(from));
+}
+
css_error css__compose_font_style(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_font_style(child);
- if (type == CSS_FONT_STYLE_INHERIT) {
- type= get_font_style(parent);
- }
-
- return set_font_style(result, type);
+ return css__copy_font_style(
+ type == CSS_FONT_STYLE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/font_variant.c b/src/select/properties/font_variant.c
index 1666153..9668fc3 100644
--- a/src/select/properties/font_variant.c
+++ b/src/select/properties/font_variant.c
@@ -51,16 +51,25 @@ css_error css__initial_font_variant(css_select_state *state)
return set_font_variant(state->computed, CSS_FONT_VARIANT_NORMAL);
}
+css_error css__copy_font_variant(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_font_variant(to, get_font_variant(from));
+}
+
css_error css__compose_font_variant(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_font_variant(child);
- if (type == CSS_FONT_VARIANT_INHERIT) {
- type = get_font_variant(parent);
- }
-
- return set_font_variant(result, type);
+ return css__copy_font_variant(
+ type == CSS_FONT_VARIANT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/font_weight.c b/src/select/properties/font_weight.c
index d9dffc9..da918a1 100644
--- a/src/select/properties/font_weight.c
+++ b/src/select/properties/font_weight.c
@@ -84,16 +84,25 @@ css_error css__initial_font_weight(css_select_state *state)
return set_font_weight(state->computed, CSS_FONT_WEIGHT_NORMAL);
}
+css_error css__copy_font_weight(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_font_weight(to, get_font_weight(from));
+}
+
css_error css__compose_font_weight(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_font_weight(child);
- if (type == CSS_FONT_WEIGHT_INHERIT) {
- type = get_font_weight(parent);
- }
-
- return set_font_weight(result, type);
+ return css__copy_font_weight(
+ type == CSS_FONT_WEIGHT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/height.c b/src/select/properties/height.c
index 1d74c4a..d449e72 100644
--- a/src/select/properties/height.c
+++ b/src/select/properties/height.c
@@ -32,6 +32,21 @@ css_error css__initial_height(css_select_state *state)
return set_height(state->computed, CSS_HEIGHT_AUTO, 0, CSS_UNIT_PX);
}
+css_error css__copy_height(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_height(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_height(to, type, length, unit);
+}
+
css_error css__compose_height(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +55,8 @@ css_error css__compose_height(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_height(child, &length, &unit);
- if (type == CSS_HEIGHT_INHERIT) {
- type = get_height(parent, &length, &unit);
- }
-
- return set_height(result, type, length, unit);
+ return css__copy_height(
+ type == CSS_HEIGHT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/justify_content.c b/src/select/properties/justify_content.c
index 03c8bb4..385bab7 100644
--- a/src/select/properties/justify_content.c
+++ b/src/select/properties/justify_content.c
@@ -64,16 +64,25 @@ css_error css__initial_justify_content(css_select_state *state)
CSS_JUSTIFY_CONTENT_FLEX_START);
}
+css_error css__copy_justify_content(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_justify_content(to, get_justify_content(from));
+}
+
css_error css__compose_justify_content(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_justify_content(child);
- if (type == CSS_JUSTIFY_CONTENT_INHERIT) {
- type = get_justify_content(parent);
- }
-
- return set_justify_content(result, type);
+ return css__copy_justify_content(
+ type == CSS_JUSTIFY_CONTENT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/left.c b/src/select/properties/left.c
index 4baa324..ca8c844 100644
--- a/src/select/properties/left.c
+++ b/src/select/properties/left.c
@@ -32,6 +32,21 @@ css_error css__initial_left(css_select_state *state)
return set_left(state->computed, CSS_LEFT_AUTO, 0, CSS_UNIT_PX);
}
+css_error css__copy_left(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_left(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_left(to, type, length, unit);
+}
+
css_error css__compose_left(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +55,8 @@ css_error css__compose_left(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_left(child, &length, &unit);
- if (type == CSS_LEFT_INHERIT) {
- type = get_left(parent, &length, &unit);
- }
-
- return set_left(result, type, length, unit);
+ return css__copy_left(
+ type == CSS_LEFT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/letter_spacing.c b/src/select/properties/letter_spacing.c
index 27ea04b..9c8e50c 100644
--- a/src/select/properties/letter_spacing.c
+++ b/src/select/properties/letter_spacing.c
@@ -33,6 +33,21 @@ css_error css__initial_letter_spacing(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_letter_spacing(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_letter_spacing(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_letter_spacing(to, type, length, unit);
+}
+
css_error css__compose_letter_spacing(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,9 +56,7 @@ css_error css__compose_letter_spacing(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_letter_spacing(child, &length, &unit);
- if (type == CSS_LETTER_SPACING_INHERIT) {
- type = get_letter_spacing(parent, &length, &unit);
- }
-
- return set_letter_spacing(result, type, length, unit);
+ return css__copy_letter_spacing(
+ type == CSS_LETTER_SPACING_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/line_height.c b/src/select/properties/line_height.c
index b43ebdd..7300b5d 100644
--- a/src/select/properties/line_height.c
+++ b/src/select/properties/line_height.c
@@ -64,6 +64,21 @@ css_error css__initial_line_height(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_line_height(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_line_height(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_line_height(to, type, length, unit);
+}
+
css_error css__compose_line_height(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -72,10 +87,8 @@ css_error css__compose_line_height(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_line_height(child, &length, &unit);
- if (type == CSS_LINE_HEIGHT_INHERIT) {
- type = get_line_height(parent, &length, &unit);
- }
-
- return set_line_height(result, type, length, unit);
+ return css__copy_line_height(
+ type == CSS_LINE_HEIGHT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/list_style_image.c b/src/select/properties/list_style_image.c
index cc77eb4..7a41c3a 100644
--- a/src/select/properties/list_style_image.c
+++ b/src/select/properties/list_style_image.c
@@ -39,6 +39,20 @@ css_error css__initial_list_style_image(css_select_state *state)
CSS_LIST_STYLE_IMAGE_NONE, NULL);
}
+css_error css__copy_list_style_image(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ lwc_string *url;
+ uint8_t type = get_list_style_image(from, &url);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_list_style_image(to, type, url);
+}
+
css_error css__compose_list_style_image(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -46,10 +60,8 @@ css_error css__compose_list_style_image(const css_computed_style *parent,
lwc_string *url;
uint8_t type = get_list_style_image(child, &url);
- if (type == CSS_LIST_STYLE_IMAGE_INHERIT) {
- type = get_list_style_image(parent, &url);
- }
-
- return set_list_style_image(result, type, url);
+ return css__copy_list_style_image(
+ type == CSS_LIST_STYLE_IMAGE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/list_style_position.c b/src/select/properties/list_style_position.c
index 0231c10..ca46850 100644
--- a/src/select/properties/list_style_position.c
+++ b/src/select/properties/list_style_position.c
@@ -52,16 +52,25 @@ css_error css__initial_list_style_position(css_select_state *state)
CSS_LIST_STYLE_POSITION_OUTSIDE);
}
+css_error css__copy_list_style_position(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_list_style_position(to, get_list_style_position(from));
+}
+
css_error css__compose_list_style_position(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_list_style_position(child);
- if (type == CSS_LIST_STYLE_POSITION_INHERIT) {
- type = get_list_style_position(parent);
- }
-
- return set_list_style_position(result, type);
+ return css__copy_list_style_position(
+ type == CSS_LIST_STYLE_POSITION_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/list_style_type.c b/src/select/properties/list_style_type.c
index 19cde9b..9d809e6 100644
--- a/src/select/properties/list_style_type.c
+++ b/src/select/properties/list_style_type.c
@@ -201,15 +201,24 @@ css_error css__initial_list_style_type(css_select_state *state)
return set_list_style_type(state->computed, CSS_LIST_STYLE_TYPE_DISC);
}
+css_error css__copy_list_style_type(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_list_style_type(to, get_list_style_type(from));
+}
+
css_error css__compose_list_style_type(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_list_style_type(child);
- if (type == CSS_LIST_STYLE_TYPE_INHERIT) {
- type = get_list_style_type(parent);
- }
-
- return set_list_style_type(result, type);
+ return css__copy_list_style_type(
+ type == CSS_LIST_STYLE_TYPE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/margin_bottom.c b/src/select/properties/margin_bottom.c
index 3b1d8a1..a0ffd89 100644
--- a/src/select/properties/margin_bottom.c
+++ b/src/select/properties/margin_bottom.c
@@ -32,6 +32,21 @@ css_error css__initial_margin_bottom(css_select_state *state)
return set_margin_bottom(state->computed, CSS_MARGIN_SET, 0, CSS_UNIT_PX);
}
+css_error css__copy_margin_bottom(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_margin_bottom(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_margin_bottom(to, type, length, unit);
+}
+
css_error css__compose_margin_bottom(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +55,8 @@ css_error css__compose_margin_bottom(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_margin_bottom(child, &length, &unit);
- if (type == CSS_MARGIN_INHERIT) {
- type = get_margin_bottom(parent, &length, &unit);
- }
-
- return set_margin_bottom(result, type, length, unit);
+ return css__copy_margin_bottom(
+ type == CSS_MARGIN_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/margin_left.c b/src/select/properties/margin_left.c
index 240285a..b163fba 100644
--- a/src/select/properties/margin_left.c
+++ b/src/select/properties/margin_left.c
@@ -32,6 +32,21 @@ css_error css__initial_margin_left(css_select_state *state)
return set_margin_left(state->computed, CSS_MARGIN_SET, 0, CSS_UNIT_PX);
}
+css_error css__copy_margin_left(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_margin_left(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_margin_left(to, type, length, unit);
+}
+
css_error css__compose_margin_left(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +55,8 @@ css_error css__compose_margin_left(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_margin_left(child, &length, &unit);
- if (type == CSS_MARGIN_INHERIT) {
- type = get_margin_left(parent, &length, &unit);
- }
-
- return set_margin_left(result, type, length, unit);
+ return css__copy_margin_left(
+ type == CSS_MARGIN_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/margin_right.c b/src/select/properties/margin_right.c
index 737fbee..2c15b54 100644
--- a/src/select/properties/margin_right.c
+++ b/src/select/properties/margin_right.c
@@ -32,6 +32,21 @@ css_error css__initial_margin_right(css_select_state *state)
return set_margin_right(state->computed, CSS_MARGIN_SET, 0, CSS_UNIT_PX);
}
+css_error css__copy_margin_right(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_margin_right(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_margin_right(to, type, length, unit);
+}
+
css_error css__compose_margin_right(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +55,8 @@ css_error css__compose_margin_right(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_margin_right(child, &length, &unit);
- if (type == CSS_MARGIN_INHERIT) {
- type = get_margin_right(parent, &length, &unit);
- }
-
- return set_margin_right(result, type, length, unit);
+ return css__copy_margin_right(
+ type == CSS_MARGIN_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/margin_top.c b/src/select/properties/margin_top.c
index 5563a48..1df811d 100644
--- a/src/select/properties/margin_top.c
+++ b/src/select/properties/margin_top.c
@@ -32,6 +32,21 @@ css_error css__initial_margin_top(css_select_state *state)
return set_margin_top(state->computed, CSS_MARGIN_SET, 0, CSS_UNIT_PX);
}
+css_error css__copy_margin_top(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_margin_top(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_margin_top(to, type, length, unit);
+}
+
css_error css__compose_margin_top(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +55,8 @@ css_error css__compose_margin_top(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_margin_top(child, &length, &unit);
- if (type == CSS_MARGIN_INHERIT) {
- type = get_margin_top(parent, &length, &unit);
- }
-
- return set_margin_top(result, type, length, unit);
+ return css__copy_margin_top(
+ type == CSS_MARGIN_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/max_height.c b/src/select/properties/max_height.c
index e03c8da..1dcf09d 100644
--- a/src/select/properties/max_height.c
+++ b/src/select/properties/max_height.c
@@ -33,6 +33,21 @@ css_error css__initial_max_height(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_max_height(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_max_height(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_max_height(to, type, length, unit);
+}
+
css_error css__compose_max_height(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,10 +56,8 @@ css_error css__compose_max_height(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_max_height(child, &length, &unit);
- if (type == CSS_MAX_HEIGHT_INHERIT) {
- type = get_max_height(parent, &length, &unit);
- }
-
- return set_max_height(result, type, length, unit);
+ return css__copy_max_height(
+ type == CSS_MAX_HEIGHT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/max_width.c b/src/select/properties/max_width.c
index ec98712..11d8ade 100644
--- a/src/select/properties/max_width.c
+++ b/src/select/properties/max_width.c
@@ -32,6 +32,21 @@ css_error css__initial_max_width(css_select_state *state)
return set_max_width(state->computed, CSS_MAX_WIDTH_NONE, 0, CSS_UNIT_PX);
}
+css_error css__copy_max_width(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_max_width(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_max_width(to, type, length, unit);
+}
+
css_error css__compose_max_width(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +55,8 @@ css_error css__compose_max_width(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_max_width(child, &length, &unit);
- if (type == CSS_MAX_WIDTH_INHERIT) {
- type = get_max_width(parent, &length, &unit);
- }
-
- return set_max_width(result, type, length, unit);
+ return css__copy_max_width(
+ type == CSS_MAX_WIDTH_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/min_height.c b/src/select/properties/min_height.c
index a5389ce..d05655c 100644
--- a/src/select/properties/min_height.c
+++ b/src/select/properties/min_height.c
@@ -33,6 +33,21 @@ css_error css__initial_min_height(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_min_height(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_min_height(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_min_height(to, type, length, unit);
+}
+
css_error css__compose_min_height(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,10 +56,8 @@ css_error css__compose_min_height(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_min_height(child, &length, &unit);
- if (type == CSS_MIN_HEIGHT_INHERIT) {
- type = get_min_height(parent, &length, &unit);
- }
-
- return set_min_height(result, type, length, unit);
+ return css__copy_min_height(
+ type == CSS_MIN_HEIGHT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/min_width.c b/src/select/properties/min_width.c
index 8460e01..af709d3 100644
--- a/src/select/properties/min_width.c
+++ b/src/select/properties/min_width.c
@@ -33,6 +33,21 @@ css_error css__initial_min_width(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_min_width(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_min_width(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_min_width(to, type, length, unit);
+}
+
css_error css__compose_min_width(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,10 +56,8 @@ css_error css__compose_min_width(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_min_width(child, &length, &unit);
- if (type == CSS_MIN_WIDTH_INHERIT) {
- type = get_min_width(parent, &length, &unit);
- }
-
- return set_min_width(result, type, length, unit);
+ return css__copy_min_width(
+ type == CSS_MIN_WIDTH_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/opacity.c b/src/select/properties/opacity.c
index c202d36..818af62 100644
--- a/src/select/properties/opacity.c
+++ b/src/select/properties/opacity.c
@@ -46,6 +46,20 @@ css_error css__initial_opacity(css_select_state *state)
return set_opacity(state->computed, CSS_OPACITY_SET, INTTOFIX(1));
}
+css_error css__copy_opacity(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed opacity = 0;
+ uint8_t type = get_opacity(from, &opacity);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_opacity(to, type, opacity);
+}
+
css_error css__compose_opacity(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -53,10 +67,8 @@ css_error css__compose_opacity(const css_computed_style *parent,
css_fixed opacity = 0;
uint8_t type = get_opacity(child, &opacity);
- if (type == CSS_OPACITY_INHERIT) {
- type = get_opacity(parent, &opacity);
- }
-
- return set_opacity(result, type, opacity);
+ return css__copy_opacity(
+ type == CSS_OPACITY_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/order.c b/src/select/properties/order.c
index 7e447f1..4004c0e 100644
--- a/src/select/properties/order.c
+++ b/src/select/properties/order.c
@@ -46,6 +46,20 @@ css_error css__initial_order(css_select_state *state)
return set_order(state->computed, CSS_ORDER_SET, 0);
}
+css_error css__copy_order(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ int32_t order = 0;
+ uint8_t type = get_order(from, &order);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_order(to, type, order);
+}
+
css_error css__compose_order(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -53,10 +67,8 @@ css_error css__compose_order(const css_computed_style *parent,
int32_t order = 0;
uint8_t type = get_order(child, &order);
- if (type == CSS_ORDER_INHERIT) {
- type = get_order(parent, &order);
- }
-
- return set_order(result, type, order);
+ return css__copy_order(
+ type == CSS_ORDER_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/orphans.c b/src/select/properties/orphans.c
index f169b81..b0fee43 100644
--- a/src/select/properties/orphans.c
+++ b/src/select/properties/orphans.c
@@ -31,6 +31,20 @@ css_error css__initial_orphans(css_select_state *state)
return set_orphans(state->computed, CSS_ORPHANS_SET, 2);
}
+css_error css__copy_orphans(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ int32_t count = 0;
+ uint8_t type = get_orphans(from, &count);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_orphans(to, type, count);
+}
+
css_error css__compose_orphans(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -38,10 +52,8 @@ css_error css__compose_orphans(const css_computed_style *parent,
int32_t count = 0;
uint8_t type = get_orphans(child, &count);
- if (type == CSS_ORPHANS_INHERIT) {
- type = get_orphans(parent, &count);
- }
-
- return set_orphans(result, type, count);
+ return css__copy_orphans(
+ type == CSS_ORPHANS_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/outline_color.c b/src/select/properties/outline_color.c
index 707dd7b..359960f 100644
--- a/src/select/properties/outline_color.c
+++ b/src/select/properties/outline_color.c
@@ -58,6 +58,20 @@ css_error css__initial_outline_color(css_select_state *state)
return set_outline_color(state->computed, CSS_OUTLINE_COLOR_INVERT, 0);
}
+css_error css__copy_outline_color(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_color color = 0;
+ uint8_t type = get_outline_color(from, &color);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_outline_color(to, type, color);
+}
+
css_error css__compose_outline_color(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -65,9 +79,7 @@ css_error css__compose_outline_color(const css_computed_style *parent,
css_color color = 0;
uint8_t type = get_outline_color(child, &color);
- if (type == CSS_OUTLINE_COLOR_INHERIT) {
- type = get_outline_color(parent, &color);
- }
-
- return set_outline_color(result, type, color);
+ return css__copy_outline_color(
+ type == CSS_OUTLINE_COLOR_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/outline_style.c b/src/select/properties/outline_style.c
index 5c30735..acdab03 100644
--- a/src/select/properties/outline_style.c
+++ b/src/select/properties/outline_style.c
@@ -31,16 +31,25 @@ css_error css__initial_outline_style(css_select_state *state)
return set_outline_style(state->computed, CSS_OUTLINE_STYLE_NONE);
}
+css_error css__copy_outline_style(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_outline_style(to, get_outline_style(from));
+}
+
css_error css__compose_outline_style(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_outline_style(child);
- if (type == CSS_OUTLINE_STYLE_INHERIT) {
- type = get_outline_style(parent);
- }
-
- return set_outline_style(result, type);
+ return css__copy_outline_style(
+ type == CSS_OUTLINE_STYLE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/outline_width.c b/src/select/properties/outline_width.c
index 0289c57..dbc0298 100644
--- a/src/select/properties/outline_width.c
+++ b/src/select/properties/outline_width.c
@@ -33,6 +33,21 @@ css_error css__initial_outline_width(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_outline_width(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_outline_width(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_outline_width(to, type, length, unit);
+}
+
css_error css__compose_outline_width(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,10 +56,8 @@ css_error css__compose_outline_width(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_outline_width(child, &length, &unit);
- if (type == CSS_OUTLINE_WIDTH_INHERIT) {
- type = get_outline_width(parent, &length, &unit);
- }
-
- return set_outline_width(result, type, length, unit);
+ return css__copy_outline_width(
+ type == CSS_OUTLINE_WIDTH_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/overflow_x.c b/src/select/properties/overflow_x.c
index 29ce7f7..98dfba5 100644
--- a/src/select/properties/overflow_x.c
+++ b/src/select/properties/overflow_x.c
@@ -57,16 +57,25 @@ css_error css__initial_overflow_x(css_select_state *state)
return set_overflow_x(state->computed, CSS_OVERFLOW_VISIBLE);
}
+css_error css__copy_overflow_x(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_overflow_x(to, get_overflow_x(from));
+}
+
css_error css__compose_overflow_x(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_overflow_x(child);
- if (type == CSS_OVERFLOW_INHERIT) {
- type = get_overflow_x(parent);
- }
-
- return set_overflow_x(result, type);
+ return css__copy_overflow_x(
+ type == CSS_OVERFLOW_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/overflow_y.c b/src/select/properties/overflow_y.c
index 398225b..d7795a2 100644
--- a/src/select/properties/overflow_y.c
+++ b/src/select/properties/overflow_y.c
@@ -57,16 +57,25 @@ css_error css__initial_overflow_y(css_select_state *state)
return set_overflow_y(state->computed, CSS_OVERFLOW_VISIBLE);
}
+css_error css__copy_overflow_y(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_overflow_y(to, get_overflow_y(from));
+}
+
css_error css__compose_overflow_y(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_overflow_y(child);
- if (type == CSS_OVERFLOW_INHERIT) {
- type = get_overflow_y(parent);
- }
-
- return set_overflow_y(result, type);
+ return css__copy_overflow_y(
+ type == CSS_OVERFLOW_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/padding_bottom.c b/src/select/properties/padding_bottom.c
index e3b36f7..53c749c 100644
--- a/src/select/properties/padding_bottom.c
+++ b/src/select/properties/padding_bottom.c
@@ -33,6 +33,21 @@ css_error css__initial_padding_bottom(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_padding_bottom(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_padding_bottom(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_padding_bottom(to, type, length, unit);
+}
+
css_error css__compose_padding_bottom(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,10 +56,8 @@ css_error css__compose_padding_bottom(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_padding_bottom(child, &length, &unit);
- if (type == CSS_PADDING_INHERIT) {
- type = get_padding_bottom(parent, &length, &unit);
- }
-
- return set_padding_bottom(result, type, length, unit);
+ return css__copy_padding_bottom(
+ type == CSS_PADDING_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/padding_left.c b/src/select/properties/padding_left.c
index bdea11e..b61ca83 100644
--- a/src/select/properties/padding_left.c
+++ b/src/select/properties/padding_left.c
@@ -32,6 +32,21 @@ css_error css__initial_padding_left(css_select_state *state)
return set_padding_left(state->computed, CSS_PADDING_SET, 0, CSS_UNIT_PX);
}
+css_error css__copy_padding_left(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_padding_left(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_padding_left(to, type, length, unit);
+}
+
css_error css__compose_padding_left(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +55,8 @@ css_error css__compose_padding_left(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_padding_left(child, &length, &unit);
- if (type == CSS_PADDING_INHERIT) {
- type = get_padding_left(parent, &length, &unit);
- }
-
- return set_padding_left(result, type, length, unit);
+ return css__copy_padding_left(
+ type == CSS_PADDING_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/padding_right.c b/src/select/properties/padding_right.c
index 82c1ed3..35417d6 100644
--- a/src/select/properties/padding_right.c
+++ b/src/select/properties/padding_right.c
@@ -33,6 +33,21 @@ css_error css__initial_padding_right(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_padding_right(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_padding_right(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_padding_right(to, type, length, unit);
+}
+
css_error css__compose_padding_right(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,10 +56,8 @@ css_error css__compose_padding_right(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_padding_right(child, &length, &unit);
- if (type == CSS_PADDING_INHERIT) {
- type = get_padding_right(parent, &length, &unit);
- }
-
- return set_padding_right(result, type, length, unit);
+ return css__copy_padding_right(
+ type == CSS_PADDING_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/padding_top.c b/src/select/properties/padding_top.c
index f6d8b3e..a2cec95 100644
--- a/src/select/properties/padding_top.c
+++ b/src/select/properties/padding_top.c
@@ -32,6 +32,21 @@ css_error css__initial_padding_top(css_select_state *state)
return set_padding_top(state->computed, CSS_PADDING_SET, 0, CSS_UNIT_PX);
}
+css_error css__copy_padding_top(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_padding_top(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_padding_top(to, type, length, unit);
+}
+
css_error css__compose_padding_top(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +55,8 @@ css_error css__compose_padding_top(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_padding_top(child, &length, &unit);
- if (type == CSS_PADDING_INHERIT) {
- type = get_padding_top(parent, &length, &unit);
- }
-
- return set_padding_top(result, type, length, unit);
+ return css__copy_padding_top(
+ type == CSS_PADDING_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/page_break_after.c b/src/select/properties/page_break_after.c
index fdb6774..4065a17 100644
--- a/src/select/properties/page_break_after.c
+++ b/src/select/properties/page_break_after.c
@@ -33,16 +33,25 @@ css_error css__initial_page_break_after(css_select_state *state)
CSS_PAGE_BREAK_AFTER_AUTO);
}
+css_error css__copy_page_break_after(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_page_break_after(to, get_page_break_after(from));
+}
+
css_error css__compose_page_break_after(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_page_break_after(child);
- if (type == CSS_PAGE_BREAK_AFTER_INHERIT) {
- type = get_page_break_after(parent);
- }
-
- return set_page_break_after(result, type);
+ return css__copy_page_break_after(
+ type == CSS_PAGE_BREAK_AFTER_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/page_break_before.c b/src/select/properties/page_break_before.c
index 1491997..d8fdd93 100644
--- a/src/select/properties/page_break_before.c
+++ b/src/select/properties/page_break_before.c
@@ -33,15 +33,24 @@ css_error css__initial_page_break_before(css_select_state *state)
CSS_PAGE_BREAK_BEFORE_AUTO);
}
+css_error css__copy_page_break_before(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_page_break_before(to, get_page_break_before(from));
+}
+
css_error css__compose_page_break_before(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_page_break_before(child);
- if (type == CSS_PAGE_BREAK_BEFORE_INHERIT) {
- type = get_page_break_before(parent);
- }
-
- return set_page_break_before(result, type);
+ return css__copy_page_break_before(
+ type == CSS_PAGE_BREAK_BEFORE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/page_break_inside.c b/src/select/properties/page_break_inside.c
index ddcb19f..8655c40 100644
--- a/src/select/properties/page_break_inside.c
+++ b/src/select/properties/page_break_inside.c
@@ -33,16 +33,25 @@ css_error css__initial_page_break_inside(css_select_state *state)
CSS_PAGE_BREAK_INSIDE_AUTO);
}
+css_error css__copy_page_break_inside(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_page_break_inside(to, get_page_break_inside(from));
+}
+
css_error css__compose_page_break_inside(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_page_break_inside(child);
- if (type == CSS_PAGE_BREAK_INSIDE_INHERIT) {
- type = get_page_break_inside(parent);
- }
-
- return set_page_break_inside(result, type);
+ return css__copy_page_break_inside(
+ type == CSS_PAGE_BREAK_INSIDE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/pause_after.c b/src/select/properties/pause_after.c
index 16bbefe..b8bf968 100644
--- a/src/select/properties/pause_after.c
+++ b/src/select/properties/pause_after.c
@@ -37,6 +37,16 @@ css_error css__initial_pause_after(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_pause_after(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_pause_after(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/pause_before.c b/src/select/properties/pause_before.c
index 7770615..74cb565 100644
--- a/src/select/properties/pause_before.c
+++ b/src/select/properties/pause_before.c
@@ -37,6 +37,16 @@ css_error css__initial_pause_before(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_pause_before(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_pause_before(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/pitch.c b/src/select/properties/pitch.c
index cdff1d6..c0c5c88 100644
--- a/src/select/properties/pitch.c
+++ b/src/select/properties/pitch.c
@@ -64,6 +64,16 @@ css_error css__initial_pitch(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_pitch(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_pitch(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/pitch_range.c b/src/select/properties/pitch_range.c
index 52a5751..c8f7526 100644
--- a/src/select/properties/pitch_range.c
+++ b/src/select/properties/pitch_range.c
@@ -37,6 +37,16 @@ css_error css__initial_pitch_range(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_pitch_range(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_pitch_range(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/play_during.c b/src/select/properties/play_during.c
index d397b82..0f38f74 100644
--- a/src/select/properties/play_during.c
+++ b/src/select/properties/play_during.c
@@ -58,6 +58,16 @@ css_error css__initial_play_during(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_play_during(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_play_during(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/position.c b/src/select/properties/position.c
index c7cc6bf..738dbff 100644
--- a/src/select/properties/position.c
+++ b/src/select/properties/position.c
@@ -57,16 +57,25 @@ css_error css__initial_position(css_select_state *state)
return set_position(state->computed, CSS_POSITION_STATIC);
}
+css_error css__copy_position(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_position(to, get_position(from));
+}
+
css_error css__compose_position(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_position(child);
- if (type == CSS_POSITION_INHERIT) {
- type = get_position(parent);
- }
-
- return set_position(result, type);
+ return css__copy_position(
+ type == CSS_POSITION_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/properties.h b/src/select/properties/properties.h
index 6eac397..be31d0b 100644
--- a/src/select/properties/properties.h
+++ b/src/select/properties/properties.h
@@ -18,6 +18,7 @@
css_error css__cascade_##pname (uint32_t opv, css_style *style, css_select_state *state); \
css_error css__set_##pname##_from_hint(const css_hint *hint, css_computed_style *style); \
css_error css__initial_##pname (css_select_state *state); \
+ css_error css__copy_##pname (const css_computed_style *from, css_computed_style *to); \
css_error css__compose_##pname (const css_computed_style *parent, const css_computed_style *child, css_computed_style *result); \
uint32_t destroy_##pname (void *bytecode)
diff --git a/src/select/properties/richness.c b/src/select/properties/richness.c
index 9656486..cd62d5c 100644
--- a/src/select/properties/richness.c
+++ b/src/select/properties/richness.c
@@ -37,6 +37,16 @@ css_error css__initial_richness(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_richness(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_richness(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/right.c b/src/select/properties/right.c
index 142e7e8..ee4f4a0 100644
--- a/src/select/properties/right.c
+++ b/src/select/properties/right.c
@@ -32,6 +32,21 @@ css_error css__initial_right(css_select_state *state)
return set_right(state->computed, CSS_RIGHT_AUTO, 0, CSS_UNIT_PX);
}
+css_error css__copy_right(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_right(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_right(to, type, length, unit);
+}
+
css_error css__compose_right(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +55,8 @@ css_error css__compose_right(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_right(child, &length, &unit);
- if (type == CSS_RIGHT_INHERIT) {
- type = get_right(parent, &length, &unit);
- }
-
- return set_right(result, type, length, unit);
+ return css__copy_right(
+ type == CSS_RIGHT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/speak.c b/src/select/properties/speak.c
index 87e77d9..7b0d014 100644
--- a/src/select/properties/speak.c
+++ b/src/select/properties/speak.c
@@ -53,6 +53,16 @@ css_error css__initial_speak(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_speak(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_speak(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/speak_header.c b/src/select/properties/speak_header.c
index 9d74228..88ad0d7 100644
--- a/src/select/properties/speak_header.c
+++ b/src/select/properties/speak_header.c
@@ -52,6 +52,16 @@ css_error css__initial_speak_header(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_speak_header(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_speak_header(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/speak_numeral.c b/src/select/properties/speak_numeral.c
index ae94d2e..1cd6e98 100644
--- a/src/select/properties/speak_numeral.c
+++ b/src/select/properties/speak_numeral.c
@@ -52,6 +52,16 @@ css_error css__initial_speak_numeral(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_speak_numeral(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_speak_numeral(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/speak_punctuation.c b/src/select/properties/speak_punctuation.c
index e9f8575..916d530 100644
--- a/src/select/properties/speak_punctuation.c
+++ b/src/select/properties/speak_punctuation.c
@@ -52,6 +52,16 @@ css_error css__initial_speak_punctuation(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_speak_punctuation(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_speak_punctuation(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/speech_rate.c b/src/select/properties/speech_rate.c
index ac9d300..296c248 100644
--- a/src/select/properties/speech_rate.c
+++ b/src/select/properties/speech_rate.c
@@ -61,6 +61,16 @@ css_error css__initial_speech_rate(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_speech_rate(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_speech_rate(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/stress.c b/src/select/properties/stress.c
index c9d61dd..0320fd0 100644
--- a/src/select/properties/stress.c
+++ b/src/select/properties/stress.c
@@ -37,6 +37,16 @@ css_error css__initial_stress(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_stress(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_stress(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/table_layout.c b/src/select/properties/table_layout.c
index 013ae47..255ce37 100644
--- a/src/select/properties/table_layout.c
+++ b/src/select/properties/table_layout.c
@@ -51,16 +51,25 @@ css_error css__initial_table_layout(css_select_state *state)
return set_table_layout(state->computed, CSS_TABLE_LAYOUT_AUTO);
}
+css_error css__copy_table_layout(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_table_layout(to, get_table_layout(from));
+}
+
css_error css__compose_table_layout(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_table_layout(child);
- if (type == CSS_TABLE_LAYOUT_INHERIT) {
- type = get_table_layout(parent);
- }
-
- return set_table_layout(result, type);
+ return css__copy_table_layout(
+ type == CSS_TABLE_LAYOUT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/text_decoration.c b/src/select/properties/text_decoration.c
index 759009c..bfea8a8 100644
--- a/src/select/properties/text_decoration.c
+++ b/src/select/properties/text_decoration.c
@@ -59,16 +59,25 @@ css_error css__initial_text_decoration(css_select_state *state)
return set_text_decoration(state->computed, CSS_TEXT_DECORATION_NONE);
}
+css_error css__copy_text_decoration(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_text_decoration(to, get_text_decoration(from));
+}
+
css_error css__compose_text_decoration(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_text_decoration(child);
- if (type == CSS_TEXT_DECORATION_INHERIT) {
- type = get_text_decoration(parent);
- }
-
- return set_text_decoration(result, type);
+ return css__copy_text_decoration(
+ type == CSS_TEXT_DECORATION_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/text_indent.c b/src/select/properties/text_indent.c
index 787c0be..3708130 100644
--- a/src/select/properties/text_indent.c
+++ b/src/select/properties/text_indent.c
@@ -33,6 +33,21 @@ css_error css__initial_text_indent(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_text_indent(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_text_indent(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_text_indent(to, type, length, unit);
+}
+
css_error css__compose_text_indent(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,10 +56,8 @@ css_error css__compose_text_indent(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_text_indent(child, &length, &unit);
- if (type == CSS_TEXT_INDENT_INHERIT) {
- type = get_text_indent(parent, &length, &unit);
- }
-
- return set_text_indent(result, type, length, unit);
+ return css__copy_text_indent(
+ type == CSS_TEXT_INDENT_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/text_transform.c b/src/select/properties/text_transform.c
index f3fac38..3bc5757 100644
--- a/src/select/properties/text_transform.c
+++ b/src/select/properties/text_transform.c
@@ -57,16 +57,25 @@ css_error css__initial_text_transform(css_select_state *state)
return set_text_transform(state->computed, CSS_TEXT_TRANSFORM_NONE);
}
+css_error css__copy_text_transform(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_text_transform(to, get_text_transform(from));
+}
+
css_error css__compose_text_transform(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_text_transform(child);
- if (type == CSS_TEXT_TRANSFORM_INHERIT) {
- type = get_text_transform(parent);
- }
-
- return set_text_transform(result, type);
+ return css__copy_text_transform(
+ type == CSS_TEXT_TRANSFORM_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/top.c b/src/select/properties/top.c
index 72129aa..473a105 100644
--- a/src/select/properties/top.c
+++ b/src/select/properties/top.c
@@ -32,6 +32,21 @@ css_error css__initial_top(css_select_state *state)
return set_top(state->computed, CSS_TOP_AUTO, 0, CSS_UNIT_PX);
}
+css_error css__copy_top(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_top(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_top(to, type, length, unit);
+}
+
css_error css__compose_top(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +55,8 @@ css_error css__compose_top(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_top(child, &length, &unit);
- if (type == CSS_TOP_INHERIT) {
- type = get_top(parent, &length, &unit);
- }
-
- return set_top(result, type, length, unit);
+ return css__copy_top(
+ type == CSS_TOP_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/unicode_bidi.c b/src/select/properties/unicode_bidi.c
index 0a4c0d1..ae0f4ad 100644
--- a/src/select/properties/unicode_bidi.c
+++ b/src/select/properties/unicode_bidi.c
@@ -54,16 +54,25 @@ css_error css__initial_unicode_bidi(css_select_state *state)
return set_unicode_bidi(state->computed, CSS_UNICODE_BIDI_NORMAL);
}
+css_error css__copy_unicode_bidi(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_unicode_bidi(to, get_unicode_bidi(from));
+}
+
css_error css__compose_unicode_bidi(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_unicode_bidi(child);
- if (type == CSS_UNICODE_BIDI_INHERIT) {
- type = get_unicode_bidi(parent);
- }
-
- return set_unicode_bidi(result, type);
+ return css__copy_unicode_bidi(
+ type == CSS_UNICODE_BIDI_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/vertical_align.c b/src/select/properties/vertical_align.c
index 18b8b55..9fbffe6 100644
--- a/src/select/properties/vertical_align.c
+++ b/src/select/properties/vertical_align.c
@@ -81,6 +81,21 @@ css_error css__initial_vertical_align(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_vertical_align(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_vertical_align(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_vertical_align(to, type, length, unit);
+}
+
css_error css__compose_vertical_align(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -89,10 +104,8 @@ css_error css__compose_vertical_align(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_vertical_align(child, &length, &unit);
- if (type == CSS_VERTICAL_ALIGN_INHERIT) {
- type = get_vertical_align(parent, &length, &unit);
- }
-
- return set_vertical_align(result, type, length, unit);
+ return css__copy_vertical_align(
+ type == CSS_VERTICAL_ALIGN_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/visibility.c b/src/select/properties/visibility.c
index 901700d..674e433 100644
--- a/src/select/properties/visibility.c
+++ b/src/select/properties/visibility.c
@@ -54,16 +54,25 @@ css_error css__initial_visibility(css_select_state *state)
return set_visibility(state->computed, CSS_VISIBILITY_VISIBLE);
}
+css_error css__copy_visibility(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_visibility(to, get_visibility(from));
+}
+
css_error css__compose_visibility(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_visibility(child);
- if (type == CSS_VISIBILITY_INHERIT) {
- type = get_visibility(parent);
- }
-
- return set_visibility(result, type);
+ return css__copy_visibility(
+ type == CSS_VISIBILITY_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/voice_family.c b/src/select/properties/voice_family.c
index ff0324c..66e3123 100644
--- a/src/select/properties/voice_family.c
+++ b/src/select/properties/voice_family.c
@@ -120,6 +120,16 @@ css_error css__initial_voice_family(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_voice_family(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_voice_family(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/volume.c b/src/select/properties/volume.c
index 65bf979..65bdd03 100644
--- a/src/select/properties/volume.c
+++ b/src/select/properties/volume.c
@@ -69,6 +69,16 @@ css_error css__initial_volume(css_select_state *state)
return CSS_OK;
}
+css_error css__copy_volume(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ UNUSED(from);
+ UNUSED(to);
+
+ return CSS_OK;
+}
+
css_error css__compose_volume(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
diff --git a/src/select/properties/white_space.c b/src/select/properties/white_space.c
index 1c22f9d..edc35cd 100644
--- a/src/select/properties/white_space.c
+++ b/src/select/properties/white_space.c
@@ -60,16 +60,25 @@ css_error css__initial_white_space(css_select_state *state)
return set_white_space(state->computed, CSS_WHITE_SPACE_NORMAL);
}
+css_error css__copy_white_space(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_white_space(to, get_white_space(from));
+}
+
css_error css__compose_white_space(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
uint8_t type = get_white_space(child);
- if (type == CSS_WHITE_SPACE_INHERIT) {
- type = get_white_space(parent);
- }
-
- return set_white_space(result, type);
+ return css__copy_white_space(
+ type == CSS_WHITE_SPACE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/widows.c b/src/select/properties/widows.c
index 61126c2..853c08d 100644
--- a/src/select/properties/widows.c
+++ b/src/select/properties/widows.c
@@ -31,6 +31,20 @@ css_error css__initial_widows(css_select_state *state)
return set_widows(state->computed, CSS_WIDOWS_SET, 2);
}
+css_error css__copy_widows(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ int32_t count = 0;
+ uint8_t type = get_widows(from, &count);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_widows(to, type, count);
+}
+
css_error css__compose_widows(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -38,10 +52,8 @@ css_error css__compose_widows(const css_computed_style *parent,
int32_t count = 0;
uint8_t type = get_widows(child, &count);
- if (type == CSS_WIDOWS_INHERIT) {
- type = get_widows(parent, &count);
- }
-
- return set_widows(result, type, count);
+ return css__copy_widows(
+ type == CSS_WIDOWS_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/width.c b/src/select/properties/width.c
index 829df91..c6d33ff 100644
--- a/src/select/properties/width.c
+++ b/src/select/properties/width.c
@@ -32,6 +32,21 @@ css_error css__initial_width(css_select_state *state)
return set_width(state->computed, CSS_WIDTH_AUTO, 0, CSS_UNIT_PX);
}
+css_error css__copy_width(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_width(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_width(to, type, length, unit);
+}
+
css_error css__compose_width(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -40,10 +55,8 @@ css_error css__compose_width(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_width(child, &length, &unit);
- if (type == CSS_WIDTH_INHERIT) {
- type = get_width(parent, &length, &unit);
- }
-
- return set_width(result, type, length, unit);
+ return css__copy_width(
+ type == CSS_WIDTH_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/word_spacing.c b/src/select/properties/word_spacing.c
index eb39b50..c1c6782 100644
--- a/src/select/properties/word_spacing.c
+++ b/src/select/properties/word_spacing.c
@@ -33,6 +33,21 @@ css_error css__initial_word_spacing(css_select_state *state)
0, CSS_UNIT_PX);
}
+css_error css__copy_word_spacing(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_word_spacing(from, &length, &unit);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_word_spacing(to, type, length, unit);
+}
+
css_error css__compose_word_spacing(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -41,9 +56,7 @@ css_error css__compose_word_spacing(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_word_spacing(child, &length, &unit);
- if (type == CSS_WORD_SPACING_INHERIT) {
- type = get_word_spacing(parent, &length, &unit);
- }
-
- return set_word_spacing(result, type, length, unit);
+ return css__copy_word_spacing(
+ type == CSS_WORD_SPACING_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/writing_mode.c b/src/select/properties/writing_mode.c
index 99ebd9e..05c0b26 100644
--- a/src/select/properties/writing_mode.c
+++ b/src/select/properties/writing_mode.c
@@ -55,16 +55,25 @@ css_error css__initial_writing_mode(css_select_state *state)
CSS_WRITING_MODE_HORIZONTAL_TB);
}
+css_error css__copy_writing_mode(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_writing_mode(to, get_writing_mode(from));
+}
+
css_error css__compose_writing_mode(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- uint8_t writing_mode = get_writing_mode(child);
-
- if (writing_mode == CSS_WRITING_MODE_INHERIT) {
- writing_mode = get_writing_mode(parent);
- }
+ uint8_t type = get_writing_mode(child);
- return set_writing_mode(result, writing_mode);
+ return css__copy_writing_mode(
+ type == CSS_WRITING_MODE_INHERIT ? parent : child,
+ result);
}
diff --git a/src/select/properties/z_index.c b/src/select/properties/z_index.c
index 32a952d..e5159e5 100644
--- a/src/select/properties/z_index.c
+++ b/src/select/properties/z_index.c
@@ -53,6 +53,20 @@ css_error css__initial_z_index(css_select_state *state)
return set_z_index(state->computed, CSS_Z_INDEX_AUTO, 0);
}
+css_error css__copy_z_index(
+ const css_computed_style *from,
+ css_computed_style *to)
+{
+ int32_t index = 0;
+ uint8_t type = get_z_index(from, &index);
+
+ if (from == to) {
+ return CSS_OK;
+ }
+
+ return set_z_index(to, type, index);
+}
+
css_error css__compose_z_index(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
@@ -60,10 +74,8 @@ css_error css__compose_z_index(const css_computed_style *parent,
int32_t index = 0;
uint8_t type = get_z_index(child, &index);
- if (type == CSS_Z_INDEX_INHERIT) {
- type = get_z_index(parent, &index);
- }
-
- return set_z_index(result, type, index);
+ return css__copy_z_index(
+ type == CSS_Z_INDEX_INHERIT ? parent : child,
+ result);
}