68 css_fixed awidth, bwidth;
74 if (a->
style == CSS_BORDER_STYLE_HIDDEN ||
75 b->
style == CSS_BORDER_STYLE_NONE)
78 if (b->
style == CSS_BORDER_STYLE_HIDDEN ||
79 a->
style == CSS_BORDER_STYLE_NONE)
85 assert(a->
unit != CSS_UNIT_EM && a->
unit != CSS_UNIT_EX);
86 assert(b->
unit != CSS_UNIT_EM && b->
unit != CSS_UNIT_EX);
87 awidth = css_unit_len2device_px(NULL, unit_len_ctx, a->
width, a->
unit);
88 bwidth = css_unit_len2device_px(NULL, unit_len_ctx, b->
width, b->
unit);
92 else if (bwidth < awidth)
97 case CSS_BORDER_STYLE_DOUBLE: impact++;
fallthrough;
99 case CSS_BORDER_STYLE_DASHED: impact++;
fallthrough;
100 case CSS_BORDER_STYLE_DOTTED: impact++;
fallthrough;
101 case CSS_BORDER_STYLE_RIDGE: impact++;
fallthrough;
102 case CSS_BORDER_STYLE_OUTSET: impact++;
fallthrough;
103 case CSS_BORDER_STYLE_GROOVE: impact++;
fallthrough;
104 case CSS_BORDER_STYLE_INSET: impact++;
fallthrough;
110 case CSS_BORDER_STYLE_DOUBLE: impact--;
fallthrough;
111 case CSS_BORDER_STYLE_SOLID: impact--;
fallthrough;
112 case CSS_BORDER_STYLE_DASHED: impact--;
fallthrough;
113 case CSS_BORDER_STYLE_DOTTED: impact--;
fallthrough;
114 case CSS_BORDER_STYLE_RIDGE: impact--;
fallthrough;
115 case CSS_BORDER_STYLE_OUTSET: impact--;
fallthrough;
116 case CSS_BORDER_STYLE_GROOVE: impact--;
fallthrough;
117 case CSS_BORDER_STYLE_INSET: impact--;
fallthrough;
182 b.
style = css_computed_border_top_style(table->
style);
183 b.
color = css_computed_border_top_color(table->
style, &b.
c);
185 b.
width = css_unit_len2device_px(table->
style, unit_len_ctx,
187 b.
unit = CSS_UNIT_PX;
221 b.
style = css_computed_border_bottom_style(row->
style);
222 b.
color = css_computed_border_bottom_color(row->
style, &b.
c);
224 b.
width = css_unit_len2device_px(row->
style, unit_len_ctx,
226 b.
unit = CSS_UNIT_PX;
236 b.
style = css_computed_border_top_style(row->
style);
237 b.
color = css_computed_border_top_color(row->
style, &b.
c);
239 b.
width = css_unit_len2device_px(row->
style, unit_len_ctx,
241 b.
unit = CSS_UNIT_PX;
245 a, *a_src, &b, b_src)) {
256 bool processed =
false;
258 while (processed ==
false) {
273 b.
style = css_computed_border_bottom_style(
275 b.
color = css_computed_border_bottom_color(
277 css_computed_border_bottom_width(c->
style,
279 b.
width = css_unit_len2device_px(
280 c->
style, unit_len_ctx,
282 b.
unit = CSS_UNIT_PX;
295 if (processed ==
false) {
297 assert(row->
prev != NULL);
332 b.
style = css_computed_border_bottom_style(group->
style);
333 b.
color = css_computed_border_bottom_color(group->
style, &b.
c);
334 css_computed_border_bottom_width(group->
style, &b.
width, &b.
unit);
335 b.
width = css_unit_len2device_px(group->
style, unit_len_ctx,
337 b.
unit = CSS_UNIT_PX;
345 if (group->
last != NULL) {
350 a, a_src) ==
false) {
351 if (row->
prev == NULL) {
359 b.
style = css_computed_border_top_style(group->
style);
360 b.
color = css_computed_border_top_color(group->
style, &b.
c);
362 b.
width = css_unit_len2device_px(group->
style, unit_len_ctx,
364 b.
unit = CSS_UNIT_PX;
368 a, *a_src, &b, b_src)) {
395 a.
style = css_computed_border_left_style(cell->
style);
396 a.
color = css_computed_border_left_color(cell->
style, &a.
c);
398 a.
width = css_unit_len2device_px(cell->
style, unit_len_ctx,
400 a.
unit = CSS_UNIT_PX;
407 if (cell->
prev == NULL) {
411 for (row = cell->
parent; row != NULL; row = row->
prev) {
424 assert(
prev != NULL);
434 b.
unit = CSS_UNIT_PX;
438 &a, a_src, &b, b_src)) {
449 while (
rows-- > 0 && row != NULL) {
451 b.
style = css_computed_border_left_style(row->
style);
452 b.
color = css_computed_border_left_color(
454 css_computed_border_left_width(
456 b.
width = css_unit_len2device_px(
457 row->
style, unit_len_ctx,
459 b.
unit = CSS_UNIT_PX;
463 &a, a_src, &b, b_src)) {
474 b.
style = css_computed_border_left_style(group->
style);
475 b.
color = css_computed_border_left_color(group->
style, &b.
c);
477 b.
width = css_unit_len2device_px(group->
style, unit_len_ctx,
479 b.
unit = CSS_UNIT_PX;
483 &a, a_src, &b, b_src)) {
489 b.
style = css_computed_border_left_style(table->
style);
490 b.
color = css_computed_border_left_color(table->
style, &b.
c);
492 b.
width = css_unit_len2device_px(table->
style, unit_len_ctx,
494 b.
unit = CSS_UNIT_PX;
498 &a, a_src, &b, b_src)) {
524 bool process_group =
false;
527 a.
style = css_computed_border_top_style(cell->
style);
528 css_computed_border_top_color(cell->
style, &a.
c);
530 a.
width = css_unit_len2device_px(cell->
style, unit_len_ctx,
532 a.
unit = CSS_UNIT_PX;
536 b.
style = css_computed_border_top_style(row->
style);
537 css_computed_border_top_color(row->
style, &b.
c);
539 b.
width = css_unit_len2device_px(row->
style, unit_len_ctx,
541 b.
unit = CSS_UNIT_PX;
549 if (row->
prev != NULL) {
552 &a, &a_src) ==
false) {
555 process_group =
true;
562 process_group =
true;
569 b.
style = css_computed_border_top_style(group->
style);
570 b.
color = css_computed_border_top_color(group->
style, &b.
c);
572 b.
width = css_unit_len2device_px(group->
style, unit_len_ctx,
574 b.
unit = CSS_UNIT_PX;
578 &a, a_src, &b, b_src)) {
583 if (group->
prev == NULL) {
586 group->
parent, &a, &a_src);
591 &a, &a_src) ==
false) {
627 a.
style = css_computed_border_right_style(cell->
style);
628 css_computed_border_right_color(cell->
style, &a.
c);
630 a.
width = css_unit_len2device_px(cell->
style, unit_len_ctx,
632 a.
unit = CSS_UNIT_PX;
638 a.
style = CSS_BORDER_STYLE_NONE;
640 a.
unit = CSS_UNIT_PX;
648 while (
rows-- > 0 && row != NULL) {
650 b.
style = css_computed_border_right_style(row->
style);
651 b.
color = css_computed_border_right_color(row->
style,
653 css_computed_border_right_width(row->
style,
656 b.
width = css_unit_len2device_px(
657 row->
style, unit_len_ctx,
659 b.
unit = CSS_UNIT_PX;
675 b.
style = css_computed_border_right_style(group->
style);
676 b.
color = css_computed_border_right_color(group->
style, &b.
c);
677 css_computed_border_right_width(group->
style,
679 b.
width = css_unit_len2device_px(group->
style, unit_len_ctx,
681 b.
unit = CSS_UNIT_PX;
685 &a, a_src, &b, b_src)) {
691 b.
style = css_computed_border_right_style(table->
style);
692 b.
color = css_computed_border_right_color(table->
style, &b.
c);
693 css_computed_border_right_width(table->
style,
695 b.
width = css_unit_len2device_px(table->
style, unit_len_ctx,
697 b.
unit = CSS_UNIT_PX;
732 a.
style = css_computed_border_bottom_style(cell->
style);
733 css_computed_border_bottom_color(cell->
style, &a.
c);
735 a.
width = css_unit_len2device_px(cell->
style, unit_len_ctx,
737 a.
unit = CSS_UNIT_PX;
740 while (
rows-- > 0 && row != NULL)
747 a.
style = CSS_BORDER_STYLE_NONE;
749 a.
unit = CSS_UNIT_PX;
757 b.
style = css_computed_border_bottom_style(row->
style);
758 b.
color = css_computed_border_bottom_color(row->
style, &b.
c);
760 b.
width = css_unit_len2device_px(row->
style, unit_len_ctx,
762 b.
unit = CSS_UNIT_PX;
766 &a, a_src, &b, b_src)) {
772 b.
style = css_computed_border_bottom_style(group->
style);
773 b.
color = css_computed_border_bottom_color(group->
style, &b.
c);
774 css_computed_border_bottom_width(group->
style,
776 b.
width = css_unit_len2device_px(group->
style, unit_len_ctx,
778 b.
unit = CSS_UNIT_PX;
782 &a, a_src, &b, b_src)) {
788 b.
style = css_computed_border_bottom_style(table->
style);
789 b.
color = css_computed_border_bottom_color(table->
style, &b.
c);
790 css_computed_border_bottom_width(table->
style,
792 b.
width = css_unit_len2device_px(table->
style, unit_len_ctx,
794 b.
unit = CSS_UNIT_PX;
798 &a, a_src, &b, b_src)) {
817 struct box *row_group, *row, *cell;
827 for (i = 0; i != table->
columns; i++) {
828 col[i].
type = COLUMN_WIDTH_UNKNOWN;
834 for (row_group = table->
children; row_group; row_group =row_group->
next)
837 enum css_width_e
type;
839 css_unit unit = CSS_UNIT_PX;
848 if (css_computed_position(cell->
style) !=
849 CSS_POSITION_ABSOLUTE &&
850 css_computed_position(cell->
style) !=
851 CSS_POSITION_FIXED) {
855 type = css_computed_width(cell->
style, &value, &unit);
858 if (
col[i].
type != COLUMN_WIDTH_FIXED &&
859 type == CSS_WIDTH_SET && unit != CSS_UNIT_PCT) {
860 col[i].
type = COLUMN_WIDTH_FIXED;
861 col[i].
width = FIXTOINT(css_unit_len2device_px(
870 if (
col[i].
type != COLUMN_WIDTH_UNKNOWN)
873 if (
type == CSS_WIDTH_SET && unit == CSS_UNIT_PCT) {
874 col[i].
type = COLUMN_WIDTH_PERCENT;
878 }
else if (
type == CSS_WIDTH_AUTO) {
879 col[i].
type = COLUMN_WIDTH_AUTO;
884 for (row_group = table->
children; row_group; row_group =row_group->
next)
887 unsigned int fixed_columns = 0,
891 int fixed_width = 0, percent_width = 0;
892 enum css_width_e
type;
894 css_unit unit = CSS_UNIT_PX;
900 for (j = i; j < i + cell->
columns; j++) {
905 for (j = 0; j != cell->
columns; j++) {
906 if (
col[i + j].
type == COLUMN_WIDTH_FIXED) {
909 }
else if (
col[i + j].
type == COLUMN_WIDTH_PERCENT) {
912 }
else if (
col[i + j].
type == COLUMN_WIDTH_AUTO) {
919 if (!unknown_columns)
922 type = css_computed_width(cell->
style, &value, &unit);
926 if (
type == CSS_WIDTH_SET && unit != CSS_UNIT_PCT &&
927 fixed_columns + unknown_columns ==
929 int width = (FIXTOFLT(css_unit_len2device_px(
933 fixed_width) / unknown_columns;
936 for (j = 0; j != cell->
columns; j++) {
937 if (
col[i + j].
type == COLUMN_WIDTH_UNKNOWN) {
938 col[i + j].
type = COLUMN_WIDTH_FIXED;
945 if (
type == CSS_WIDTH_SET && unit == CSS_UNIT_PCT &&
946 percent_columns + unknown_columns ==
948 int width = (FIXTOFLT(value) -
949 percent_width) / unknown_columns;
952 for (j = 0; j != cell->
columns; j++) {
953 if (
col[i + j].
type == COLUMN_WIDTH_UNKNOWN) {
954 col[i + j].
type = COLUMN_WIDTH_PERCENT;
962 for (i = 0; i != table->
columns; i++) {
963 if (
col[i].
type == COLUMN_WIDTH_UNKNOWN)
964 col[i].
type = COLUMN_WIDTH_AUTO;
968 for (i = 0; i != table->
columns; i++)
970 "table %p, column %u: type %s, width %i",
994 if (css_computed_border_collapse(cell->
style) ==
995 CSS_BORDER_COLLAPSE_SEPARATE) {
997 css_unit unit = CSS_UNIT_PX;
1001 css_computed_border_left_style(cell->
style);
1002 css_computed_border_left_color(cell->
style,
1004 css_computed_border_left_width(cell->
style, &
width, &unit);
1006 FIXTOINT(css_unit_len2device_px(
1007 cell->
style, unit_len_ctx,
1012 css_computed_border_top_style(cell->
style);
1013 css_computed_border_top_color(cell->
style,
1015 css_computed_border_top_width(cell->
style, &
width, &unit);
1017 FIXTOINT(css_unit_len2device_px(
1018 cell->
style, unit_len_ctx,
1023 css_computed_border_right_style(cell->
style);
1024 css_computed_border_right_color(cell->
style,
1026 css_computed_border_right_width(cell->
style, &
width, &unit);
1028 FIXTOINT(css_unit_len2device_px(
1029 cell->
style, unit_len_ctx,
1034 css_computed_border_bottom_style(cell->
style);
1035 css_computed_border_bottom_color(cell->
style,
1037 css_computed_border_bottom_width(cell->
style, &
width, &unit);
1039 FIXTOINT(css_unit_len2device_px(
1040 cell->
style, unit_len_ctx,
1058 for (side = 0; side != 4; side++) {
1059 if (cell->
border[side].
style == CSS_BORDER_STYLE_HIDDEN ||
1061 CSS_BORDER_STYLE_NONE)
box_type
Type of a struct box.
#define NSLOG(catname, level, logmsg, args...)
Container for border values during table border calculations.
enum css_border_color_e color
border-color type
css_unit unit
border-width units
enum css_border_style_e style
border-style
css_fixed width
border-width length
css_color c
border-color value
enum css_border_style_e style
border-style
css_color c
border-color value
int width
border-width (pixels)
struct box_border border[4]
Border: TOP, RIGHT, BOTTOM, LEFT.
struct box * parent
Parent box, or NULL.
struct column * col
Array of table column data for TABLE only.
struct box * children
First child box, or NULL.
struct box * prev
Previous sibling box, or NULL.
struct box * last
Last child box, or NULL.
struct box * next
Next sibling box, or NULL.
unsigned int start_column
Start column for TABLE_CELL only.
box_type type
Type of box.
css_computed_style * style
Style for this box.
unsigned int rows
Number of rows for TABLE only.
unsigned int columns
Number of columns for TABLE / TABLE_CELL.
bool positioned
Whether all of column's cells are css positioned.
int width
Preferred width of column.
enum column::@131 type
Type of column.
static void table_used_top_border_for_cell(const css_unit_ctx *unit_len_ctx, struct box *cell)
Calculate used values of border-top-{style,color,width}.
static bool table_cell_top_process_row(const css_unit_ctx *unit_len_ctx, struct box *cell, struct box *row, struct border *a, box_type *a_src)
Process a row.
static bool table_border_is_more_eyecatching(const css_unit_ctx *unit_len_ctx, const struct border *a, box_type a_src, const struct border *b, box_type b_src)
Determine if a border style is more eyecatching than another.
static void table_used_bottom_border_for_cell(const css_unit_ctx *unit_len_ctx, struct box *cell)
Calculate used values of border-bottom-{style,color,width}.
static void table_used_right_border_for_cell(const css_unit_ctx *unit_len_ctx, struct box *cell)
Calculate used values of border-right-{style,color,width}.
bool table_calculate_column_types(const css_unit_ctx *unit_len_ctx, struct box *table)
Determine the column width types for a table.
static void table_cell_top_process_table(const css_unit_ctx *unit_len_ctx, struct box *table, struct border *a, box_type *a_src)
Process a table.
static void table_used_left_border_for_cell(const css_unit_ctx *unit_len_ctx, struct box *cell)
Calculate used values of border-left-{style,color,width}.
static bool table_cell_top_process_group(const css_unit_ctx *unit_len_ctx, struct box *cell, struct box *group, struct border *a, box_type *a_src)
Process a group.
void table_used_border_for_cell(const css_unit_ctx *unit_len_ctx, struct box *cell)
Calculate used values of border-{trbl}-{style,color,width} for table cells.
Interface to HTML table processing and layout.
#define talloc_array(ctx, type, count)
Interface to a number of general purpose functionality.
#define fallthrough
switch fall through