20#include <libcss/libcss.h>
35#define NSCSS_ABS(x) (uint32_t)((x) < 0 ? -(x) : (x))
36 uint32_t uintpart = FIXTOINT(
NSCSS_ABS(f));
38 uint32_t fracpart = ((
NSCSS_ABS(f) & 0x3ff) * 1000 + 500) / (1 << 10);
41 fprintf(stream,
"%s%"PRIu32
".%03"PRIu32, f < 0 ?
"-" :
"", uintpart, fracpart);
52 if (INTTOFIX(FIXTOINT(val)) == val)
53 fprintf(stream,
"%"PRId32, FIXTOINT(val));
71 fprintf(stream,
"px");
74 fprintf(stream,
"ex");
77 fprintf(stream,
"em");
80 fprintf(stream,
"in");
83 fprintf(stream,
"cm");
86 fprintf(stream,
"mm");
89 fprintf(stream,
"pt");
92 fprintf(stream,
"pc");
95 fprintf(stream,
"%%");
98 fprintf(stream,
"deg");
101 fprintf(stream,
"grad");
104 fprintf(stream,
"rad");
107 fprintf(stream,
"ms");
110 fprintf(stream,
"s");
113 fprintf(stream,
"Hz");
116 fprintf(stream,
"kHz");
119 fprintf(stream,
"ch");
122 fprintf(stream,
"rem");
125 fprintf(stream,
"lh");
128 fprintf(stream,
"vh");
131 fprintf(stream,
"vw");
134 fprintf(stream,
"vi");
137 fprintf(stream,
"vb");
140 fprintf(stream,
"vmin");
143 fprintf(stream,
"vmax");
146 fprintf(stream,
"q");
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,
162 const css_computed_content_item *
content = NULL;
163 const css_computed_counter *counter = NULL;
164 lwc_string **string_list = NULL;
167 fprintf(stream,
"{ ");
170 val = css_computed_background_attachment(style);
172 case CSS_BACKGROUND_ATTACHMENT_FIXED:
173 fprintf(stream,
"background-attachment: fixed ");
175 case CSS_BACKGROUND_ATTACHMENT_SCROLL:
176 fprintf(stream,
"background-attachment: scroll ");
183 val = css_computed_background_color(style, &color);
185 case CSS_BACKGROUND_COLOR_COLOR:
186 fprintf(stream,
"background-color: #%08"PRIx32
" ", color);
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 ");
203 val = css_computed_background_position(style, &len1, &unit1,
205 if (val == CSS_BACKGROUND_POSITION_SET) {
206 fprintf(stream,
"background-position: ");
208 fprintf(stream,
" ");
210 fprintf(stream,
" ");
214 val = css_computed_background_repeat(style);
216 case CSS_BACKGROUND_REPEAT_REPEAT_X:
217 fprintf(stream,
"background-repeat: repeat-x ");
219 case CSS_BACKGROUND_REPEAT_REPEAT_Y:
220 fprintf(stream,
"background-repeat: repeat-y ");
222 case CSS_BACKGROUND_REPEAT_REPEAT:
223 fprintf(stream,
"background-repeat: repeat ");
225 case CSS_BACKGROUND_REPEAT_NO_REPEAT:
226 fprintf(stream,
"background-repeat: no-repeat ");
233 val = css_computed_border_collapse(style);
235 case CSS_BORDER_COLLAPSE_SEPARATE:
236 fprintf(stream,
"border-collapse: separate ");
238 case CSS_BORDER_COLLAPSE_COLLAPSE:
239 fprintf(stream,
"border-collapse: collapse ");
247 val = css_computed_border_spacing(style, &len1, &unit1, &len2, &unit2);
248 if (val == CSS_BORDER_SPACING_SET) {
249 fprintf(stream,
"border-spacing: ");
251 fprintf(stream,
" ");
253 fprintf(stream,
" ");
257 val = css_computed_border_top_color(style, &color);
259 case CSS_BORDER_COLOR_COLOR:
260 fprintf(stream,
"border-top-color: #%08"PRIx32
" ", color);
267 val = css_computed_border_right_color(style, &color);
269 case CSS_BORDER_COLOR_COLOR:
270 fprintf(stream,
"border-right-color: #%08"PRIx32
" ", color);
277 val = css_computed_border_bottom_color(style, &color);
279 case CSS_BORDER_COLOR_COLOR:
280 fprintf(stream,
"border-bottom-color: #%08"PRIx32
" ", color);
287 val = css_computed_border_left_color(style, &color);
289 case CSS_BORDER_COLOR_COLOR:
290 fprintf(stream,
"border-left-color: #%08"PRIx32
" ", color);
297 val = css_computed_border_top_style(style);
299 case CSS_BORDER_STYLE_NONE:
300 fprintf(stream,
"border-top-style: none ");
302 case CSS_BORDER_STYLE_HIDDEN:
303 fprintf(stream,
"border-top-style: hidden ");
305 case CSS_BORDER_STYLE_DOTTED:
306 fprintf(stream,
"border-top-style: dotted ");
308 case CSS_BORDER_STYLE_DASHED:
309 fprintf(stream,
"border-top-style: dashed ");
311 case CSS_BORDER_STYLE_SOLID:
312 fprintf(stream,
"border-top-style: solid ");
314 case CSS_BORDER_STYLE_DOUBLE:
315 fprintf(stream,
"border-top-style: double ");
317 case CSS_BORDER_STYLE_GROOVE:
318 fprintf(stream,
"border-top-style: groove ");
320 case CSS_BORDER_STYLE_RIDGE:
321 fprintf(stream,
"border-top-style: ridge ");
323 case CSS_BORDER_STYLE_INSET:
324 fprintf(stream,
"border-top-style: inset ");
326 case CSS_BORDER_STYLE_OUTSET:
327 fprintf(stream,
"border-top-style: outset ");
334 val = css_computed_border_right_style(style);
336 case CSS_BORDER_STYLE_NONE:
337 fprintf(stream,
"border-right-style: none ");
339 case CSS_BORDER_STYLE_HIDDEN:
340 fprintf(stream,
"border-right-style: hidden ");
342 case CSS_BORDER_STYLE_DOTTED:
343 fprintf(stream,
"border-right-style: dotted ");
345 case CSS_BORDER_STYLE_DASHED:
346 fprintf(stream,
"border-right-style: dashed ");
348 case CSS_BORDER_STYLE_SOLID:
349 fprintf(stream,
"border-right-style: solid ");
351 case CSS_BORDER_STYLE_DOUBLE:
352 fprintf(stream,
"border-right-style: double ");
354 case CSS_BORDER_STYLE_GROOVE:
355 fprintf(stream,
"border-right-style: groove ");
357 case CSS_BORDER_STYLE_RIDGE:
358 fprintf(stream,
"border-right-style: ridge ");
360 case CSS_BORDER_STYLE_INSET:
361 fprintf(stream,
"border-right-style: inset ");
363 case CSS_BORDER_STYLE_OUTSET:
364 fprintf(stream,
"border-right-style: outset ");
371 val = css_computed_border_bottom_style(style);
373 case CSS_BORDER_STYLE_NONE:
374 fprintf(stream,
"border-bottom-style: none ");
376 case CSS_BORDER_STYLE_HIDDEN:
377 fprintf(stream,
"border-bottom-style: hidden ");
379 case CSS_BORDER_STYLE_DOTTED:
380 fprintf(stream,
"border-bottom-style: dotted ");
382 case CSS_BORDER_STYLE_DASHED:
383 fprintf(stream,
"border-bottom-style: dashed ");
385 case CSS_BORDER_STYLE_SOLID:
386 fprintf(stream,
"border-bottom-style: solid ");
388 case CSS_BORDER_STYLE_DOUBLE:
389 fprintf(stream,
"border-bottom-style: double ");
391 case CSS_BORDER_STYLE_GROOVE:
392 fprintf(stream,
"border-bottom-style: groove ");
394 case CSS_BORDER_STYLE_RIDGE:
395 fprintf(stream,
"border-bottom-style: ridge ");
397 case CSS_BORDER_STYLE_INSET:
398 fprintf(stream,
"border-bottom-style: inset ");
400 case CSS_BORDER_STYLE_OUTSET:
401 fprintf(stream,
"border-bottom-style: outset ");
408 val = css_computed_border_left_style(style);
410 case CSS_BORDER_STYLE_NONE:
411 fprintf(stream,
"border-left-style: none ");
413 case CSS_BORDER_STYLE_HIDDEN:
414 fprintf(stream,
"border-left-style: hidden ");
416 case CSS_BORDER_STYLE_DOTTED:
417 fprintf(stream,
"border-left-style: dotted ");
419 case CSS_BORDER_STYLE_DASHED:
420 fprintf(stream,
"border-left-style: dashed ");
422 case CSS_BORDER_STYLE_SOLID:
423 fprintf(stream,
"border-left-style: solid ");
425 case CSS_BORDER_STYLE_DOUBLE:
426 fprintf(stream,
"border-left-style: double ");
428 case CSS_BORDER_STYLE_GROOVE:
429 fprintf(stream,
"border-left-style: groove ");
431 case CSS_BORDER_STYLE_RIDGE:
432 fprintf(stream,
"border-left-style: ridge ");
434 case CSS_BORDER_STYLE_INSET:
435 fprintf(stream,
"border-left-style: inset ");
437 case CSS_BORDER_STYLE_OUTSET:
438 fprintf(stream,
"border-left-style: outset ");
445 val = css_computed_border_top_width(style, &len1, &unit1);
447 case CSS_BORDER_WIDTH_THIN:
448 fprintf(stream,
"border-top-width: thin ");
450 case CSS_BORDER_WIDTH_MEDIUM:
451 fprintf(stream,
"border-top-width: medium ");
453 case CSS_BORDER_WIDTH_THICK:
454 fprintf(stream,
"border-top-width: thick ");
456 case CSS_BORDER_WIDTH_WIDTH:
457 fprintf(stream,
"border-top-width: ");
459 fprintf(stream,
" ");
466 val = css_computed_border_right_width(style, &len1, &unit1);
468 case CSS_BORDER_WIDTH_THIN:
469 fprintf(stream,
"border-right-width: thin ");
471 case CSS_BORDER_WIDTH_MEDIUM:
472 fprintf(stream,
"border-right-width: medium ");
474 case CSS_BORDER_WIDTH_THICK:
475 fprintf(stream,
"border-right-width: thick ");
477 case CSS_BORDER_WIDTH_WIDTH:
478 fprintf(stream,
"border-right-width: ");
480 fprintf(stream,
" ");
487 val = css_computed_border_bottom_width(style, &len1, &unit1);
489 case CSS_BORDER_WIDTH_THIN:
490 fprintf(stream,
"border-bottom-width: thin ");
492 case CSS_BORDER_WIDTH_MEDIUM:
493 fprintf(stream,
"border-bottom-width: medium ");
495 case CSS_BORDER_WIDTH_THICK:
496 fprintf(stream,
"border-bottom-width: thick ");
498 case CSS_BORDER_WIDTH_WIDTH:
499 fprintf(stream,
"border-bottom-width: ");
501 fprintf(stream,
" ");
508 val = css_computed_border_left_width(style, &len1, &unit1);
510 case CSS_BORDER_WIDTH_THIN:
511 fprintf(stream,
"border-left-width: thin ");
513 case CSS_BORDER_WIDTH_MEDIUM:
514 fprintf(stream,
"border-left-width: medium ");
516 case CSS_BORDER_WIDTH_THICK:
517 fprintf(stream,
"border-left-width: thick ");
519 case CSS_BORDER_WIDTH_WIDTH:
520 fprintf(stream,
"border-left-width: ");
522 fprintf(stream,
" ");
529 val = css_computed_bottom(style, &len1, &unit1);
531 case CSS_BOTTOM_AUTO:
532 fprintf(stream,
"bottom: auto ");
535 fprintf(stream,
"bottom: ");
537 fprintf(stream,
" ");
544 val = css_computed_caption_side(style);
546 case CSS_CAPTION_SIDE_TOP:
547 fprintf(stream,
"caption_side: top ");
549 case CSS_CAPTION_SIDE_BOTTOM:
550 fprintf(stream,
"caption_side: bottom ");
557 val = css_computed_clear(style);
560 fprintf(stream,
"clear: none ");
563 fprintf(stream,
"clear: left ");
565 case CSS_CLEAR_RIGHT:
566 fprintf(stream,
"clear: right ");
569 fprintf(stream,
"clear: both ");
576 val = css_computed_clip(style, &
rect);
579 fprintf(stream,
"clip: auto ");
582 fprintf(stream,
"clip: rect( ");
585 fprintf(stream,
"auto");
588 fprintf(stream,
", ");
591 fprintf(stream,
"auto");
594 fprintf(stream,
", ");
596 if (
rect.bottom_auto)
597 fprintf(stream,
"auto");
600 fprintf(stream,
", ");
603 fprintf(stream,
"auto");
606 fprintf(stream,
") ");
613 val = css_computed_color(style, &color);
614 if (val == CSS_COLOR_COLOR) {
615 fprintf(stream,
"color: #%08"PRIx32
" ", color);
619 val = css_computed_content(style, &
content);
621 case CSS_CONTENT_NONE:
622 fprintf(stream,
"content: none ");
624 case CSS_CONTENT_NORMAL:
625 fprintf(stream,
"content: normal ");
627 case CSS_CONTENT_SET:
628 fprintf(stream,
"content:");
630 while (
content->type != CSS_COMPUTED_CONTENT_NONE) {
631 fprintf(stream,
" ");
634 case CSS_COMPUTED_CONTENT_STRING:
635 fprintf(stream,
"\"%.*s\"",
636 (
int) lwc_string_length(
641 case CSS_COMPUTED_CONTENT_URI:
642 fprintf(stream,
"uri(\"%.*s\")",
643 (
int) lwc_string_length(
648 case CSS_COMPUTED_CONTENT_COUNTER:
649 fprintf(stream,
"counter(%.*s)",
650 (
int) lwc_string_length(
655 case CSS_COMPUTED_CONTENT_COUNTERS:
656 fprintf(stream,
"counters(%.*s, \"%.*s\")",
657 (
int) lwc_string_length(
661 (
int) lwc_string_length(
666 case CSS_COMPUTED_CONTENT_ATTR:
667 fprintf(stream,
"attr(%.*s)",
668 (
int) lwc_string_length(
673 case CSS_COMPUTED_CONTENT_OPEN_QUOTE:
674 fprintf(stream,
"open-quote");
676 case CSS_COMPUTED_CONTENT_CLOSE_QUOTE:
677 fprintf(stream,
"close-quote");
679 case CSS_COMPUTED_CONTENT_NO_OPEN_QUOTE:
680 fprintf(stream,
"no-open-quote");
682 case CSS_COMPUTED_CONTENT_NO_CLOSE_QUOTE:
683 fprintf(stream,
"no-close-quote");
690 fprintf(stream,
" ");
697 val = css_computed_counter_increment(style, &counter);
698 if ((val == CSS_COUNTER_INCREMENT_NONE) || (counter == NULL)) {
699 fprintf(stream,
"counter-increment: none ");
701 fprintf(stream,
"counter-increment:");
703 while (counter->name != NULL) {
704 fprintf(stream,
" %.*s ",
705 (
int) lwc_string_length(counter->name),
706 lwc_string_data(counter->name));
713 fprintf(stream,
" ");
717 val = css_computed_counter_reset(style, &counter);
718 if ((val == CSS_COUNTER_RESET_NONE) || (counter == NULL)) {
719 fprintf(stream,
"counter-reset: none ");
721 fprintf(stream,
"counter-reset:");
723 while (counter->name != NULL) {
724 fprintf(stream,
" %.*s ",
725 (
int) lwc_string_length(counter->name),
726 lwc_string_data(counter->name));
733 fprintf(stream,
" ");
737 val = css_computed_cursor(style, &string_list);
738 fprintf(stream,
"cursor:");
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));
750 case CSS_CURSOR_AUTO:
751 fprintf(stream,
" auto ");
753 case CSS_CURSOR_CROSSHAIR:
754 fprintf(stream,
" crosshair ");
756 case CSS_CURSOR_DEFAULT:
757 fprintf(stream,
" default ");
759 case CSS_CURSOR_POINTER:
760 fprintf(stream,
" pointer ");
762 case CSS_CURSOR_MOVE:
763 fprintf(stream,
" move ");
765 case CSS_CURSOR_E_RESIZE:
766 fprintf(stream,
" e-resize ");
768 case CSS_CURSOR_NE_RESIZE:
769 fprintf(stream,
" ne-resize ");
771 case CSS_CURSOR_NW_RESIZE:
772 fprintf(stream,
" nw-resize ");
774 case CSS_CURSOR_N_RESIZE:
775 fprintf(stream,
" n-resize ");
777 case CSS_CURSOR_SE_RESIZE:
778 fprintf(stream,
" se-resize ");
780 case CSS_CURSOR_SW_RESIZE:
781 fprintf(stream,
" sw-resize ");
783 case CSS_CURSOR_S_RESIZE:
784 fprintf(stream,
" s-resize ");
786 case CSS_CURSOR_W_RESIZE:
787 fprintf(stream,
" w-resize ");
789 case CSS_CURSOR_TEXT:
790 fprintf(stream,
" text ");
792 case CSS_CURSOR_WAIT:
793 fprintf(stream,
" wait ");
795 case CSS_CURSOR_HELP:
796 fprintf(stream,
" help ");
798 case CSS_CURSOR_PROGRESS:
799 fprintf(stream,
" progress ");
806 val = css_computed_direction(style);
808 case CSS_DIRECTION_LTR:
809 fprintf(stream,
"direction: ltr ");
811 case CSS_DIRECTION_RTL:
812 fprintf(stream,
"direction: rtl ");
821 case CSS_DISPLAY_INLINE:
822 fprintf(stream,
"display: inline ");
824 case CSS_DISPLAY_BLOCK:
825 fprintf(stream,
"display: block ");
827 case CSS_DISPLAY_LIST_ITEM:
828 fprintf(stream,
"display: list-item ");
830 case CSS_DISPLAY_RUN_IN:
831 fprintf(stream,
"display: run-in ");
833 case CSS_DISPLAY_INLINE_BLOCK:
834 fprintf(stream,
"display: inline-block ");
836 case CSS_DISPLAY_TABLE:
837 fprintf(stream,
"display: table ");
839 case CSS_DISPLAY_INLINE_TABLE:
840 fprintf(stream,
"display: inline-table ");
842 case CSS_DISPLAY_TABLE_ROW_GROUP:
843 fprintf(stream,
"display: table-row-group ");
845 case CSS_DISPLAY_TABLE_HEADER_GROUP:
846 fprintf(stream,
"display: table-header-group ");
848 case CSS_DISPLAY_TABLE_FOOTER_GROUP:
849 fprintf(stream,
"display: table-footer-group ");
851 case CSS_DISPLAY_TABLE_ROW:
852 fprintf(stream,
"display: table-row ");
854 case CSS_DISPLAY_TABLE_COLUMN_GROUP:
855 fprintf(stream,
"display: table-column-group ");
857 case CSS_DISPLAY_TABLE_COLUMN:
858 fprintf(stream,
"display: table-column ");
860 case CSS_DISPLAY_TABLE_CELL:
861 fprintf(stream,
"display: table-cell ");
863 case CSS_DISPLAY_TABLE_CAPTION:
864 fprintf(stream,
"display: table-caption ");
866 case CSS_DISPLAY_NONE:
867 fprintf(stream,
"display: none ");
869 case CSS_DISPLAY_FLEX:
870 fprintf(stream,
"display: flex ");
872 case CSS_DISPLAY_INLINE_FLEX:
873 fprintf(stream,
"display: inline-flex ");
880 val = css_computed_empty_cells(style);
882 case CSS_EMPTY_CELLS_SHOW:
883 fprintf(stream,
"empty-cells: show ");
885 case CSS_EMPTY_CELLS_HIDE:
886 fprintf(stream,
"empty-cells: hide ");
893 val = css_computed_float(style);
896 fprintf(stream,
"float: left ");
898 case CSS_FLOAT_RIGHT:
899 fprintf(stream,
"float: right ");
902 fprintf(stream,
"float: none ");
909 val = css_computed_font_family(style, &string_list);
910 if (val != CSS_FONT_FAMILY_INHERIT) {
911 fprintf(stream,
"font-family:");
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));
923 case CSS_FONT_FAMILY_SERIF:
924 fprintf(stream,
" serif ");
926 case CSS_FONT_FAMILY_SANS_SERIF:
927 fprintf(stream,
" sans-serif ");
929 case CSS_FONT_FAMILY_CURSIVE:
930 fprintf(stream,
" cursive ");
932 case CSS_FONT_FAMILY_FANTASY:
933 fprintf(stream,
" fantasy ");
935 case CSS_FONT_FAMILY_MONOSPACE:
936 fprintf(stream,
" monospace ");
942 val = css_computed_font_size(style, &len1, &unit1);
944 case CSS_FONT_SIZE_XX_SMALL:
945 fprintf(stream,
"font-size: xx-small ");
947 case CSS_FONT_SIZE_X_SMALL:
948 fprintf(stream,
"font-size: x-small ");
950 case CSS_FONT_SIZE_SMALL:
951 fprintf(stream,
"font-size: small ");
953 case CSS_FONT_SIZE_MEDIUM:
954 fprintf(stream,
"font-size: medium ");
956 case CSS_FONT_SIZE_LARGE:
957 fprintf(stream,
"font-size: large ");
959 case CSS_FONT_SIZE_X_LARGE:
960 fprintf(stream,
"font-size: x-large ");
962 case CSS_FONT_SIZE_XX_LARGE:
963 fprintf(stream,
"font-size: xx-large ");
965 case CSS_FONT_SIZE_LARGER:
966 fprintf(stream,
"font-size: larger ");
968 case CSS_FONT_SIZE_SMALLER:
969 fprintf(stream,
"font-size: smaller ");
971 case CSS_FONT_SIZE_DIMENSION:
972 fprintf(stream,
"font-size: ");
976 fprintf(stream,
" ");
983 val = css_computed_font_style(style);
985 case CSS_FONT_STYLE_NORMAL:
986 fprintf(stream,
"font-style: normal ");
988 case CSS_FONT_STYLE_ITALIC:
989 fprintf(stream,
"font-style: italic ");
991 case CSS_FONT_STYLE_OBLIQUE:
992 fprintf(stream,
"font-style: oblique ");
999 val = css_computed_font_variant(style);
1001 case CSS_FONT_VARIANT_NORMAL:
1002 fprintf(stream,
"font-variant: normal ");
1004 case CSS_FONT_VARIANT_SMALL_CAPS:
1005 fprintf(stream,
"font-variant: small-caps ");
1012 val = css_computed_font_weight(style);
1014 case CSS_FONT_WEIGHT_NORMAL:
1015 fprintf(stream,
"font-weight: normal ");
1017 case CSS_FONT_WEIGHT_BOLD:
1018 fprintf(stream,
"font-weight: bold ");
1020 case CSS_FONT_WEIGHT_BOLDER:
1021 fprintf(stream,
"font-weight: bolder ");
1023 case CSS_FONT_WEIGHT_LIGHTER:
1024 fprintf(stream,
"font-weight: lighter ");
1026 case CSS_FONT_WEIGHT_100:
1027 fprintf(stream,
"font-weight: 100 ");
1029 case CSS_FONT_WEIGHT_200:
1030 fprintf(stream,
"font-weight: 200 ");
1032 case CSS_FONT_WEIGHT_300:
1033 fprintf(stream,
"font-weight: 300 ");
1035 case CSS_FONT_WEIGHT_400:
1036 fprintf(stream,
"font-weight: 400 ");
1038 case CSS_FONT_WEIGHT_500:
1039 fprintf(stream,
"font-weight: 500 ");
1041 case CSS_FONT_WEIGHT_600:
1042 fprintf(stream,
"font-weight: 600 ");
1044 case CSS_FONT_WEIGHT_700:
1045 fprintf(stream,
"font-weight: 700 ");
1047 case CSS_FONT_WEIGHT_800:
1048 fprintf(stream,
"font-weight: 800 ");
1050 case CSS_FONT_WEIGHT_900:
1051 fprintf(stream,
"font-weight: 900 ");
1058 val = css_computed_height(style, &len1, &unit1);
1060 case CSS_HEIGHT_AUTO:
1061 fprintf(stream,
"height: auto ");
1063 case CSS_HEIGHT_SET:
1064 fprintf(stream,
"height: ");
1068 fprintf(stream,
" ");
1075 val = css_computed_left(style, &len1, &unit1);
1078 fprintf(stream,
"left: auto ");
1081 fprintf(stream,
"left: ");
1085 fprintf(stream,
" ");
1092 val = css_computed_letter_spacing(style, &len1, &unit1);
1094 case CSS_LETTER_SPACING_NORMAL:
1095 fprintf(stream,
"letter-spacing: normal ");
1097 case CSS_LETTER_SPACING_SET:
1098 fprintf(stream,
"letter-spacing: ");
1102 fprintf(stream,
" ");
1109 val = css_computed_line_height(style, &len1, &unit1);
1111 case CSS_LINE_HEIGHT_NORMAL:
1112 fprintf(stream,
"line-height: normal ");
1114 case CSS_LINE_HEIGHT_NUMBER:
1115 fprintf(stream,
"line-height: ");
1119 fprintf(stream,
" ");
1121 case CSS_LINE_HEIGHT_DIMENSION:
1122 fprintf(stream,
"line-height: ");
1126 fprintf(stream,
" ");
1133 val = css_computed_list_style_image(style, &url);
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 ");
1143 val = css_computed_list_style_position(style);
1145 case CSS_LIST_STYLE_POSITION_INSIDE:
1146 fprintf(stream,
"list-style-position: inside ");
1148 case CSS_LIST_STYLE_POSITION_OUTSIDE:
1149 fprintf(stream,
"list-style-position: outside ");
1156 val = css_computed_list_style_type(style);
1158 case CSS_LIST_STYLE_TYPE_DISC:
1159 fprintf(stream,
"list-style-type: disc ");
1161 case CSS_LIST_STYLE_TYPE_CIRCLE:
1162 fprintf(stream,
"list-style-type: circle ");
1164 case CSS_LIST_STYLE_TYPE_SQUARE:
1165 fprintf(stream,
"list-style-type: square ");
1167 case CSS_LIST_STYLE_TYPE_DECIMAL:
1168 fprintf(stream,
"list-style-type: decimal ");
1170 case CSS_LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO:
1171 fprintf(stream,
"list-style-type: decimal-leading-zero ");
1173 case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
1174 fprintf(stream,
"list-style-type: lower-roman ");
1176 case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
1177 fprintf(stream,
"list-style-type: upper-roman ");
1179 case CSS_LIST_STYLE_TYPE_LOWER_GREEK:
1180 fprintf(stream,
"list-style-type: lower-greek ");
1182 case CSS_LIST_STYLE_TYPE_LOWER_LATIN:
1183 fprintf(stream,
"list-style-type: lower-latin ");
1185 case CSS_LIST_STYLE_TYPE_UPPER_LATIN:
1186 fprintf(stream,
"list-style-type: upper-latin ");
1188 case CSS_LIST_STYLE_TYPE_ARMENIAN:
1189 fprintf(stream,
"list-style-type: armenian ");
1191 case CSS_LIST_STYLE_TYPE_GEORGIAN:
1192 fprintf(stream,
"list-style-type: georgian ");
1194 case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
1195 fprintf(stream,
"list-style-type: lower-alpha ");
1197 case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
1198 fprintf(stream,
"list-style-type: upper-alpha ");
1200 case CSS_LIST_STYLE_TYPE_NONE:
1201 fprintf(stream,
"list-style-type: none ");
1208 val = css_computed_margin_top(style, &len1, &unit1);
1210 case CSS_MARGIN_AUTO:
1211 fprintf(stream,
"margin-top: auto ");
1213 case CSS_MARGIN_SET:
1214 fprintf(stream,
"margin-top: ");
1218 fprintf(stream,
" ");
1225 val = css_computed_margin_right(style, &len1, &unit1);
1227 case CSS_MARGIN_AUTO:
1228 fprintf(stream,
"margin-right: auto ");
1230 case CSS_MARGIN_SET:
1231 fprintf(stream,
"margin-right: ");
1235 fprintf(stream,
" ");
1242 val = css_computed_margin_bottom(style, &len1, &unit1);
1244 case CSS_MARGIN_AUTO:
1245 fprintf(stream,
"margin-bottom: auto ");
1247 case CSS_MARGIN_SET:
1248 fprintf(stream,
"margin-bottom: ");
1252 fprintf(stream,
" ");
1259 val = css_computed_margin_left(style, &len1, &unit1);
1261 case CSS_MARGIN_AUTO:
1262 fprintf(stream,
"margin-left: auto ");
1264 case CSS_MARGIN_SET:
1265 fprintf(stream,
"margin-left: ");
1269 fprintf(stream,
" ");
1276 val = css_computed_max_height(style, &len1, &unit1);
1278 case CSS_MAX_HEIGHT_NONE:
1279 fprintf(stream,
"max-height: none ");
1281 case CSS_MAX_HEIGHT_SET:
1282 fprintf(stream,
"max-height: ");
1286 fprintf(stream,
" ");
1293 val = css_computed_max_width(style, &len1, &unit1);
1295 case CSS_MAX_WIDTH_NONE:
1296 fprintf(stream,
"max-width: none ");
1298 case CSS_MAX_WIDTH_SET:
1299 fprintf(stream,
"max-width: ");
1303 fprintf(stream,
" ");
1312 case CSS_MIN_HEIGHT_SET:
1313 fprintf(stream,
"min-height: ");
1317 fprintf(stream,
" ");
1326 case CSS_MIN_WIDTH_SET:
1327 fprintf(stream,
"min-width: ");
1331 fprintf(stream,
" ");
1338 val = css_computed_opacity(style, &len1);
1340 case CSS_OPACITY_SET:
1341 fprintf(stream,
"opacity: ");
1345 fprintf(stream,
" ");
1352 val = css_computed_outline_color(style, &color);
1354 case CSS_OUTLINE_COLOR_INVERT:
1355 fprintf(stream,
"outline-color: invert ");
1357 case CSS_OUTLINE_COLOR_COLOR:
1358 fprintf(stream,
"outline-color: #%08"PRIx32
" ", color);
1365 val = css_computed_outline_style(style);
1367 case CSS_OUTLINE_STYLE_NONE:
1368 fprintf(stream,
"outline-style: none ");
1370 case CSS_OUTLINE_STYLE_DOTTED:
1371 fprintf(stream,
"outline-style: dotted ");
1373 case CSS_OUTLINE_STYLE_DASHED:
1374 fprintf(stream,
"outline-style: dashed ");
1376 case CSS_OUTLINE_STYLE_SOLID:
1377 fprintf(stream,
"outline-style: solid ");
1379 case CSS_OUTLINE_STYLE_DOUBLE:
1380 fprintf(stream,
"outline-style: double ");
1382 case CSS_OUTLINE_STYLE_GROOVE:
1383 fprintf(stream,
"outline-style: groove ");
1385 case CSS_OUTLINE_STYLE_RIDGE:
1386 fprintf(stream,
"outline-style: ridge ");
1388 case CSS_OUTLINE_STYLE_INSET:
1389 fprintf(stream,
"outline-style: inset ");
1391 case CSS_OUTLINE_STYLE_OUTSET:
1392 fprintf(stream,
"outline-style: outset ");
1399 val = css_computed_outline_width(style, &len1, &unit1);
1401 case CSS_OUTLINE_WIDTH_THIN:
1402 fprintf(stream,
"outline-width: thin ");
1404 case CSS_OUTLINE_WIDTH_MEDIUM:
1405 fprintf(stream,
"outline-width: medium ");
1407 case CSS_OUTLINE_WIDTH_THICK:
1408 fprintf(stream,
"outline-width: thick ");
1410 case CSS_OUTLINE_WIDTH_WIDTH:
1411 fprintf(stream,
"outline-width: ");
1415 fprintf(stream,
" ");
1422 val = css_computed_overflow_x(style);
1424 case CSS_OVERFLOW_VISIBLE:
1425 fprintf(stream,
"overflow-x: visible ");
1427 case CSS_OVERFLOW_HIDDEN:
1428 fprintf(stream,
"overflow-x: hidden ");
1430 case CSS_OVERFLOW_SCROLL:
1431 fprintf(stream,
"overflow-x: scroll ");
1433 case CSS_OVERFLOW_AUTO:
1434 fprintf(stream,
"overflow-x auto ");
1441 val = css_computed_overflow_y(style);
1443 case CSS_OVERFLOW_VISIBLE:
1444 fprintf(stream,
"overflow-y: visible ");
1446 case CSS_OVERFLOW_HIDDEN:
1447 fprintf(stream,
"overflow-y: hidden ");
1449 case CSS_OVERFLOW_SCROLL:
1450 fprintf(stream,
"overflow-y: scroll ");
1452 case CSS_OVERFLOW_AUTO:
1453 fprintf(stream,
"overflow-y: auto ");
1460 val = css_computed_padding_top(style, &len1, &unit1);
1462 case CSS_PADDING_SET:
1463 fprintf(stream,
"padding-top: ");
1467 fprintf(stream,
" ");
1474 val = css_computed_padding_right(style, &len1, &unit1);
1476 case CSS_PADDING_SET:
1477 fprintf(stream,
"padding-right: ");
1481 fprintf(stream,
" ");
1488 val = css_computed_padding_bottom(style, &len1, &unit1);
1490 case CSS_PADDING_SET:
1491 fprintf(stream,
"padding-bottom: ");
1495 fprintf(stream,
" ");
1502 val = css_computed_padding_left(style, &len1, &unit1);
1504 case CSS_PADDING_SET:
1505 fprintf(stream,
"padding-left: ");
1509 fprintf(stream,
" ");
1516 val = css_computed_position(style);
1518 case CSS_POSITION_STATIC:
1519 fprintf(stream,
"position: static ");
1521 case CSS_POSITION_RELATIVE:
1522 fprintf(stream,
"position: relative ");
1524 case CSS_POSITION_ABSOLUTE:
1525 fprintf(stream,
"position: absolute ");
1527 case CSS_POSITION_FIXED:
1528 fprintf(stream,
"position: fixed ");
1535 val = css_computed_quotes(style, &string_list);
1536 if (val == CSS_QUOTES_STRING && string_list != NULL) {
1537 fprintf(stream,
"quotes:");
1539 while (*string_list != NULL) {
1540 fprintf(stream,
" \"%.*s\"",
1541 (
int) lwc_string_length(*string_list),
1542 lwc_string_data(*string_list));
1547 fprintf(stream,
" ");
1550 case CSS_QUOTES_NONE:
1551 fprintf(stream,
"quotes: none ");
1559 val = css_computed_right(style, &len1, &unit1);
1561 case CSS_RIGHT_AUTO:
1562 fprintf(stream,
"right: auto ");
1565 fprintf(stream,
"right: ");
1569 fprintf(stream,
" ");
1576 val = css_computed_table_layout(style);
1578 case CSS_TABLE_LAYOUT_AUTO:
1579 fprintf(stream,
"table-layout: auto ");
1581 case CSS_TABLE_LAYOUT_FIXED:
1582 fprintf(stream,
"table-layout: fixed ");
1589 val = css_computed_text_align(style);
1591 case CSS_TEXT_ALIGN_LEFT:
1592 fprintf(stream,
"text-align: left ");
1594 case CSS_TEXT_ALIGN_RIGHT:
1595 fprintf(stream,
"text-align: right ");
1597 case CSS_TEXT_ALIGN_CENTER:
1598 fprintf(stream,
"text-align: center ");
1600 case CSS_TEXT_ALIGN_JUSTIFY:
1601 fprintf(stream,
"text-align: justify ");
1603 case CSS_TEXT_ALIGN_DEFAULT:
1604 fprintf(stream,
"text-align: default ");
1606 case CSS_TEXT_ALIGN_LIBCSS_LEFT:
1607 fprintf(stream,
"text-align: -libcss-left ");
1609 case CSS_TEXT_ALIGN_LIBCSS_CENTER:
1610 fprintf(stream,
"text-align: -libcss-center ");
1612 case CSS_TEXT_ALIGN_LIBCSS_RIGHT:
1613 fprintf(stream,
"text-align: -libcss-right ");
1620 val = css_computed_text_decoration(style);
1621 if (val == CSS_TEXT_DECORATION_NONE) {
1622 fprintf(stream,
"text-decoration: none ");
1624 fprintf(stream,
"text-decoration:");
1626 if (val & CSS_TEXT_DECORATION_BLINK) {
1627 fprintf(stream,
" blink");
1629 if (val & CSS_TEXT_DECORATION_LINE_THROUGH) {
1630 fprintf(stream,
" line-through");
1632 if (val & CSS_TEXT_DECORATION_OVERLINE) {
1633 fprintf(stream,
" overline");
1635 if (val & CSS_TEXT_DECORATION_UNDERLINE) {
1636 fprintf(stream,
" underline");
1639 fprintf(stream,
" ");
1643 val = css_computed_text_indent(style, &len1, &unit1);
1645 case CSS_TEXT_INDENT_SET:
1646 fprintf(stream,
"text-indent: ");
1650 fprintf(stream,
" ");
1657 val = css_computed_text_transform(style);
1659 case CSS_TEXT_TRANSFORM_CAPITALIZE:
1660 fprintf(stream,
"text-transform: capitalize ");
1662 case CSS_TEXT_TRANSFORM_UPPERCASE:
1663 fprintf(stream,
"text-transform: uppercase ");
1665 case CSS_TEXT_TRANSFORM_LOWERCASE:
1666 fprintf(stream,
"text-transform: lowercase ");
1668 case CSS_TEXT_TRANSFORM_NONE:
1669 fprintf(stream,
"text-transform: none ");
1676 val = css_computed_top(style, &len1, &unit1);
1679 fprintf(stream,
"top: auto ");
1682 fprintf(stream,
"top: ");
1686 fprintf(stream,
" ");
1693 val = css_computed_unicode_bidi(style);
1695 case CSS_UNICODE_BIDI_NORMAL:
1696 fprintf(stream,
"unicode-bidi: normal ");
1698 case CSS_UNICODE_BIDI_EMBED:
1699 fprintf(stream,
"unicode-bidi: embed ");
1701 case CSS_UNICODE_BIDI_BIDI_OVERRIDE:
1702 fprintf(stream,
"unicode-bidi: bidi-override ");
1709 val = css_computed_vertical_align(style, &len1, &unit1);
1711 case CSS_VERTICAL_ALIGN_BASELINE:
1712 fprintf(stream,
"vertical-align: baseline ");
1714 case CSS_VERTICAL_ALIGN_SUB:
1715 fprintf(stream,
"vertical-align: sub ");
1717 case CSS_VERTICAL_ALIGN_SUPER:
1718 fprintf(stream,
"vertical-align: super ");
1720 case CSS_VERTICAL_ALIGN_TOP:
1721 fprintf(stream,
"vertical-align: top ");
1723 case CSS_VERTICAL_ALIGN_TEXT_TOP:
1724 fprintf(stream,
"vertical-align: text-top ");
1726 case CSS_VERTICAL_ALIGN_MIDDLE:
1727 fprintf(stream,
"vertical-align: middle ");
1729 case CSS_VERTICAL_ALIGN_BOTTOM:
1730 fprintf(stream,
"vertical-align: bottom ");
1732 case CSS_VERTICAL_ALIGN_TEXT_BOTTOM:
1733 fprintf(stream,
"vertical-align: text-bottom ");
1735 case CSS_VERTICAL_ALIGN_SET:
1736 fprintf(stream,
"vertical-align: ");
1740 fprintf(stream,
" ");
1747 val = css_computed_visibility(style);
1749 case CSS_VISIBILITY_VISIBLE:
1750 fprintf(stream,
"visibility: visible ");
1752 case CSS_VISIBILITY_HIDDEN:
1753 fprintf(stream,
"visibility: hidden ");
1755 case CSS_VISIBILITY_COLLAPSE:
1756 fprintf(stream,
"visibility: collapse ");
1763 val = css_computed_white_space(style);
1765 case CSS_WHITE_SPACE_NORMAL:
1766 fprintf(stream,
"white-space: normal ");
1768 case CSS_WHITE_SPACE_PRE:
1769 fprintf(stream,
"white-space: pre ");
1771 case CSS_WHITE_SPACE_NOWRAP:
1772 fprintf(stream,
"white-space: nowrap ");
1774 case CSS_WHITE_SPACE_PRE_WRAP:
1775 fprintf(stream,
"white-space: pre-wrap ");
1777 case CSS_WHITE_SPACE_PRE_LINE:
1778 fprintf(stream,
"white-space: pre-line ");
1785 val = css_computed_width(style, &len1, &unit1);
1787 case CSS_WIDTH_AUTO:
1788 fprintf(stream,
"width: auto ");
1791 fprintf(stream,
"width: ");
1795 fprintf(stream,
" ");
1802 val = css_computed_word_spacing(style, &len1, &unit1);
1804 case CSS_WORD_SPACING_NORMAL:
1805 fprintf(stream,
"word-spacing: normal ");
1807 case CSS_WORD_SPACING_SET:
1808 fprintf(stream,
"word-spacing: ");
1812 fprintf(stream,
" ");
1819 val = css_computed_z_index(style, &zindex);
1821 case CSS_Z_INDEX_AUTO:
1822 fprintf(stream,
"z-index: auto ");
1824 case CSS_Z_INDEX_SET:
1825 fprintf(stream,
"z-index: %"PRId32
" ", zindex);
1831 fprintf(stream,
"}");
static uint8_t ns_computed_min_height(const css_computed_style *style, css_fixed *length, css_unit *unit)
static uint8_t ns_computed_min_width(const css_computed_style *style, css_fixed *length, css_unit *unit)
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 ...
static void dump_css_fixed(FILE *stream, css_fixed f)
Dump a fixed point value to the stream in a textual form.
static void dump_css_unit(FILE *stream, css_fixed val, css_unit unit)
Dump a dimension to the stream in a textual form.
static void dump_css_number(FILE *stream, css_fixed val)
Dump a numeric value to the stream in a textual form.
void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
Dump a computed style style to the give file handle stream.
Netsurf additional integer type formatting macros.
Content which corresponds to a single URL.