From a3ec55e0f72fb0d55b2309d5688d7f8ce3194e2d Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 15 Feb 2009 10:58:36 +0000 Subject: Move property dispatch table out of select.c so it can be used by the computed style composition code. svn path=/trunk/libcss/; revision=6523 --- src/select/Makefile | 2 +- src/select/computed.c | 1 + src/select/dispatch.c | 115 ++++++++++++++ src/select/dispatch.h | 39 +++++ src/select/properties.c | 404 ++++++++++++++++++++++++------------------------ src/select/properties.h | 316 +++++++++++++++++++++++++++++++++++++ src/select/propset.h | 2 + src/select/select.c | 199 ++---------------------- src/select/select.h | 67 ++++++++ 9 files changed, 761 insertions(+), 384 deletions(-) create mode 100644 src/select/dispatch.c create mode 100644 src/select/dispatch.h create mode 100644 src/select/properties.h create mode 100644 src/select/select.h (limited to 'src/select') diff --git a/src/select/Makefile b/src/select/Makefile index 9d5656c..ea105fe 100644 --- a/src/select/Makefile +++ b/src/select/Makefile @@ -35,7 +35,7 @@ d := $(DIR) CFLAGS := $(CFLAGS) -I$(d) # Sources -SRCS_$(d) := computed.c hash.c select.c +SRCS_$(d) := computed.c dispatch.c hash.c properties.c select.c # Append to sources for component SOURCES += $(addprefix $(d), $(SRCS_$(d))) diff --git a/src/select/computed.c b/src/select/computed.c index bae776d..948a18b 100644 --- a/src/select/computed.c +++ b/src/select/computed.c @@ -9,6 +9,7 @@ #include +#include "select/dispatch.h" #include "utils/utils.h" /** diff --git a/src/select/dispatch.c b/src/select/dispatch.c new file mode 100644 index 0000000..49f73b2 --- /dev/null +++ b/src/select/dispatch.c @@ -0,0 +1,115 @@ +/* + * This file is part of LibCSS + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2009 John-Mark Bell + */ + +#include "select/dispatch.h" +#include "select/properties.h" + +/** + * Dispatch table for properties, indexed by opcode + */ +struct prop_table prop_dispatch[N_OPCODES] = { + { cascade_azimuth, initial_azimuth, 1, GROUP_AURAL}, + { cascade_background_attachment, initial_background_attachment, 0, GROUP_NORMAL }, + { cascade_background_color, initial_background_color, 0, GROUP_NORMAL }, + { cascade_background_image, initial_background_image, 0, GROUP_NORMAL }, + { cascade_background_position, initial_background_position, 0, GROUP_NORMAL }, + { cascade_background_repeat, initial_background_repeat, 0, GROUP_NORMAL }, + { cascade_border_collapse, initial_border_collapse, 1, GROUP_NORMAL }, + { cascade_border_spacing, initial_border_spacing, 1, GROUP_UNCOMMON }, + { cascade_border_top_color, initial_border_top_color, 0, GROUP_NORMAL }, + { cascade_border_right_color, initial_border_right_color, 0, GROUP_NORMAL }, + { cascade_border_bottom_color, initial_border_bottom_color, 0, GROUP_NORMAL }, + { cascade_border_left_color, initial_border_left_color, 0, GROUP_NORMAL }, + { cascade_border_top_style, initial_border_top_style, 0, GROUP_NORMAL }, + { cascade_border_right_style, initial_border_right_style, 0, GROUP_NORMAL }, + { cascade_border_bottom_style, initial_border_bottom_style, 0, GROUP_NORMAL }, + { cascade_border_left_style, initial_border_left_style, 0, GROUP_NORMAL }, + { cascade_border_top_width, initial_border_top_width, 0, GROUP_NORMAL }, + { cascade_border_right_width, initial_border_right_width, 0, GROUP_NORMAL }, + { cascade_border_bottom_width, initial_border_bottom_width, 0, GROUP_NORMAL }, + { cascade_border_left_width, initial_border_left_width, 0, GROUP_NORMAL }, + { cascade_bottom, initial_bottom, 0, GROUP_NORMAL }, + { cascade_caption_side, initial_caption_side, 1, GROUP_NORMAL }, + { cascade_clear, initial_clear, 0, GROUP_NORMAL }, + { cascade_clip, initial_clip, 0, GROUP_UNCOMMON }, + { cascade_color, initial_color, 1, GROUP_NORMAL }, + { cascade_content, initial_content, 0, GROUP_UNCOMMON }, + { cascade_counter_increment, initial_counter_increment, 0, GROUP_UNCOMMON }, + { cascade_counter_reset, initial_counter_reset, 0, GROUP_UNCOMMON }, + { cascade_cue_after, initial_cue_after, 0, GROUP_AURAL }, + { cascade_cue_before, initial_cue_before, 0, GROUP_AURAL }, + { cascade_cursor, initial_cursor, 1, GROUP_UNCOMMON }, + { cascade_direction, initial_direction, 1, GROUP_NORMAL }, + { cascade_display, initial_display, 0, GROUP_NORMAL }, + { cascade_elevation, initial_elevation, 1, GROUP_AURAL }, + { cascade_empty_cells, initial_empty_cells, 1, GROUP_NORMAL }, + { cascade_float, initial_float, 0, GROUP_NORMAL }, + { cascade_font_family, initial_font_family, 1, GROUP_NORMAL }, + { cascade_font_size, initial_font_size, 1, GROUP_NORMAL }, + { cascade_font_style, initial_font_style, 1, GROUP_NORMAL }, + { cascade_font_variant, initial_font_variant, 1, GROUP_NORMAL }, + { cascade_font_weight, initial_font_weight, 1, GROUP_NORMAL }, + { cascade_height, initial_height, 0, GROUP_NORMAL }, + { cascade_left, initial_left, 0, GROUP_NORMAL }, + { cascade_letter_spacing, initial_letter_spacing, 1, GROUP_UNCOMMON }, + { cascade_line_height, initial_line_height, 1, GROUP_NORMAL }, + { cascade_list_style_image, initial_list_style_image, 1, GROUP_NORMAL }, + { cascade_list_style_position, initial_list_style_position, 1, GROUP_NORMAL }, + { cascade_list_style_type, initial_list_style_type, 1, GROUP_NORMAL }, + { cascade_margin_top, initial_margin_top, 0, GROUP_NORMAL }, + { cascade_margin_right, initial_margin_right, 0, GROUP_NORMAL }, + { cascade_margin_bottom, initial_margin_bottom, 0, GROUP_NORMAL }, + { cascade_margin_left, initial_margin_left, 0, GROUP_NORMAL }, + { cascade_max_height, initial_max_height, 0, GROUP_NORMAL }, + { cascade_max_width, initial_max_width, 0, GROUP_NORMAL }, + { cascade_min_height, initial_min_height, 0, GROUP_NORMAL }, + { cascade_min_width, initial_min_width, 0, GROUP_NORMAL }, + { cascade_orphans, initial_orphans, 1, GROUP_PAGE }, + { cascade_outline_color, initial_outline_color, 0, GROUP_UNCOMMON }, + { cascade_outline_style, initial_outline_style, 0, GROUP_NORMAL }, + { cascade_outline_width, initial_outline_width, 0, GROUP_UNCOMMON }, + { cascade_overflow, initial_overflow, 0, GROUP_NORMAL }, + { cascade_padding_top, initial_padding_top, 0, GROUP_NORMAL }, + { cascade_padding_right, initial_padding_right, 0, GROUP_NORMAL }, + { cascade_padding_bottom, initial_padding_bottom, 0, GROUP_NORMAL }, + { cascade_padding_left, initial_padding_left, 0, GROUP_NORMAL }, + { cascade_page_break_after, initial_page_break_after, 0, GROUP_PAGE }, + { cascade_page_break_before, initial_page_break_before, 0, GROUP_PAGE }, + { cascade_page_break_inside, initial_page_break_inside, 1, GROUP_PAGE }, + { cascade_pause_after, initial_pause_after, 0, GROUP_AURAL }, + { cascade_pause_before, initial_pause_before, 0, GROUP_AURAL }, + { cascade_pitch_range, initial_pitch_range, 1, GROUP_AURAL }, + { cascade_pitch, initial_pitch, 1, GROUP_AURAL }, + { cascade_play_during, initial_play_during, 0, GROUP_AURAL }, + { cascade_position, initial_position, 0, GROUP_NORMAL }, + { cascade_quotes, initial_quotes, 1, GROUP_UNCOMMON }, + { cascade_richness, initial_richness, 1, GROUP_AURAL }, + { cascade_right, initial_right, 0, GROUP_NORMAL }, + { cascade_speak_header, initial_speak_header, 1, GROUP_AURAL }, + { cascade_speak_numeral, initial_speak_numeral, 1, GROUP_AURAL }, + { cascade_speak_punctuation, initial_speak_punctuation, 1, GROUP_AURAL }, + { cascade_speak, initial_speak, 1, GROUP_AURAL }, + { cascade_speech_rate, initial_speech_rate, 1, GROUP_AURAL }, + { cascade_stress, initial_stress, 1, GROUP_AURAL }, + { cascade_table_layout, initial_table_layout, 0, GROUP_NORMAL }, + { cascade_text_align, initial_text_align, 1, GROUP_NORMAL }, + { cascade_text_decoration, initial_text_decoration, 0, GROUP_NORMAL }, + { cascade_text_indent, initial_text_indent, 1, GROUP_NORMAL }, + { cascade_text_transform, initial_text_transform, 1, GROUP_NORMAL }, + { cascade_top, initial_top, 0, GROUP_NORMAL }, + { cascade_unicode_bidi, initial_unicode_bidi, 0, GROUP_NORMAL }, + { cascade_vertical_align, initial_vertical_align, 0, GROUP_NORMAL }, + { cascade_visibility, initial_visibility, 1, GROUP_NORMAL }, + { cascade_voice_family, initial_voice_family, 1, GROUP_AURAL }, + { cascade_volume, initial_volume, 1, GROUP_AURAL }, + { cascade_white_space, initial_white_space, 1, GROUP_NORMAL }, + { cascade_widows, initial_widows, 1, GROUP_PAGE }, + { cascade_width, initial_width, 0, GROUP_NORMAL }, + { cascade_word_spacing, initial_word_spacing, 1, GROUP_UNCOMMON }, + { cascade_z_index, initial_z_index, 0, GROUP_NORMAL } +}; + diff --git a/src/select/dispatch.h b/src/select/dispatch.h new file mode 100644 index 0000000..2c68e69 --- /dev/null +++ b/src/select/dispatch.h @@ -0,0 +1,39 @@ +/* + * This file is part of LibCSS + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2009 John-Mark Bell + */ + +#ifndef css_select_dispatch_h_ +#define css_select_dispatch_h_ + +#include + +#include +#include + +#include "stylesheet.h" +#include "bytecode/bytecode.h" +#include "select/select.h" + +/** + * Enumeration of property groups + */ +enum prop_group { + GROUP_NORMAL = 0x0, + GROUP_UNCOMMON = 0x1, + GROUP_PAGE = 0x2, + GROUP_AURAL = 0x3 +}; + +extern struct prop_table { + css_error (*cascade)(uint32_t opv, css_style *style, + css_select_state *state); + css_error (*initial)(css_computed_style *style); + + uint32_t inherited : 1, + group : 2; +} prop_dispatch[N_OPCODES]; + +#endif diff --git a/src/select/properties.c b/src/select/properties.c index 710e3fc..42ae10f 100644 --- a/src/select/properties.c +++ b/src/select/properties.c @@ -5,6 +5,14 @@ * Copyright 2009 John-Mark Bell */ +#include + +#include "bytecode/bytecode.h" +#include "bytecode/opcodes.h" +#include "select/properties.h" +#include "select/propset.h" +#include "utils/utils.h" + static css_error cascade_bg_border_color(uint32_t opv, css_style *style, css_select_state *state, css_error (*fun)(css_computed_style *, uint8_t, css_color)); @@ -46,7 +54,7 @@ static css_error cascade_counter_increment_reset(uint32_t opv, css_style *style, css_error (*fun)(css_computed_style *, uint8_t, css_computed_counter *)); -static css_error cascade_azimuth(uint32_t opv, css_style *style, +css_error cascade_azimuth(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = 0; @@ -88,14 +96,14 @@ static css_error cascade_azimuth(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_azimuth(css_computed_style *style) +css_error initial_azimuth(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_background_attachment(uint32_t opv, css_style *style, +css_error cascade_background_attachment(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_BACKGROUND_ATTACHMENT_INHERIT; @@ -120,35 +128,35 @@ static css_error cascade_background_attachment(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_background_attachment(css_computed_style *style) +css_error initial_background_attachment(css_computed_style *style) { return set_background_attachment(style, CSS_BACKGROUND_ATTACHMENT_SCROLL); } -static css_error cascade_background_color(uint32_t opv, css_style *style, +css_error cascade_background_color(uint32_t opv, css_style *style, css_select_state *state) { return cascade_bg_border_color(opv, style, state, set_background_color); } -static css_error initial_background_color(css_computed_style *style) +css_error initial_background_color(css_computed_style *style) { return set_background_color(style, CSS_BACKGROUND_COLOR_TRANSPARENT, 0); } -static css_error cascade_background_image(uint32_t opv, css_style *style, +css_error cascade_background_image(uint32_t opv, css_style *style, css_select_state *state) { return cascade_uri_none(opv, style, state, set_background_image); } -static css_error initial_background_image(css_computed_style *style) +css_error initial_background_image(css_computed_style *style) { return set_background_image(style, CSS_BACKGROUND_IMAGE_NONE, NULL); } -static css_error cascade_background_position(uint32_t opv, css_style *style, +css_error cascade_background_position(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_BACKGROUND_POSITION_INHERIT; @@ -211,13 +219,13 @@ static css_error cascade_background_position(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_background_position(css_computed_style *style) +css_error initial_background_position(css_computed_style *style) { return set_background_position(style, CSS_BACKGROUND_POSITION_SET, 0, CSS_UNIT_PCT, 0, CSS_UNIT_PCT); } -static css_error cascade_background_repeat(uint32_t opv, css_style *style, +css_error cascade_background_repeat(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_BACKGROUND_REPEAT_INHERIT; @@ -248,12 +256,12 @@ static css_error cascade_background_repeat(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_background_repeat(css_computed_style *style) +css_error initial_background_repeat(css_computed_style *style) { return set_background_repeat(style, CSS_BACKGROUND_REPEAT_REPEAT); } -static css_error cascade_border_collapse(uint32_t opv, css_style *style, +css_error cascade_border_collapse(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_BORDER_COLLAPSE_INHERIT; @@ -278,12 +286,12 @@ static css_error cascade_border_collapse(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_border_collapse(css_computed_style *style) +css_error initial_border_collapse(css_computed_style *style) { return set_border_collapse(style, CSS_BORDER_COLLAPSE_SEPARATE); } -static css_error cascade_border_spacing(uint32_t opv, css_style *style, +css_error cascade_border_spacing(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_BORDER_SPACING_INHERIT; @@ -313,163 +321,163 @@ static css_error cascade_border_spacing(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_border_spacing(css_computed_style *style) +css_error initial_border_spacing(css_computed_style *style) { return set_border_spacing(style, CSS_BORDER_SPACING_SET, 0, CSS_UNIT_PX, 0, CSS_UNIT_PX); } -static css_error cascade_border_top_color(uint32_t opv, css_style *style, +css_error cascade_border_top_color(uint32_t opv, css_style *style, css_select_state *state) { return cascade_bg_border_color(opv, style, state, set_border_top_color); } -static css_error initial_border_top_color(css_computed_style *style) +css_error initial_border_top_color(css_computed_style *style) { return set_border_top_color(style, CSS_BORDER_COLOR_COLOR, 0); } -static css_error cascade_border_right_color(uint32_t opv, css_style *style, +css_error cascade_border_right_color(uint32_t opv, css_style *style, css_select_state *state) { return cascade_bg_border_color(opv, style, state, set_border_right_color); } -static css_error initial_border_right_color(css_computed_style *style) +css_error initial_border_right_color(css_computed_style *style) { return set_border_right_color(style, CSS_BORDER_COLOR_COLOR, 0); } -static css_error cascade_border_bottom_color(uint32_t opv, css_style *style, +css_error cascade_border_bottom_color(uint32_t opv, css_style *style, css_select_state *state) { return cascade_bg_border_color(opv, style, state, set_border_bottom_color); } -static css_error initial_border_bottom_color(css_computed_style *style) +css_error initial_border_bottom_color(css_computed_style *style) { return set_border_bottom_color(style, CSS_BORDER_COLOR_COLOR, 0); } -static css_error cascade_border_left_color(uint32_t opv, css_style *style, +css_error cascade_border_left_color(uint32_t opv, css_style *style, css_select_state *state) { return cascade_bg_border_color(opv, style, state, set_border_left_color); } -static css_error initial_border_left_color(css_computed_style *style) +css_error initial_border_left_color(css_computed_style *style) { return set_border_left_color(style, CSS_BORDER_COLOR_COLOR, 0); } -static css_error cascade_border_top_style(uint32_t opv, css_style *style, +css_error cascade_border_top_style(uint32_t opv, css_style *style, css_select_state *state) { return cascade_border_style(opv, style, state, set_border_top_style); } -static css_error initial_border_top_style(css_computed_style *style) +css_error initial_border_top_style(css_computed_style *style) { return set_border_top_style(style, CSS_BORDER_STYLE_NONE); } -static css_error cascade_border_right_style(uint32_t opv, css_style *style, +css_error cascade_border_right_style(uint32_t opv, css_style *style, css_select_state *state) { return cascade_border_style(opv, style, state, set_border_right_style); } -static css_error initial_border_right_style(css_computed_style *style) +css_error initial_border_right_style(css_computed_style *style) { return set_border_right_style(style, CSS_BORDER_STYLE_NONE); } -static css_error cascade_border_bottom_style(uint32_t opv, css_style *style, +css_error cascade_border_bottom_style(uint32_t opv, css_style *style, css_select_state *state) { return cascade_border_style(opv, style, state, set_border_bottom_style); } -static css_error initial_border_bottom_style(css_computed_style *style) +css_error initial_border_bottom_style(css_computed_style *style) { return set_border_bottom_style(style, CSS_BORDER_STYLE_NONE); } -static css_error cascade_border_left_style(uint32_t opv, css_style *style, +css_error cascade_border_left_style(uint32_t opv, css_style *style, css_select_state *state) { return cascade_border_style(opv, style, state, set_border_left_style); } -static css_error initial_border_left_style(css_computed_style *style) +css_error initial_border_left_style(css_computed_style *style) { return set_border_left_style(style, CSS_BORDER_STYLE_NONE); } -static css_error cascade_border_top_width(uint32_t opv, css_style *style, +css_error cascade_border_top_width(uint32_t opv, css_style *style, css_select_state *state) { return cascade_border_width(opv, style, state, set_border_top_width); } -static css_error initial_border_top_width(css_computed_style *style) +css_error initial_border_top_width(css_computed_style *style) { return set_border_top_width(style, CSS_BORDER_WIDTH_MEDIUM, 0, CSS_UNIT_PX); } -static css_error cascade_border_right_width(uint32_t opv, css_style *style, +css_error cascade_border_right_width(uint32_t opv, css_style *style, css_select_state *state) { return cascade_border_width(opv, style, state, set_border_right_width); } -static css_error initial_border_right_width(css_computed_style *style) +css_error initial_border_right_width(css_computed_style *style) { return set_border_right_width(style, CSS_BORDER_WIDTH_MEDIUM, 0, CSS_UNIT_PX); } -static css_error cascade_border_bottom_width(uint32_t opv, css_style *style, +css_error cascade_border_bottom_width(uint32_t opv, css_style *style, css_select_state *state) { return cascade_border_width(opv, style, state, set_border_bottom_width); } -static css_error initial_border_bottom_width(css_computed_style *style) +css_error initial_border_bottom_width(css_computed_style *style) { return set_border_bottom_width(style, CSS_BORDER_WIDTH_MEDIUM, 0, CSS_UNIT_PX); } -static css_error cascade_border_left_width(uint32_t opv, css_style *style, +css_error cascade_border_left_width(uint32_t opv, css_style *style, css_select_state *state) { return cascade_border_width(opv, style, state, set_border_left_width); } -static css_error initial_border_left_width(css_computed_style *style) +css_error initial_border_left_width(css_computed_style *style) { return set_border_left_width(style, CSS_BORDER_WIDTH_MEDIUM, 0, CSS_UNIT_PX); } -static css_error cascade_bottom(uint32_t opv, css_style *style, +css_error cascade_bottom(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_auto(opv, style, state, set_bottom); } -static css_error initial_bottom(css_computed_style *style) +css_error initial_bottom(css_computed_style *style) { return set_bottom(style, CSS_BOTTOM_AUTO, 0, CSS_UNIT_PX); } -static css_error cascade_caption_side(uint32_t opv, css_style *style, +css_error cascade_caption_side(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_CAPTION_SIDE_INHERIT; @@ -494,12 +502,12 @@ static css_error cascade_caption_side(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_caption_side(css_computed_style *style) +css_error initial_caption_side(css_computed_style *style) { return set_caption_side(style, CSS_CAPTION_SIDE_TOP); } -static css_error cascade_clear(uint32_t opv, css_style *style, +css_error cascade_clear(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_CLEAR_INHERIT; @@ -530,12 +538,12 @@ static css_error cascade_clear(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_clear(css_computed_style *style) +css_error initial_clear(css_computed_style *style) { return set_clear(style, CSS_CLEAR_NONE); } -static css_error cascade_clip(uint32_t opv, css_style *style, +css_error cascade_clip(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_CLIP_INHERIT; @@ -592,7 +600,7 @@ static css_error cascade_clip(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_clip(css_computed_style *style) +css_error initial_clip(css_computed_style *style) { css_computed_clip_rect rect = { 0, 0, 0, 0, CSS_UNIT_PX, CSS_UNIT_PX, CSS_UNIT_PX, CSS_UNIT_PX, @@ -601,7 +609,7 @@ static css_error initial_clip(css_computed_style *style) return set_clip(style, CSS_CLIP_AUTO, &rect); } -static css_error cascade_color(uint32_t opv, css_style *style, +css_error cascade_color(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_COLOR_INHERIT; @@ -620,12 +628,12 @@ static css_error cascade_color(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_color(css_computed_style *style) +css_error initial_color(css_computed_style *style) { return set_color(style, CSS_COLOR_COLOR, 0); } -static css_error cascade_content(uint32_t opv, css_style *style, +css_error cascade_content(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_CONTENT_INHERIT; @@ -759,66 +767,66 @@ static css_error cascade_content(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_content(css_computed_style *style) +css_error initial_content(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_counter_increment(uint32_t opv, css_style *style, +css_error cascade_counter_increment(uint32_t opv, css_style *style, css_select_state *state) { return cascade_counter_increment_reset(opv, style, state, set_counter_increment); } -static css_error initial_counter_increment(css_computed_style *style) +css_error initial_counter_increment(css_computed_style *style) { return set_counter_increment(style, CSS_COUNTER_INCREMENT_NONE, NULL); } -static css_error cascade_counter_reset(uint32_t opv, css_style *style, +css_error cascade_counter_reset(uint32_t opv, css_style *style, css_select_state *state) { return cascade_counter_increment_reset(opv, style, state, set_counter_reset); } -static css_error initial_counter_reset(css_computed_style *style) +css_error initial_counter_reset(css_computed_style *style) { return set_counter_reset(style, CSS_COUNTER_RESET_NONE, NULL); } -static css_error cascade_cue_after(uint32_t opv, css_style *style, +css_error cascade_cue_after(uint32_t opv, css_style *style, css_select_state *state) { /** \todo cue-after */ return cascade_uri_none(opv, style, state, NULL); } -static css_error initial_cue_after(css_computed_style *style) +css_error initial_cue_after(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_cue_before(uint32_t opv, css_style *style, +css_error cascade_cue_before(uint32_t opv, css_style *style, css_select_state *state) { /** \todo cue-before */ return cascade_uri_none(opv, style, state, NULL); } -static css_error initial_cue_before(css_computed_style *style) +css_error initial_cue_before(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_cursor(uint32_t opv, css_style *style, +css_error cascade_cursor(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_CURSOR_INHERIT; @@ -938,12 +946,12 @@ static css_error cascade_cursor(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_cursor(css_computed_style *style) +css_error initial_cursor(css_computed_style *style) { return set_cursor(style, CSS_CURSOR_AUTO, NULL); } -static css_error cascade_direction(uint32_t opv, css_style *style, +css_error cascade_direction(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_DIRECTION_INHERIT; @@ -968,12 +976,12 @@ static css_error cascade_direction(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_direction(css_computed_style *style) +css_error initial_direction(css_computed_style *style) { return set_direction(style, CSS_DIRECTION_LTR); } -static css_error cascade_display(uint32_t opv, css_style *style, +css_error cascade_display(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_DISPLAY_INHERIT; @@ -1040,12 +1048,12 @@ static css_error cascade_display(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_display(css_computed_style *style) +css_error initial_display(css_computed_style *style) { return set_display(style, CSS_DISPLAY_INLINE); } -static css_error cascade_elevation(uint32_t opv, css_style *style, +css_error cascade_elevation(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = 0; @@ -1080,14 +1088,14 @@ static css_error cascade_elevation(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_elevation(css_computed_style *style) +css_error initial_elevation(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_empty_cells(uint32_t opv, css_style *style, +css_error cascade_empty_cells(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_EMPTY_CELLS_INHERIT; @@ -1112,12 +1120,12 @@ static css_error cascade_empty_cells(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_empty_cells(css_computed_style *style) +css_error initial_empty_cells(css_computed_style *style) { return set_empty_cells(style, CSS_EMPTY_CELLS_SHOW); } -static css_error cascade_float(uint32_t opv, css_style *style, +css_error cascade_float(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_FLOAT_INHERIT; @@ -1145,12 +1153,12 @@ static css_error cascade_float(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_float(css_computed_style *style) +css_error initial_float(css_computed_style *style) { return set_float(style, CSS_FLOAT_NONE); } -static css_error cascade_font_family(uint32_t opv, css_style *style, +css_error cascade_font_family(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_FONT_FAMILY_INHERIT; @@ -1248,12 +1256,12 @@ static css_error cascade_font_family(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_font_family(css_computed_style *style) +css_error initial_font_family(css_computed_style *style) { return set_font_family(style, CSS_FONT_FAMILY_DEFAULT, NULL); } -static css_error cascade_font_size(uint32_t opv, css_style *style, +css_error cascade_font_size(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_FONT_SIZE_INHERIT; @@ -1308,12 +1316,12 @@ static css_error cascade_font_size(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_font_size(css_computed_style *style) +css_error initial_font_size(css_computed_style *style) { return set_font_size(style, CSS_FONT_SIZE_MEDIUM, 0, CSS_UNIT_PX); } -static css_error cascade_font_style(uint32_t opv, css_style *style, +css_error cascade_font_style(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_FONT_STYLE_INHERIT; @@ -1341,12 +1349,12 @@ static css_error cascade_font_style(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_font_style(css_computed_style *style) +css_error initial_font_style(css_computed_style *style) { return set_font_style(style, CSS_FONT_STYLE_NORMAL); } -static css_error cascade_font_variant(uint32_t opv, css_style *style, +css_error cascade_font_variant(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_FONT_VARIANT_INHERIT; @@ -1371,12 +1379,12 @@ static css_error cascade_font_variant(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_font_variant(css_computed_style *style) +css_error initial_font_variant(css_computed_style *style) { return set_font_variant(style, CSS_FONT_VARIANT_NORMAL); } -static css_error cascade_font_weight(uint32_t opv, css_style *style, +css_error cascade_font_weight(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_FONT_WEIGHT_INHERIT; @@ -1434,46 +1442,46 @@ static css_error cascade_font_weight(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_font_weight(css_computed_style *style) +css_error initial_font_weight(css_computed_style *style) { return set_font_weight(style, CSS_FONT_WEIGHT_NORMAL); } -static css_error cascade_height(uint32_t opv, css_style *style, +css_error cascade_height(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_auto(opv, style, state, set_height); } -static css_error initial_height(css_computed_style *style) +css_error initial_height(css_computed_style *style) { return set_height(style, CSS_HEIGHT_AUTO, 0, CSS_UNIT_PX); } -static css_error cascade_left(uint32_t opv, css_style *style, +css_error cascade_left(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_auto(opv, style, state, set_left); } -static css_error initial_left(css_computed_style *style) +css_error initial_left(css_computed_style *style) { return set_left(style, CSS_LEFT_AUTO, 0, CSS_UNIT_PX); } -static css_error cascade_letter_spacing(uint32_t opv, css_style *style, +css_error cascade_letter_spacing(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_normal(opv, style, state, set_letter_spacing); } -static css_error initial_letter_spacing(css_computed_style *style) +css_error initial_letter_spacing(css_computed_style *style) { return set_letter_spacing(style, CSS_LETTER_SPACING_NORMAL, 0, CSS_UNIT_PX); } -static css_error cascade_line_height(uint32_t opv, css_style *style, +css_error cascade_line_height(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_LINE_HEIGHT_INHERIT; @@ -1507,23 +1515,23 @@ static css_error cascade_line_height(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_line_height(css_computed_style *style) +css_error initial_line_height(css_computed_style *style) { return set_line_height(style, CSS_LINE_HEIGHT_NORMAL, 0, CSS_UNIT_PX); } -static css_error cascade_list_style_image(uint32_t opv, css_style *style, +css_error cascade_list_style_image(uint32_t opv, css_style *style, css_select_state *state) { return cascade_uri_none(opv, style, state, set_list_style_image); } -static css_error initial_list_style_image(css_computed_style *style) +css_error initial_list_style_image(css_computed_style *style) { return set_list_style_image(style, CSS_LIST_STYLE_IMAGE_NONE, NULL); } -static css_error cascade_list_style_position(uint32_t opv, css_style *style, +css_error cascade_list_style_position(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_LIST_STYLE_POSITION_INHERIT; @@ -1548,12 +1556,12 @@ static css_error cascade_list_style_position(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_list_style_position(css_computed_style *style) +css_error initial_list_style_position(css_computed_style *style) { return set_list_style_position(style, CSS_LIST_STYLE_POSITION_OUTSIDE); } -static css_error cascade_list_style_type(uint32_t opv, css_style *style, +css_error cascade_list_style_type(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_LIST_STYLE_TYPE_INHERIT; @@ -1617,114 +1625,114 @@ static css_error cascade_list_style_type(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_list_style_type(css_computed_style *style) +css_error initial_list_style_type(css_computed_style *style) { return set_list_style_type(style, CSS_LIST_STYLE_TYPE_DISC); } -static css_error cascade_margin_top(uint32_t opv, css_style *style, +css_error cascade_margin_top(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_auto(opv, style, state, set_margin_top); } -static css_error initial_margin_top(css_computed_style *style) +css_error initial_margin_top(css_computed_style *style) { return set_margin_top(style, CSS_MARGIN_SET, 0, CSS_UNIT_PX); } -static css_error cascade_margin_right(uint32_t opv, css_style *style, +css_error cascade_margin_right(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_auto(opv, style, state, set_margin_right); } -static css_error initial_margin_right(css_computed_style *style) +css_error initial_margin_right(css_computed_style *style) { return set_margin_right(style, CSS_MARGIN_SET, 0, CSS_UNIT_PX); } -static css_error cascade_margin_bottom(uint32_t opv, css_style *style, +css_error cascade_margin_bottom(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_auto(opv, style, state, set_margin_bottom); } -static css_error initial_margin_bottom(css_computed_style *style) +css_error initial_margin_bottom(css_computed_style *style) { return set_margin_bottom(style, CSS_MARGIN_SET, 0, CSS_UNIT_PX); } -static css_error cascade_margin_left(uint32_t opv, css_style *style, +css_error cascade_margin_left(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_auto(opv, style, state, set_margin_left); } -static css_error initial_margin_left(css_computed_style *style) +css_error initial_margin_left(css_computed_style *style) { return set_margin_left(style, CSS_MARGIN_SET, 0, CSS_UNIT_PX); } -static css_error cascade_max_height(uint32_t opv, css_style *style, +css_error cascade_max_height(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_none(opv, style, state, set_max_height); } -static css_error initial_max_height(css_computed_style *style) +css_error initial_max_height(css_computed_style *style) { return set_max_height(style, CSS_MAX_HEIGHT_NONE, 0, CSS_UNIT_PX); } -static css_error cascade_max_width(uint32_t opv, css_style *style, +css_error cascade_max_width(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_none(opv, style, state, set_max_width);; } -static css_error initial_max_width(css_computed_style *style) +css_error initial_max_width(css_computed_style *style) { return set_max_width(style, CSS_MAX_WIDTH_NONE, 0, CSS_UNIT_PX); } -static css_error cascade_min_height(uint32_t opv, css_style *style, +css_error cascade_min_height(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length(opv, style, state, set_min_height); } -static css_error initial_min_height(css_computed_style *style) +css_error initial_min_height(css_computed_style *style) { return set_min_height(style, CSS_MIN_HEIGHT_SET, 0, CSS_UNIT_PX); } -static css_error cascade_min_width(uint32_t opv, css_style *style, +css_error cascade_min_width(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length(opv, style, state, set_min_width); } -static css_error initial_min_width(css_computed_style *style) +css_error initial_min_width(css_computed_style *style) { return set_min_width(style, CSS_MIN_WIDTH_SET, 0, CSS_UNIT_PX); } -static css_error cascade_orphans(uint32_t opv, css_style *style, +css_error cascade_orphans(uint32_t opv, css_style *style, css_select_state *state) { /** \todo orphans */ return cascade_number(opv, style, state, NULL); } -static css_error initial_orphans(css_computed_style *style) +css_error initial_orphans(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_outline_color(uint32_t opv, css_style *style, +css_error cascade_outline_color(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_OUTLINE_COLOR_INHERIT; @@ -1750,35 +1758,35 @@ static css_error cascade_outline_color(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_outline_color(css_computed_style *style) +css_error initial_outline_color(css_computed_style *style) { return set_outline_color(style, CSS_OUTLINE_COLOR_INVERT, 0); } -static css_error cascade_outline_style(uint32_t opv, css_style *style, +css_error cascade_outline_style(uint32_t opv, css_style *style, css_select_state *state) { return cascade_border_style(opv, style, state, set_outline_style); } -static css_error initial_outline_style(css_computed_style *style) +css_error initial_outline_style(css_computed_style *style) { return set_outline_style(style, CSS_OUTLINE_STYLE_NONE); } -static css_error cascade_outline_width(uint32_t opv, css_style *style, +css_error cascade_outline_width(uint32_t opv, css_style *style, css_select_state *state) { return cascade_border_width(opv, style, state, set_outline_width); } -static css_error initial_outline_width(css_computed_style *style) +css_error initial_outline_width(css_computed_style *style) { return set_outline_width(style, CSS_OUTLINE_WIDTH_MEDIUM, 0, CSS_UNIT_PX); } -static css_error cascade_overflow(uint32_t opv, css_style *style, +css_error cascade_overflow(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_OVERFLOW_INHERIT; @@ -1809,84 +1817,84 @@ static css_error cascade_overflow(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_overflow(css_computed_style *style) +css_error initial_overflow(css_computed_style *style) { return set_overflow(style, CSS_OVERFLOW_VISIBLE); } -static css_error cascade_padding_top(uint32_t opv, css_style *style, +css_error cascade_padding_top(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length(opv, style, state, set_padding_top); } -static css_error initial_padding_top(css_computed_style *style) +css_error initial_padding_top(css_computed_style *style) { return set_padding_top(style, CSS_PADDING_SET, 0, CSS_UNIT_PX); } -static css_error cascade_padding_right(uint32_t opv, css_style *style, +css_error cascade_padding_right(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length(opv, style, state, set_padding_right); } -static css_error initial_padding_right(css_computed_style *style) +css_error initial_padding_right(css_computed_style *style) { return set_padding_right(style, CSS_PADDING_SET, 0, CSS_UNIT_PX); } -static css_error cascade_padding_bottom(uint32_t opv, css_style *style, +css_error cascade_padding_bottom(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length(opv, style, state, set_padding_bottom); } -static css_error initial_padding_bottom(css_computed_style *style) +css_error initial_padding_bottom(css_computed_style *style) { return set_padding_bottom(style, CSS_PADDING_SET, 0, CSS_UNIT_PX); } -static css_error cascade_padding_left(uint32_t opv, css_style *style, +css_error cascade_padding_left(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length(opv, style, state, set_padding_left); } -static css_error initial_padding_left(css_computed_style *style) +css_error initial_padding_left(css_computed_style *style) { return set_padding_left(style, CSS_PADDING_SET, 0, CSS_UNIT_PX); } -static css_error cascade_page_break_after(uint32_t opv, css_style *style, +css_error cascade_page_break_after(uint32_t opv, css_style *style, css_select_state *state) { /** \todo page-break-after */ return cascade_page_break_after_before(opv, style, state, NULL); } -static css_error initial_page_break_after(css_computed_style *style) +css_error initial_page_break_after(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_page_break_before(uint32_t opv, css_style *style, +css_error cascade_page_break_before(uint32_t opv, css_style *style, css_select_state *state) { /** \todo page-break-before */ return cascade_page_break_after_before(opv, style, state, NULL); } -static css_error initial_page_break_before(css_computed_style *style) +css_error initial_page_break_before(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_page_break_inside(uint32_t opv, css_style *style, +css_error cascade_page_break_inside(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = 0; @@ -1910,56 +1918,56 @@ static css_error cascade_page_break_inside(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_page_break_inside(css_computed_style *style) +css_error initial_page_break_inside(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_pause_after(uint32_t opv, css_style *style, +css_error cascade_pause_after(uint32_t opv, css_style *style, css_select_state *state) { /** \todo pause-after */ return cascade_length(opv, style, state, NULL); } -static css_error initial_pause_after(css_computed_style *style) +css_error initial_pause_after(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_pause_before(uint32_t opv, css_style *style, +css_error cascade_pause_before(uint32_t opv, css_style *style, css_select_state *state) { /** \todo pause-before */ return cascade_length(opv, style, state, NULL); } -static css_error initial_pause_before(css_computed_style *style) +css_error initial_pause_before(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_pitch_range(uint32_t opv, css_style *style, +css_error cascade_pitch_range(uint32_t opv, css_style *style, css_select_state *state) { /** \todo pitch-range */ return cascade_number(opv, style, state, NULL); } -static css_error initial_pitch_range(css_computed_style *style) +css_error initial_pitch_range(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_pitch(uint32_t opv, css_style *style, +css_error cascade_pitch(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = 0; @@ -1993,14 +2001,14 @@ static css_error cascade_pitch(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_pitch(css_computed_style *style) +css_error initial_pitch(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_play_during(uint32_t opv, css_style *style, +css_error cascade_play_during(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = 0; @@ -2030,14 +2038,14 @@ static css_error cascade_play_during(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_play_during(css_computed_style *style) +css_error initial_play_during(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_position(uint32_t opv, css_style *style, +css_error cascade_position(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_POSITION_INHERIT; @@ -2068,12 +2076,12 @@ static css_error cascade_position(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_position(css_computed_style *style) +css_error initial_position(css_computed_style *style) { return set_position(style, CSS_POSITION_STATIC); } -static css_error cascade_quotes(uint32_t opv, css_style *style, +css_error cascade_quotes(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_QUOTES_INHERIT; @@ -2141,37 +2149,37 @@ static css_error cascade_quotes(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_quotes(css_computed_style *style) +css_error initial_quotes(css_computed_style *style) { return set_quotes(style, CSS_QUOTES_DEFAULT, NULL); } -static css_error cascade_richness(uint32_t opv, css_style *style, +css_error cascade_richness(uint32_t opv, css_style *style, css_select_state *state) { /** \todo richness */ return cascade_number(opv, style, state, NULL); } -static css_error initial_richness(css_computed_style *style) +css_error initial_richness(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_right(uint32_t opv, css_style *style, +css_error cascade_right(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_auto(opv, style, state, set_right); } -static css_error initial_right(css_computed_style *style) +css_error initial_right(css_computed_style *style) { return set_right(style, CSS_RIGHT_AUTO, 0, CSS_UNIT_PX); } -static css_error cascade_speak_header(uint32_t opv, css_style *style, +css_error cascade_speak_header(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = 0; @@ -2195,14 +2203,14 @@ static css_error cascade_speak_header(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_speak_header(css_computed_style *style) +css_error initial_speak_header(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_speak_numeral(uint32_t opv, css_style *style, +css_error cascade_speak_numeral(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = 0; @@ -2226,14 +2234,14 @@ static css_error cascade_speak_numeral(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_speak_numeral(css_computed_style *style) +css_error initial_speak_numeral(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_speak_punctuation( +css_error cascade_speak_punctuation( uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = 0; @@ -2257,14 +2265,14 @@ static css_error cascade_speak_punctuation( return CSS_OK; } -static css_error initial_speak_punctuation(css_computed_style *style) +css_error initial_speak_punctuation(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_speak(uint32_t opv, css_style *style, +css_error cascade_speak(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = 0; @@ -2289,14 +2297,14 @@ static css_error cascade_speak(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_speak(css_computed_style *style) +css_error initial_speak(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_speech_rate(uint32_t opv, css_style *style, +css_error cascade_speech_rate(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = 0; @@ -2329,28 +2337,28 @@ static css_error cascade_speech_rate(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_speech_rate(css_computed_style *style) +css_error initial_speech_rate(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_stress(uint32_t opv, css_style *style, +css_error cascade_stress(uint32_t opv, css_style *style, css_select_state *state) { /** \todo stress */ return cascade_number(opv, style, state, NULL); } -static css_error initial_stress(css_computed_style *style) +css_error initial_stress(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_table_layout(uint32_t opv, css_style *style, +css_error cascade_table_layout(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_TABLE_LAYOUT_INHERIT; @@ -2375,12 +2383,12 @@ static css_error cascade_table_layout(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_table_layout(css_computed_style *style) +css_error initial_table_layout(css_computed_style *style) { return set_table_layout(style, CSS_TABLE_LAYOUT_AUTO); } -static css_error cascade_text_align(uint32_t opv, css_style *style, +css_error cascade_text_align(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_TEXT_ALIGN_INHERIT; @@ -2411,12 +2419,12 @@ static css_error cascade_text_align(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_text_align(css_computed_style *style) +css_error initial_text_align(css_computed_style *style) { return set_text_align(style, CSS_TEXT_ALIGN_DEFAULT); } -static css_error cascade_text_decoration(uint32_t opv, css_style *style, +css_error cascade_text_decoration(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_TEXT_DECORATION_INHERIT; @@ -2447,23 +2455,23 @@ static css_error cascade_text_decoration(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_text_decoration(css_computed_style *style) +css_error initial_text_decoration(css_computed_style *style) { return set_text_decoration(style, CSS_TEXT_DECORATION_NONE); } -static css_error cascade_text_indent(uint32_t opv, css_style *style, +css_error cascade_text_indent(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length(opv, style, state, set_text_indent); } -static css_error initial_text_indent(css_computed_style *style) +css_error initial_text_indent(css_computed_style *style) { return set_text_indent(style, CSS_TEXT_INDENT_SET, 0, CSS_UNIT_PX); } -static css_error cascade_text_transform(uint32_t opv, css_style *style, +css_error cascade_text_transform(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_TEXT_TRANSFORM_INHERIT; @@ -2494,23 +2502,23 @@ static css_error cascade_text_transform(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_text_transform(css_computed_style *style) +css_error initial_text_transform(css_computed_style *style) { return set_text_transform(style, CSS_TEXT_TRANSFORM_NONE); } -static css_error cascade_top(uint32_t opv, css_style *style, +css_error cascade_top(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_auto(opv, style, state, set_top); } -static css_error initial_top(css_computed_style *style) +css_error initial_top(css_computed_style *style) { return set_top(style, CSS_TOP_AUTO, 0, CSS_UNIT_PX); } -static css_error cascade_unicode_bidi(uint32_t opv, css_style *style, +css_error cascade_unicode_bidi(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_UNICODE_BIDI_INHERIT; @@ -2538,12 +2546,12 @@ static css_error cascade_unicode_bidi(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_unicode_bidi(css_computed_style *style) +css_error initial_unicode_bidi(css_computed_style *style) { return set_unicode_bidi(style, CSS_UNICODE_BIDI_NORMAL); } -static css_error cascade_vertical_align(uint32_t opv, css_style *style, +css_error cascade_vertical_align(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_VERTICAL_ALIGN_INHERIT; @@ -2594,13 +2602,13 @@ static css_error cascade_vertical_align(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_vertical_align(css_computed_style *style) +css_error initial_vertical_align(css_computed_style *style) { return set_vertical_align(style, CSS_VERTICAL_ALIGN_BASELINE, 0, CSS_UNIT_PX); } -static css_error cascade_visibility(uint32_t opv, css_style *style, +css_error cascade_visibility(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_VISIBILITY_INHERIT; @@ -2628,12 +2636,12 @@ static css_error cascade_visibility(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_visibility(css_computed_style *style) +css_error initial_visibility(css_computed_style *style) { return set_visibility(style, CSS_VISIBILITY_VISIBLE); } -static css_error cascade_voice_family(uint32_t opv, css_style *style, +css_error cascade_voice_family(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = 0; @@ -2725,14 +2733,14 @@ static css_error cascade_voice_family(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_voice_family(css_computed_style *style) +css_error initial_voice_family(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_volume(uint32_t opv, css_style *style, +css_error cascade_volume(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = 0; @@ -2773,14 +2781,14 @@ static css_error cascade_volume(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_volume(css_computed_style *style) +css_error initial_volume(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_white_space(uint32_t opv, css_style *style, +css_error cascade_white_space(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_WHITE_SPACE_INHERIT; @@ -2814,48 +2822,48 @@ static css_error cascade_white_space(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_white_space(css_computed_style *style) +css_error initial_white_space(css_computed_style *style) { return set_white_space(style, CSS_WHITE_SPACE_NORMAL); } -static css_error cascade_widows(uint32_t opv, css_style *style, +css_error cascade_widows(uint32_t opv, css_style *style, css_select_state *state) { /** \todo widows */ return cascade_number(opv, style, state, NULL); } -static css_error initial_widows(css_computed_style *style) +css_error initial_widows(css_computed_style *style) { UNUSED(style); return CSS_OK; } -static css_error cascade_width(uint32_t opv, css_style *style, +css_error cascade_width(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_auto(opv, style, state, set_width); } -static css_error initial_width(css_computed_style *style) +css_error initial_width(css_computed_style *style) { return set_width(style, CSS_WIDTH_AUTO, 0, CSS_UNIT_PX); } -static css_error cascade_word_spacing(uint32_t opv, css_style *style, +css_error cascade_word_spacing(uint32_t opv, css_style *style, css_select_state *state) { return cascade_length_normal(opv, style, state, set_word_spacing); } -static css_error initial_word_spacing(css_computed_style *style) +css_error initial_word_spacing(css_computed_style *style) { return set_word_spacing(style, CSS_WORD_SPACING_NORMAL, 0, CSS_UNIT_PX); } -static css_error cascade_z_index(uint32_t opv, css_style *style, +css_error cascade_z_index(uint32_t opv, css_style *style, css_select_state *state) { uint16_t value = CSS_Z_INDEX_INHERIT; @@ -2882,7 +2890,7 @@ static css_error cascade_z_index(uint32_t opv, css_style *style, return CSS_OK; } -static css_error initial_z_index(css_computed_style *style) +css_error initial_z_index(css_computed_style *style) { return set_z_index(style, CSS_Z_INDEX_AUTO, 0); } diff --git a/src/select/properties.h b/src/select/properties.h new file mode 100644 index 0000000..552afd9 --- /dev/null +++ b/src/select/properties.h @@ -0,0 +1,316 @@ +/* + * This file is part of LibCSS + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2009 John-Mark Bell + */ + +#ifndef css_select_properties_h_ +#define css_select_properties_h_ + +#include +#include + +#include "stylesheet.h" +#include "select/select.h" + +css_error cascade_azimuth(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_azimuth(css_computed_style *style); +css_error cascade_background_attachment(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_background_attachment(css_computed_style *style); +css_error cascade_background_color(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_background_color(css_computed_style *style); +css_error cascade_background_image(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_background_image(css_computed_style *style); +css_error cascade_background_position(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_background_position(css_computed_style *style); +css_error cascade_background_repeat(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_background_repeat(css_computed_style *style); +css_error cascade_border_collapse(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_collapse(css_computed_style *style); +css_error cascade_border_spacing(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_spacing(css_computed_style *style); +css_error cascade_border_top_color(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_top_color(css_computed_style *style); +css_error cascade_border_right_color(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_right_color(css_computed_style *style); +css_error cascade_border_bottom_color(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_bottom_color(css_computed_style *style); +css_error cascade_border_left_color(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_left_color(css_computed_style *style); +css_error cascade_border_top_style(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_top_style(css_computed_style *style); +css_error cascade_border_right_style(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_right_style(css_computed_style *style); +css_error cascade_border_bottom_style(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_bottom_style(css_computed_style *style); +css_error cascade_border_left_style(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_left_style(css_computed_style *style); +css_error cascade_border_top_width(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_top_width(css_computed_style *style); +css_error cascade_border_right_width(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_right_width(css_computed_style *style); +css_error cascade_border_bottom_width(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_bottom_width(css_computed_style *style); +css_error cascade_border_left_width(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_border_left_width(css_computed_style *style); +css_error cascade_bottom(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_bottom(css_computed_style *style); +css_error cascade_caption_side(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_caption_side(css_computed_style *style); +css_error cascade_clear(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_clear(css_computed_style *style); +css_error cascade_clip(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_clip(css_computed_style *style); +css_error cascade_color(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_color(css_computed_style *style); +css_error cascade_content(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_content(css_computed_style *style); +css_error cascade_counter_increment(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_counter_increment(css_computed_style *style); +css_error cascade_counter_reset(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_counter_reset(css_computed_style *style); +css_error cascade_cue_after(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_cue_after(css_computed_style *style); +css_error cascade_cue_before(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_cue_before(css_computed_style *style); +css_error cascade_cursor(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_cursor(css_computed_style *style); +css_error cascade_direction(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_direction(css_computed_style *style); +css_error cascade_display(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_display(css_computed_style *style); +css_error cascade_elevation(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_elevation(css_computed_style *style); +css_error cascade_empty_cells(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_empty_cells(css_computed_style *style); +css_error cascade_float(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_float(css_computed_style *style); +css_error cascade_font_family(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_font_family(css_computed_style *style); +css_error cascade_font_size(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_font_size(css_computed_style *style); +css_error cascade_font_style(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_font_style(css_computed_style *style); +css_error cascade_font_variant(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_font_variant(css_computed_style *style); +css_error cascade_font_weight(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_font_weight(css_computed_style *style); +css_error cascade_height(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_height(css_computed_style *style); +css_error cascade_left(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_left(css_computed_style *style); +css_error cascade_letter_spacing(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_letter_spacing(css_computed_style *style); +css_error cascade_line_height(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_line_height(css_computed_style *style); +css_error cascade_list_style_image(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_list_style_image(css_computed_style *style); +css_error cascade_list_style_position(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_list_style_position(css_computed_style *style); +css_error cascade_list_style_type(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_list_style_type(css_computed_style *style); +css_error cascade_margin_top(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_margin_top(css_computed_style *style); +css_error cascade_margin_right(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_margin_right(css_computed_style *style); +css_error cascade_margin_bottom(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_margin_bottom(css_computed_style *style); +css_error cascade_margin_left(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_margin_left(css_computed_style *style); +css_error cascade_max_height(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_max_height(css_computed_style *style); +css_error cascade_max_width(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_max_width(css_computed_style *style); +css_error cascade_min_height(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_min_height(css_computed_style *style); +css_error cascade_min_width(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_min_width(css_computed_style *style); +css_error cascade_orphans(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_orphans(css_computed_style *style); +css_error cascade_outline_color(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_outline_color(css_computed_style *style); +css_error cascade_outline_style(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_outline_style(css_computed_style *style); +css_error cascade_outline_width(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_outline_width(css_computed_style *style); +css_error cascade_overflow(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_overflow(css_computed_style *style); +css_error cascade_padding_top(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_padding_top(css_computed_style *style); +css_error cascade_padding_right(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_padding_right(css_computed_style *style); +css_error cascade_padding_bottom(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_padding_bottom(css_computed_style *style); +css_error cascade_padding_left(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_padding_left(css_computed_style *style); +css_error cascade_page_break_after(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_page_break_after(css_computed_style *style); +css_error cascade_page_break_before(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_page_break_before(css_computed_style *style); +css_error cascade_page_break_inside(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_page_break_inside(css_computed_style *style); +css_error cascade_pause_after(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_pause_after(css_computed_style *style); +css_error cascade_pause_before(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_pause_before(css_computed_style *style); +css_error cascade_pitch_range(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_pitch_range(css_computed_style *style); +css_error cascade_pitch(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_pitch(css_computed_style *style); +css_error cascade_play_during(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_play_during(css_computed_style *style); +css_error cascade_position(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_position(css_computed_style *style); +css_error cascade_quotes(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_quotes(css_computed_style *style); +css_error cascade_richness(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_richness(css_computed_style *style); +css_error cascade_right(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_right(css_computed_style *style); +css_error cascade_speak_header(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_speak_header(css_computed_style *style); +css_error cascade_speak_numeral(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_speak_numeral(css_computed_style *style); +css_error cascade_speak_punctuation(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_speak_punctuation(css_computed_style *style); +css_error cascade_speak(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_speak(css_computed_style *style); +css_error cascade_speech_rate(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_speech_rate(css_computed_style *style); +css_error cascade_stress(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_stress(css_computed_style *style); +css_error cascade_table_layout(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_table_layout(css_computed_style *style); +css_error cascade_text_align(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_text_align(css_computed_style *style); +css_error cascade_text_decoration(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_text_decoration(css_computed_style *style); +css_error cascade_text_indent(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_text_indent(css_computed_style *style); +css_error cascade_text_transform(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_text_transform(css_computed_style *style); +css_error cascade_top(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_top(css_computed_style *style); +css_error cascade_unicode_bidi(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_unicode_bidi(css_computed_style *style); +css_error cascade_vertical_align(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_vertical_align(css_computed_style *style); +css_error cascade_visibility(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_visibility(css_computed_style *style); +css_error cascade_voice_family(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_voice_family(css_computed_style *style); +css_error cascade_volume(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_volume(css_computed_style *style); +css_error cascade_white_space(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_white_space(css_computed_style *style); +css_error cascade_widows(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_widows(css_computed_style *style); +css_error cascade_width(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_width(css_computed_style *style); +css_error cascade_word_spacing(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_word_spacing(css_computed_style *style); +css_error cascade_z_index(uint32_t opv, css_style *style, + css_select_state *state); +css_error initial_z_index(css_computed_style *style); + +#endif + diff --git a/src/select/propset.h b/src/select/propset.h index 730822a..27860f0 100644 --- a/src/select/propset.h +++ b/src/select/propset.h @@ -8,6 +8,8 @@ #ifndef css_select_propset_h_ #define css_select_propset_h_ +#include + #include /* Important: keep this file in sync with computed.h */ diff --git a/src/select/select.c b/src/select/select.c index 9efc912..77209ed 100644 --- a/src/select/select.c +++ b/src/select/select.c @@ -14,8 +14,10 @@ #include "bytecode/bytecode.h" #include "bytecode/opcodes.h" #include "stylesheet.h" +#include "select/dispatch.h" #include "select/hash.h" #include "select/propset.h" +#include "select/select.h" #include "utils/parserutilserror.h" #include "utils/utils.h" @@ -31,46 +33,6 @@ struct css_select_ctx { void *pw; /**< Client-specific private data */ }; -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 */ -} prop_state; - -/** - * Selection state - */ -typedef struct css_select_state { - void *node; /* Node we're selecting for */ - uint32_t pseudo_element; /* Pseudo element to select for */ - uint64_t media; /* Currently active media types */ - css_computed_style *result; /* Style to populate */ - - css_select_handler *handler; /* Handler functions */ - void *pw; /* Client data for handlers */ - - const css_stylesheet *sheet; /* Current sheet being processed */ - - css_origin current_origin; /* Origin of current sheet */ - uint32_t current_specificity; /* Specificity of current rule */ - - /* Useful interned strings */ - lwc_string *universal; - lwc_string *first_child; - lwc_string *link; - lwc_string *visited; - lwc_string *hover; - lwc_string *active; - lwc_string *focus; - lwc_string *first_line; - lwc_string *first_letter; - lwc_string *before; - lwc_string *after; - - prop_state props[N_OPCODES]; -} css_select_state; - 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, @@ -92,134 +54,6 @@ static css_error match_detail(css_select_ctx *ctx, void *node, const css_selector_detail *detail, css_select_state *state, bool *match); static css_error cascade_style(const css_style *style, css_select_state *state); -static inline void advance_bytecode(css_style *style, uint32_t n_bytes); -static bool outranks_existing(uint16_t op, bool important, - css_select_state *state); - -/* Property handlers */ -#include "select/properties.c" - -/** - * Enumeration of property groups - */ -enum prop_group { - GROUP_NORMAL = 0x0, - GROUP_UNCOMMON = 0x1, - GROUP_PAGE = 0x2, - GROUP_AURAL = 0x3 -}; - -/** - * Dispatch table for properties, indexed by opcode - */ -static struct prop_table { - css_error (*cascade)(uint32_t opv, css_style *style, - css_select_state *state); - css_error (*initial)(css_computed_style *style); - - uint32_t inherited : 1, - group : 2; -} properties[N_OPCODES] = { - { cascade_azimuth, initial_azimuth, 1, GROUP_AURAL}, - { cascade_background_attachment, initial_background_attachment, 0, GROUP_NORMAL }, - { cascade_background_color, initial_background_color, 0, GROUP_NORMAL }, - { cascade_background_image, initial_background_image, 0, GROUP_NORMAL }, - { cascade_background_position, initial_background_position, 0, GROUP_NORMAL }, - { cascade_background_repeat, initial_background_repeat, 0, GROUP_NORMAL }, - { cascade_border_collapse, initial_border_collapse, 1, GROUP_NORMAL }, - { cascade_border_spacing, initial_border_spacing, 1, GROUP_UNCOMMON }, - { cascade_border_top_color, initial_border_top_color, 0, GROUP_NORMAL }, - { cascade_border_right_color, initial_border_right_color, 0, GROUP_NORMAL }, - { cascade_border_bottom_color, initial_border_bottom_color, 0, GROUP_NORMAL }, - { cascade_border_left_color, initial_border_left_color, 0, GROUP_NORMAL }, - { cascade_border_top_style, initial_border_top_style, 0, GROUP_NORMAL }, - { cascade_border_right_style, initial_border_right_style, 0, GROUP_NORMAL }, - { cascade_border_bottom_style, initial_border_bottom_style, 0, GROUP_NORMAL }, - { cascade_border_left_style, initial_border_left_style, 0, GROUP_NORMAL }, - { cascade_border_top_width, initial_border_top_width, 0, GROUP_NORMAL }, - { cascade_border_right_width, initial_border_right_width, 0, GROUP_NORMAL }, - { cascade_border_bottom_width, initial_border_bottom_width, 0, GROUP_NORMAL }, - { cascade_border_left_width, initial_border_left_width, 0, GROUP_NORMAL }, - { cascade_bottom, initial_bottom, 0, GROUP_NORMAL }, - { cascade_caption_side, initial_caption_side, 1, GROUP_NORMAL }, - { cascade_clear, initial_clear, 0, GROUP_NORMAL }, - { cascade_clip, initial_clip, 0, GROUP_UNCOMMON }, - { cascade_color, initial_color, 1, GROUP_NORMAL }, - { cascade_content, initial_content, 0, GROUP_UNCOMMON }, - { cascade_counter_increment, initial_counter_increment, 0, GROUP_UNCOMMON }, - { cascade_counter_reset, initial_counter_reset, 0, GROUP_UNCOMMON }, - { cascade_cue_after, initial_cue_after, 0, GROUP_AURAL }, - { cascade_cue_before, initial_cue_before, 0, GROUP_AURAL }, - { cascade_cursor, initial_cursor, 1, GROUP_UNCOMMON }, - { cascade_direction, initial_direction, 1, GROUP_NORMAL }, - { cascade_display, initial_display, 0, GROUP_NORMAL }, - { cascade_elevation, initial_elevation, 1, GROUP_AURAL }, - { cascade_empty_cells, initial_empty_cells, 1, GROUP_NORMAL }, - { cascade_float, initial_float, 0, GROUP_NORMAL }, - { cascade_font_family, initial_font_family, 1, GROUP_NORMAL }, - { cascade_font_size, initial_font_size, 1, GROUP_NORMAL }, - { cascade_font_style, initial_font_style, 1, GROUP_NORMAL }, - { cascade_font_variant, initial_font_variant, 1, GROUP_NORMAL }, - { cascade_font_weight, initial_font_weight, 1, GROUP_NORMAL }, - { cascade_height, initial_height, 0, GROUP_NORMAL }, - { cascade_left, initial_left, 0, GROUP_NORMAL }, - { cascade_letter_spacing, initial_letter_spacing, 1, GROUP_UNCOMMON }, - { cascade_line_height, initial_line_height, 1, GROUP_NORMAL }, - { cascade_list_style_image, initial_list_style_image, 1, GROUP_NORMAL }, - { cascade_list_style_position, initial_list_style_position, 1, GROUP_NORMAL }, - { cascade_list_style_type, initial_list_style_type, 1, GROUP_NORMAL }, - { cascade_margin_top, initial_margin_top, 0, GROUP_NORMAL }, - { cascade_margin_right, initial_margin_right, 0, GROUP_NORMAL }, - { cascade_margin_bottom, initial_margin_bottom, 0, GROUP_NORMAL }, - { cascade_margin_left, initial_margin_left, 0, GROUP_NORMAL }, - { cascade_max_height, initial_max_height, 0, GROUP_NORMAL }, - { cascade_max_width, initial_max_width, 0, GROUP_NORMAL }, - { cascade_min_height, initial_min_height, 0, GROUP_NORMAL }, - { cascade_min_width, initial_min_width, 0, GROUP_NORMAL }, - { cascade_orphans, initial_orphans, 1, GROUP_PAGE }, - { cascade_outline_color, initial_outline_color, 0, GROUP_UNCOMMON }, - { cascade_outline_style, initial_outline_style, 0, GROUP_NORMAL }, - { cascade_outline_width, initial_outline_width, 0, GROUP_UNCOMMON }, - { cascade_overflow, initial_overflow, 0, GROUP_NORMAL }, - { cascade_padding_top, initial_padding_top, 0, GROUP_NORMAL }, - { cascade_padding_right, initial_padding_right, 0, GROUP_NORMAL }, - { cascade_padding_bottom, initial_padding_bottom, 0, GROUP_NORMAL }, - { cascade_padding_left, initial_padding_left, 0, GROUP_NORMAL }, - { cascade_page_break_after, initial_page_break_after, 0, GROUP_PAGE }, - { cascade_page_break_before, initial_page_break_before, 0, GROUP_PAGE }, - { cascade_page_break_inside, initial_page_break_inside, 1, GROUP_PAGE }, - { cascade_pause_after, initial_pause_after, 0, GROUP_AURAL }, - { cascade_pause_before, initial_pause_before, 0, GROUP_AURAL }, - { cascade_pitch_range, initial_pitch_range, 1, GROUP_AURAL }, - { cascade_pitch, initial_pitch, 1, GROUP_AURAL }, - { cascade_play_during, initial_play_during, 0, GROUP_AURAL }, - { cascade_position, initial_position, 0, GROUP_NORMAL }, - { cascade_quotes, initial_quotes, 1, GROUP_UNCOMMON }, - { cascade_richness, initial_richness, 1, GROUP_AURAL }, - { cascade_right, initial_right, 0, GROUP_NORMAL }, - { cascade_speak_header, initial_speak_header, 1, GROUP_AURAL }, - { cascade_speak_numeral, initial_speak_numeral, 1, GROUP_AURAL }, - { cascade_speak_punctuation, initial_speak_punctuation, 1, GROUP_AURAL }, - { cascade_speak, initial_speak, 1, GROUP_AURAL }, - { cascade_speech_rate, initial_speech_rate, 1, GROUP_AURAL }, - { cascade_stress, initial_stress, 1, GROUP_AURAL }, - { cascade_table_layout, initial_table_layout, 0, GROUP_NORMAL }, - { cascade_text_align, initial_text_align, 1, GROUP_NORMAL }, - { cascade_text_decoration, initial_text_decoration, 0, GROUP_NORMAL }, - { cascade_text_indent, initial_text_indent, 1, GROUP_NORMAL }, - { cascade_text_transform, initial_text_transform, 1, GROUP_NORMAL }, - { cascade_top, initial_top, 0, GROUP_NORMAL }, - { cascade_unicode_bidi, initial_unicode_bidi, 0, GROUP_NORMAL }, - { cascade_vertical_align, initial_vertical_align, 0, GROUP_NORMAL }, - { cascade_visibility, initial_visibility, 1, GROUP_NORMAL }, - { cascade_voice_family, initial_voice_family, 1, GROUP_AURAL }, - { cascade_volume, initial_volume, 1, GROUP_AURAL }, - { cascade_white_space, initial_white_space, 1, GROUP_NORMAL }, - { cascade_widows, initial_widows, 1, GROUP_PAGE }, - { cascade_width, initial_width, 0, GROUP_NORMAL }, - { cascade_word_spacing, initial_word_spacing, 1, GROUP_UNCOMMON }, - { cascade_z_index, initial_z_index, 0, GROUP_NORMAL } -}; /** * Create a selection context @@ -465,7 +299,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node, /* Do nothing if this property is inherited (the default state * of a clean computed style is for everything to be set to * inherit) */ - if (properties[i].inherited) + if (prop_dispatch[i].inherited) continue; /* Remaining properties are neither inherited nor already set. @@ -475,23 +309,23 @@ css_error css_select_style(css_select_ctx *ctx, void *node, * allocated. In that case, we do nothing and leave it to the * property accessors to return the initial values for the * property. */ - if (properties[i].group == GROUP_NORMAL) { - error = properties[i].initial(result); + if (prop_dispatch[i].group == GROUP_NORMAL) { + error = prop_dispatch[i].initial(result); if (error != CSS_OK) goto cleanup; - } else if (properties[i].group == GROUP_UNCOMMON && + } else if (prop_dispatch[i].group == GROUP_UNCOMMON && result->uncommon != NULL) { - error = properties[i].initial(result); + error = prop_dispatch[i].initial(result); if (error != CSS_OK) goto cleanup; - } else if (properties[i].group == GROUP_PAGE && + } else if (prop_dispatch[i].group == GROUP_PAGE && result->page != NULL) { - error = properties[i].initial(result); + error = prop_dispatch[i].initial(result); if (error != CSS_OK) goto cleanup; - } else if (properties[i].group == GROUP_AURAL && + } else if (prop_dispatch[i].group == GROUP_AURAL && result->aural != NULL) { - error = properties[i].initial(result); + error = prop_dispatch[i].initial(result); if (error != CSS_OK) goto cleanup; } @@ -689,7 +523,8 @@ css_error match_selectors_in_sheet(css_select_ctx *ctx, css_error error; /* Get node's name */ - error = state->handler->node_name(state->pw, state->node, sheet->dictionary, &element); + error = state->handler->node_name(state->pw, state->node, + sheet->dictionary, &element); if (error != CSS_OK) return error; @@ -1007,7 +842,7 @@ css_error cascade_style(const css_style *style, css_select_state *state) op = getOpcode(opv); - error = properties[op].cascade(opv, &s, state); + error = prop_dispatch[op].cascade(opv, &s, state); if (error != CSS_OK) return error; } @@ -1015,12 +850,6 @@ css_error cascade_style(const css_style *style, css_select_state *state) return CSS_OK; } -void advance_bytecode(css_style *style, uint32_t n_bytes) -{ - style->length -= n_bytes; - style->bytecode = ((uint8_t *) style->bytecode) + n_bytes; -} - bool outranks_existing(uint16_t op, bool important, css_select_state *state) { prop_state *existing = &state->props[op]; diff --git a/src/select/select.h b/src/select/select.h new file mode 100644 index 0000000..e232a0b --- /dev/null +++ b/src/select/select.h @@ -0,0 +1,67 @@ +/* + * This file is part of LibCSS + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2009 John-Mark Bell + */ + +#ifndef css_select_select_h_ +#define css_select_select_h_ + +#include +#include + +#include + +#include "stylesheet.h" + +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 */ +} prop_state; + +/** + * Selection state + */ +typedef struct css_select_state { + void *node; /* Node we're selecting for */ + uint32_t pseudo_element; /* Pseudo element to select for */ + uint64_t media; /* Currently active media types */ + css_computed_style *result; /* Style to populate */ + + css_select_handler *handler; /* Handler functions */ + void *pw; /* Client data for handlers */ + + const css_stylesheet *sheet; /* Current sheet being processed */ + + css_origin current_origin; /* Origin of current sheet */ + uint32_t current_specificity; /* Specificity of current rule */ + + /* Useful interned strings */ + lwc_string *universal; + lwc_string *first_child; + lwc_string *link; + lwc_string *visited; + lwc_string *hover; + lwc_string *active; + lwc_string *focus; + lwc_string *first_line; + lwc_string *first_letter; + lwc_string *before; + lwc_string *after; + + prop_state props[N_OPCODES]; +} css_select_state; + +static inline void advance_bytecode(css_style *style, uint32_t n_bytes) +{ + style->length -= n_bytes; + style->bytecode = ((uint8_t *) style->bytecode) + n_bytes; +} + +bool outranks_existing(uint16_t op, bool important, css_select_state *state); + +#endif + -- cgit v1.2.3