File: 0006-Patch-out-unused-CSS-style-code.patch

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (445 lines) | stat: -rw-r--r-- 14,738 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
From 168dad55b6278cd45e0f0b2aed802ce9bace3274 Mon Sep 17 00:00:00 2001
From: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Date: Sun, 7 Jan 2024 21:59:28 +0100
Subject: [PATCH 6/6] Patch out unused CSS style code

---
 source/lexbor/css/rule.h                      |  2 ++
 source/lexbor/html/interfaces/document.c      | 29 +++++++++++++++++++
 source/lexbor/html/interfaces/document.h      |  2 --
 source/lexbor/html/interfaces/element.c       | 29 +++++++++++++++++++
 source/lexbor/html/interfaces/style_element.c |  6 ++++
 5 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/source/lexbor/css/rule.h b/source/lexbor/css/rule.h
index 7cc4f0b..bd191f9 100644
--- a/source/lexbor/css/rule.h
+++ b/source/lexbor/css/rule.h
@@ -339,6 +339,7 @@ lxb_css_rule_ref_dec(lxb_css_rule_t *rule)
 lxb_inline void
 lxb_css_rule_ref_dec_destroy(lxb_css_rule_t *rule)
 {
+#if 0
     if (rule->ref_count > 0) {
         rule->ref_count--;
     }
@@ -346,6 +347,7 @@ lxb_css_rule_ref_dec_destroy(lxb_css_rule_t *rule)
     if (rule->ref_count == 0) {
         (void) lxb_css_rule_destroy(rule, true);
     }
+#endif
 }
 
 lxb_inline void
diff --git a/source/lexbor/html/interfaces/document.c b/source/lexbor/html/interfaces/document.c
index bd3c02b..aa305a9 100644
--- a/source/lexbor/html/interfaces/document.c
+++ b/source/lexbor/html/interfaces/document.c
@@ -58,6 +58,7 @@ static lxb_html_document_css_custom_entry_t *
 lxb_html_document_css_customs_insert(lxb_html_document_t *document,
                                      const lxb_char_t *key, size_t length);
 
+#if 0
 static lxb_status_t
 lxb_html_document_style_remove_by_rule_cb(lxb_dom_node_t *node,
                                           lxb_css_selector_specificity_t spec,
@@ -74,6 +75,7 @@ lxb_html_document_style_cb(lxb_dom_node_t *node,
 
 static lxb_status_t
 lxb_html_document_done(lxb_html_document_t *document);
+#endif
 
 
 lxb_status_t
@@ -86,6 +88,7 @@ lxb_html_document_parser_prepare(lxb_html_document_t *document);
 static lexbor_action_t
 lxb_html_document_title_walker(lxb_dom_node_t *node, void *ctx);
 
+#if 0
 static lxb_status_t
 lxb_html_document_event_insert(lxb_dom_node_t *node);
 
@@ -112,6 +115,7 @@ lxb_html_document_event_destroy(lxb_dom_node_t *node);
 static lxb_status_t
 lxb_html_document_event_set_value(lxb_dom_node_t *node,
                                   const lxb_char_t *value, size_t length);
+#endif
 
 
 lxb_html_document_t *
@@ -171,7 +175,9 @@ lxb_html_document_interface_destroy(lxb_html_document_t *document)
 
     if (doc->node.owner_document == doc) {
         (void) lxb_html_parser_unref(doc->parser);
+#if 0
         lxb_html_document_css_destroy(document);
+#endif
     }
 
     (void) lxb_dom_document_destroy(doc);
@@ -193,11 +199,14 @@ lxb_html_document_clean(lxb_html_document_t *document)
     document->iframe_srcdoc = NULL;
     document->ready_state = LXB_HTML_DOCUMENT_READY_STATE_UNDEF;
 
+#if 0
     lxb_html_document_css_clean(document);
+#endif
 
     lxb_dom_document_clean(lxb_dom_interface_document(document));
 }
 
+#if 0
 lxb_status_t
 lxb_html_document_css_init(lxb_html_document_t *document)
 {
@@ -330,6 +339,7 @@ lxb_html_document_css_clean(lxb_html_document_t *document)
         lexbor_dobject_clean(css->weak);
     }
 }
