summaryrefslogtreecommitdiff
path: root/src/select
diff options
context:
space:
mode:
Diffstat (limited to 'src/select')
-rw-r--r--src/select/properties.c173
-rw-r--r--src/select/select.c124
-rw-r--r--src/select/select.h6
3 files changed, 189 insertions, 114 deletions
diff --git a/src/select/properties.c b/src/select/properties.c
index cb9ed02..c6d1f75 100644
--- a/src/select/properties.c
+++ b/src/select/properties.c
@@ -116,7 +116,8 @@ css_error cascade_azimuth(uint32_t opv, css_style *style,
unit = to_css_unit(unit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
/** \todo set computed azimuth */
}
@@ -168,7 +169,8 @@ css_error cascade_background_attachment(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_background_attachment(state->result, value);
}
@@ -326,7 +328,8 @@ css_error cascade_background_position(uint32_t opv, css_style *style,
hunit = to_css_unit(hunit);
vunit = to_css_unit(vunit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_background_position(state->result, value,
hlength, hunit, vlength, vunit);
}
@@ -393,7 +396,8 @@ css_error cascade_background_repeat(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_background_repeat(state->result, value);
}
@@ -443,7 +447,8 @@ css_error cascade_border_collapse(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_border_collapse(state->result, value);
}
@@ -499,7 +504,8 @@ css_error cascade_border_spacing(uint32_t opv, css_style *style,
hunit = to_css_unit(hunit);
vunit = to_css_unit(vunit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_border_spacing(state->result, value,
hlength, hunit, vlength, vunit);
}
@@ -1001,7 +1007,8 @@ css_error cascade_caption_side(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_caption_side(state->result, value);
}
@@ -1056,7 +1063,8 @@ css_error cascade_clear(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_clear(state->result, value);
}
@@ -1140,7 +1148,8 @@ css_error cascade_clip(uint32_t opv, css_style *style,
rect.bunit = to_css_unit(rect.bunit);
rect.lunit = to_css_unit(rect.lunit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_clip(state->result, value, &rect);
}
@@ -1192,7 +1201,8 @@ css_error cascade_color(uint32_t opv, css_style *style,
advance_bytecode(style, sizeof(color));
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_color(state->result, value, color);
}
@@ -1358,7 +1368,8 @@ css_error cascade_content(uint32_t opv, css_style *style,
content[n_contents].type = CSS_COMPUTED_CONTENT_NONE;
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
css_error error;
error = set_content(state->result, value, content);
@@ -1796,7 +1807,8 @@ css_error cascade_cursor(uint32_t opv, css_style *style,
uris[n_uris] = NULL;
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
css_error error;
error = set_cursor(state->result, value, uris);
@@ -1904,7 +1916,8 @@ css_error cascade_direction(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_direction(state->result, value);
}
@@ -1993,7 +2006,8 @@ css_error cascade_display(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_display(state->result, value);
}
@@ -2052,7 +2066,8 @@ css_error cascade_elevation(uint32_t opv, css_style *style,
unit = to_css_unit(unit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
/** \todo set computed elevation */
}
@@ -2104,7 +2119,8 @@ css_error cascade_empty_cells(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_empty_cells(state->result, value);
}
@@ -2155,7 +2171,8 @@ css_error cascade_float(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_float(state->result, value);
}
@@ -2272,7 +2289,8 @@ css_error cascade_font_family(uint32_t opv, css_style *style,
fonts[n_fonts] = NULL;
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
css_error error;
error = set_font_family(state->result, value, fonts);
@@ -2418,7 +2436,8 @@ css_error cascade_font_size(uint32_t opv, css_style *style,
unit = to_css_unit(unit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_font_size(state->result, value, size, unit);
}
@@ -2475,7 +2494,8 @@ css_error cascade_font_style(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_font_style(state->result, value);
}
@@ -2522,7 +2542,8 @@ css_error cascade_font_variant(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_font_variant(state->result, value);
}
@@ -2603,7 +2624,8 @@ css_error cascade_font_weight(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_font_weight(state->result, value);
}
@@ -2769,7 +2791,8 @@ css_error cascade_line_height(uint32_t opv, css_style *style,
unit = to_css_unit(unit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_line_height(state->result, value, val, unit);
}
@@ -2858,7 +2881,8 @@ css_error cascade_list_style_position(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_list_style_position(state->result, value);
}
@@ -2947,7 +2971,8 @@ css_error cascade_list_style_type(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_list_style_type(state->result, value);
}
@@ -3313,7 +3338,8 @@ css_error cascade_outline_color(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_outline_color(state->result, value, color);
}
@@ -3438,7 +3464,8 @@ css_error cascade_overflow(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_overflow(state->result, value);
}
@@ -3694,7 +3721,8 @@ css_error cascade_page_break_inside(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
/** \todo page-break-inside */
}
@@ -3859,7 +3887,8 @@ css_error cascade_pitch(uint32_t opv, css_style *style,
unit = to_css_unit(unit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
/** \todo pitch */
}
@@ -3916,7 +3945,8 @@ css_error cascade_play_during(uint32_t opv, css_style *style,
/** \todo mix & repeat */
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
/** \todo play-during */
}
@@ -3974,7 +4004,8 @@ css_error cascade_position(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_position(state->result, value);
}
@@ -4061,7 +4092,8 @@ css_error cascade_quotes(uint32_t opv, css_style *style,
quotes[n_quotes] = NULL;
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
css_error error;
error = set_quotes(state->result, value, quotes);
@@ -4243,7 +4275,8 @@ css_error cascade_speak_header(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
/** \todo speak-header */
}
@@ -4294,7 +4327,8 @@ css_error cascade_speak_numeral(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
/** \todo speak-numeral */
}
@@ -4345,7 +4379,8 @@ css_error cascade_speak_punctuation(
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
/** \todo speak-punctuation */
}
@@ -4397,7 +4432,8 @@ css_error cascade_speak(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
/** \todo speak */
}
@@ -4457,7 +4493,8 @@ css_error cascade_speech_rate(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
/** \todo speech-rate */
}
@@ -4543,7 +4580,8 @@ css_error cascade_table_layout(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_table_layout(state->result, value);
}
@@ -4597,7 +4635,8 @@ css_error cascade_text_align(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_text_align(state->result, value);
}
@@ -4650,7 +4689,8 @@ css_error cascade_text_decoration(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_text_decoration(state->result, value);
}
@@ -4741,7 +4781,8 @@ css_error cascade_text_transform(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_text_transform(state->result, value);
}
@@ -4827,7 +4868,8 @@ css_error cascade_unicode_bidi(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_unicode_bidi(state->result, value);
}
@@ -4903,7 +4945,8 @@ css_error cascade_vertical_align(uint32_t opv, css_style *style,
unit = to_css_unit(unit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_vertical_align(state->result, value, length, unit);
}
@@ -4961,7 +5004,8 @@ css_error cascade_visibility(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_visibility(state->result, value);
}
@@ -5070,7 +5114,8 @@ css_error cascade_voice_family(uint32_t opv, css_style *style,
voices[n_voices] = NULL;
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
/** \todo voice-family */
if (n_voices > 0)
state->result->alloc(voices, 0, state->result->pw);
@@ -5145,7 +5190,8 @@ css_error cascade_volume(uint32_t opv, css_style *style,
unit = to_css_unit(unit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
/** \todo volume */
}
@@ -5206,7 +5252,8 @@ css_error cascade_white_space(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_white_space(state->result, value);
}
@@ -5361,7 +5408,8 @@ css_error cascade_z_index(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return set_z_index(state->result, value, index);
}
@@ -5422,7 +5470,8 @@ css_error cascade_bg_border_color(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return fun(state->result, value, color);
}
@@ -5452,7 +5501,7 @@ css_error cascade_uri_none(uint32_t opv, css_style *style,
/** \todo lose fun != NULL once all properties have set routines */
if (fun != NULL && outranks_existing(getOpcode(opv),
- isImportant(opv), state)) {
+ isImportant(opv), state, isInherit(opv))) {
return fun(state->result, value, uri);
}
@@ -5502,7 +5551,8 @@ css_error cascade_border_style(uint32_t opv, css_style *style,
}
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return fun(state->result, value);
}
@@ -5541,7 +5591,8 @@ css_error cascade_border_width(uint32_t opv, css_style *style,
unit = to_css_unit(unit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return fun(state->result, value, length, unit);
}
@@ -5574,7 +5625,8 @@ css_error cascade_length_auto(uint32_t opv, css_style *style,
unit = to_css_unit(unit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return fun(state->result, value, length, unit);
}
@@ -5607,7 +5659,8 @@ css_error cascade_length_normal(uint32_t opv, css_style *style,
unit = to_css_unit(unit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return fun(state->result, value, length, unit);
}
@@ -5640,7 +5693,8 @@ css_error cascade_length_none(uint32_t opv, css_style *style,
unit = to_css_unit(unit);
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
return fun(state->result, value, length, unit);
}
@@ -5668,7 +5722,7 @@ css_error cascade_length(uint32_t opv, css_style *style,
/** \todo lose fun != NULL once all properties have set routines */
if (fun != NULL && outranks_existing(getOpcode(opv),
- isImportant(opv), state)) {
+ isImportant(opv), state, isInherit(opv))) {
return fun(state->result, value, length, unit);
}
@@ -5692,7 +5746,7 @@ css_error cascade_number(uint32_t opv, css_style *style,
/** \todo lose fun != NULL once all properties have set routines */
if (fun != NULL && outranks_existing(getOpcode(opv),
- isImportant(opv), state)) {
+ isImportant(opv), state, isInherit(opv))) {
return fun(state->result, value, length);
}
@@ -5721,7 +5775,7 @@ css_error cascade_page_break_after_before(uint32_t opv, css_style *style,
/** \todo lose fun != NULL */
if (fun != NULL && outranks_existing(getOpcode(opv),
- isImportant(opv), state)) {
+ isImportant(opv), state, isInherit(opv))) {
return fun(state->result, value);
}
@@ -5803,7 +5857,8 @@ css_error cascade_counter_increment_reset(uint32_t opv, css_style *style,
counters[n_counters].value = 0;
}
- if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
css_error error;
error = fun(state->result, value, counters);
diff --git a/src/select/select.c b/src/select/select.c
index b3fde4e..c839be1 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -33,8 +33,9 @@ struct css_select_ctx {
void *pw; /**< Client-specific private data */
};
-static css_error set_hint_or_initial(css_select_state *state, uint32_t i,
- void *parent);
+static css_error set_hint(css_select_state *state, uint32_t i);
+static css_error set_initial(css_select_state *state, uint32_t i, void *parent);
+
static css_error select_from_sheet(css_select_ctx *ctx,
const css_stylesheet *sheet, css_select_state *state);
static css_error intern_strings_for_sheet(css_select_ctx *ctx,
@@ -333,7 +334,16 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
if (state.props[i].set == false ||
(state.props[i].origin != CSS_ORIGIN_AUTHOR &&
state.props[i].important == false)) {
- error = set_hint_or_initial(&state, i, parent);
+ error = set_hint(&state, i);
+ if (error != CSS_OK)
+ goto cleanup;
+ }
+
+ /* If the property is still unset or it's set to inherit and
+ * we're the root element, then set it to its initial value. */
+ if (state.props[i].set == false || (parent == NULL &&
+ state.props[i].inherit == true)) {
+ error = set_initial(&state, i, parent);
if (error != CSS_OK)
goto cleanup;
}
@@ -383,7 +393,7 @@ cleanup:
* Selection engine internals below here *
******************************************************************************/
-css_error set_hint_or_initial(css_select_state *state, uint32_t i, void *parent)
+css_error set_hint(css_select_state *state, uint32_t i)
{
css_hint hint;
css_error error;
@@ -394,56 +404,62 @@ css_error set_hint_or_initial(css_select_state *state, uint32_t i, void *parent)
if (error != CSS_OK && error != CSS_PROPERTY_NOT_SET)
return error;
- if (error == CSS_OK) {
- /* Hint defined -- set it in the result */
- error = prop_dispatch[i].set_from_hint(&hint, state->result);
- if (error != CSS_OK)
- return error;
+ if (error != CSS_OK)
+ return (error == CSS_PROPERTY_NOT_SET) ? CSS_OK : error;
+
+ /* Hint defined -- set it in the result */
+ error = prop_dispatch[i].set_from_hint(&hint, state->result);
+ if (error != CSS_OK)
+ return error;
+
+ /* Keep selection state in sync with reality */
+ state->props[i].set = 1;
+ state->props[i].specificity = 0;
+ state->props[i].origin = CSS_ORIGIN_AUTHOR;
+ state->props[i].important = 0;
+ state->props[i].inherit = (hint.status == 0);
+
+ return CSS_OK;
+}
- /* Keep selection state in sync with reality */
- state->props[i].set = 1;
- state->props[i].specificity = 0;
- state->props[i].origin = CSS_ORIGIN_AUTHOR;
- state->props[i].important = 0;
- } else if (state->props[i].set == false) {
- /* No hint and property unset */
-
- /* Do nothing if this property is inherited (the default state
- * of a clean computed style is for everything to be set to
- * inherit)
- *
- * If the node is tree root, everything should be defaulted.
+css_error set_initial(css_select_state *state, uint32_t i, void *parent)
+{
+ css_error error;
+
+ /* Do nothing if this property is inherited (the default state
+ * of a clean computed style is for everything to be set to inherit)
+ *
+ * If the node is tree root, everything should be defaulted.
+ */
+ if (prop_dispatch[i].inherited == false || parent == NULL) {
+ /* Remaining properties are neither inherited nor
+ * already set. Thus, we set them to their initial
+ * values here. Except, however, if the property in
+ * question resides in one of the extension blocks and
+ * the extension block has yet to be allocated. In that
+ * case, we do nothing and leave it to the property
+ * accessors to return the initial values for the
+ * property.
*/
- if (prop_dispatch[i].inherited == false || parent == NULL) {
- /* Remaining properties are neither inherited nor
- * already set. Thus, we set them to their initial
- * values here. Except, however, if the property in
- * question resides in one of the extension blocks and
- * the extension block has yet to be allocated. In that
- * case, we do nothing and leave it to the property
- * accessors to return the initial values for the
- * property.
- */
- if (prop_dispatch[i].group == GROUP_NORMAL) {
- error = prop_dispatch[i].initial(state);
- if (error != CSS_OK)
- return error;
- } else if (prop_dispatch[i].group == GROUP_UNCOMMON &&
- state->result->uncommon != NULL) {
- error = prop_dispatch[i].initial(state);
- if (error != CSS_OK)
- return error;
- } else if (prop_dispatch[i].group == GROUP_PAGE &&
- state->result->page != NULL) {
- error = prop_dispatch[i].initial(state);
- if (error != CSS_OK)
- return error;
- } else if (prop_dispatch[i].group == GROUP_AURAL &&
- state->result->aural != NULL) {
- error = prop_dispatch[i].initial(state);
- if (error != CSS_OK)
- return error;
- }
+ if (prop_dispatch[i].group == GROUP_NORMAL) {
+ error = prop_dispatch[i].initial(state);
+ if (error != CSS_OK)
+ return error;
+ } else if (prop_dispatch[i].group == GROUP_UNCOMMON &&
+ state->result->uncommon != NULL) {
+ error = prop_dispatch[i].initial(state);
+ if (error != CSS_OK)
+ return error;
+ } else if (prop_dispatch[i].group == GROUP_PAGE &&
+ state->result->page != NULL) {
+ error = prop_dispatch[i].initial(state);
+ if (error != CSS_OK)
+ return error;
+ } else if (prop_dispatch[i].group == GROUP_AURAL &&
+ state->result->aural != NULL) {
+ error = prop_dispatch[i].initial(state);
+ if (error != CSS_OK)
+ return error;
}
}
@@ -967,7 +983,8 @@ css_error cascade_style(const css_style *style, css_select_state *state)
return CSS_OK;
}
-bool outranks_existing(uint16_t op, bool important, css_select_state *state)
+bool outranks_existing(uint16_t op, bool important, css_select_state *state,
+ bool inherit)
{
prop_state *existing = &state->props[op];
bool outranks = false;
@@ -1062,6 +1079,7 @@ bool outranks_existing(uint16_t op, bool important, css_select_state *state)
existing->specificity = state->current_specificity;
existing->origin = state->current_origin;
existing->important = important;
+ existing->inherit = inherit;
}
return outranks;
diff --git a/src/select/select.h b/src/select/select.h
index 1b3c702..320efd0 100644
--- a/src/select/select.h
+++ b/src/select/select.h
@@ -19,7 +19,8 @@ typedef struct prop_state {
uint32_t specificity; /* Specificity of property in result */
uint32_t set : 1, /* Whether property is set in result */
origin : 2, /* Origin of property in result */
- important : 1; /* Importance of property in result */
+ important : 1, /* Importance of property in result */
+ inherit : 1; /* Property is set to inherit */
} prop_state;
/**
@@ -61,7 +62,8 @@ static inline void advance_bytecode(css_style *style, uint32_t n_bytes)
style->bytecode = ((uint8_t *) style->bytecode) + n_bytes;
}
-bool outranks_existing(uint16_t op, bool important, css_select_state *state);
+bool outranks_existing(uint16_t op, bool important, css_select_state *state,
+ bool inherit);
#endif