aboutsummaryrefslogtreecommitdiffstats
path: root/table.c
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2003-05-13 17:08:19 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2003-05-13 17:08:19 +0000
commit72f0c2764dd22084dc70f9d9bbd8b060cec81e31 (patch)
tree903ca3c5f0b392b532894a759444fb5afaec3e87 /table.c
parentfix indent (diff)
downloadw3m-72f0c2764dd22084dc70f9d9bbd8b060cec81e31.tar.gz
w3m-72f0c2764dd22084dc70f9d9bbd8b060cec81e31.zip
[w3m-dev 03898] Re: table rendering
* table.c (check_relative_width): added (set_table_matrix): use check_relative_width From: Akinori Ito <aito@fw.ipsj.or.jp>
Diffstat (limited to '')
-rw-r--r--table.c79
1 files changed, 78 insertions, 1 deletions
diff --git a/table.c b/table.c
index cfb8a65..44d6e21 100644
--- a/table.c
+++ b/table.c
@@ -1,4 +1,4 @@
-/* $Id: table.c,v 1.40 2003/02/20 15:39:22 ukai Exp $ */
+/* $Id: table.c,v 1.41 2003/05/13 17:08:20 ukai Exp $ */
/*
* HTML table
*/
@@ -3491,6 +3491,81 @@ set_table_matrix0(struct table *t, int maxwidth)
}
void
+check_relative_width(struct table *t,int maxwidth)
+{
+ int i;
+ double rel_total = 0;
+ int size = t->maxcol+1;
+ double *rcolwidth = New_N(double,size);
+ struct table_cell *cell = &t->cell;
+ int n_leftcol = 0;
+
+ for (i = 0; i < size; i++)
+ rcolwidth[i] = 0;
+
+ for (i = 0; i < size; i++) {
+ if (t->fixed_width[i] < 0)
+ rcolwidth[i] = -(double)t->fixed_width[i]/100.0;
+ else if (t->fixed_width[i] > 0)
+ rcolwidth[i] = (double)t->fixed_width[i]/maxwidth;
+ else
+ n_leftcol++;
+ }
+ for (i = 0; i <= cell->maxcell; i++) {
+ if (cell->fixed_width[i] < 0) {
+ double w = -(double)cell->fixed_width[i]/100.0;
+ double r;
+ int j,k;
+ int n_leftcell = 0;
+ k = cell->col[i];
+ r = 0.0;
+ for (j = 1; j < cell->colspan[i]; j++) {
+ if (rcolwidth[j+k] > 0)
+ r += rcolwidth[j+k];
+ else
+ n_leftcell++;
+ }
+ if (w < r || (w == r && n_leftcell > 0)) {
+ cell->fixed_width[i] = -100*r;
+ }
+ else {
+ for (j = 1; j < cell->colspan[i]; j++) {
+ if (rcolwidth[j+k] == 0)
+ rcolwidth[j+k] = (w-r)/n_leftcell;
+ }
+ }
+ }
+ else if (cell->fixed_width[i] > 0) {
+ /* todo */
+ }
+ }
+ /* sanity check */
+ for (i = 0; i < size; i++)
+ rel_total += rcolwidth[i];
+
+ if ((n_leftcol == 0 && rel_total < 0.9) || 1.1 < rel_total) {
+ for (i = 0; i < size; i++) {
+ rcolwidth[i] /= rel_total;
+ }
+ for (i = 0; i < size; i++) {
+ if (t->fixed_width[i] < 0)
+ t->fixed_width[i] = -rcolwidth[i]*100;
+ }
+ for (i = 0; i <= cell->maxcell; i++) {
+ if (cell->fixed_width[i] < 0) {
+ double r;
+ int j,k;
+ k = cell->col[i];
+ r = 0.0;
+ for (j = 1; j < cell->colspan[i]; j++)
+ r += rcolwidth[j+k];
+ cell->fixed_width[i] = -r*100;
+ }
+ }
+ }
+}
+
+void
set_table_matrix(struct table *t, int width)
{
int size = t->maxcol + 1;
@@ -3510,6 +3585,8 @@ set_table_matrix(struct table *t, int width)
v_set_val(t->vector, i, 0.);
}
+ check_relative_width(t,width);
+
for (i = 0; i < size; i++) {
if (t->fixed_width[i] > 0) {
a = max(t->fixed_width[i], t->minimum_width[i]);