+#endif
 
 void
 lxb_html_document_css_parser_attach(lxb_html_document_t *document,
@@ -575,6 +585,7 @@ void
 lxb_html_document_stylesheet_destroy_all(lxb_html_document_t *document,
                                          bool destroy_memory)
 {
+#if 0
     size_t length;
     lxb_css_stylesheet_t *sst;
     lxb_html_document_css_t *css = &document->css;
@@ -586,29 +597,37 @@ lxb_html_document_stylesheet_destroy_all(lxb_html_document_t *document,
 
         (void) lxb_css_stylesheet_destroy(sst, destroy_memory);
     }
+#endif
 }
 
 lxb_status_t
 lxb_html_document_style_attach(lxb_html_document_t *document,
                                lxb_css_rule_style_t *style)
 {
+#if 0
     lxb_html_document_css_t *css = &document->css;
 
     return lxb_selectors_find(css->selectors, lxb_dom_interface_node(document),
                               style->selector, lxb_html_document_style_cb, style);
+#endif
+    return LXB_STATUS_OK;
 }
 
 lxb_status_t
 lxb_html_document_style_remove(lxb_html_document_t *document,
                                lxb_css_rule_style_t *style)
 {
+#if 0
     lxb_html_document_css_t *css = &document->css;
 
     return lxb_selectors_find(css->selectors, lxb_dom_interface_node(document),
                               style->selector,
                               lxb_html_document_style_remove_by_rule_cb, style);
+#endif
+    return LXB_STATUS_OK;
 }
 
+#if 0
 static lxb_status_t
 lxb_html_document_style_remove_by_rule_cb(lxb_dom_node_t *node,
                                           lxb_css_selector_specificity_t spec,
@@ -646,20 +665,25 @@ lxb_html_document_style_remove_avl_cb(lexbor_avl_t *avl,
                                           style, context->list);
     return LXB_STATUS_OK;
 }
+#endif
 
 lxb_status_t
 lxb_html_document_style_attach_by_element(lxb_html_document_t *document,
                                           lxb_html_element_t *element,
                                           lxb_css_rule_style_t *style)
 {
+#if 0
     lxb_html_document_css_t *css = &document->css;
 
     return lxb_selectors_match_node(css->selectors,
                                     lxb_dom_interface_node(element),
                                     style->selector,
                                     lxb_html_document_style_cb, style);
+#endif
+    return LXB_STATUS_OK;
 }
 
+#if 0
 static lxb_status_t
 lxb_html_document_style_cb(lxb_dom_node_t *node,
                            lxb_css_selector_specificity_t spec, void *ctx)
@@ -675,6 +699,7 @@ lxb_html_document_style_cb(lxb_dom_node_t *node,
     return lxb_html_element_style_list_append(lxb_html_interface_element(node),
                                               style->declarations, spec);
 }
+#endif
 
 lxb_html_document_t *
 lxb_html_document_destroy(lxb_html_document_t *document)
@@ -851,6 +876,7 @@ lxb_html_document_parser_prepare(lxb_html_document_t *document)
     return LXB_STATUS_OK;
 }
 
+#if 0
 static lxb_status_t
 lxb_html_document_done(lxb_html_document_t *document)
 {
@@ -875,6 +901,7 @@ lxb_html_document_done(lxb_html_document_t *document)
 
     return LXB_STATUS_OK;
 }
+#endif
 
 const lxb_char_t *
 lxb_html_document_title(lxb_html_document_t *document, size_t *len)
@@ -962,6 +989,7 @@ lxb_html_document_import_node(lxb_html_document_t *doc, lxb_dom_node_t *node,
     return lxb_dom_document_import_node(&doc->dom_document, node, deep);
 }
 
