summaryrefslogtreecommitdiff
path: root/src/select/properties/font_family.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/select/properties/font_family.c')
-rw-r--r--src/select/properties/font_family.c61
1 files changed, 30 insertions, 31 deletions
diff --git a/src/select/properties/font_family.c b/src/select/properties/font_family.c
index f853fcc..b0183e2 100644
--- a/src/select/properties/font_family.c
+++ b/src/select/properties/font_family.c
@@ -21,7 +21,7 @@ css_error css__cascade_font_family(uint32_t opv, css_style *style,
lwc_string **fonts = NULL;
uint32_t n_fonts = 0;
- if (isInherit(opv) == false) {
+ if (hasFlagValue(opv) == false) {
uint32_t v = getValue(opv);
while (v != FONT_FAMILY_END) {
@@ -134,7 +134,7 @@ css_error css__cascade_font_family(uint32_t opv, css_style *style,
}
if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
- isInherit(opv))) {
+ getFlagValue(opv))) {
css_error error;
error = set_font_family(state->computed, value, fonts);
@@ -182,42 +182,41 @@ css_error css__initial_font_family(css_select_state *state)
return css__set_font_family_from_hint(&hint, state->computed);
}
-css_error css__compose_font_family(const css_computed_style *parent,
- const css_computed_style *child,
- css_computed_style *result)
+css_error css__copy_font_family(
+ const css_computed_style *from,
+ css_computed_style *to)
{
css_error error;
- lwc_string **names = NULL;
- uint8_t type = get_font_family(child, &names);
-
- if (type == CSS_FONT_FAMILY_INHERIT || result != child) {
- size_t n_names = 0;
- lwc_string **copy = NULL;
-
- if (type == CSS_FONT_FAMILY_INHERIT)
- type = get_font_family(parent, &names);
+ lwc_string **copy = NULL;
+ lwc_string **font_family = NULL;
+ uint8_t type = get_font_family(from, &font_family);
- if (names != NULL) {
- lwc_string **i;
-
- for (i = names; (*i) != NULL; i++)
- n_names++;
+ if (from == to) {
+ return CSS_OK;
+ }
- copy = malloc((n_names + 1) * sizeof(lwc_string *));
- if (copy == NULL)
- return CSS_NOMEM;
+ error = css__copy_lwc_string_array(false, font_family, &copy);
+ if (error != CSS_OK) {
+ return CSS_NOMEM;
+ }
- memcpy(copy, names, (n_names + 1) *
- sizeof(lwc_string *));
- }
+ error = set_font_family(to, type, copy);
+ if (error != CSS_OK) {
+ free(copy);
+ }
- error = set_font_family(result, type, copy);
- if (error != CSS_OK && copy != NULL)
- free(copy);
+ return error;
+}
- return error;
- }
+css_error css__compose_font_family(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ lwc_string **font_family = NULL;
+ uint8_t type = get_font_family(child, &font_family);
- return CSS_OK;
+ return css__copy_font_family(
+ type == CSS_FONT_FAMILY_INHERIT ? parent : child,
+ result);
}