mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-11-30 16:48:21 +01:00
feat(css): add css value definition parser refactor(css): change the parameter types of css_parse_* functions refactor(css): migrate to new data types refactor(css): migrate to new data types (2) refactor(css): migrate to new data types (3) test: add valdef test feat(css): add css_valdef_parser_finish() refactor(css): split css_library.c refactor(css): css_data_type.c -> css_data_types.c fix(css): the parsing error message of sign is not truncated fix(css): correct initialization of data type library fix(css): error message should not be empty feat(css): add css_valdef_to_string() feat(css): add double bar combinator feat(css): add double ampersand combinator feat(css): add curly braces multiplier feat(css): add brackets combinator parser docs: update css value matcher section feat(css): add question mark multiplier test(css): add test for brackets combinator docs(css): update libcss_css_value.md docs: update directory structure refactor: numberic -> numeric refactor(css): delete style property parser refactor: migrate to css property API docs(css): add css value converter section feat(css): add css_computed_style_t refactor(css): rename `css_style` associated identifiers feat(css): add css_cascade_style() refactor(css): change type of css_value_matcher_t::value refactor(css): update args of css_register_property() refactor(css): move css_computed_style_t feat(css): update opacity property feat(css): update z-index property feat(css): update display property feat(css): update pointer-events property feat(css): update flex-wrap property feat(css): update flex-direction property feat(css): update flex-grow property feat(css): update flex-shrink property feat(css): update align-items property feat(css): update justify-content property feat(css): update position property feat(css): update box-sizing property feat(css): update align-content property feat(css): update white-space property feat(css): update content property feat(css): update text-align property feat(css): automatically register new keywords feat(css): update font-style property feat(css): update visibility property feat(css): update border-*-style property refactor: update css_unit_t definition feat(css): update border-*-*-radius properties refactor(css): delete CSS_PERCENTAGE_VALUE refactor(css): css_cascade_length() -> css_cascade_length_auto() refactor(css): update enum definitions feat(css): update border-*-width properties feat(css): update border-*-color properties feat(css): add css_array_value_get_length() feat(css): add border-width shorthand property feat(css): add border-style shorthand property feat(css): add border-radius shorthand property feat(css): add border-color shorthand property feat(css): add border shorthand property feat(css): add margin shorthand property feat(css): add padding shorthand property feat(css): update size related properties feat(css): update top, right, bottom, left properties feat(css): update flex-basis property feat(css): update line-height property feat(css): update color property refactor(css): add css_cascade_bg_border_color() refactor(css): bits -> keyword_bits refactor(css): flag -> keyword refactor(css): update css_color_value_t definition feat(css): add CSS_COLOR_TRANSPARENT refactor(css): remove transparent keyword feat(css): update font-size property feat(css): update font-family property feat(css): update background shorthand property feat(css): update vertical-align property feat(css): update box-shadow property feat(css): update the computing of the box-shadow property feat(css): update the computing of the background property feat(css): update the computing of the border property refactor(css): keyword_bits -> type_bits refactor(css): enum css_*_e -> uint8_t feat(css): add absolute size computing feat(css): add absolute padding computing feat(css): add absolute margin computing style(css): format code feat(css): add top, right, bottom, and left absolute value computing feat(css): add flex-basis absolute value computing refactor(ui): replace data type of computed style feat(ui): update widget background style computing feat(ui): update widget box-shadow style computing feat(ui): update widget border style computing feat(ui): update widget box computing feat(ui): use tabindex instead of focusable feat(css): remove focusable property feat(css): update font-weight property fix(css): clear compile errors refactor(ui): adapt to new computed style data structure refactor(ui): delete ui_widget_box_model_t fix: clear some compiler warnings refactor(ui): ui_font_style.c -> ui_text_style.c feat(ui): remove unnecessary helper functions fix: clear some compiler warnings fix(font): correct bitmap cache access fix(css): correct the key assignment of keywords fix(css): some memory access errors fix: missing NULL at the end of font names fix: clear gcc errors refactor: clear gcc warnings fix(css): array subscript is above array bounds fix(css): incorrect property name memory allocation fix(css): style parser memory leak fix(css): prop->valdef memory leak refactor(css): logger_debug -> DEBUG_MSG refactor(ui-builder): clear warnings fix(css): css_properties.list memory leak fix(css): css_style_link_group_create() memory leak fix(css): incorrect keyword storage test(css): correct color_value comparison test: clear compiler errors fix(css): correct the return value of css_register_keyword() fix(css): correct integer type value parsing chore(css): _DEBUG -> DEBUG feat(css): add string value parsing fix(css): correct font-family initial value test(css): add test_css_computed.c fix(css): value read error in css_cascade_background() fix(css): add some missing properties feat(css): add flex shorthand property build: update rundir of lcui-css-test fix(css): font-family parsing error feat(css): style array value to string chore(vscode): add compileCommands fix(css): string value parsing error fix(css): correct content property initial value fix(css): the parsed style data is not stored correctly fix(css): correct cascading of some properties fix(css): percentage value parsing inccorect fix(css): <length> should not contain <percentage> fix(css): css_array_value_duplicate() did not copy the last value feat(css): add visible keyword feat(css): cascade each property in order refactor(css): add style_decl.c refactor(css): use css_style_decl_t instead of css_style_t fix(css): incorrect number of resolved values refactor(css): add css_style.c feat(css): parse shorthand properties in the parsing phase refactor(css): add background property parser refactor(css): add border property parser refactor(css): css_select_style_decl -> css_find_style_store refactor(css): add css_select_style_with_cache() refactor(css): add margin property parser refactor(css): add padding property parser refactor(css): add flex property parser fix(ui): incorrect widget style cascading order refactor(css): const css_propdef_t* -> css_propdef_t* refactor(css): update arguments of shorthand property parser fix(css): incorrect value parsing of shorthand property fix(css): unexpected truncation while parsing color value fix(css): correct value matching and style computing fix(ui): correct css style operation fix(platform): crash when closing window refactor(css): delete file prefix refactor(css): delete style.c refactor(css): clear compiler warnings refactor: update directory structure and build configuration feat(css): add dump functions fix(css): correct valdef parser cursor operation fix(css): correct the definition of margin and padding fix(css): correct flex property parsing and definition refactor(ui): adjust the use of calculated styles in the layout engine chore: tests/helloword -> examples/hello fix(ui): some bugs in block layout fix(css): correct flex property definition refactor(ui): simplify the naming of widget style and layout diff API refactor(ui): update reflow trigger rules refactor(ui): ui_widget_auto_reflow -> ui_widget_reflow feat(ui): allow multiple observers to connect to the same widget refactor(ui): simplify widget update process refactor(ui): adjust row processing in block layout refactor(ui): adjust the data structure used in the flexbox layout fix(ui): correct flex layout algorithm build: update config
259 lines
8.2 KiB
C
259 lines
8.2 KiB
C
|
|
#ifndef LIBCSS_INCLUDE_CSS_COMPUTED_H
|
|
#define LIBCSS_INCLUDE_CSS_COMPUTED_H
|
|
|
|
#include <LCUI/def.h>
|
|
#include "def.h"
|
|
|
|
LCUI_BEGIN_HEADER
|
|
|
|
#define IS_CSS_LENGTH(S, PROP_KEY) (S)->type_bits.PROP_KEY == CSS_LENGTH_SET
|
|
|
|
#define IS_CSS_FIXED_LENGTH(S, PROP_KEY) \
|
|
((S)->type_bits.PROP_KEY == CSS_LENGTH_SET && \
|
|
(S)->unit_bits.PROP_KEY == CSS_UNIT_PX)
|
|
|
|
#define IS_CSS_PERCENTAGE(S, PROP_KEY) \
|
|
((S)->type_bits.PROP_KEY == CSS_LENGTH_SET && \
|
|
(S)->unit_bits.PROP_KEY == CSS_UNIT_PERCENT)
|
|
|
|
#define CSS_SET_FIXED_LENGTH(S, PROP_KEY, PROP_VALUE) \
|
|
do { \
|
|
(S)->PROP_KEY = PROP_VALUE; \
|
|
(S)->type_bits.PROP_KEY = CSS_LENGTH_SET; \
|
|
(S)->unit_bits.PROP_KEY = CSS_UNIT_PX; \
|
|
} while (0);
|
|
|
|
#define CSS_COPY_LENGTH(SRC, DEST, PROP_KEY) \
|
|
do { \
|
|
(SRC)->PROP_KEY = (DEST)->PROP_KEY; \
|
|
(SRC)->type_bits.PROP_KEY = (DEST)->type_bits.PROP_KEY; \
|
|
(SRC)->unit_bits.PROP_KEY = (DEST)->unit_bits.PROP_KEY; \
|
|
} while (0);
|
|
|
|
INLINE LCUI_BOOL is_css_display_inline(uint8_t display)
|
|
{
|
|
return display == CSS_DISPLAY_INLINE ||
|
|
display == CSS_DISPLAY_INLINE_BLOCK ||
|
|
display == CSS_DISPLAY_INLINE_FLEX;
|
|
}
|
|
|
|
INLINE css_numeric_value_t css_padding_x(const css_computed_style_t *s)
|
|
{
|
|
return s->padding_left + s->padding_right;
|
|
}
|
|
|
|
INLINE css_numeric_value_t css_padding_y(const css_computed_style_t *s)
|
|
{
|
|
return s->padding_top + s->padding_bottom;
|
|
}
|
|
|
|
INLINE css_numeric_value_t css_margin_x(const css_computed_style_t *s)
|
|
{
|
|
return s->margin_left + s->margin_right;
|
|
}
|
|
|
|
INLINE css_numeric_value_t css_margin_y(const css_computed_style_t *s)
|
|
{
|
|
return s->margin_top + s->margin_bottom;
|
|
}
|
|
|
|
INLINE css_numeric_value_t css_border_x(const css_computed_style_t *s)
|
|
{
|
|
return s->border_left_width + s->border_right_width;
|
|
}
|
|
|
|
INLINE css_numeric_value_t css_border_y(const css_computed_style_t *s)
|
|
{
|
|
return s->border_top_width + s->border_bottom_width;
|
|
}
|
|
|
|
LCUI_API uint8_t css_computed_padding_top(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_padding_right(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_padding_bottom(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_padding_left(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_margin_top(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_margin_right(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_margin_bottom(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_margin_left(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_top(const css_computed_style_t *s,
|
|
css_numeric_value_t *value, css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_right(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_bottom(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_left(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_display(const css_computed_style_t *s);
|
|
|
|
LCUI_API uint8_t css_computed_vertical_align(const css_computed_style_t *s);
|
|
|
|
LCUI_API uint8_t css_computed_box_sizing(const css_computed_style_t *s);
|
|
|
|
LCUI_API uint8_t css_computed_position(const css_computed_style_t *s);
|
|
|
|
LCUI_API uint8_t css_computed_min_width(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_min_height(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_max_width(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_max_height(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_width(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_height(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_border_top_style(const css_computed_style_t *s);
|
|
|
|
LCUI_API uint8_t css_computed_border_right_style(const css_computed_style_t *s);
|
|
|
|
LCUI_API uint8_t
|
|
css_computed_border_bottom_style(const css_computed_style_t *s);
|
|
|
|
LCUI_API uint8_t css_computed_border_left_style(const css_computed_style_t *s);
|
|
|
|
LCUI_API uint8_t css_computed_border_top_color(const css_computed_style_t *s,
|
|
css_color_value_t *value);
|
|
|
|
LCUI_API uint8_t css_computed_border_right_color(const css_computed_style_t *s,
|
|
css_color_value_t *value);
|
|
|
|
LCUI_API uint8_t css_computed_border_bottom_color(const css_computed_style_t *s,
|
|
css_color_value_t *value);
|
|
|
|
LCUI_API uint8_t css_computed_border_left_color(const css_computed_style_t *s,
|
|
css_color_value_t *value);
|
|
|
|
LCUI_API uint8_t css_computed_background_position_x(
|
|
const css_computed_style_t *s, css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_background_position_y(
|
|
const css_computed_style_t *s, css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_background_width(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_background_height(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_background_image(const css_computed_style_t *s,
|
|
css_image_value_t *value);
|
|
|
|
LCUI_API uint8_t css_computed_box_shadow_x(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_box_shadow_y(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_box_shadow_blur(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_box_shadow_spread(const css_computed_style_t *s,
|
|
css_numeric_value_t *value,
|
|
css_unit_t *unit);
|
|
|
|
LCUI_API uint8_t css_computed_box_shadow_color(const css_computed_style_t *s,
|
|
css_color_value_t *value);
|
|
|
|
LCUI_API uint8_t css_computed_visibility(const css_computed_style_t *s);
|
|
|
|
LCUI_API void css_computed_style_destroy(css_computed_style_t *s);
|
|
|
|
LCUI_API int css_cascade_style(const css_style_decl_t *style,
|
|
css_computed_style_t *computed);
|
|
|
|
LCUI_API void css_compute_absolute_values(const css_computed_style_t *parent,
|
|
css_computed_style_t *s,
|
|
css_metrics_t *m);
|
|
|
|
INLINE css_numeric_value_t css_convert_content_box_width(
|
|
css_computed_style_t *s, css_numeric_value_t content_width)
|
|
{
|
|
if (css_computed_box_sizing(s) == CSS_BOX_SIZING_BORDER_BOX) {
|
|
return content_width + css_border_x(s) + css_padding_x(s);
|
|
}
|
|
return content_width;
|
|
}
|
|
|
|
INLINE css_numeric_value_t css_convert_content_box_height(
|
|
css_computed_style_t *s, css_numeric_value_t content_height)
|
|
{
|
|
if (css_computed_box_sizing(s) == CSS_BOX_SIZING_BORDER_BOX) {
|
|
return content_height + css_border_y(s) + css_padding_y(s);
|
|
}
|
|
return content_height;
|
|
}
|
|
|
|
INLINE css_numeric_value_t css_convert_border_box_width(
|
|
css_computed_style_t *s, css_numeric_value_t border_width)
|
|
{
|
|
if (css_computed_box_sizing(s) == CSS_BOX_SIZING_CONTENT_BOX) {
|
|
return border_width - css_border_x(s) - css_padding_x(s);
|
|
}
|
|
return border_width;
|
|
}
|
|
|
|
INLINE css_numeric_value_t css_convert_border_box_height(
|
|
css_computed_style_t *s, css_numeric_value_t border_height)
|
|
{
|
|
if (css_computed_box_sizing(s) == CSS_BOX_SIZING_CONTENT_BOX) {
|
|
return border_height - css_border_y(s) - css_padding_y(s);
|
|
}
|
|
return border_height;
|
|
}
|
|
|
|
LCUI_END_HEADER
|
|
|
|
#endif
|