+#if 0
 static lxb_status_t
 lxb_html_document_event_insert(lxb_dom_node_t *node)
 {
@@ -1233,6 +1261,7 @@ lxb_html_document_event_set_value(lxb_dom_node_t *node,
     return lxb_html_element_style_parse(lxb_html_interface_element(node),
                                         value, length);
 }
+#endif
 
 /*
  * No inline functions for ABI.
diff --git a/source/lexbor/html/interfaces/document.h b/source/lexbor/html/interfaces/document.h
index 7e8d1ea..827ff64 100644
--- a/source/lexbor/html/interfaces/document.h
+++ b/source/lexbor/html/interfaces/document.h
@@ -20,7 +20,6 @@ extern "C" {
 #include "lexbor/dom/interfaces/attr.h"
 #include "lexbor/dom/interfaces/document.h"
 #include "lexbor/css/css.h"
-#include "lexbor/selectors/selectors.h"
 
 
 typedef lxb_status_t
@@ -45,7 +44,6 @@ typedef struct {
     lxb_css_memory_t    *memory;
     lxb_css_selectors_t *css_selectors;
     lxb_css_parser_t    *parser;
-    lxb_selectors_t     *selectors;
 
     lexbor_avl_t        *styles;
     lexbor_array_t      *stylesheets;
diff --git a/source/lexbor/html/interfaces/element.c b/source/lexbor/html/interfaces/element.c
index 229d3d7..363040c 100644
--- a/source/lexbor/html/interfaces/element.c
+++ b/source/lexbor/html/interfaces/element.c
@@ -38,9 +38,11 @@ static lxb_status_t
 lxb_html_element_style_serialize_cb(lexbor_avl_t *avl, lexbor_avl_node_t **root,
                                     lexbor_avl_node_t *node, void *ctx);
 
+#if 0
 static lxb_status_t
 lxb_html_element_style_serialize_str_cb(const lxb_char_t *data,
                                         size_t len, void *ctx);
+#endif
 
 
 lxb_html_element_t *
@@ -102,6 +104,7 @@ const lxb_css_rule_declaration_t *
 lxb_html_element_style_by_name(lxb_html_element_t *element,
                                const lxb_char_t *name, size_t size)
 {
+#if 0
     uintptr_t id;
     lxb_html_style_node_t *node;
     lxb_dom_document_t *ddoc = lxb_dom_interface_node(element)->owner_document;
@@ -115,11 +118,14 @@ lxb_html_element_style_by_name(lxb_html_element_t *element,
     node = (void *) lexbor_avl_search(doc->css.styles, element->style, id);
 
     return (node != NULL) ? node->entry.value : NULL;
+#endif
+    return NULL;
 }
 
 const lxb_css_rule_declaration_t *
 lxb_html_element_style_by_id(lxb_html_element_t *element, uintptr_t id)
 {
+#if 0
     const lxb_html_style_node_t *node;
 
     node = lxb_html_element_style_node_by_id(element, id);
@@ -128,6 +134,8 @@ lxb_html_element_style_by_id(lxb_html_element_t *element, uintptr_t id)
     }
 
     return node->entry.value;
+#endif
+    return NULL;
 }
 
 const lxb_html_style_node_t *
@@ -144,6 +152,7 @@ const lxb_html_style_node_t *
 lxb_html_element_style_node_by_name(lxb_html_element_t *element,
                                     const lxb_char_t *name, size_t size)
 {
+#if 0
     uintptr_t id;
     lxb_dom_document_t *ddoc = lxb_dom_interface_node(element)->owner_document;
     lxb_html_document_t *doc = lxb_html_interface_document(ddoc);
@@ -155,11 +164,14 @@ lxb_html_element_style_node_by_name(lxb_html_element_t *element,
 
     return (lxb_html_style_node_t *) lexbor_avl_search(doc->css.styles,
                                                        element->style, id);
+#endif
+    return NULL;
 }
 
 const void *
 lxb_html_element_css_property_by_id(lxb_html_element_t *element, uintptr_t id)
 {
+#if 0
     lxb_css_rule_declaration_t *declr;
     const lxb_html_style_node_t *node;
 
@@ -171,6 +183,8 @@ lxb_html_element_css_property_by_id(lxb_html_element_t *element, uintptr_t id)
     declr = node->entry.value;
 
     return declr->u.user;
+#endif
+    return NULL;
 }
 
 lxb_status_t
@@ -224,6 +238,7 @@ lxb_status_t
 lxb_html_element_style_parse(lxb_html_element_t *element,
                              const lxb_char_t *style, size_t size)
 {
+#if 0
     lxb_css_rule_declaration_list_t *list;
 
     lxb_dom_document_t *ddoc = lxb_dom_interface_node(element)->owner_document;
@@ -240,6 +255,8 @@ lxb_html_element_style_parse(lxb_html_element_t *element,
 
     return lxb_html_element_style_list_append(element, list,
                                               lxb_css_selector_sp_up_s(0));
+#endif
+    return LXB_STATUS_ERROR;
 }
 
 lxb_status_t
@@ -393,6 +410,7 @@ void
 lxb_html_element_style_remove_by_name(lxb_html_element_t *element,
                                       const lxb_char_t *name, size_t size)
 {
+#if 0
     uintptr_t id;
     lxb_dom_document_t *ddoc = lxb_dom_interface_node(element)->owner_document;
     lxb_html_document_t *doc = lxb_html_interface_document(ddoc);
@@ -403,11 +421,13 @@ lxb_html_element_style_remove_by_name(lxb_html_element_t *element,
     }
 
     lxb_html_element_style_remove_by_id(element, id);
+#endif
 }
 
 void
 lxb_html_element_style_remove_by_id(lxb_html_element_t *element, uintptr_t id)
 {
+#if 0
     lxb_html_style_node_t *node;
     lxb_dom_document_t *ddoc = lxb_dom_interface_node(element)->owner_document;
     lxb_html_document_t *doc = lxb_html_interface_document(ddoc);
@@ -417,6 +437,7 @@ lxb_html_element_style_remove_by_id(lxb_html_element_t *element, uintptr_t id)
     if (node != NULL) {
         lxb_html_element_style_remove_all(doc, &element->style, node);
     }
+#endif
 }
 
 lxb_html_style_node_t *
@@ -576,6 +597,7 @@ static lxb_status_t
 lxb_html_element_style_serialize_cb(lexbor_avl_t *avl, lexbor_avl_node_t **root,
                                     lexbor_avl_node_t *node, void *ctx)
 {
+#if 0
     lxb_status_t status;
     lexbor_serialize_ctx_t *context = ctx;
 
@@ -589,6 +611,8 @@ lxb_html_element_style_serialize_cb(lexbor_avl_t *avl, lexbor_avl_node_t **root,
     context->count = 1;
 
     return lxb_css_rule_serialize(node->value, context->cb, context->ctx);
+#endif
+    return LXB_STATUS_ERROR;
 }
 
 lxb_status_t
@@ -596,6 +620,7 @@ lxb_html_element_style_serialize_str(lxb_html_element_t *element,
                                      lexbor_str_t *str,
                                      lxb_html_element_style_opt_t opt)
 {
+#if 0
     lxb_dom_document_t *doc;
     lxb_html_element_style_ctx_t context;
 
@@ -614,8 +639,11 @@ lxb_html_element_style_serialize_str(lxb_html_element_t *element,
 
     return lxb_html_element_style_serialize(element, opt,
                             lxb_html_element_style_serialize_str_cb, &context);
+#endif
+    return LXB_STATUS_ERROR;
 }
 
+#if 0
 static lxb_status_t
 lxb_html_element_style_serialize_str_cb(const lxb_char_t *data,
                                         size_t len, void *ctx)
@@ -630,3 +658,4 @@ lxb_html_element_style_serialize_str_cb(const lxb_char_t *data,
 
     return LXB_STATUS_OK;
 }
+#endif
diff --git a/source/lexbor/html/interfaces/style_element.c b/source/lexbor/html/interfaces/style_element.c
index 66d55c4..9a402ef 100644
--- a/source/lexbor/html/interfaces/style_element.c
+++ b/source/lexbor/html/interfaces/style_element.c
@@ -35,7 +35,9 @@ lxb_html_style_element_interface_destroy(lxb_html_style_element_t *style_element
     (void) lxb_dom_node_interface_destroy(lxb_dom_interface_node(style_element));
 
     if (sst != NULL) {
+#if 0
         (void) lxb_css_stylesheet_destroy(sst, true);
+#endif
     }
 
     return NULL;
@@ -44,8 +46,10 @@ lxb_html_style_element_interface_destroy(lxb_html_style_element_t *style_element
 lxb_status_t
 lxb_html_style_element_parse(lxb_html_style_element_t *element)
 {
+#if 0
     lexbor_str_t *str;
     lxb_dom_text_t *text;
+#endif
     lxb_dom_node_t *node;
 
     lxb_dom_document_t *ddoc = lxb_dom_interface_node(element)->owner_document;
@@ -61,11 +65,13 @@ lxb_html_style_element_parse(lxb_html_style_element_t *element)
         return LXB_STATUS_OK;
     }
 
+#if 0
     text = lxb_dom_interface_text(lxb_dom_interface_node(element)->first_child);
     str = &text->char_data.data;
 
     element->stylesheet = lxb_css_stylesheet_parse(css->parser, str->data,
                                                    str->length);
+#endif
     if (element->stylesheet == NULL) {
         return css->parser->status;
     }
-- 
2.44.0