NetSurf
dump.c
Go to the documentation of this file.
1/*
2 * Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <stdio.h>
20#include <libcss/libcss.h>
21
22#include "netsurf/inttypes.h"
23
24#include "css/dump.h"
25#include "css/utils.h"
26
27/**
28 * Dump a fixed point value to the stream in a textual form.
29 *
30 * \param stream Stream to write to
31 * \param f Value to write
32 */
33static void dump_css_fixed(FILE *stream, css_fixed f)
34{
35#define NSCSS_ABS(x) (uint32_t)((x) < 0 ? -(x) : (x))
36 uint32_t uintpart = FIXTOINT(NSCSS_ABS(f));
37 /* + 500 to ensure round to nearest (division will truncate) */
38 uint32_t fracpart = ((NSCSS_ABS(f) & 0x3ff) * 1000 + 500) / (1 << 10);
39#undef NSCSS_ABS
40
41 fprintf(stream, "%s%"PRIu32".%03"PRIu32, f < 0 ? "-" : "", uintpart, fracpart);
42}
43
44/**
45 * Dump a numeric value to the stream in a textual form.
46 *
47 * \param stream Stream to write to
48 * \param val Value to write
49 */
50static void dump_css_number(FILE *stream, css_fixed val)
51{
52 if (INTTOFIX(FIXTOINT(val)) == val)
53 fprintf(stream, "%"PRId32, FIXTOINT(val));
54 else
55 dump_css_fixed(stream, val);
56}
57
58/**
59 * Dump a dimension to the stream in a textual form.
60 *
61 * \param stream Stream to write to
62 * \param val Value to write
63 * \param unit Unit to write
64 */
65static void dump_css_unit(FILE *stream, css_fixed val, css_unit unit)
66{
67 dump_css_number(stream, val);
68
69 switch (unit) {
70 case CSS_UNIT_PX:
71 fprintf(stream, "px");
72 break;
73 case CSS_UNIT_EX:
74 fprintf(stream, "ex");
75 break;
76 case CSS_UNIT_EM:
77 fprintf(stream, "em");
78 break;
79 case CSS_UNIT_IN:
80 fprintf(stream, "in");
81 break;
82 case CSS_UNIT_CM:
83 fprintf(stream, "cm");
84 break;
85 case CSS_UNIT_MM:
86 fprintf(stream, "mm");
87 break;
88 case CSS_UNIT_PT:
89 fprintf(stream, "pt");
90 break;
91 case CSS_UNIT_PC:
92 fprintf(stream, "pc");
93 break;
94 case CSS_UNIT_PCT:
95 fprintf(stream, "%%");
96 break;
97 case CSS_UNIT_DEG:
98 fprintf(stream, "deg");
99 break;
100 case CSS_UNIT_GRAD:
101 fprintf(stream, "grad");
102 break;
103 case CSS_UNIT_RAD:
104 fprintf(stream, "rad");
105 break;
106 case CSS_UNIT_MS:
107 fprintf(stream, "ms");
108 break;
109 case CSS_UNIT_S:
110 fprintf(stream, "s");
111 break;
112 case CSS_UNIT_HZ:
113 fprintf(stream, "Hz");
114 break;
115 case CSS_UNIT_KHZ:
116 fprintf(stream, "kHz");
117 break;
118 case CSS_UNIT_CH:
119 fprintf(stream, "ch");
120 break;
121 case CSS_UNIT_REM:
122 fprintf(stream, "rem");
123 break;
124 case CSS_UNIT_LH:
125 fprintf(stream, "lh");
126 break;
127 case CSS_UNIT_VH:
128 fprintf(stream, "vh");
129 break;
130 case CSS_UNIT_VW:
131 fprintf(stream, "vw");
132 break;
133 case CSS_UNIT_VI:
134 fprintf(stream, "vi");
135 break;
136 case CSS_UNIT_VB:
137 fprintf(stream, "vb");
138 break;
139 case CSS_UNIT_VMIN:
140 fprintf(stream, "vmin");
141 break;
142 case CSS_UNIT_VMAX:
143 fprintf(stream, "vmax");
144 break;
145 case CSS_UNIT_Q:
146 fprintf(stream, "q");
147 break;
148 case CSS_UNIT_CALC:
149 fprintf(stream, "calc()");
150 break;
151 }
152}
153
154/* exported interface documented in content/handlers/css/dump.h */
155void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
156{
157 uint8_t val;
158 css_color color = 0;
159 lwc_string *url = NULL;
160 css_fixed len1 = 0, len2 = 0;
161 css_unit unit1 = CSS_UNIT_PX, unit2 = CSS_UNIT_PX;
162 css_computed_clip_rect rect = { 0, 0, 0, 0, CSS_UNIT_PX, CSS_UNIT_PX,
163 CSS_UNIT_PX, CSS_UNIT_PX, true, true,
164 true, true };
165 const css_computed_content_item *content = NULL;
166 const css_computed_counter *counter = NULL;
167 lwc_string **string_list = NULL;
168 int32_t zindex = 0;
169
170 fprintf(stream, "{ ");
171
172 /* background-attachment */
173 val = css_computed_background_attachment(style);
174 switch (val) {
175 case CSS_BACKGROUND_ATTACHMENT_FIXED:
176 fprintf(stream, "background-attachment: fixed ");
177 break;
178 case CSS_BACKGROUND_ATTACHMENT_SCROLL:
179 fprintf(stream, "background-attachment: scroll ");
180 break;
181 default:
182 break;
183 }
184
185 /* background-color */
186 val = css_computed_background_color(style, &color);
187 switch (val) {
188 case CSS_BACKGROUND_COLOR_COLOR:
189 fprintf(stream, "background-color: #%08"PRIx32" ", color);
190 break;
191 default:
192 break;
193 }
194
195 /* background-image */
196 val = css_computed_background_image(style, &url);
197 if (val == CSS_BACKGROUND_IMAGE_IMAGE && url != NULL) {
198 fprintf(stream, "background-image: url('%.*s') ",
199 (int) lwc_string_length(url),
200 lwc_string_data(url));
201 } else if (val == CSS_BACKGROUND_IMAGE_NONE) {
202 fprintf(stream, "background-image: none ");
203 }
204
205 /* background-position */
206 val = css_computed_background_position(style, &len1, &unit1,
207 &len2, &unit2);
208 if (val == CSS_BACKGROUND_POSITION_SET) {
209 fprintf(stream, "background-position: ");
210 dump_css_unit(stream, len1, unit1);
211 fprintf(stream, " ");
212 dump_css_unit(stream, len2, unit2);
213 fprintf(stream, " ");
214 }
215
216 /* background-repeat */
217 val = css_computed_background_repeat(style);
218 switch (val) {
219 case CSS_BACKGROUND_REPEAT_REPEAT_X:
220 fprintf(stream, "background-repeat: repeat-x ");
221 break;
222 case CSS_BACKGROUND_REPEAT_REPEAT_Y:
223 fprintf(stream, "background-repeat: repeat-y ");
224 break;
225 case CSS_BACKGROUND_REPEAT_REPEAT:
226 fprintf(stream, "background-repeat: repeat ");
227 break;
228 case CSS_BACKGROUND_REPEAT_NO_REPEAT:
229 fprintf(stream, "background-repeat: no-repeat ");
230 break;
231 default:
232 break;
233 }
234
235 /* border-collapse */
236 val = css_computed_border_collapse(style);
237 switch (val) {
238 case CSS_BORDER_COLLAPSE_SEPARATE:
239 fprintf(stream, "border-collapse: separate ");
240 break;
241 case CSS_BORDER_COLLAPSE_COLLAPSE:
242 fprintf(stream, "border-collapse: collapse ");
243 break;
244 default:
245
246 break;
247 }
248
249 /* border-spacing */
250 val = css_computed_border_spacing(style, &len1, &unit1, &len2, &unit2);
251 if (val == CSS_BORDER_SPACING_SET) {
252 fprintf(stream, "border-spacing: ");
253 dump_css_unit(stream, len1, unit1);
254 fprintf(stream, " ");
255 dump_css_unit(stream, len2, unit2);
256 fprintf(stream, " ");
257 }
258
259 /* border-top-color */
260 val = css_computed_border_top_color(style, &color);
261 switch (val) {
262 case CSS_BORDER_COLOR_COLOR:
263 fprintf(stream, "border-top-color: #%08"PRIx32" ", color);
264 break;
265 default:
266 break;
267 }
268
269 /* border-right-color */
270 val = css_computed_border_right_color(style, &color);
271 switch (val) {
272 case CSS_BORDER_COLOR_COLOR:
273 fprintf(stream, "border-right-color: #%08"PRIx32" ", color);
274 break;
275 default:
276 break;
277 }
278
279 /* border-bottom-color */
280 val = css_computed_border_bottom_color(style, &color);
281 switch (val) {
282 case CSS_BORDER_COLOR_COLOR:
283 fprintf(stream, "border-bottom-color: #%08"PRIx32" ", color);
284 break;
285 default:
286 break;
287 }
288
289 /* border-left-color */
290 val = css_computed_border_left_color(style, &color);
291 switch (val) {
292 case CSS_BORDER_COLOR_COLOR:
293 fprintf(stream, "border-left-color: #%08"PRIx32" ", color);
294 break;
295 default:
296 break;
297 }
298
299 /* border-top-style */
300 val = css_computed_border_top_style(style);
301 switch (val) {
302 case CSS_BORDER_STYLE_NONE:
303 fprintf(stream, "border-top-style: none ");
304 break;
305 case CSS_BORDER_STYLE_HIDDEN:
306 fprintf(stream, "border-top-style: hidden ");
307 break;
308 case CSS_BORDER_STYLE_DOTTED:
309 fprintf(stream, "border-top-style: dotted ");
310 break;
311 case CSS_BORDER_STYLE_DASHED:
312 fprintf(stream, "border-top-style: dashed ");
313 break;
314 case CSS_BORDER_STYLE_SOLID:
315 fprintf(stream, "border-top-style: solid ");
316 break;
317 case CSS_BORDER_STYLE_DOUBLE:
318 fprintf(stream, "border-top-style: double ");
319 break;
320 case CSS_BORDER_STYLE_GROOVE:
321 fprintf(stream, "border-top-style: groove ");
322 break;
323 case CSS_BORDER_STYLE_RIDGE:
324 fprintf(stream, "border-top-style: ridge ");
325 break;
326 case CSS_BORDER_STYLE_INSET:
327 fprintf(stream, "border-top-style: inset ");
328 break;
329 case CSS_BORDER_STYLE_OUTSET:
330 fprintf(stream, "border-top-style: outset ");
331 break;
332 default:
333 break;
334 }
335
336 /* border-right-style */
337 val = css_computed_border_right_style(style);
338 switch (val) {
339 case CSS_BORDER_STYLE_NONE:
340 fprintf(stream, "border-right-style: none ");
341 break;
342 case CSS_BORDER_STYLE_HIDDEN:
343 fprintf(stream, "border-right-style: hidden ");
344 break;
345 case CSS_BORDER_STYLE_DOTTED:
346 fprintf(stream, "border-right-style: dotted ");
347 break;
348 case CSS_BORDER_STYLE_DASHED:
349 fprintf(stream, "border-right-style: dashed ");
350 break;
351 case CSS_BORDER_STYLE_SOLID:
352 fprintf(stream, "border-right-style: solid ");
353 break;
354 case CSS_BORDER_STYLE_DOUBLE:
355 fprintf(stream, "border-right-style: double ");
356 break;
357 case CSS_BORDER_STYLE_GROOVE:
358 fprintf(stream, "border-right-style: groove ");
359 break;
360 case CSS_BORDER_STYLE_RIDGE:
361 fprintf(stream, "border-right-style: ridge ");
362 break;
363 case CSS_BORDER_STYLE_INSET:
364 fprintf(stream, "border-right-style: inset ");
365 break;
366 case CSS_BORDER_STYLE_OUTSET:
367 fprintf(stream, "border-right-style: outset ");
368 break;
369 default:
370 break;
371 }
372
373 /* border-bottom-style */
374 val = css_computed_border_bottom_style(style);
375 switch (val) {
376 case CSS_BORDER_STYLE_NONE:
377 fprintf(stream, "border-bottom-style: none ");
378 break;
379 case CSS_BORDER_STYLE_HIDDEN:
380 fprintf(stream, "border-bottom-style: hidden ");
381 break;
382 case CSS_BORDER_STYLE_DOTTED:
383 fprintf(stream, "border-bottom-style: dotted ");
384 break;
385 case CSS_BORDER_STYLE_DASHED:
386 fprintf(stream, "border-bottom-style: dashed ");
387 break;
388 case CSS_BORDER_STYLE_SOLID:
389 fprintf(stream, "border-bottom-style: solid ");
390 break;
391 case CSS_BORDER_STYLE_DOUBLE:
392 fprintf(stream, "border-bottom-style: double ");
393 break;
394 case CSS_BORDER_STYLE_GROOVE:
395 fprintf(stream, "border-bottom-style: groove ");
396 break;
397 case CSS_BORDER_STYLE_RIDGE:
398 fprintf(stream, "border-bottom-style: ridge ");
399 break;
400 case CSS_BORDER_STYLE_INSET:
401 fprintf(stream, "border-bottom-style: inset ");
402 break;
403 case CSS_BORDER_STYLE_OUTSET:
404 fprintf(stream, "border-bottom-style: outset ");
405 break;
406 default:
407 break;
408 }
409
410 /* border-left-style */
411 val = css_computed_border_left_style(style);
412 switch (val) {
413 case CSS_BORDER_STYLE_NONE:
414 fprintf(stream, "border-left-style: none ");
415 break;
416 case CSS_BORDER_STYLE_HIDDEN:
417 fprintf(stream, "border-left-style: hidden ");
418 break;
419 case CSS_BORDER_STYLE_DOTTED:
420 fprintf(stream, "border-left-style: dotted ");
421 break;
422 case CSS_BORDER_STYLE_DASHED:
423 fprintf(stream, "border-left-style: dashed ");
424 break;
425 case CSS_BORDER_STYLE_SOLID:
426 fprintf(stream, "border-left-style: solid ");
427 break;
428 case CSS_BORDER_STYLE_DOUBLE:
429 fprintf(stream, "border-left-style: double ");
430 break;
431 case CSS_BORDER_STYLE_GROOVE:
432 fprintf(stream, "border-left-style: groove ");
433 break;
434 case CSS_BORDER_STYLE_RIDGE:
435 fprintf(stream, "border-left-style: ridge ");
436 break;
437 case CSS_BORDER_STYLE_INSET:
438 fprintf(stream, "border-left-style: inset ");
439 break;
440 case CSS_BORDER_STYLE_OUTSET:
441 fprintf(stream, "border-left-style: outset ");
442 break;
443 default:
444 break;
445 }
446
447 /* border-top-width */
448 val = css_computed_border_top_width(style, &len1, &unit1);
449 switch (val) {
450 case CSS_BORDER_WIDTH_THIN:
451 fprintf(stream, "border-top-width: thin ");
452 break;
453 case CSS_BORDER_WIDTH_MEDIUM:
454 fprintf(stream, "border-top-width: medium ");
455 break;
456 case CSS_BORDER_WIDTH_THICK:
457 fprintf(stream, "border-top-width: thick ");
458 break;
459 case CSS_BORDER_WIDTH_WIDTH:
460 fprintf(stream, "border-top-width: ");
461 dump_css_unit(stream, len1, unit1);
462 fprintf(stream, " ");
463 break;
464 default:
465 break;
466 }
467
468 /* border-right-width */
469 val = css_computed_border_right_width(style, &len1, &unit1);
470 switch (val) {
471 case CSS_BORDER_WIDTH_THIN:
472 fprintf(stream, "border-right-width: thin ");
473 break;
474 case CSS_BORDER_WIDTH_MEDIUM:
475 fprintf(stream, "border-right-width: medium ");
476 break;
477 case CSS_BORDER_WIDTH_THICK:
478 fprintf(stream, "border-right-width: thick ");
479 break;
480 case CSS_BORDER_WIDTH_WIDTH:
481 fprintf(stream, "border-right-width: ");
482 dump_css_unit(stream, len1, unit1);
483 fprintf(stream, " ");
484 break;
485 default:
486 break;
487 }
488
489 /* border-bottom-width */
490 val = css_computed_border_bottom_width(style, &len1, &unit1);
491 switch (val) {
492 case CSS_BORDER_WIDTH_THIN:
493 fprintf(stream, "border-bottom-width: thin ");
494 break;
495 case CSS_BORDER_WIDTH_MEDIUM:
496 fprintf(stream, "border-bottom-width: medium ");
497 break;
498 case CSS_BORDER_WIDTH_THICK:
499 fprintf(stream, "border-bottom-width: thick ");
500 break;
501 case CSS_BORDER_WIDTH_WIDTH:
502 fprintf(stream, "border-bottom-width: ");
503 dump_css_unit(stream, len1, unit1);
504 fprintf(stream, " ");
505 break;
506 default:
507 break;
508 }
509
510 /* border-left-width */
511 val = css_computed_border_left_width(style, &len1, &unit1);
512 switch (val) {
513 case CSS_BORDER_WIDTH_THIN:
514 fprintf(stream, "border-left-width: thin ");
515 break;
516 case CSS_BORDER_WIDTH_MEDIUM:
517 fprintf(stream, "border-left-width: medium ");
518 break;
519 case CSS_BORDER_WIDTH_THICK:
520 fprintf(stream, "border-left-width: thick ");
521 break;
522 case CSS_BORDER_WIDTH_WIDTH:
523 fprintf(stream, "border-left-width: ");
524 dump_css_unit(stream, len1, unit1);
525 fprintf(stream, " ");
526 break;
527 default:
528 break;
529 }
530
531 /* bottom */
532 val = css_computed_bottom(style, &len1, &unit1);
533 switch (val) {
534 case CSS_BOTTOM_AUTO:
535 fprintf(stream, "bottom: auto ");
536 break;
537 case CSS_BOTTOM_SET:
538 fprintf(stream, "bottom: ");
539 dump_css_unit(stream, len1, unit1);
540 fprintf(stream, " ");
541 break;
542 default:
543 break;
544 }
545
546 /* caption-side */
547 val = css_computed_caption_side(style);
548 switch (val) {
549 case CSS_CAPTION_SIDE_TOP:
550 fprintf(stream, "caption_side: top ");
551 break;
552 case CSS_CAPTION_SIDE_BOTTOM:
553 fprintf(stream, "caption_side: bottom ");
554 break;
555 default:
556 break;
557 }
558
559 /* clear */
560 val = css_computed_clear(style);
561 switch (val) {
562 case CSS_CLEAR_NONE:
563 fprintf(stream, "clear: none ");
564 break;
565 case CSS_CLEAR_LEFT:
566 fprintf(stream, "clear: left ");
567 break;
568 case CSS_CLEAR_RIGHT:
569 fprintf(stream, "clear: right ");
570 break;
571 case CSS_CLEAR_BOTH:
572 fprintf(stream, "clear: both ");
573 break;
574 default:
575 break;
576 }
577
578 /* clip */
579 val = css_computed_clip(style, &rect);
580 switch (val) {
581 case CSS_CLIP_AUTO:
582 fprintf(stream, "clip: auto ");
583 break;
584 case CSS_CLIP_RECT:
585 fprintf(stream, "clip: rect( ");
586
587 if (rect.top_auto)
588 fprintf(stream, "auto");
589 else
590 dump_css_unit(stream, rect.top, rect.tunit);
591 fprintf(stream, ", ");
592
593 if (rect.right_auto)
594 fprintf(stream, "auto");
595 else
596 dump_css_unit(stream, rect.right, rect.runit);
597 fprintf(stream, ", ");
598
599 if (rect.bottom_auto)
600 fprintf(stream, "auto");
601 else
602 dump_css_unit(stream, rect.bottom, rect.bunit);
603 fprintf(stream, ", ");
604
605 if (rect.left_auto)
606 fprintf(stream, "auto");
607 else
608 dump_css_unit(stream, rect.left, rect.lunit);
609 fprintf(stream, ") ");
610 break;
611 default:
612 break;
613 }
614
615 /* color */
616 val = css_computed_color(style, &color);
617 if (val == CSS_COLOR_COLOR) {
618 fprintf(stream, "color: #%08"PRIx32" ", color);
619 }
620
621 /* content */
622 val = css_computed_content(style, &content);
623 switch (val) {
624 case CSS_CONTENT_NONE:
625 fprintf(stream, "content: none ");
626 break;
627 case CSS_CONTENT_NORMAL:
628 fprintf(stream, "content: normal ");
629 break;
630 case CSS_CONTENT_SET:
631 fprintf(stream, "content:");
632
633 while (content->type != CSS_COMPUTED_CONTENT_NONE) {
634 fprintf(stream, " ");
635
636 switch (content->type) {
637 case CSS_COMPUTED_CONTENT_STRING:
638 fprintf(stream, "\"%.*s\"",
639 (int) lwc_string_length(
640 content->data.string),
641 lwc_string_data(
642 content->data.string));
643 break;
644 case CSS_COMPUTED_CONTENT_URI:
645 fprintf(stream, "uri(\"%.*s\")",
646 (int) lwc_string_length(
647 content->data.uri),
648 lwc_string_data(
649 content->data.uri));
650 break;
651 case CSS_COMPUTED_CONTENT_COUNTER:
652 fprintf(stream, "counter(%.*s)",
653 (int) lwc_string_length(
654 content->data.counter.name),
655 lwc_string_data(
656 content->data.counter.name));
657 break;
658 case CSS_COMPUTED_CONTENT_COUNTERS:
659 fprintf(stream, "counters(%.*s, \"%.*s\")",
660 (int) lwc_string_length(
661 content->data.counters.name),
662 lwc_string_data(
663 content->data.counters.name),
664 (int) lwc_string_length(
665 content->data.counters.sep),
666 lwc_string_data(
667 content->data.counters.sep));
668 break;
669 case CSS_COMPUTED_CONTENT_ATTR:
670 fprintf(stream, "attr(%.*s)",
671 (int) lwc_string_length(
672 content->data.attr),
673 lwc_string_data(
674 content->data.attr));
675 break;
676 case CSS_COMPUTED_CONTENT_OPEN_QUOTE:
677 fprintf(stream, "open-quote");
678 break;
679 case CSS_COMPUTED_CONTENT_CLOSE_QUOTE:
680 fprintf(stream, "close-quote");
681 break;
682 case CSS_COMPUTED_CONTENT_NO_OPEN_QUOTE:
683 fprintf(stream, "no-open-quote");
684 break;
685 case CSS_COMPUTED_CONTENT_NO_CLOSE_QUOTE:
686 fprintf(stream, "no-close-quote");
687 break;
688 }
689
690 content++;
691 }
692
693 fprintf(stream, " ");
694 break;
695 default:
696 break;
697 }
698
699 /* counter-increment */
700 val = css_computed_counter_increment(style, &counter);
701 if ((val == CSS_COUNTER_INCREMENT_NONE) || (counter == NULL)) {
702 fprintf(stream, "counter-increment: none ");
703 } else {
704 fprintf(stream, "counter-increment:");
705
706 while (counter->name != NULL) {
707 fprintf(stream, " %.*s ",
708 (int) lwc_string_length(counter->name),
709 lwc_string_data(counter->name));
710
711 dump_css_fixed(stream, counter->value);
712
713 counter++;
714 }
715
716 fprintf(stream, " ");
717 }
718
719 /* counter-reset */
720 val = css_computed_counter_reset(style, &counter);
721 if ((val == CSS_COUNTER_RESET_NONE) || (counter == NULL)) {
722 fprintf(stream, "counter-reset: none ");
723 } else {
724 fprintf(stream, "counter-reset:");
725
726 while (counter->name != NULL) {
727 fprintf(stream, " %.*s ",
728 (int) lwc_string_length(counter->name),
729 lwc_string_data(counter->name));
730
731 dump_css_fixed(stream, counter->value);
732
733 counter++;
734 }
735
736 fprintf(stream, " ");
737 }
738
739 /* cursor */
740 val = css_computed_cursor(style, &string_list);
741 fprintf(stream, "cursor:");
742
743 if (string_list != NULL) {
744 while (*string_list != NULL) {
745 fprintf(stream, " url\"%.*s\")",
746 (int) lwc_string_length(*string_list),
747 lwc_string_data(*string_list));
748
749 string_list++;
750 }
751 }
752 switch (val) {
753 case CSS_CURSOR_AUTO:
754 fprintf(stream, " auto ");
755 break;
756 case CSS_CURSOR_CROSSHAIR:
757 fprintf(stream, " crosshair ");
758 break;
759 case CSS_CURSOR_DEFAULT:
760 fprintf(stream, " default ");
761 break;
762 case CSS_CURSOR_POINTER:
763 fprintf(stream, " pointer ");
764 break;
765 case CSS_CURSOR_MOVE:
766 fprintf(stream, " move ");
767 break;
768 case CSS_CURSOR_E_RESIZE:
769 fprintf(stream, " e-resize ");
770 break;
771 case CSS_CURSOR_NE_RESIZE:
772 fprintf(stream, " ne-resize ");
773 break;
774 case CSS_CURSOR_NW_RESIZE:
775 fprintf(stream, " nw-resize ");
776 break;
777 case CSS_CURSOR_N_RESIZE:
778 fprintf(stream, " n-resize ");
779 break;
780 case CSS_CURSOR_SE_RESIZE:
781 fprintf(stream, " se-resize ");
782 break;
783 case CSS_CURSOR_SW_RESIZE:
784 fprintf(stream, " sw-resize ");
785 break;
786 case CSS_CURSOR_S_RESIZE:
787 fprintf(stream, " s-resize ");
788 break;
789 case CSS_CURSOR_W_RESIZE:
790 fprintf(stream, " w-resize ");
791 break;
792 case CSS_CURSOR_TEXT:
793 fprintf(stream, " text ");
794 break;
795 case CSS_CURSOR_WAIT:
796 fprintf(stream, " wait ");
797 break;
798 case CSS_CURSOR_HELP:
799 fprintf(stream, " help ");
800 break;
801 case CSS_CURSOR_PROGRESS:
802 fprintf(stream, " progress ");
803 break;
804 default:
805 break;
806 }
807
808 /* direction */
809 val = css_computed_direction(style);
810 switch (val) {
811 case CSS_DIRECTION_LTR:
812 fprintf(stream, "direction: ltr ");
813 break;
814 case CSS_DIRECTION_RTL:
815 fprintf(stream, "direction: rtl ");
816 break;
817 default:
818 break;
819 }
820
821 /* display */
822 val = ns_computed_display_static(style);
823 switch (val) {
824 case CSS_DISPLAY_INLINE:
825 fprintf(stream, "display: inline ");
826 break;
827 case CSS_DISPLAY_BLOCK:
828 fprintf(stream, "display: block ");
829 break;
830 case CSS_DISPLAY_LIST_ITEM:
831 fprintf(stream, "display: list-item ");
832 break;
833 case CSS_DISPLAY_RUN_IN:
834 fprintf(stream, "display: run-in ");
835 break;
836 case CSS_DISPLAY_INLINE_BLOCK:
837 fprintf(stream, "display: inline-block ");
838 break;
839 case CSS_DISPLAY_TABLE:
840 fprintf(stream, "display: table ");
841 break;
842 case CSS_DISPLAY_INLINE_TABLE:
843 fprintf(stream, "display: inline-table ");
844 break;
845 case CSS_DISPLAY_TABLE_ROW_GROUP:
846 fprintf(stream, "display: table-row-group ");
847 break;
848 case CSS_DISPLAY_TABLE_HEADER_GROUP:
849 fprintf(stream, "display: table-header-group ");
850 break;
851 case CSS_DISPLAY_TABLE_FOOTER_GROUP:
852 fprintf(stream, "display: table-footer-group ");
853 break;
854 case CSS_DISPLAY_TABLE_ROW:
855 fprintf(stream, "display: table-row ");
856 break;
857 case CSS_DISPLAY_TABLE_COLUMN_GROUP:
858 fprintf(stream, "display: table-column-group ");
859 break;
860 case CSS_DISPLAY_TABLE_COLUMN:
861 fprintf(stream, "display: table-column ");
862 break;
863 case CSS_DISPLAY_TABLE_CELL:
864 fprintf(stream, "display: table-cell ");
865 break;
866 case CSS_DISPLAY_TABLE_CAPTION:
867 fprintf(stream, "display: table-caption ");
868 break;
869 case CSS_DISPLAY_NONE:
870 fprintf(stream, "display: none ");
871 break;
872 case CSS_DISPLAY_FLEX:
873 fprintf(stream, "display: flex ");
874 break;
875 case CSS_DISPLAY_INLINE_FLEX:
876 fprintf(stream, "display: inline-flex ");
877 break;
878 default:
879 break;
880 }
881
882 /* empty-cells */
883 val = css_computed_empty_cells(style);
884 switch (val) {
885 case CSS_EMPTY_CELLS_SHOW:
886 fprintf(stream, "empty-cells: show ");
887 break;
888 case CSS_EMPTY_CELLS_HIDE:
889 fprintf(stream, "empty-cells: hide ");
890 break;
891 default:
892 break;
893 }
894
895 /* float */
896 val = css_computed_float(style);
897 switch (val) {
898 case CSS_FLOAT_LEFT:
899 fprintf(stream, "float: left ");
900 break;
901 case CSS_FLOAT_RIGHT:
902 fprintf(stream, "float: right ");
903 break;
904 case CSS_FLOAT_NONE:
905 fprintf(stream, "float: none ");
906 break;
907 default:
908 break;
909 }
910
911 /* font-family */
912 val = css_computed_font_family(style, &string_list);
913 if (val != CSS_FONT_FAMILY_INHERIT) {
914 fprintf(stream, "font-family:");
915
916 if (string_list != NULL) {
917 while (*string_list != NULL) {
918 fprintf(stream, " \"%.*s\"",
919 (int) lwc_string_length(*string_list),
920 lwc_string_data(*string_list));
921
922 string_list++;
923 }
924 }
925 switch (val) {
926 case CSS_FONT_FAMILY_SERIF:
927 fprintf(stream, " serif ");
928 break;
929 case CSS_FONT_FAMILY_SANS_SERIF:
930 fprintf(stream, " sans-serif ");
931 break;
932 case CSS_FONT_FAMILY_CURSIVE:
933 fprintf(stream, " cursive ");
934 break;
935 case CSS_FONT_FAMILY_FANTASY:
936 fprintf(stream, " fantasy ");
937 break;
938 case CSS_FONT_FAMILY_MONOSPACE:
939 fprintf(stream, " monospace ");
940 break;
941 }
942 }
943
944 /* font-size */
945 val = css_computed_font_size(style, &len1, &unit1);
946 switch (val) {
947 case CSS_FONT_SIZE_XX_SMALL:
948 fprintf(stream, "font-size: xx-small ");
949 break;
950 case CSS_FONT_SIZE_X_SMALL:
951 fprintf(stream, "font-size: x-small ");
952 break;
953 case CSS_FONT_SIZE_SMALL:
954 fprintf(stream, "font-size: small ");
955 break;
956 case CSS_FONT_SIZE_MEDIUM:
957 fprintf(stream, "font-size: medium ");
958 break;
959 case CSS_FONT_SIZE_LARGE:
960 fprintf(stream, "font-size: large ");
961 break;
962 case CSS_FONT_SIZE_X_LARGE:
963 fprintf(stream, "font-size: x-large ");
964 break;
965 case CSS_FONT_SIZE_XX_LARGE:
966 fprintf(stream, "font-size: xx-large ");
967 break;
968 case CSS_FONT_SIZE_LARGER:
969 fprintf(stream, "font-size: larger ");
970 break;
971 case CSS_FONT_SIZE_SMALLER:
972 fprintf(stream, "font-size: smaller ");
973 break;
974 case CSS_FONT_SIZE_DIMENSION:
975 fprintf(stream, "font-size: ");
976
977 dump_css_unit(stream, len1, unit1);
978
979 fprintf(stream, " ");
980 break;
981 default:
982 break;
983 }
984
985 /* font-style */
986 val = css_computed_font_style(style);
987 switch (val) {
988 case CSS_FONT_STYLE_NORMAL:
989 fprintf(stream, "font-style: normal ");
990 break;
991 case CSS_FONT_STYLE_ITALIC:
992 fprintf(stream, "font-style: italic ");
993 break;
994 case CSS_FONT_STYLE_OBLIQUE:
995 fprintf(stream, "font-style: oblique ");
996 break;
997 default:
998 break;
999 }
1000
1001 /* font-variant */
1002 val = css_computed_font_variant(style);
1003 switch (val) {
1004 case CSS_FONT_VARIANT_NORMAL:
1005 fprintf(stream, "font-variant: normal ");
1006 break;
1007 case CSS_FONT_VARIANT_SMALL_CAPS:
1008 fprintf(stream, "font-variant: small-caps ");
1009 break;
1010 default:
1011 break;
1012 }
1013
1014 /* font-weight */
1015 val = css_computed_font_weight(style);
1016 switch (val) {
1017 case CSS_FONT_WEIGHT_NORMAL:
1018 fprintf(stream, "font-weight: normal ");
1019 break;
1020 case CSS_FONT_WEIGHT_BOLD:
1021 fprintf(stream, "font-weight: bold ");
1022 break;
1023 case CSS_FONT_WEIGHT_BOLDER:
1024 fprintf(stream, "font-weight: bolder ");
1025 break;
1026 case CSS_FONT_WEIGHT_LIGHTER:
1027 fprintf(stream, "font-weight: lighter ");
1028 break;
1029 case CSS_FONT_WEIGHT_100:
1030 fprintf(stream, "font-weight: 100 ");
1031 break;
1032 case CSS_FONT_WEIGHT_200:
1033 fprintf(stream, "font-weight: 200 ");
1034 break;
1035 case CSS_FONT_WEIGHT_300:
1036 fprintf(stream, "font-weight: 300 ");
1037 break;
1038 case CSS_FONT_WEIGHT_400:
1039 fprintf(stream, "font-weight: 400 ");
1040 break;
1041 case CSS_FONT_WEIGHT_500:
1042 fprintf(stream, "font-weight: 500 ");
1043 break;
1044 case CSS_FONT_WEIGHT_600:
1045 fprintf(stream, "font-weight: 600 ");
1046 break;
1047 case CSS_FONT_WEIGHT_700:
1048 fprintf(stream, "font-weight: 700 ");
1049 break;
1050 case CSS_FONT_WEIGHT_800:
1051 fprintf(stream, "font-weight: 800 ");
1052 break;
1053 case CSS_FONT_WEIGHT_900:
1054 fprintf(stream, "font-weight: 900 ");
1055 break;
1056 default:
1057 break;
1058 }
1059
1060 /* height */
1061 val = css_computed_height(style, &len1, &unit1);
1062 switch (val) {
1063 case CSS_HEIGHT_AUTO:
1064 fprintf(stream, "height: auto ");
1065 break;
1066 case CSS_HEIGHT_SET:
1067 fprintf(stream, "height: ");
1068
1069 dump_css_unit(stream, len1, unit1);
1070
1071 fprintf(stream, " ");
1072 break;
1073 default:
1074 break;
1075 }
1076
1077 /* left */
1078 val = css_computed_left(style, &len1, &unit1);
1079 switch (val) {
1080 case CSS_LEFT_AUTO:
1081 fprintf(stream, "left: auto ");
1082 break;
1083 case CSS_LEFT_SET:
1084 fprintf(stream, "left: ");
1085
1086 dump_css_unit(stream, len1, unit1);
1087
1088 fprintf(stream, " ");
1089 break;
1090 default:
1091 break;
1092 }
1093
1094 /* letter-spacing */
1095 val = css_computed_letter_spacing(style, &len1, &unit1);
1096 switch (val) {
1097 case CSS_LETTER_SPACING_NORMAL:
1098 fprintf(stream, "letter-spacing: normal ");
1099 break;
1100 case CSS_LETTER_SPACING_SET:
1101 fprintf(stream, "letter-spacing: ");
1102
1103 dump_css_unit(stream, len1, unit1);
1104
1105 fprintf(stream, " ");
1106 break;
1107 default:
1108 break;
1109 }
1110
1111 /* line-height */
1112 val = css_computed_line_height(style, &len1, &unit1);
1113 switch (val) {
1114 case CSS_LINE_HEIGHT_NORMAL:
1115 fprintf(stream, "line-height: normal ");
1116 break;
1117 case CSS_LINE_HEIGHT_NUMBER:
1118 fprintf(stream, "line-height: ");
1119
1120 dump_css_fixed(stream, len1);
1121
1122 fprintf(stream, " ");
1123 break;
1124 case CSS_LINE_HEIGHT_DIMENSION:
1125 fprintf(stream, "line-height: ");
1126
1127 dump_css_unit(stream, len1, unit1);
1128
1129 fprintf(stream, " ");
1130 break;
1131 default:
1132 break;
1133 }
1134
1135 /* list-style-image */
1136 val = css_computed_list_style_image(style, &url);
1137 if (url != NULL) {
1138 fprintf(stream, "list-style-image: url('%.*s') ",
1139 (int) lwc_string_length(url),
1140 lwc_string_data(url));
1141 } else if (val == CSS_LIST_STYLE_IMAGE_NONE) {
1142 fprintf(stream, "list-style-image: none ");
1143 }
1144
1145 /* list-style-position */
1146 val = css_computed_list_style_position(style);
1147 switch (val) {
1148 case CSS_LIST_STYLE_POSITION_INSIDE:
1149 fprintf(stream, "list-style-position: inside ");
1150 break;
1151 case CSS_LIST_STYLE_POSITION_OUTSIDE:
1152 fprintf(stream, "list-style-position: outside ");
1153 break;
1154 default:
1155 break;
1156 }
1157
1158 /* list-style-type */
1159 val = css_computed_list_style_type(style);
1160 switch (val) {
1161 case CSS_LIST_STYLE_TYPE_DISC:
1162 fprintf(stream, "list-style-type: disc ");
1163 break;
1164 case CSS_LIST_STYLE_TYPE_CIRCLE:
1165 fprintf(stream, "list-style-type: circle ");
1166 break;
1167 case CSS_LIST_STYLE_TYPE_SQUARE:
1168 fprintf(stream, "list-style-type: square ");
1169 break;
1170 case CSS_LIST_STYLE_TYPE_DECIMAL:
1171 fprintf(stream, "list-style-type: decimal ");
1172 break;
1173 case CSS_LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO:
1174 fprintf(stream, "list-style-type: decimal-leading-zero ");
1175 break;
1176 case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
1177 fprintf(stream, "list-style-type: lower-roman ");
1178 break;
1179 case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
1180 fprintf(stream, "list-style-type: upper-roman ");
1181 break;
1182 case CSS_LIST_STYLE_TYPE_LOWER_GREEK:
1183 fprintf(stream, "list-style-type: lower-greek ");
1184 break;
1185 case CSS_LIST_STYLE_TYPE_LOWER_LATIN:
1186 fprintf(stream, "list-style-type: lower-latin ");
1187 break;
1188 case CSS_LIST_STYLE_TYPE_UPPER_LATIN:
1189 fprintf(stream, "list-style-type: upper-latin ");
1190 break;
1191 case CSS_LIST_STYLE_TYPE_ARMENIAN:
1192 fprintf(stream, "list-style-type: armenian ");
1193 break;
1194 case CSS_LIST_STYLE_TYPE_GEORGIAN:
1195 fprintf(stream, "list-style-type: georgian ");
1196 break;
1197 case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
1198 fprintf(stream, "list-style-type: lower-alpha ");
1199 break;
1200 case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
1201 fprintf(stream, "list-style-type: upper-alpha ");
1202 break;
1203 case CSS_LIST_STYLE_TYPE_NONE:
1204 fprintf(stream, "list-style-type: none ");
1205 break;
1206 default:
1207 break;
1208 }
1209
1210 /* margin-top */
1211 val = css_computed_margin_top(style, &len1, &unit1);
1212 switch (val) {
1213 case CSS_MARGIN_AUTO:
1214 fprintf(stream, "margin-top: auto ");
1215 break;
1216 case CSS_MARGIN_SET:
1217 fprintf(stream, "margin-top: ");
1218
1219 dump_css_unit(stream, len1, unit1);
1220
1221 fprintf(stream, " ");
1222 break;
1223 default:
1224 break;
1225 }
1226
1227 /* margin-right */
1228 val = css_computed_margin_right(style, &len1, &unit1);
1229 switch (val) {
1230 case CSS_MARGIN_AUTO:
1231 fprintf(stream, "margin-right: auto ");
1232 break;
1233 case CSS_MARGIN_SET:
1234 fprintf(stream, "margin-right: ");
1235
1236 dump_css_unit(stream, len1, unit1);
1237
1238 fprintf(stream, " ");
1239 break;
1240 default:
1241 break;
1242 }
1243
1244 /* margin-bottom */
1245 val = css_computed_margin_bottom(style, &len1, &unit1);
1246 switch (val) {
1247 case CSS_MARGIN_AUTO:
1248 fprintf(stream, "margin-bottom: auto ");
1249 break;
1250 case CSS_MARGIN_SET:
1251 fprintf(stream, "margin-bottom: ");
1252
1253 dump_css_unit(stream, len1, unit1);
1254
1255 fprintf(stream, " ");
1256 break;
1257 default:
1258 break;
1259 }
1260
1261 /* margin-left */
1262 val = css_computed_margin_left(style, &len1, &unit1);
1263 switch (val) {
1264 case CSS_MARGIN_AUTO:
1265 fprintf(stream, "margin-left: auto ");
1266 break;
1267 case CSS_MARGIN_SET:
1268 fprintf(stream, "margin-left: ");
1269
1270 dump_css_unit(stream, len1, unit1);
1271
1272 fprintf(stream, " ");
1273 break;
1274 default:
1275 break;
1276 }
1277
1278 /* max-height */
1279 val = css_computed_max_height(style, &len1, &unit1);
1280 switch (val) {
1281 case CSS_MAX_HEIGHT_NONE:
1282 fprintf(stream, "max-height: none ");
1283 break;
1284 case CSS_MAX_HEIGHT_SET:
1285 fprintf(stream, "max-height: ");
1286
1287 dump_css_unit(stream, len1, unit1);
1288
1289 fprintf(stream, " ");
1290 break;
1291 default:
1292 break;
1293 }
1294
1295 /* max-width */
1296 val = css_computed_max_width(style, &len1, &unit1);
1297 switch (val) {
1298 case CSS_MAX_WIDTH_NONE:
1299 fprintf(stream, "max-width: none ");
1300 break;
1301 case CSS_MAX_WIDTH_SET:
1302 fprintf(stream, "max-width: ");
1303
1304 dump_css_unit(stream, len1, unit1);
1305
1306 fprintf(stream, " ");
1307 break;
1308 default:
1309 break;
1310 }
1311
1312 /* min-height */
1313 val = ns_computed_min_height(style, &len1, &unit1);
1314 switch (val) {
1315 case CSS_MIN_HEIGHT_SET:
1316 fprintf(stream, "min-height: ");
1317
1318 dump_css_unit(stream, len1, unit1);
1319
1320 fprintf(stream, " ");
1321 break;
1322 default:
1323 break;
1324 }
1325
1326 /* min-width */
1327 val = ns_computed_min_width(style, &len1, &unit1);
1328 switch (val) {
1329 case CSS_MIN_WIDTH_SET:
1330 fprintf(stream, "min-width: ");
1331
1332 dump_css_unit(stream, len1, unit1);
1333
1334 fprintf(stream, " ");
1335 break;
1336 default:
1337 break;
1338 }
1339
1340 /* opacity */
1341 val = css_computed_opacity(style, &len1);
1342 switch (val) {
1343 case CSS_OPACITY_SET:
1344 fprintf(stream, "opacity: ");
1345
1346 dump_css_fixed(stream, len1);
1347
1348 fprintf(stream, " ");
1349 break;
1350 default:
1351 break;
1352 }
1353
1354 /* outline-color */
1355 val = css_computed_outline_color(style, &color);
1356 switch (val) {
1357 case CSS_OUTLINE_COLOR_INVERT:
1358 fprintf(stream, "outline-color: invert ");
1359 break;
1360 case CSS_OUTLINE_COLOR_COLOR:
1361 fprintf(stream, "outline-color: #%08"PRIx32" ", color);
1362 break;
1363 default:
1364 break;
1365 }
1366
1367 /* outline-style */
1368 val = css_computed_outline_style(style);
1369 switch (val) {
1370 case CSS_OUTLINE_STYLE_NONE:
1371 fprintf(stream, "outline-style: none ");
1372 break;
1373 case CSS_OUTLINE_STYLE_DOTTED:
1374 fprintf(stream, "outline-style: dotted ");
1375 break;
1376 case CSS_OUTLINE_STYLE_DASHED:
1377 fprintf(stream, "outline-style: dashed ");
1378 break;
1379 case CSS_OUTLINE_STYLE_SOLID:
1380 fprintf(stream, "outline-style: solid ");
1381 break;
1382 case CSS_OUTLINE_STYLE_DOUBLE:
1383 fprintf(stream, "outline-style: double ");
1384 break;
1385 case CSS_OUTLINE_STYLE_GROOVE:
1386 fprintf(stream, "outline-style: groove ");
1387 break;
1388 case CSS_OUTLINE_STYLE_RIDGE:
1389 fprintf(stream, "outline-style: ridge ");
1390 break;
1391 case CSS_OUTLINE_STYLE_INSET:
1392 fprintf(stream, "outline-style: inset ");
1393 break;
1394 case CSS_OUTLINE_STYLE_OUTSET:
1395 fprintf(stream, "outline-style: outset ");
1396 break;
1397 default:
1398 break;
1399 }
1400
1401 /* outline-width */
1402 val = css_computed_outline_width(style, &len1, &unit1);
1403 switch (val) {
1404 case CSS_OUTLINE_WIDTH_THIN:
1405 fprintf(stream, "outline-width: thin ");
1406 break;
1407 case CSS_OUTLINE_WIDTH_MEDIUM:
1408 fprintf(stream, "outline-width: medium ");
1409 break;
1410 case CSS_OUTLINE_WIDTH_THICK:
1411 fprintf(stream, "outline-width: thick ");
1412 break;
1413 case CSS_OUTLINE_WIDTH_WIDTH:
1414 fprintf(stream, "outline-width: ");
1415
1416 dump_css_unit(stream, len1, unit1);
1417
1418 fprintf(stream, " ");
1419 break;
1420 default:
1421 break;
1422 }
1423
1424 /* overflow */
1425 val = css_computed_overflow_x(style);
1426 switch (val) {
1427 case CSS_OVERFLOW_VISIBLE:
1428 fprintf(stream, "overflow-x: visible ");
1429 break;
1430 case CSS_OVERFLOW_HIDDEN:
1431 fprintf(stream, "overflow-x: hidden ");
1432 break;
1433 case CSS_OVERFLOW_SCROLL:
1434 fprintf(stream, "overflow-x: scroll ");
1435 break;
1436 case CSS_OVERFLOW_AUTO:
1437 fprintf(stream, "overflow-x auto ");
1438 break;
1439 default:
1440 break;
1441 }
1442
1443 /* overflow */
1444 val = css_computed_overflow_y(style);
1445 switch (val) {
1446 case CSS_OVERFLOW_VISIBLE:
1447 fprintf(stream, "overflow-y: visible ");
1448 break;
1449 case CSS_OVERFLOW_HIDDEN:
1450 fprintf(stream, "overflow-y: hidden ");
1451 break;
1452 case CSS_OVERFLOW_SCROLL:
1453 fprintf(stream, "overflow-y: scroll ");
1454 break;
1455 case CSS_OVERFLOW_AUTO:
1456 fprintf(stream, "overflow-y: auto ");
1457 break;
1458 default:
1459 break;
1460 }
1461
1462 /* padding-top */
1463 val = css_computed_padding_top(style, &len1, &unit1);
1464 switch (val) {
1465 case CSS_PADDING_SET:
1466 fprintf(stream, "padding-top: ");
1467
1468 dump_css_unit(stream, len1, unit1);
1469
1470 fprintf(stream, " ");
1471 break;
1472 default:
1473 break;
1474 }
1475
1476 /* padding-right */
1477 val = css_computed_padding_right(style, &len1, &unit1);
1478 switch (val) {
1479 case CSS_PADDING_SET:
1480 fprintf(stream, "padding-right: ");
1481
1482 dump_css_unit(stream, len1, unit1);
1483
1484 fprintf(stream, " ");
1485 break;
1486 default:
1487 break;
1488 }
1489
1490 /* padding-bottom */
1491 val = css_computed_padding_bottom(style, &len1, &unit1);
1492 switch (val) {
1493 case CSS_PADDING_SET:
1494 fprintf(stream, "padding-bottom: ");
1495
1496 dump_css_unit(stream, len1, unit1);
1497
1498 fprintf(stream, " ");
1499 break;
1500 default:
1501 break;
1502 }
1503
1504 /* padding-left */
1505 val = css_computed_padding_left(style, &len1, &unit1);
1506 switch (val) {
1507 case CSS_PADDING_SET:
1508 fprintf(stream, "padding-left: ");
1509
1510 dump_css_unit(stream, len1, unit1);
1511
1512 fprintf(stream, " ");
1513 break;
1514 default:
1515 break;
1516 }
1517
1518 /* position */
1519 val = css_computed_position(style);
1520 switch (val) {
1521 case CSS_POSITION_STATIC:
1522 fprintf(stream, "position: static ");
1523 break;
1524 case CSS_POSITION_RELATIVE:
1525 fprintf(stream, "position: relative ");
1526 break;
1527 case CSS_POSITION_ABSOLUTE:
1528 fprintf(stream, "position: absolute ");
1529 break;
1530 case CSS_POSITION_FIXED:
1531 fprintf(stream, "position: fixed ");
1532 break;
1533 default:
1534 break;
1535 }
1536
1537 /* quotes */
1538 val = css_computed_quotes(style, &string_list);
1539 if (val == CSS_QUOTES_STRING && string_list != NULL) {
1540 fprintf(stream, "quotes:");
1541
1542 while (*string_list != NULL) {
1543 fprintf(stream, " \"%.*s\"",
1544 (int) lwc_string_length(*string_list),
1545 lwc_string_data(*string_list));
1546
1547 string_list++;
1548 }
1549
1550 fprintf(stream, " ");
1551 } else {
1552 switch (val) {
1553 case CSS_QUOTES_NONE:
1554 fprintf(stream, "quotes: none ");
1555 break;
1556 default:
1557 break;
1558 }
1559 }
1560
1561 /* right */
1562 val = css_computed_right(style, &len1, &unit1);
1563 switch (val) {
1564 case CSS_RIGHT_AUTO:
1565 fprintf(stream, "right: auto ");
1566 break;
1567 case CSS_RIGHT_SET:
1568 fprintf(stream, "right: ");
1569
1570 dump_css_unit(stream, len1, unit1);
1571
1572 fprintf(stream, " ");
1573 break;
1574 default:
1575 break;
1576 }
1577
1578 /* table-layout */
1579 val = css_computed_table_layout(style);
1580 switch (val) {
1581 case CSS_TABLE_LAYOUT_AUTO:
1582 fprintf(stream, "table-layout: auto ");
1583 break;
1584 case CSS_TABLE_LAYOUT_FIXED:
1585 fprintf(stream, "table-layout: fixed ");
1586 break;
1587 default:
1588 break;
1589 }
1590
1591 /* text-align */
1592 val = css_computed_text_align(style);
1593 switch (val) {
1594 case CSS_TEXT_ALIGN_LEFT:
1595 fprintf(stream, "text-align: left ");
1596 break;
1597 case CSS_TEXT_ALIGN_RIGHT:
1598 fprintf(stream, "text-align: right ");
1599 break;
1600 case CSS_TEXT_ALIGN_CENTER:
1601 fprintf(stream, "text-align: center ");
1602 break;
1603 case CSS_TEXT_ALIGN_JUSTIFY:
1604 fprintf(stream, "text-align: justify ");
1605 break;
1606 case CSS_TEXT_ALIGN_DEFAULT:
1607 fprintf(stream, "text-align: default ");
1608 break;
1609 case CSS_TEXT_ALIGN_LIBCSS_LEFT:
1610 fprintf(stream, "text-align: -libcss-left ");
1611 break;
1612 case CSS_TEXT_ALIGN_LIBCSS_CENTER:
1613 fprintf(stream, "text-align: -libcss-center ");
1614 break;
1615 case CSS_TEXT_ALIGN_LIBCSS_RIGHT:
1616 fprintf(stream, "text-align: -libcss-right ");
1617 break;
1618 default:
1619 break;
1620 }
1621
1622 /* text-decoration */
1623 val = css_computed_text_decoration(style);
1624 if (val == CSS_TEXT_DECORATION_NONE) {
1625 fprintf(stream, "text-decoration: none ");
1626 } else {
1627 fprintf(stream, "text-decoration:");
1628
1629 if (val & CSS_TEXT_DECORATION_BLINK) {
1630 fprintf(stream, " blink");
1631 }
1632 if (val & CSS_TEXT_DECORATION_LINE_THROUGH) {
1633 fprintf(stream, " line-through");
1634 }
1635 if (val & CSS_TEXT_DECORATION_OVERLINE) {
1636 fprintf(stream, " overline");
1637 }
1638 if (val & CSS_TEXT_DECORATION_UNDERLINE) {
1639 fprintf(stream, " underline");
1640 }
1641
1642 fprintf(stream, " ");
1643 }
1644
1645 /* text-indent */
1646 val = css_computed_text_indent(style, &len1, &unit1);
1647 switch (val) {
1648 case CSS_TEXT_INDENT_SET:
1649 fprintf(stream, "text-indent: ");
1650
1651 dump_css_unit(stream, len1, unit1);
1652
1653 fprintf(stream, " ");
1654 break;
1655 default:
1656 break;
1657 }
1658
1659 /* text-transform */
1660 val = css_computed_text_transform(style);
1661 switch (val) {
1662 case CSS_TEXT_TRANSFORM_CAPITALIZE:
1663 fprintf(stream, "text-transform: capitalize ");
1664 break;
1665 case CSS_TEXT_TRANSFORM_UPPERCASE:
1666 fprintf(stream, "text-transform: uppercase ");
1667 break;
1668 case CSS_TEXT_TRANSFORM_LOWERCASE:
1669 fprintf(stream, "text-transform: lowercase ");
1670 break;
1671 case CSS_TEXT_TRANSFORM_NONE:
1672 fprintf(stream, "text-transform: none ");
1673 break;
1674 default:
1675 break;
1676 }
1677
1678 /* top */
1679 val = css_computed_top(style, &len1, &unit1);
1680 switch (val) {
1681 case CSS_TOP_AUTO:
1682 fprintf(stream, "top: auto ");
1683 break;
1684 case CSS_TOP_SET:
1685 fprintf(stream, "top: ");
1686
1687 dump_css_unit(stream, len1, unit1);
1688
1689 fprintf(stream, " ");
1690 break;
1691 default:
1692 break;
1693 }
1694
1695 /* unicode-bidi */
1696 val = css_computed_unicode_bidi(style);
1697 switch (val) {
1698 case CSS_UNICODE_BIDI_NORMAL:
1699 fprintf(stream, "unicode-bidi: normal ");
1700 break;
1701 case CSS_UNICODE_BIDI_EMBED:
1702 fprintf(stream, "unicode-bidi: embed ");
1703 break;
1704 case CSS_UNICODE_BIDI_BIDI_OVERRIDE:
1705 fprintf(stream, "unicode-bidi: bidi-override ");
1706 break;
1707 default:
1708 break;
1709 }
1710
1711 /* vertical-align */
1712 val = css_computed_vertical_align(style, &len1, &unit1);
1713 switch (val) {
1714 case CSS_VERTICAL_ALIGN_BASELINE:
1715 fprintf(stream, "vertical-align: baseline ");
1716 break;
1717 case CSS_VERTICAL_ALIGN_SUB:
1718 fprintf(stream, "vertical-align: sub ");
1719 break;
1720 case CSS_VERTICAL_ALIGN_SUPER:
1721 fprintf(stream, "vertical-align: super ");
1722 break;
1723 case CSS_VERTICAL_ALIGN_TOP:
1724 fprintf(stream, "vertical-align: top ");
1725 break;
1726 case CSS_VERTICAL_ALIGN_TEXT_TOP:
1727 fprintf(stream, "vertical-align: text-top ");
1728 break;
1729 case CSS_VERTICAL_ALIGN_MIDDLE:
1730 fprintf(stream, "vertical-align: middle ");
1731 break;
1732 case CSS_VERTICAL_ALIGN_BOTTOM:
1733 fprintf(stream, "vertical-align: bottom ");
1734 break;
1735 case CSS_VERTICAL_ALIGN_TEXT_BOTTOM:
1736 fprintf(stream, "vertical-align: text-bottom ");
1737 break;
1738 case CSS_VERTICAL_ALIGN_SET:
1739 fprintf(stream, "vertical-align: ");
1740
1741 dump_css_unit(stream, len1, unit1);
1742
1743 fprintf(stream, " ");
1744 break;
1745 default:
1746 break;
1747 }
1748
1749 /* visibility */
1750 val = css_computed_visibility(style);
1751 switch (val) {
1752 case CSS_VISIBILITY_VISIBLE:
1753 fprintf(stream, "visibility: visible ");
1754 break;
1755 case CSS_VISIBILITY_HIDDEN:
1756 fprintf(stream, "visibility: hidden ");
1757 break;
1758 case CSS_VISIBILITY_COLLAPSE:
1759 fprintf(stream, "visibility: collapse ");
1760 break;
1761 default:
1762 break;
1763 }
1764
1765 /* white-space */
1766 val = css_computed_white_space(style);
1767 switch (val) {
1768 case CSS_WHITE_SPACE_NORMAL:
1769 fprintf(stream, "white-space: normal ");
1770 break;
1771 case CSS_WHITE_SPACE_PRE:
1772 fprintf(stream, "white-space: pre ");
1773 break;
1774 case CSS_WHITE_SPACE_NOWRAP:
1775 fprintf(stream, "white-space: nowrap ");
1776 break;
1777 case CSS_WHITE_SPACE_PRE_WRAP:
1778 fprintf(stream, "white-space: pre-wrap ");
1779 break;
1780 case CSS_WHITE_SPACE_PRE_LINE:
1781 fprintf(stream, "white-space: pre-line ");
1782 break;
1783 default:
1784 break;
1785 }
1786
1787 /* width */
1788 val = css_computed_width(style, &len1, &unit1);
1789 switch (val) {
1790 case CSS_WIDTH_AUTO:
1791 fprintf(stream, "width: auto ");
1792 break;
1793 case CSS_WIDTH_SET:
1794 fprintf(stream, "width: ");
1795
1796 dump_css_unit(stream, len1, unit1);
1797
1798 fprintf(stream, " ");
1799 break;
1800 default:
1801 break;
1802 }
1803
1804 /* word-spacing */
1805 val = css_computed_word_spacing(style, &len1, &unit1);
1806 switch (val) {
1807 case CSS_WORD_SPACING_NORMAL:
1808 fprintf(stream, "word-spacing: normal ");
1809 break;
1810 case CSS_WORD_SPACING_SET:
1811 fprintf(stream, "word-spacing: ");
1812
1813 dump_css_unit(stream, len1, unit1);
1814
1815 fprintf(stream, " ");
1816 break;
1817 default:
1818 break;
1819 }
1820
1821 /* z-index */
1822 val = css_computed_z_index(style, &zindex);
1823 switch (val) {
1824 case CSS_Z_INDEX_AUTO:
1825 fprintf(stream, "z-index: auto ");
1826 break;
1827 case CSS_Z_INDEX_SET:
1828 fprintf(stream, "z-index: %"PRId32" ", zindex);
1829 break;
1830 default:
1831 break;
1832 }
1833
1834 fprintf(stream, "}");
1835}
static uint8_t ns_computed_min_height(const css_computed_style *style, css_fixed *length, css_unit *unit)
Definition: utils.h:75
static uint8_t ns_computed_min_width(const css_computed_style *style, css_fixed *length, css_unit *unit)
Definition: utils.h:91
static uint8_t ns_computed_display_static(const css_computed_style *style)
Temporary helper wrappers for for libcss computed style getter, while we don't support all values of ...
Definition: utils.h:56
static void dump_css_fixed(FILE *stream, css_fixed f)
Dump a fixed point value to the stream in a textual form.
Definition: dump.c:33
static void dump_css_unit(FILE *stream, css_fixed val, css_unit unit)
Dump a dimension to the stream in a textual form.
Definition: dump.c:65
static void dump_css_number(FILE *stream, css_fixed val)
Dump a numeric value to the stream in a textual form.
Definition: dump.c:50
void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
Dump a computed style style to the give file handle stream.
Definition: dump.c:155
#define NSCSS_ABS(x)
Netsurf additional integer type formatting macros.
Content which corresponds to a single URL.
Rectangle coordinates.
Definition: types.h:40