209 |
/* read entity */ |
/* read entity */ |
210 |
offset1 = *offset_ptr; |
offset1 = *offset_ptr; |
211 |
q = name; |
q = name; |
212 |
for(;;) { |
for (;;) { |
213 |
ch1 = eb_nextc(b, *offset_ptr, (int *)offset_ptr); |
ch1 = eb_nextc(b, *offset_ptr, (int *)offset_ptr); |
214 |
if (ch1 == '\n' || ch1 == ';') |
if (ch1 == '\n' || ch1 == ';') |
215 |
break; |
break; |
247 |
|
|
248 |
static NextCharFunc get_nextc(CSSBox *box) |
static NextCharFunc get_nextc(CSSBox *box) |
249 |
{ |
{ |
250 |
switch(box->content_type) { |
switch (box->content_type) { |
251 |
case CSS_CONTENT_TYPE_STRING: |
case CSS_CONTENT_TYPE_STRING: |
252 |
return str_nextc; |
return str_nextc; |
253 |
case CSS_CONTENT_TYPE_BUFFER: |
case CSS_CONTENT_TYPE_BUFFER: |
339 |
if (table_ident_nb != 0) |
if (table_ident_nb != 0) |
340 |
return; |
return; |
341 |
|
|
342 |
for(p = css_idents; *p != '\1'; p = r + 1) { |
for (p = css_idents; *p != '\1'; p = r + 1) { |
343 |
r = p; |
r = p; |
344 |
while (*r) |
while (*r) |
345 |
r++; |
r++; |
356 |
static void set_counter(CSSContext *s, CSSIdent counter_id, int value) |
static void set_counter(CSSContext *s, CSSIdent counter_id, int value) |
357 |
{ |
{ |
358 |
CSSCounterValue *p; |
CSSCounterValue *p; |
359 |
for(p = s->counter_stack_ptr; p != s->counter_stack_base; p = p->prev) { |
for (p = s->counter_stack_ptr; p != s->counter_stack_base; p = p->prev) { |
360 |
if (p->counter_id == counter_id) { |
if (p->counter_id == counter_id) { |
361 |
p->value = value; |
p->value = value; |
362 |
} |
} |
384 |
{ |
{ |
385 |
CSSCounterValue *p, *p1; |
CSSCounterValue *p, *p1; |
386 |
|
|
387 |
for(p = s->counter_stack_ptr; p != s->counter_stack_base; p = p1) { |
for (p = s->counter_stack_ptr; p != s->counter_stack_base; p = p1) { |
388 |
p1 = p->prev; |
p1 = p->prev; |
389 |
free(p); |
free(p); |
390 |
p = p1; |
p = p1; |
396 |
static void incr_counter(CSSContext *s, CSSIdent counter_id, int incr) |
static void incr_counter(CSSContext *s, CSSIdent counter_id, int incr) |
397 |
{ |
{ |
398 |
CSSCounterValue *p; |
CSSCounterValue *p; |
399 |
for(p = s->counter_stack_ptr; p != NULL; p = p->prev) { |
for (p = s->counter_stack_ptr; p != NULL; p = p->prev) { |
400 |
if (p->counter_id == counter_id) { |
if (p->counter_id == counter_id) { |
401 |
p->value += incr; |
p->value += incr; |
402 |
return; |
return; |
409 |
static int get_counter(CSSContext *s, CSSIdent counter_id) |
static int get_counter(CSSContext *s, CSSIdent counter_id) |
410 |
{ |
{ |
411 |
CSSCounterValue *p; |
CSSCounterValue *p; |
412 |
for(p = s->counter_stack_ptr; p != NULL; p = p->prev) { |
for (p = s->counter_stack_ptr; p != NULL; p = p->prev) { |
413 |
if (p->counter_id == counter_id) { |
if (p->counter_id == counter_id) { |
414 |
return p->value; |
return p->value; |
415 |
} |
} |
436 |
ptr = (int *)((char *)state + def->struct_offset); |
ptr = (int *)((char *)state + def->struct_offset); |
437 |
if (p->value.u.val == CSS_INHERIT) { |
if (p->value.u.val == CSS_INHERIT) { |
438 |
/* XXX: invalid if pointer */ |
/* XXX: invalid if pointer */ |
439 |
switch(def->storage) { |
switch (def->storage) { |
440 |
default: |
default: |
441 |
case CSS_STORAGE_INT: |
case CSS_STORAGE_INT: |
442 |
*ptr = *(int *)((char *)state_parent + def->struct_offset); |
*ptr = *(int *)((char *)state_parent + def->struct_offset); |
449 |
if (def->storage == CSS_STORAGE_PTR) { |
if (def->storage == CSS_STORAGE_PTR) { |
450 |
*(void **)ptr = p; |
*(void **)ptr = p; |
451 |
} else { |
} else { |
452 |
switch(p->value.type) { |
switch (p->value.type) { |
453 |
case CSS_VALUE_COLOR: |
case CSS_VALUE_COLOR: |
454 |
case CSS_UNIT_NONE: |
case CSS_UNIT_NONE: |
455 |
case CSS_VALUE_INTEGER: |
case CSS_VALUE_INTEGER: |
499 |
op = e->op; |
op = e->op; |
500 |
do { |
do { |
501 |
if (attr == a->attr) { |
if (attr == a->attr) { |
502 |
switch(op) { |
switch (op) { |
503 |
case CSS_ATTR_OP_SET: |
case CSS_ATTR_OP_SET: |
504 |
return 1; |
return 1; |
505 |
case CSS_ATTR_OP_EQUAL: |
case CSS_ATTR_OP_EQUAL: |
537 |
return 0; |
return 0; |
538 |
} |
} |
539 |
|
|
540 |
switch(ss->tree_op) { |
switch (ss->tree_op) { |
541 |
case CSS_TREE_OP_DESCENDANT: |
case CSS_TREE_OP_DESCENDANT: |
542 |
box1 = box->parent; |
box1 = box->parent; |
543 |
while (box1 != NULL) { |
while (box1 != NULL) { |
632 |
|
|
633 |
buf[0] = '\0'; |
buf[0] = '\0'; |
634 |
value = &p->value; |
value = &p->value; |
635 |
for(i=0;i<p->nb_values;i++) { |
for (i = 0; i < p->nb_values; i++) { |
636 |
switch(value->type) { |
switch (value->type) { |
637 |
case CSS_VALUE_STRING: |
case CSS_VALUE_STRING: |
638 |
pstrcat(buf, sizeof(buf), value->u.str); |
pstrcat(buf, sizeof(buf), value->u.str); |
639 |
break; |
break; |
640 |
case CSS_VALUE_ATTR: |
case CSS_VALUE_ATTR: |
641 |
for(attr = box->attrs; attr != NULL; attr = attr->next) { |
for (attr = box->attrs; attr != NULL; attr = attr->next) { |
642 |
if (attr->attr == value->u.attr_id) { |
if (attr->attr == value->u.attr_id) { |
643 |
pstrcat(buf, sizeof(buf), attr->value); |
pstrcat(buf, sizeof(buf), attr->value); |
644 |
break; |
break; |
665 |
CSSPropertyValue *value = &p->value; |
CSSPropertyValue *value = &p->value; |
666 |
int counter_id, n, i; |
int counter_id, n, i; |
667 |
|
|
668 |
for(i=0;i<p->nb_values;) { |
for (i = 0; i < p->nb_values;) { |
669 |
if (value->type != CSS_VALUE_IDENT) |
if (value->type != CSS_VALUE_IDENT) |
670 |
break; |
break; |
671 |
counter_id = value->u.attr_id; |
counter_id = value->u.attr_id; |
756 |
} |
} |
757 |
|
|
758 |
/* border colors are set to color by default */ |
/* border colors are set to color by default */ |
759 |
for(i=0;i<4;i++) { |
for (i = 0; i < 4; i++) { |
760 |
if (state->border_colors[i] == COLOR_TRANSPARENT) |
if (state->border_colors[i] == COLOR_TRANSPARENT) |
761 |
state->border_colors[i] = state->color; |
state->border_colors[i] = state->color; |
762 |
} |
} |
798 |
const unsigned char *p_end; |
const unsigned char *p_end; |
799 |
|
|
800 |
p_end = p + len; |
p_end = p + len; |
801 |
for(; p < p_end; p++) { |
for (; p < p_end; p++) { |
802 |
h = ((h << 8) + p[0]) % PROPS_HASH_SIZE; |
h = ((h << 8) + p[0]) % PROPS_HASH_SIZE; |
803 |
} |
} |
804 |
return h; |
return h; |
826 |
{ |
{ |
827 |
CSSState **pp, *p; |
CSSState **pp, *p; |
828 |
pp = &s->hash_props[hash_props(props)]; |
pp = &s->hash_props[hash_props(props)]; |
829 |
for(;;) { |
for (;;) { |
830 |
p = *pp; |
p = *pp; |
831 |
if (!p) |
if (!p) |
832 |
break; |
break; |
921 |
int index, int list_style_type, int adjust) |
int index, int list_style_type, int adjust) |
922 |
{ |
{ |
923 |
/* insert marker text */ |
/* insert marker text */ |
924 |
switch(list_style_type) { |
switch (list_style_type) { |
925 |
case CSS_LIST_STYLE_TYPE_DISC: |
case CSS_LIST_STYLE_TYPE_DISC: |
926 |
strcpy(text, "o"); |
strcpy(text, "o"); |
927 |
break; |
break; |
1043 |
|
|
1044 |
counter_stack = push_counters(s); |
counter_stack = push_counters(s); |
1045 |
|
|
1046 |
for(box1 = box->u.child.first; box1 != NULL; box1 = box_next) { |
for (box1 = box->u.child.first; box1 != NULL; box1 = box_next) { |
1047 |
/* need to take next here because of :after inserted boxes */ |
/* need to take next here because of :after inserted boxes */ |
1048 |
box_next = box1->next; |
box_next = box1->next; |
1049 |
if (css_compute_block(s, box1, props) < 0) |
if (css_compute_block(s, box1, props) < 0) |
1320 |
s->ltype = FRIBIDI_TYPE_SOT; |
s->ltype = FRIBIDI_TYPE_SOT; |
1321 |
s->pos = 0; |
s->pos = 0; |
1322 |
|
|
1323 |
for(box = first_box; box != NULL; box = box->next_inline) { |
for (box = first_box; box != NULL; box = box->next_inline) { |
1324 |
bidir_compute_attributes_box(s, box); |
bidir_compute_attributes_box(s, box); |
1325 |
} |
} |
1326 |
|
|
1395 |
bidir_split.ctx = s; |
bidir_split.ctx = s; |
1396 |
bidir_split.l = l + 1; |
bidir_split.l = l + 1; |
1397 |
bidir_split.pos = 0; |
bidir_split.pos = 0; |
1398 |
for(box = first_box; box != NULL; box = box->next_inline) { |
for (box = first_box; box != NULL; box = box->next_inline) { |
1399 |
css_bidir_split_box(&bidir_split, box); |
css_bidir_split_box(&bidir_split, box); |
1400 |
} |
} |
1401 |
} |
} |
1435 |
TypeLink *p; |
TypeLink *p; |
1436 |
p = embeds; |
p = embeds; |
1437 |
printf("bidi_start:\n"); |
printf("bidi_start:\n"); |
1438 |
for(;;) { |
for (;;) { |
1439 |
printf("type=%d pos=%d len=%d level=%d\n", p->type, p->pos, p->len, p->level); |
printf("type=%d pos=%d len=%d level=%d\n", p->type, p->pos, p->len, p->level); |
1440 |
if (p->type == FRIBIDI_TYPE_EOT) |
if (p->type == FRIBIDI_TYPE_EOT) |
1441 |
break; |
break; |
1466 |
css_layout_bidir_block(s->ctx, box); |
css_layout_bidir_block(s->ctx, box); |
1467 |
} else { |
} else { |
1468 |
/* now do the layout, according to the display type */ |
/* now do the layout, according to the display type */ |
1469 |
switch(props->display) { |
switch (props->display) { |
1470 |
case CSS_DISPLAY_INLINE: |
case CSS_DISPLAY_INLINE: |
1471 |
case CSS_DISPLAY_INLINE_TABLE: |
case CSS_DISPLAY_INLINE_TABLE: |
1472 |
case CSS_DISPLAY_INLINE_BLOCK: |
case CSS_DISPLAY_INLINE_BLOCK: |
1482 |
props->display != CSS_DISPLAY_INLINE_BLOCK && |
props->display != CSS_DISPLAY_INLINE_BLOCK && |
1483 |
box->content_type == CSS_CONTENT_TYPE_CHILDS) { |
box->content_type == CSS_CONTENT_TYPE_CHILDS) { |
1484 |
/* recurse inside in same formatting context */ |
/* recurse inside in same formatting context */ |
1485 |
for(box1 = box->u.child.first; box1 != NULL; box1 = box1->next) { |
for (box1 = box->u.child.first; box1 != NULL; box1 = box1->next) { |
1486 |
ret = css_layout_bidir_box(s, box1); |
ret = css_layout_bidir_box(s, box1); |
1487 |
if (ret) |
if (ret) |
1488 |
return ret; |
return ret; |
1520 |
|
|
1521 |
s->inline_layout = 0; |
s->inline_layout = 0; |
1522 |
s->ctx = ctx; |
s->ctx = ctx; |
1523 |
for(box1 = box->u.child.first; box1 != NULL; box1 = box1->next) { |
for (box1 = box->u.child.first; box1 != NULL; box1 = box1->next) { |
1524 |
ret = css_layout_bidir_box(s, box1); |
ret = css_layout_bidir_box(s, box1); |
1525 |
if (ret) |
if (ret) |
1526 |
return ret; |
return ret; |
1542 |
int i, len2 = len / 2; |
int i, len2 = len / 2; |
1543 |
|
|
1544 |
for (i = 0; i < len2; i++) { |
for (i = 0; i < len2; i++) { |
1545 |
InlineBox tmp = str[i]; |
InlineBox tmp = str[i]; |
1546 |
str[i] = str[len - 1 - i]; |
str[i] = str[len - 1 - i]; |
1547 |
str[len - 1 - i] = tmp; |
str[len - 1 - i] = tmp; |
1548 |
} |
} |
1549 |
} |
} |
1550 |
|
|
1557 |
while (pos < len) { |
while (pos < len) { |
1558 |
if (line[pos].box->embedding_level >= level) { |
if (line[pos].box->embedding_level >= level) { |
1559 |
/* find all chars >= level */ |
/* find all chars >= level */ |
1560 |
for(p = pos + 1; p < len && line[p].box->embedding_level >= level; p++); |
for (p = pos + 1; p < len && line[p].box->embedding_level >= level; p++); |
1561 |
reverse_boxes(line + pos, p - pos); |
reverse_boxes(line + pos, p - pos); |
1562 |
pos = p + 1; |
pos = p + 1; |
1563 |
} else { |
} else { |
1661 |
/* we go down until we find no floats or enough space to put the |
/* we go down until we find no floats or enough space to put the |
1662 |
new float */ |
new float */ |
1663 |
y = s->y0 + s->y; |
y = s->y0 + s->y; |
1664 |
for(;;) { |
for (;;) { |
1665 |
x1 = s->x0; |
x1 = s->x0; |
1666 |
x2 = s->x0 + s->total_width; |
x2 = s->x0 + s->total_width; |
1667 |
y_next = MAXINT; |
y_next = MAXINT; |
1668 |
for(b1 = s->layout_state->first_float; b1 != NULL; b1 = b1->next) { |
for (b1 = s->layout_state->first_float; b1 != NULL; b1 = b1->next) { |
1669 |
if (b1->float_type != -1) { |
if (b1->float_type != -1) { |
1670 |
/* if intersection in y, then update x1 and x2 */ |
/* if intersection in y, then update x1 and x2 */ |
1671 |
y2 = b1->y + b1->height; |
y2 = b1->y + b1->height; |
1711 |
FloatBlock *b; |
FloatBlock *b; |
1712 |
int ret; |
int ret; |
1713 |
|
|
1714 |
for(b = s->layout_state->first_float; b != NULL; b = b->next) { |
for (b = s->layout_state->first_float; b != NULL; b = b->next) { |
1715 |
if (b->float_type == -1) { |
if (b->float_type == -1) { |
1716 |
ret = css_layout_float(s, b); |
ret = css_layout_float(s, b); |
1717 |
if (ret) |
if (ret) |
1821 |
baseline = 0; |
baseline = 0; |
1822 |
descent = 0; |
descent = 0; |
1823 |
level_max = 0; |
level_max = 0; |
1824 |
for(i=0;i<nb_boxes;i++) { |
for (i = 0; i < nb_boxes; i++) { |
1825 |
box = line_boxes[i].box; |
box = line_boxes[i].box; |
1826 |
props = box->props; |
props = box->props; |
1827 |
line_width += box->width; |
line_width += box->width; |
1869 |
box_table1 = line_boxes; |
box_table1 = line_boxes; |
1870 |
|
|
1871 |
/* now do the real layout ! */ |
/* now do the real layout ! */ |
1872 |
switch(line_props->text_align) { |
switch (line_props->text_align) { |
1873 |
case CSS_TEXT_ALIGN_LEFT: |
case CSS_TEXT_ALIGN_LEFT: |
1874 |
default: |
default: |
1875 |
x = 0; |
x = 0; |
1886 |
x += s->xstart; |
x += s->xstart; |
1887 |
|
|
1888 |
y = s->y; |
y = s->y; |
1889 |
for(i=0;i<nb_boxes;i++) { |
for (i = 0; i < nb_boxes; i++) { |
1890 |
ib = &box_table1[i]; |
ib = &box_table1[i]; |
1891 |
/* get next box in visual order */ |
/* get next box in visual order */ |
1892 |
box = ib->box; |
box = ib->box; |
1900 |
} |
} |
1901 |
x += left_pad; |
x += left_pad; |
1902 |
box->x = x; |
box->x = x; |
1903 |
switch(box->props->vertical_align) { |
switch (box->props->vertical_align) { |
1904 |
case CSS_VERTICAL_ALIGN_TOP: |
case CSS_VERTICAL_ALIGN_TOP: |
1905 |
box->y = y; |
box->y = y; |
1906 |
break; |
break; |
1988 |
{ |
{ |
1989 |
int i; |
int i; |
1990 |
printf("flush_word: '"); |
printf("flush_word: '"); |
1991 |
for(i=0;i<s->word_index;i++) |
for (i = 0; i < s->word_index; i++) |
1992 |
printf("%c", s->word_buf[i]); |
printf("%c", s->word_buf[i]); |
1993 |
printf("' x=%d w=%d avail=%d white_space=%d word_index=%d\n", |
printf("' x=%d w=%d avail=%d white_space=%d word_index=%d\n", |
1994 |
s->x, w, s->avail_width, props->white_space, s->word_index); |
s->x, w, s->avail_width, props->white_space, s->word_index); |
2028 |
/* try to put as much chars as possible on the |
/* try to put as much chars as possible on the |
2029 |
line (maybe none) */ |
line (maybe none) */ |
2030 |
/* XXX: use dichotomy */ |
/* XXX: use dichotomy */ |
2031 |
for(;;) { |
for (;;) { |
2032 |
s->word_index--; |
s->word_index--; |
2033 |
text_metrics(s->ctx->screen, font, &metrics, |
text_metrics(s->ctx->screen, font, &metrics, |
2034 |
s->word_buf, s->word_index); |
s->word_buf, s->word_index); |
2067 |
/* push in the stack all remaining boxes for the next line */ |
/* push in the stack all remaining boxes for the next line */ |
2068 |
if (s->box_stack_index < BOX_STACK_SIZE) |
if (s->box_stack_index < BOX_STACK_SIZE) |
2069 |
s->box_stack[s->box_stack_index++] = box_bow; |
s->box_stack[s->box_stack_index++] = box_bow; |
2070 |
for(i=s->index_bow + 1;i<s->line_pos;i++) { |
for (i = s->index_bow + 1; i < s->line_pos; i++) { |
2071 |
if (s->box_stack_index < BOX_STACK_SIZE) |
if (s->box_stack_index < BOX_STACK_SIZE) |
2072 |
s->box_stack[s->box_stack_index++] = s->line_boxes[i].box; |
s->box_stack[s->box_stack_index++] = s->line_boxes[i].box; |
2073 |
} |
} |
2118 |
descent = parent_font->descent; |
descent = parent_font->descent; |
2119 |
|
|
2120 |
/* align vertically with respect to the parent */ |
/* align vertically with respect to the parent */ |
2121 |
switch(props->vertical_align) { |
switch (props->vertical_align) { |
2122 |
case CSS_VERTICAL_ALIGN_SUPER: |
case CSS_VERTICAL_ALIGN_SUPER: |
2123 |
baseline -= (ascent * SUPER_PERCENT) / 100; |
baseline -= (ascent * SUPER_PERCENT) / 100; |
2124 |
break; |
break; |
2251 |
s->line_pos++; |
s->line_pos++; |
2252 |
} |
} |
2253 |
|
|
2254 |
for(;;) { |
for (;;) { |
2255 |
/* end of block reached ? */ |
/* end of block reached ? */ |
2256 |
if (offset >= box->u.buffer.end) { |
if (offset >= box->u.buffer.end) { |
2257 |
css_flush_fragment(s, box, props, font); |
css_flush_fragment(s, box, props, font); |
2341 |
|
|
2342 |
/* layout boxes at the end of the line if needed */ |
/* layout boxes at the end of the line if needed */ |
2343 |
/* XXX: use another function */ |
/* XXX: use another function */ |
2344 |
for(i=box_stack_base; i < s->box_stack_index; i++) { |
for (i = box_stack_base; i < s->box_stack_index; i++) { |
2345 |
css_layout_inline_box(s, s->box_stack[i], baseline); |
css_layout_inline_box(s, s->box_stack[i], baseline); |
2346 |
} |
} |
2347 |
/* remove all boxes from the stack */ |
/* remove all boxes from the stack */ |
2456 |
if (s->row != 0) |
if (s->row != 0) |
2457 |
return; |
return; |
2458 |
|
|
2459 |
for(cell = row->u.child.first; cell != NULL; |
for (cell = row->u.child.first; cell != NULL; cell = cell->next) { |
|
cell = cell->next) { |
|
2460 |
cell_props = cell->props; |
cell_props = cell->props; |
2461 |
if (cell_props->display == CSS_DISPLAY_TABLE_CELL) { |
if (cell_props->display == CSS_DISPLAY_TABLE_CELL) { |
2462 |
colspan = cell_props->column_span; |
colspan = cell_props->column_span; |
2463 |
if (colspan < 1) |
if (colspan < 1) |
2464 |
colspan = 1; |
colspan = 1; |
2465 |
for(i=0;i<colspan;i++) |
for (i = 0; i < colspan; i++) |
2466 |
allocate_column(s); |
allocate_column(s); |
2467 |
|
|
2468 |
/* if a width is specified, we use it */ |
/* if a width is specified, we use it */ |
2472 |
w = cell_props->width / colspan; |
w = cell_props->width / colspan; |
2473 |
if (w < 1) |
if (w < 1) |
2474 |
w = 1; |
w = 1; |
2475 |
for(i=0;i<colspan;i++) { |
for (i = 0; i < colspan; i++) { |
2476 |
s->cols[s->nb_cols - colspan + i].width_fixed = 1; |
s->cols[s->nb_cols - colspan + i].width_fixed = 1; |
2477 |
s->cols[s->nb_cols - colspan + i].width = |
s->cols[s->nb_cols - colspan + i].width = |
2478 |
max(w, s->cols[s->nb_cols - colspan + i].width); |
max(w, s->cols[s->nb_cols - colspan + i].width); |
2491 |
box = parent_box->u.child.first; |
box = parent_box->u.child.first; |
2492 |
while (box != NULL) { |
while (box != NULL) { |
2493 |
props = box->props; |
props = box->props; |
2494 |
switch(props->display) { |
switch (props->display) { |
2495 |
case CSS_DISPLAY_TABLE_ROW: |
case CSS_DISPLAY_TABLE_ROW: |
2496 |
layout_table_row_fixed(s, box); |
layout_table_row_fixed(s, box); |
2497 |
s->row++; |
s->row++; |
2544 |
available_width -= tl->border_h * (tl->nb_cols + 1); |
available_width -= tl->border_h * (tl->nb_cols + 1); |
2545 |
available_width1 = available_width; |
available_width1 = available_width; |
2546 |
nb_auto_cols = 0; |
nb_auto_cols = 0; |
2547 |
for(i=0;i<tl->nb_cols;i++) { |
for (i = 0; i < tl->nb_cols; i++) { |
2548 |
if (tl->cols[i].width_fixed) |
if (tl->cols[i].width_fixed) |
2549 |
available_width -= tl->cols[i].width; |
available_width -= tl->cols[i].width; |
2550 |
else |
else |
2558 |
} |
} |
2559 |
|
|
2560 |
tot_width = 0; |
tot_width = 0; |
2561 |
for(i=0;i<tl->nb_cols;i++) { |
for (i = 0; i < tl->nb_cols; i++) { |
2562 |
if (!tl->cols[i].width_fixed) |
if (!tl->cols[i].width_fixed) |
2563 |
tl->cols[i].width = cell_width; |
tl->cols[i].width = cell_width; |
2564 |
tot_width += tl->cols[i].width; |
tot_width += tl->cols[i].width; |
2594 |
|
|
2595 |
col = 0; |
col = 0; |
2596 |
cell1 = row->u.child.first; |
cell1 = row->u.child.first; |
2597 |
for(;;) { |
for (;;) { |
2598 |
/* XXX: factorize with rendering step */ |
/* XXX: factorize with rendering step */ |
2599 |
if (col < s->nb_cols) |
if (col < s->nb_cols) |
2600 |
c = &s->cols[col]; |
c = &s->cols[col]; |
2620 |
} else { |
} else { |
2621 |
/* increase number of column if needed */ |
/* increase number of column if needed */ |
2622 |
col1 = col + colspan; |
col1 = col + colspan; |
2623 |
for(i=s->nb_cols;i<col1;i++) |
for (i = s->nb_cols; i < col1; i++) |
2624 |
allocate_column(s); |
allocate_column(s); |
2625 |
|
|
2626 |
/* compute min & max size for the cell */ |
/* compute min & max size for the cell */ |
2665 |
larger enough for the cell */ |
larger enough for the cell */ |
2666 |
min_w1 = 0; |
min_w1 = 0; |
2667 |
max_w1 = 0; |
max_w1 = 0; |
2668 |
for(i=0;i<colspan;i++) { |
for (i = 0; i < colspan; i++) { |
2669 |
c->width_fixed = fixed; |
c->width_fixed = fixed; |
2670 |
min_w1 += c->min_width; |
min_w1 += c->min_width; |
2671 |
max_w1 += c->max_width; |
max_w1 += c->max_width; |
2676 |
d = delta / colspan; |
d = delta / colspan; |
2677 |
r = delta % colspan; |
r = delta % colspan; |
2678 |
c = &s->cols[col]; |
c = &s->cols[col]; |
2679 |
for(i=0;i<colspan;i++) { |
for (i = 0; i < colspan; i++) { |
2680 |
c->min_width += d; |
c->min_width += d; |
2681 |
if (i < r) |
if (i < r) |
2682 |
c->min_width++; |
c->min_width++; |
2688 |
d = delta / colspan; |
d = delta / colspan; |
2689 |
r = delta % colspan; |
r = delta % colspan; |
2690 |
c = &s->cols[col]; |
c = &s->cols[col]; |
2691 |
for(i=0;i<colspan;i++) { |
for (i = 0; i < colspan; i++) { |
2692 |
c->max_width += d; |
c->max_width += d; |
2693 |
if (i < r) |
if (i < r) |
2694 |
c->max_width++; |
c->max_width++; |
2711 |
box = parent_box->u.child.first; |
box = parent_box->u.child.first; |
2712 |
while (box != NULL) { |
while (box != NULL) { |
2713 |
props = box->props; |
props = box->props; |
2714 |
switch(props->display) { |
switch (props->display) { |
2715 |
case CSS_DISPLAY_TABLE_ROW: |
case CSS_DISPLAY_TABLE_ROW: |
2716 |
if (layout_table_row_auto(s, box) < 0) |
if (layout_table_row_auto(s, box) < 0) |
2717 |
return -1; |
return -1; |
2755 |
/* compute the minimum and maximum table width */ |
/* compute the minimum and maximum table width */ |
2756 |
min_tw = s->border_h * (s->nb_cols + 1); |
min_tw = s->border_h * (s->nb_cols + 1); |
2757 |
max_tw = min_tw; |
max_tw = min_tw; |
2758 |
for(i = 0, c = s->cols; i < s->nb_cols; i++, c++) { |
for (i = 0, c = s->cols; i < s->nb_cols; i++, c++) { |
2759 |
min_tw += c->min_width; |
min_tw += c->min_width; |
2760 |
max_tw += c->max_width; |
max_tw += c->max_width; |
2761 |
} |
} |
2788 |
|
|
2789 |
/* compute the cell widths from the computed table width */ |
/* compute the cell widths from the computed table width */ |
2790 |
if (tw < max_tw) { |
if (tw < max_tw) { |
2791 |
for(i = 0, c = s->cols; i < s->nb_cols; i++, c++) |
for (i = 0, c = s->cols; i < s->nb_cols; i++, c++) |
2792 |
c->width = c->min_width; |
c->width = c->min_width; |
2793 |
delta = tw - min_tw; |
delta = tw - min_tw; |
2794 |
} else { |
} else { |
2795 |
for(i = 0, c = s->cols; i < s->nb_cols; i++, c++) |
for (i = 0, c = s->cols; i < s->nb_cols; i++, c++) |
2796 |
c->width = c->max_width; |
c->width = c->max_width; |
2797 |
delta = tw - max_tw; |
delta = tw - max_tw; |
2798 |
} |
} |
2801 |
fast */ |
fast */ |
2802 |
d = delta / s->nb_cols; |
d = delta / s->nb_cols; |
2803 |
r = delta % s->nb_cols; |
r = delta % s->nb_cols; |
2804 |
for(i = 0, c = s->cols; i < s->nb_cols; i++, c++) { |
for (i = 0, c = s->cols; i < s->nb_cols; i++, c++) { |
2805 |
c->width += d; |
c->width += d; |
2806 |
if (i < r) |
if (i < r) |
2807 |
c->width++; |
c->width++; |
2809 |
} |
} |
2810 |
|
|
2811 |
/* init again row span left, in case the row spans were incorrect */ |
/* init again row span left, in case the row spans were incorrect */ |
2812 |
for(i = 0, c = s->cols; i < s->nb_cols; i++, c++) |
for (i = 0, c = s->cols; i < s->nb_cols; i++, c++) |
2813 |
c->row_span_left = 0; |
c->row_span_left = 0; |
2814 |
|
|
2815 |
s->table_width = tw; |
s->table_width = tw; |
2843 |
baseline = 0; |
baseline = 0; |
2844 |
cell1 = row->u.child.first; |
cell1 = row->u.child.first; |
2845 |
col = 0; |
col = 0; |
2846 |
for(;;) { |
for (;;) { |
2847 |
ColStruct *c = &s->cols[col]; |
ColStruct *c = &s->cols[col]; |
2848 |
|
|
2849 |
/* compute which cell we examine */ |
/* compute which cell we examine */ |
2870 |
if (c->row_span_left != 0) { |
if (c->row_span_left != 0) { |
2871 |
c->row_span_left--; |
c->row_span_left--; |
2872 |
/* modify x to skip column */ |
/* modify x to skip column */ |
2873 |
for(i=0;i<colspan;i++) |
for (i = 0; i < colspan; i++) |
2874 |
x += s->border_h + s->cols[col + i].width; |
x += s->border_h + s->cols[col + i].width; |
2875 |
} else { |
} else { |
2876 |
c->cell = cell; |
c->cell = cell; |
2885 |
|
|
2886 |
/* set the cell width */ |
/* set the cell width */ |
2887 |
w = s->cols[col].width; |
w = s->cols[col].width; |
2888 |
for(i=1;i<colspan;i++) |
for (i = 1; i < colspan; i++) |
2889 |
w += s->border_h + s->cols[col + i].width; |
w += s->border_h + s->cols[col + i].width; |
2890 |
|
|
2891 |
cell->width = w - props->padding.x1 - props->padding.x2 - |
cell->width = w - props->padding.x1 - props->padding.x2 - |
2917 |
/* now compute vertical position of cells if baseline and |
/* now compute vertical position of cells if baseline and |
2918 |
compute row_height */ |
compute row_height */ |
2919 |
row_height = 0; |
row_height = 0; |
2920 |
for(col = 0; col < nb_cols;) { |
for (col = 0; col < nb_cols;) { |
2921 |
ColStruct *c = &s->cols[col]; |
ColStruct *c = &s->cols[col]; |
2922 |
cell = c->cell; |
cell = c->cell; |
2923 |
colspan = cell->props->column_span; |
colspan = cell->props->column_span; |
2944 |
} |
} |
2945 |
|
|
2946 |
/* we know row_height: definitive vertical positionning */ |
/* we know row_height: definitive vertical positionning */ |
2947 |
for(col = 0; col < nb_cols;) { |
for (col = 0; col < nb_cols;) { |
2948 |
ColStruct *c = &s->cols[col]; |
ColStruct *c = &s->cols[col]; |
2949 |
int delta, cell_height; |
int delta, cell_height; |
2950 |
|
|
2952 |
cell_height = c->prev_row_height + row_height; |
cell_height = c->prev_row_height + row_height; |
2953 |
if (c->row_span_left == 0) { |
if (c->row_span_left == 0) { |
2954 |
h = c->height; |
h = c->height; |
2955 |
switch(c->vertical_align) { |
switch (c->vertical_align) { |
2956 |
case CSS_VERTICAL_ALIGN_BOTTOM: |
case CSS_VERTICAL_ALIGN_BOTTOM: |
2957 |
delta = cell_height - c->height; |
delta = cell_height - c->height; |
2958 |
cell->padding_top = delta; |
cell->padding_top = delta; |
2994 |
box = parent_box->u.child.first; |
box = parent_box->u.child.first; |
2995 |
while (box != NULL) { |
while (box != NULL) { |
2996 |
props = box->props; |
props = box->props; |
2997 |
switch(props->display) { |
switch (props->display) { |
2998 |
case CSS_DISPLAY_TABLE_ROW: |
case CSS_DISPLAY_TABLE_ROW: |
2999 |
if (render_table_row(s, box)) |
if (render_table_row(s, box)) |
3000 |
return -1; |
return -1; |
3104 |
caption_box->props->border.y2 + caption_box->props->padding.y2; |
caption_box->props->border.y2 + caption_box->props->padding.y2; |
3105 |
/* put the caption in the table margin */ |
/* put the caption in the table margin */ |
3106 |
/* XXX: potentially incorrect: table margins */ |
/* XXX: potentially incorrect: table margins */ |
3107 |
switch(caption_box->props->caption_side) { |
switch (caption_box->props->caption_side) { |
3108 |
case CSS_CAPTION_SIDE_TOP: |
case CSS_CAPTION_SIDE_TOP: |
3109 |
caption_box->x = (table_box->width - caption_box->width) / 2; |
caption_box->x = (table_box->width - caption_box->width) / 2; |
3110 |
caption_box->y = -h; |
caption_box->y = -h; |
3172 |
CSSBox *box1, *box2; |
CSSBox *box1, *box2; |
3173 |
int ret; |
int ret; |
3174 |
|
|
3175 |
for(box1 = box->u.child.first; box1 != NULL; box1 = box2) { |
for (box1 = box->u.child.first; box1 != NULL; box1 = box2) { |
3176 |
box2 = box1->next; /* need to do that first because boxes may be split */ |
box2 = box1->next; /* need to do that first because boxes may be split */ |
3177 |
ret = css_layout_block_recurse1(il, box1, baseline); |
ret = css_layout_block_recurse1(il, box1, baseline); |
3178 |
if (ret) |
if (ret) |
3227 |
} |
} |
3228 |
} else { |
} else { |
3229 |
/* now do the layout, according to the display type */ |
/* now do the layout, according to the display type */ |
3230 |
switch(props->display) { |
switch (props->display) { |
3231 |
case CSS_DISPLAY_LIST_ITEM: |
case CSS_DISPLAY_LIST_ITEM: |
3232 |
case CSS_DISPLAY_BLOCK: |
case CSS_DISPLAY_BLOCK: |
3233 |
case CSS_DISPLAY_TABLE: |
case CSS_DISPLAY_TABLE: |
3502 |
il->max_width = max(il->max_width, max_w1); |
il->max_width = max(il->max_width, max_w1); |
3503 |
} |
} |
3504 |
} else { |
} else { |
3505 |
switch(props->display) { |
switch (props->display) { |
3506 |
case CSS_DISPLAY_LIST_ITEM: |
case CSS_DISPLAY_LIST_ITEM: |
3507 |
case CSS_DISPLAY_BLOCK: |
case CSS_DISPLAY_BLOCK: |
3508 |
case CSS_DISPLAY_TABLE: |
case CSS_DISPLAY_TABLE: |
3536 |
props->display != CSS_DISPLAY_INLINE_BLOCK && |
props->display != CSS_DISPLAY_INLINE_BLOCK && |
3537 |
box->content_type == CSS_CONTENT_TYPE_CHILDS) { |
box->content_type == CSS_CONTENT_TYPE_CHILDS) { |
3538 |
CSSBox *box1, *box2; |
CSSBox *box1, *box2; |
3539 |
for(box1 = box->u.child.first; box1 != NULL; box1 = box2) { |
for (box1 = box->u.child.first; box1 != NULL; box1 = box2) { |
3540 |
box2 = box1->next; /* need to do that first because boxes may be split */ |
box2 = box1->next; /* need to do that first because boxes may be split */ |
3541 |
ret = css_layout_box_min_max(il, box1); |
ret = css_layout_box_min_max(il, box1); |
3542 |
if (ret) |
if (ret) |
3584 |
if (block_box->props->width != CSS_AUTO) |
if (block_box->props->width != CSS_AUTO) |
3585 |
il->min_width = il->max_width = block_box->props->width; |
il->min_width = il->max_width = block_box->props->width; |
3586 |
} else { |
} else { |
3587 |
for(;box != NULL; box = box1) { |
for (; box != NULL; box = box1) { |
3588 |
box1 = box->next; |
box1 = box->next; |
3589 |
ret = css_layout_box_min_max(il, box); |
ret = css_layout_box_min_max(il, box); |
3590 |
if (ret) |
if (ret) |
3725 |
int dir, i, t1, t2, u1, v1, u2, v2, u1incr, u2incr, style, w, v; |
int dir, i, t1, t2, u1, v1, u2, v2, u1incr, u2incr, style, w, v; |
3726 |
unsigned int color, color1, color2; |
unsigned int color, color1, color2; |
3727 |
|
|
3728 |
for(dir=0;dir<4;dir++) { |
for (dir = 0; dir < 4; dir++) { |
3729 |
style = props->border_styles[dir]; |
style = props->border_styles[dir]; |
3730 |
if (style == CSS_BORDER_STYLE_NONE || |
if (style == CSS_BORDER_STYLE_NONE || |
3731 |
style == CSS_BORDER_STYLE_HIDDEN) |
style == CSS_BORDER_STYLE_HIDDEN) |
3757 |
w = ((int *)&props->border)[dir]; |
w = ((int *)&props->border)[dir]; |
3758 |
if (w <= 0) |
if (w <= 0) |
3759 |
continue; |
continue; |
3760 |
switch(dir) { |
switch (dir) { |
3761 |
case 2: |
case 2: |
3762 |
case 0: |
case 0: |
3763 |
u1 = y1; |
u1 = y1; |
3777 |
u1 = u1 << BFRAC; |
u1 = u1 << BFRAC; |
3778 |
u2 = u2 << BFRAC; |
u2 = u2 << BFRAC; |
3779 |
|
|
3780 |
for(i=0;i<w;i++) { |
for (i = 0; i < w; i++) { |
3781 |
u1 += u1incr; |
u1 += u1incr; |
3782 |
u2 += u2incr; |
u2 += u2incr; |
3783 |
switch(style) { |
switch (style) { |
3784 |
case CSS_BORDER_STYLE_DASHED: /* not handled */ |
case CSS_BORDER_STYLE_DASHED: /* not handled */ |
3785 |
case CSS_BORDER_STYLE_DOTTED: /* not handled */ |
case CSS_BORDER_STYLE_DOTTED: /* not handled */ |
3786 |
case CSS_BORDER_STYLE_SOLID: |
case CSS_BORDER_STYLE_SOLID: |
3814 |
} |
} |
3815 |
t1 = u1 >> BFRAC; |
t1 = u1 >> BFRAC; |
3816 |
t2 = u2 >> BFRAC; |
t2 = u2 >> BFRAC; |
3817 |
switch(dir) { |
switch (dir) { |
3818 |
case 0: |
case 0: |
3819 |
fill_rectangle(scr, x1 - i - 1, t1, 1, t2 - t1, color); |
fill_rectangle(scr, x1 - i - 1, t1, 1, t2 - t1, color); |
3820 |
break; |
break; |
3877 |
/* slower and more complicated code for selection handling */ |
/* slower and more complicated code for selection handling */ |
3878 |
offsets[len1] = box->u.buffer.end; |
offsets[len1] = box->u.buffer.end; |
3879 |
x = x0; |
x = x0; |
3880 |
for(i=0;i<len;i++) { |
for (i = 0; i < len; i++) { |
3881 |
p = char_to_glyph_pos[i]; |
p = char_to_glyph_pos[i]; |
3882 |
offset0 = offsets[p]; |
offset0 = offsets[p]; |
3883 |
w = glyph_width(scr, font, glyphs[i]); |
w = glyph_width(scr, font, glyphs[i]); |
3891 |
} |
} |
3892 |
|
|
3893 |
x = x0; |
x = x0; |
3894 |
for(i=0;i<len;i++) { |
for (i = 0; i < len; i++) { |
3895 |
p = char_to_glyph_pos[i]; |
p = char_to_glyph_pos[i]; |
3896 |
offset0 = offsets[p]; |
offset0 = offsets[p]; |
3897 |
if (offset0 >= s->selection_start && |
if (offset0 >= s->selection_start && |
3929 |
img_props.border.y1 = 1; |
img_props.border.y1 = 1; |
3930 |
img_props.border.x2 = 1; |
img_props.border.x2 = 1; |
3931 |
img_props.border.y2 = 1; |
img_props.border.y2 = 1; |
3932 |
for(i=0;i<4;i++) { |
for (i = 0; i < 4; i++) { |
3933 |
img_props.border_colors[i] = QERGB(0, 0, 0); |
img_props.border_colors[i] = QERGB(0, 0, 0); |
3934 |
img_props.border_styles[i] = CSS_BORDER_STYLE_INSET; |
img_props.border_styles[i] = CSS_BORDER_STYLE_INSET; |
3935 |
} |
} |
4016 |
} |
} |
4017 |
|
|
4018 |
/* now display the content ! */ |
/* now display the content ! */ |
4019 |
switch(box->content_type) { |
switch (box->content_type) { |
4020 |
case CSS_CONTENT_TYPE_IMAGE: |
case CSS_CONTENT_TYPE_IMAGE: |
4021 |
box_display_image(s, box, x0, y0); |
box_display_image(s, box, x0, y0); |
4022 |
break; |
break; |
4126 |
len = box_get_text(s->ctx, line_buf, MAX_LINE_SIZE, offsets, box); |
len = box_get_text(s->ctx, line_buf, MAX_LINE_SIZE, offsets, box); |
4127 |
offsets[len] = box->u.buffer.end; |
offsets[len] = box->u.buffer.end; |
4128 |
|
|
4129 |
for(i=0;i<len;i++) { |
for (i = 0; i < len; i++) { |
4130 |
if (s->offset >= offsets[i] && s->offset < offsets[i + 1]) { |
if (s->offset >= offsets[i] && s->offset < offsets[i + 1]) { |
4131 |
posc = i; |
posc = i; |
4132 |
goto found1; |
goto found1; |
4142 |
font = css_select_font(scr, props); |
font = css_select_font(scr, props); |
4143 |
|
|
4144 |
x = 0; |
x = 0; |
4145 |
for(i=0;i<posc;i++) { |
for (i = 0; i < posc; i++) { |
4146 |
w = glyph_width(scr, font, glyphs[i]); |
w = glyph_width(scr, font, glyphs[i]); |
4147 |
x += w; |
x += w; |
4148 |
} |
} |
4228 |
dmin = MAXINT; |
dmin = MAXINT; |
4229 |
x = 0; |
x = 0; |
4230 |
posc = -1; |
posc = -1; |
4231 |
for(i=0;i<len;i++) { |
for (i = 0; i < len; i++) { |
4232 |
if (dir == 0 || |
if (dir == 0 || |
4233 |
(dir > 0 && x > xc) || |
(dir > 0 && x > xc) || |
4234 |
(dir < 0 && x < xc)) { |
(dir < 0 && x < xc)) { |
4279 |
CSSBox *b; |
CSSBox *b; |
4280 |
const char *tag; |
const char *tag; |
4281 |
|
|
4282 |
for(i=0;i<level;i++) |
for (i = 0; i < level; i++) |
4283 |
printf(" "); |
printf(" "); |
4284 |
if (box->tag == CSS_ID_NIL) { |
if (box->tag == CSS_ID_NIL) { |
4285 |
tag = "anon"; |
tag = "anon"; |
4289 |
printf("<%s x=%d y=%d w=%d h=%d el=%d>\n", |
printf("<%s x=%d y=%d w=%d h=%d el=%d>\n", |
4290 |
tag, box->x, box->y, box->width, box->height, box->embedding_level); |
tag, box->x, box->y, box->width, box->height, box->embedding_level); |
4291 |
|
|
4292 |
switch(box->content_type) { |
switch (box->content_type) { |
4293 |
case CSS_CONTENT_TYPE_CHILDS: |
case CSS_CONTENT_TYPE_CHILDS: |
4294 |
b = box->u.child.first; |
b = box->u.child.first; |
4295 |
while (b != NULL) { |
while (b != NULL) { |
4298 |
} |
} |
4299 |
break; |
break; |
4300 |
case CSS_CONTENT_TYPE_BUFFER: |
case CSS_CONTENT_TYPE_BUFFER: |
4301 |
for(i=0;i<level + 1;i++) |
for (i = 0; i < level + 1; i++) |
4302 |
printf(" "); |
printf(" "); |
4303 |
printf("[offs=%lu %lu]\n", |
printf("[offs=%lu %lu]\n", |
4304 |
box->u.buffer.start, box->u.buffer.end); |
box->u.buffer.start, box->u.buffer.end); |
4306 |
case CSS_CONTENT_TYPE_STRING: |
case CSS_CONTENT_TYPE_STRING: |
4307 |
{ |
{ |
4308 |
unsigned long ptr; |
unsigned long ptr; |
4309 |
for(i=0;i<level + 1;i++) |
for (i = 0; i < level + 1; i++) |
4310 |
printf(" "); |
printf(" "); |
4311 |
printf("'"); |
printf("'"); |
4312 |
for(ptr=box->u.buffer.start; ptr < box->u.buffer.end; ptr++) |
for (ptr = box->u.buffer.start; ptr < box->u.buffer.end; ptr++) |
4313 |
printf("%c", *(unsigned char *)ptr); |
printf("%c", *(unsigned char *)ptr); |
4314 |
printf("'\n"); |
printf("'\n"); |
4315 |
} |
} |
4318 |
printf("[IMAGE]\n"); |
printf("[IMAGE]\n"); |
4319 |
break; |
break; |
4320 |
} |
} |
4321 |
for(i=0;i<level;i++) |
for (i = 0; i < level; i++) |
4322 |
printf(" "); |
printf(" "); |
4323 |
printf("</%s>\n", tag); |
printf("</%s>\n", tag); |
4324 |
} |
} |
4371 |
CSSProperty *p1, *p; |
CSSProperty *p1, *p; |
4372 |
|
|
4373 |
while (box != NULL) { |
while (box != NULL) { |
4374 |
switch(box->content_type) { |
switch (box->content_type) { |
4375 |
case CSS_CONTENT_TYPE_CHILDS: |
case CSS_CONTENT_TYPE_CHILDS: |
4376 |
css_delete_box(box->u.child.first); |
css_delete_box(box->u.child.first); |
4377 |
break; |
break; |
4480 |
int i; |
int i; |
4481 |
CSSState *props, *props_next; |
CSSState *props, *props_next; |
4482 |
|
|
4483 |
for(i=0;i<PROPS_HASH_SIZE;i++) { |
for (i = 0; i < PROPS_HASH_SIZE; i++) { |
4484 |
for(props = s->hash_props[i]; props != NULL; props = props_next) { |
for (props = s->hash_props[i]; props != NULL; props = props_next) { |
4485 |
props_next = props->hash_next; |
props_next = props->hash_next; |
4486 |
free_props(props); |
free_props(props); |
4487 |
} |
} |