]> git.pld-linux.org Git - packages/elinks.git/blob - libcss-0.9.2.patch
- initialize unit_len_ctx
[packages/elinks.git] / libcss-0.9.2.patch
1 commit 2fdb04a6ab5523b94c4bd5c0062b0701686e127f
2 Author: Witold Filipczyk <witekfl@poczta.onet.pl>
3 Date:   Mon Jan 1 17:47:59 2024 +0100
4
5     [libcss] bump libcss to 0.9.2 and libdom to 0.4.2
6     
7     Needs some tweaks. Code is compilable at least.
8
9 diff --git a/meson.build b/meson.build
10 index 2917865f..20d1d93d 100644
11 --- a/meson.build
12 +++ b/meson.build
13 @@ -492,7 +492,7 @@ conf_data.set('CONFIG_LIBCSS', false)
14  cssdeps = false
15  
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')
19      deps += cssdeps
20      conf_data.set('CONFIG_LIBCSS', true)
21  endif
22 @@ -501,17 +501,17 @@ conf_data.set('CONFIG_LIBDOM', false)
23  libdomdeps = false
24  
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')
28      deps += libdomdeps
29      conf_data.set('CONFIG_LIBDOM', true)
30  endif
31  
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')
35      deps += cssdeps
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')
40          deps += libdomdeps
41          conf_data.set('CONFIG_LIBDOM', true)
42      endif
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 = {
48         node_is_lang,
49         node_presentational_hint,
50         ua_default_for_property,
51 -       compute_font_size,
52         set_libcss_node_data,
53         get_libcss_node_data
54  };
55 @@ -287,7 +286,9 @@ static void nscss_dom_user_data_handler(dom_node_operation operation,
56   *         or NULL on failure
57   */
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)
63  {
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,
67         css_error error;
68  
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);
73  
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,
76                  * element's style */
77                 error = css_computed_style_compose(ctx->parent_style,
78                                 styles->styles[CSS_PSEUDO_ELEMENT_NONE],
79 -                               compute_font_size, ctx,
80 -                               &composed);
81 +                               unit_len_ctx, &composed);
82                 if (error != CSS_OK) {
83                         css_select_results_destroy(styles);
84                         return NULL;
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,
90 -                               &composed);
91 +                               unit_len_ctx, &composed);
92                 if (error != CSS_OK) {
93                         /* TODO: perhaps this shouldn't be quite so
94                          * catastrophic? */
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
97   */
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)
101  {
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)
113         css_media media = {
114                 .type = CSS_MEDIA_SCREEN,
115         };
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;
120 +
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);
124 +
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
127 +
128 +       unit_len_ctx.font_size_default = f_size;
129 +       unit_len_ctx.font_size_minimum = f_min;
130 +
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);
133  
134 @@ -2101,7 +2116,7 @@ select_css(struct html_context *html_context, struct html_element *html_element)
135  ///    ctx.parent_style = parent_style;
136  
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);
140  
141         /* No longer need inline style */
142         if (inline_style != NULL) {
This page took 0.198967 seconds and 3 git commands to generate.