1 commit 2fdb04a6ab5523b94c4bd5c0062b0701686e127f
2 Author: Witold Filipczyk <witekfl@poczta.onet.pl>
3 Date: Mon Jan 1 17:47:59 2024 +0100
5 [libcss] bump libcss to 0.9.2 and libdom to 0.4.2
7 Needs some tweaks. Code is compilable at least.
9 diff --git a/meson.build b/meson.build
10 index 2917865f..20d1d93d 100644
13 @@ -492,7 +492,7 @@ conf_data.set('CONFIG_LIBCSS', false)
16 if conf_data.get('CONFIG_ECMASCRIPT_SMJS') or conf_data.get('CONFIG_QUICKJS') or conf_data.get('CONFIG_MUJS')
17 - cssdeps = dependency('libcss', static: st, version: '>=0.9.1')
18 + cssdeps = dependency('libcss', static: st, version: '>=0.9.2')
20 conf_data.set('CONFIG_LIBCSS', true)
22 @@ -501,17 +501,17 @@ conf_data.set('CONFIG_LIBDOM', false)
25 if conf_data.get('CONFIG_ECMASCRIPT_SMJS') or conf_data.get('CONFIG_QUICKJS') or conf_data.get('CONFIG_MUJS')
26 - libdomdeps = dependency('libdom', static: st, version: '>=0.4.1')
27 + libdomdeps = dependency('libdom', static: st, version: '>=0.4.2')
29 conf_data.set('CONFIG_LIBDOM', true)
32 if not conf_data.get('CONFIG_LIBCSS') and get_option('libcss')
33 - cssdeps = dependency('libcss', static: st, version: '>=0.9.1')
34 + cssdeps = dependency('libcss', static: st, version: '>=0.9.2')
36 conf_data.set('CONFIG_LIBCSS', true)
37 if not conf_data.get('CONFIG_LIBDOM')
38 - libdomdeps = dependency('libdom', static: st, version: '>=0.4.1')
39 + libdomdeps = dependency('libdom', static: st, version: '>=0.4.2')
41 conf_data.set('CONFIG_LIBDOM', true)
43 diff --git a/src/document/libdom/css.c b/src/document/libdom/css.c
44 index 662c5d71..02a5f66e 100644
45 --- a/src/document/libdom/css.c
46 +++ b/src/document/libdom/css.c
47 @@ -222,7 +222,6 @@ static css_select_handler selection_handler = {
49 node_presentational_hint,
50 ua_default_for_property,
55 @@ -287,7 +286,9 @@ static void nscss_dom_user_data_handler(dom_node_operation operation,
58 css_select_results *nscss_get_style(nscss_select_ctx *ctx, dom_node *n,
59 - const css_media *media, const css_stylesheet *inline_style)
60 + const css_media *media,
61 + const css_unit_ctx *unit_len_ctx,
62 + const css_stylesheet *inline_style)
64 css_computed_style *composed;
65 css_select_results *styles;
66 @@ -295,7 +296,7 @@ css_select_results *nscss_get_style(nscss_select_ctx *ctx, dom_node *n,
69 /* Select style for node */
70 - error = css_select_style(ctx->ctx, n, media, inline_style,
71 + error = css_select_style(ctx->ctx, n, unit_len_ctx, media, inline_style,
72 &selection_handler, ctx, &styles);
74 if (error != CSS_OK || styles == NULL) {
75 @@ -310,8 +311,7 @@ css_select_results *nscss_get_style(nscss_select_ctx *ctx, dom_node *n,
77 error = css_computed_style_compose(ctx->parent_style,
78 styles->styles[CSS_PSEUDO_ELEMENT_NONE],
79 - compute_font_size, ctx,
81 + unit_len_ctx, &composed);
82 if (error != CSS_OK) {
83 css_select_results_destroy(styles);
85 @@ -342,8 +342,7 @@ css_select_results *nscss_get_style(nscss_select_ctx *ctx, dom_node *n,
86 error = css_computed_style_compose(
87 styles->styles[CSS_PSEUDO_ELEMENT_NONE],
88 styles->styles[pseudo_element],
89 - compute_font_size, ctx,
91 + unit_len_ctx, &composed);
92 if (error != CSS_OK) {
93 /* TODO: perhaps this shouldn't be quite so
95 @@ -367,6 +366,7 @@ css_select_results *nscss_get_style(nscss_select_ctx *ctx, dom_node *n,
96 * \return Pointer to blank style, or NULL on failure
98 css_computed_style *nscss_get_blank_style(nscss_select_ctx *ctx,
99 + const css_unit_ctx *unit_len_ctx,
100 const css_computed_style *parent)
102 css_computed_style *partial, *composed;
103 @@ -381,7 +381,7 @@ css_computed_style *nscss_get_blank_style(nscss_select_ctx *ctx,
104 /* TODO: Do we really need to compose? Initial style shouldn't
105 * have any inherited properties. */
106 error = css_computed_style_compose(parent, partial,
107 - compute_font_size, ctx, &composed);
108 + unit_len_ctx, &composed);
109 css_computed_style_destroy(partial);
110 if (error != CSS_OK) {
111 css_computed_style_destroy(composed);
112 @@ -2063,6 +2063,21 @@ select_css(struct html_context *html_context, struct html_element *html_element)
114 .type = CSS_MEDIA_SCREEN,
116 + css_unit_ctx unit_len_ctx = {0};
117 + unit_len_ctx.viewport_width = 800; // TODO
118 + unit_len_ctx.viewport_height = 600; // TODO
119 + unit_len_ctx.device_dpi = F_90; //device_dpi;
121 + /** \todo Change nsoption font sizes to px. */
122 +/// f_size = FDIV(FMUL(F_96, FDIV(INTTOFIX(nsoption_int(font_size)), F_10)), F_72);
123 +/// f_min = FDIV(FMUL(F_96, FDIV(INTTOFIX(nsoption_int(font_min_size)), F_10)), F_72);
125 + unsigned int f_size = FDIV(FMUL(F_96, FDIV(INTTOFIX(50), F_10)), F_72); // TODO
126 + unsigned int f_min = FDIV(FMUL(F_96, FDIV(INTTOFIX(50), F_10)), F_72); // TODO
128 + unit_len_ctx.font_size_default = f_size;
129 + unit_len_ctx.font_size_minimum = f_min;
131 int offset = html_element->name - html_context->document->text.source;
132 dom_node *el = (dom_node *)find_in_map(html_context->document->element_map, offset);
134 @@ -2101,7 +2116,7 @@ select_css(struct html_context *html_context, struct html_element *html_element)
135 /// ctx.parent_style = parent_style;
137 /* Select style for element */
138 - style = nscss_get_style(&ctx, el, &media, inline_style);
139 + style = nscss_get_style(&ctx, el, &media, &unit_len_ctx, inline_style);
141 /* No longer need inline style */
142 if (inline_style != NULL) {