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