Changeset 4759


Ignore:
Timestamp:
02/06/11 17:42:54 (2 years ago)
Author:
jylam
Message:
  • Added fix_table and fix_tr
Location:
gaycko/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • gaycko/trunk/src/dom/dom.c

    r4758 r4759  
    8484        }else if(!strncmp(e->name, "table", 3)) { 
    8585                e->type = ELEM_TABLE; 
     86        e->specific.table = malloc(sizeof(gTable)); 
     87        e->specific.table->border   = 0; 
     88        e->specific.table->tr_count = 0; 
    8689        }else if(!strncmp(e->name, "tr", 3)) { 
    8790                e->type = ELEM_TR; 
     91        e->specific.tr    = malloc(sizeof(gTr)); 
     92        e->specific.tr->border   = 0; 
     93        e->specific.tr->td_count = 0; 
    8894        }else if(!strncmp(e->name, "td", 3)) { 
    8995                e->type = ELEM_TD; 
  • gaycko/trunk/src/dom/dom.h

    r4758 r4759  
    5555typedef struct gAttribute_ gAttribute; 
    5656 
     57struct gTable_ { 
     58    unsigned int border; 
     59        unsigned int tr_count;   
     60}; 
     61typedef struct gTable_ gTable; 
    5762 
     63struct gTr_ { 
     64    unsigned int border; 
     65        unsigned int td_count;   
     66}; 
     67typedef struct gTr_ gTr; 
    5868 
    5969typedef struct gNode_ gNode; 
    6070struct gNode_ { 
     71     
     72    /* General */ 
    6173    nodeType  type; 
    6274        char        *name; 
    6375    unsigned int level; 
     76     
     77    unsigned int children_count; 
     78    gNode   **children; 
     79     
    6480     
    6581    unsigned int attribute_count; 
     
    6783    char        *text; 
    6884     
    69     unsigned int children_count; 
    70     gNode   **children; 
     85    gNode     *parent; 
     86 
    7187     
     88    /* Rendering */ 
    7289    gProperty *properties; 
    73      
    74     gNode     *parent; 
     90    union  { 
     91        gTable *table; 
     92        gTr    *tr; 
     93    }specific; 
     94 
    7595}; 
    7696 
  • gaycko/trunk/src/render/position.c

    r4758 r4759  
    3030                    w = (node->children[c]->properties->width); 
    3131                } 
     32                gaycko_fix_table(node->children[c]); 
    3233                break; 
    3334                 
     
    3839                w+=node->children[c]->properties->width+1; 
    3940                break; 
     41                 
    4042            case ELEM_TD: 
    4143                gaycko_get_position(node->children[c], parent); 
     
    5153                w+=node->children[c]->properties->width+1; 
    5254                break; 
     55                 
    5356            case ELEM_HR: 
    5457                node->children[c]->properties->height+=1; 
     
    5659                w+=node->children[c]->properties->width+1; 
    5760                break; 
     61                 
    5862            case ELEM_H1: 
    5963            case ELEM_H2: 
     
    8387                break; 
    8488                 
     89                 
    8590            default: 
    8691                gaycko_get_position(node->children[c], node); 
     
    102107    node->properties->height = h;  
    103108} 
     109 
     110void gaycko_fix_table(gNode *table) { 
     111        unsigned int tr = 0; 
     112    table->specific.table->tr_count = 0; 
     113     
     114    for(tr = 0 ; tr < table->children_count; tr++) { 
     115        if(table->children[tr]->type == ELEM_TR) { 
     116            gaycko_fix_tr(table->children[tr]); 
     117            table->specific.table->tr_count++;  
     118        } 
     119    } 
     120     
     121} 
     122void gaycko_fix_tr(gNode *tr) { 
     123        unsigned int td = 0; 
     124    tr->specific.tr->td_count = 0; 
     125     
     126    for(td = 0 ; td < tr->children_count; td++) { 
     127        if(tr->children[td]->type == ELEM_TD) { 
     128            tr->specific.tr->td_count++;  
     129        } 
     130    } 
     131}     
     132     
     133     
     134     
     135     
     136     
  • gaycko/trunk/src/render/renderer.h

    r4753 r4759  
    2626void gaycko_get_position      (gNode *node, gNode *parent); 
    2727 
     28void gaycko_fix_table(gNode *table); 
     29void gaycko_fix_tr(gNode *tr); 
     30 
    2831void gaycko_print_dom(gWindow *window); 
    2932void gaycko_print_node(gNode *node,gWindow *window); 
     33 
     34 
    3035 
    3136#endif /* RENDERER_H */ 
  • gaycko/trunk/tests/table.html

    r4752 r4759  
    55<table width=50%> 
    66<tr><td> Cell1 </td><td> Cell2</td></tr> 
    7 <tr><td> Cell3 </td><td> Cell4</td></tr> 
     7<tr><td> Cell3 plus grande</td><td> Cell4</td></tr> 
    88</table> 
    99</body> 
Note: See TracChangeset for help on using the changeset viewer.