diff options
author | Dodji Seketeli <dodji@src.gnome.org> | 2003-05-11 17:58:03 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@src.gnome.org> | 2003-05-11 17:58:03 +0000 |
commit | c8291d730454e07a580942acb042c31cf644d434 (patch) | |
tree | 5ba6f7608201d219ef5220bd1c820e4185c06705 | |
parent | 43033af69e4a03c7eb4412b4be354213b87c48af (diff) | |
download | libcroco-c8291d730454e07a580942acb042c31cf644d434.tar.gz |
updated the test to reflect the new supported css2 properties.
* tests/test7-main.c: updated the test to reflect the new supported
css2 properties.
* src/layeng/cr-style.c:
(set_prop_border_x_width_from_value ()) debugged this.
(set_prop_border_x_style_from_value ()) debugged this.
* src/layeng/cr-box-view.c:
(draw_borders ()) debugged this a lot.
Dodji.
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | TODO | 6 | ||||
-rw-r--r-- | src/layeng/cr-box-view.c | 25 | ||||
-rw-r--r-- | src/layeng/cr-lay-eng.c | 12 | ||||
-rw-r--r-- | src/layeng/cr-style.c | 69 | ||||
-rw-r--r-- | tests/test7-main.c | 19 |
6 files changed, 78 insertions, 65 deletions
@@ -1,3 +1,15 @@ +2003-05-12 Dodji <dodji@seketeli.org> + + * tests/test7-main.c: updated the test to reflect the new supported + css2 properties. + + * src/layeng/cr-style.c: + (set_prop_border_x_width_from_value ()) debugged this. + (set_prop_border_x_style_from_value ()) debugged this. + + * src/layeng/cr-box-view.c: + (draw_borders ()) debugged this a lot. + 2003-05-07 Dodji <dodji@seketeli.org> * tests/test7-main.c: just added a test for the "background-color" @@ -2,10 +2,10 @@ *coding:) Go forward in the box layout (positioning/rendering) code. (hard, very hard). -This is gonna take me a coupe of months I think. +This is gonna take a coupe of months I think. Implement the style properties (of the 4 edges of the box model). - Debug the border-color-x, border-x and border-x-style properties. - debug the padding-x property + test/debug the properties used in test7 + code the shortcut properties (border, margin border-style etc ...) code the color 16 name aliases defined in the html 4.01 spec. *Doc:) diff --git a/src/layeng/cr-box-view.c b/src/layeng/cr-box-view.c index 23afbae..14ba6c3 100644 --- a/src/layeng/cr-box-view.c +++ b/src/layeng/cr-box-view.c @@ -409,10 +409,11 @@ draw_borders (CRBoxView *a_this, /* *Draw left border. */ - x0 = box->border_edge.x ; - y0 = box->padding_edge.y ; + x0 = box->border_edge.x + (box->padding_edge.x - box->border_edge.x)/2 ; + /*x0 = box->border_edge.x ;*/ + y0 = box->border_edge.y ; x1 = x0; - y1 = y0 + box->padding_edge.height ; + y1 = y0 + box->border_edge.height ; status = set_border_line_attrs (a_this, a_box, BORDER_STYLE_PROP_LEFT) ; g_return_val_if_fail (status == CR_OK, status) ; @@ -426,8 +427,10 @@ draw_borders (CRBoxView *a_this, /* *draw right border */ - x0 = box->padding_edge.x + box->padding_edge.width ; - y0 = box->padding_edge.y ; + x0 = box->padding_edge.x + box->padding_edge.width + + (box->border_edge.x + box->border_edge.width + - box->padding_edge.x - box->padding_edge.width)/2 ; + y0 = box->border_edge.y ; x1 = x0 ; /*y1 remains the same as y0*/ status = set_border_line_attrs (a_this, a_box, @@ -442,7 +445,8 @@ draw_borders (CRBoxView *a_this, *draw top border. */ x0 = box->border_edge.x ; - y0 = box->border_edge.y ; + y0 = box->border_edge.y + (box->padding_edge.y - box->border_edge.y)/2 ; + /*y0 = box->border_edge.y ;*/ x1 = x0 + box->border_edge.width ; y1 = y0 ; status = set_border_line_attrs (a_this, a_box, @@ -457,7 +461,12 @@ draw_borders (CRBoxView *a_this, *draw bottom border */ /*x0 remains the same as previous x0 ;*/ - y0 = box->padding_edge.x + box->padding_edge.height; + + y0 = box->padding_edge.y + box->padding_edge.height + + (box->border_edge.y + box->border_edge.height + - box->padding_edge.y - box->padding_edge.height)/2 ; + + /*y0 = box->padding_edge.y + box->padding_edge.height ;*/ x1 = x0 + box->border_edge.width ; y1 = y0 ; status = set_border_line_attrs (a_this, a_box, @@ -583,9 +592,9 @@ draw_box (CRBoxView *a_this, for (cur_box = a_box; cur_box ; cur_box = cur_box->next) { /*draw_margins (a_this, cur_box) ;*/ - draw_borders (a_this, cur_box) ; draw_paddings (a_this, cur_box) ; draw_inner_box (a_this, cur_box) ; + draw_borders (a_this, cur_box) ; if (cur_box->children) { diff --git a/src/layeng/cr-lay-eng.c b/src/layeng/cr-lay-eng.c index a5db5b2..91c1c30 100644 --- a/src/layeng/cr-lay-eng.c +++ b/src/layeng/cr-lay-eng.c @@ -602,6 +602,7 @@ create_box_tree_real (CRLayEng * a_this, { CRBoxContent *box_content = NULL ; xmlChar *node_text = NULL ; + CRStyle * style_dup = NULL ; if (xmlIsBlankNode (cur)) continue ; @@ -622,7 +623,16 @@ create_box_tree_real (CRLayEng * a_this, *which style inherits the style *of the parent box. */ - cur_box = cr_box_new (parent_style, TRUE) ; + style_dup = cr_style_dup (parent_style) ; + if (!style_dup) + { + cr_utils_trace_info + ("cr_style_dup " + "Maybe out of memory") ; + goto error ; + } + + cur_box = cr_box_new (style_dup, TRUE) ; if (!cur_box) { cr_utils_trace_info diff --git a/src/layeng/cr-style.c b/src/layeng/cr-style.c index 83b2d55..a12f534 100644 --- a/src/layeng/cr-style.c +++ b/src/layeng/cr-style.c @@ -422,42 +422,29 @@ set_prop_border_x_width_from_value (CRStyle *a_style, enum CRDirection a_dir) { enum CRStatus status = CR_OK ; - CRNum *num_val = NULL, *parent_num_val = NULL ; + CRNum *num_val = NULL ; g_return_val_if_fail (a_value - && a_style->parent_style, + && a_style, CR_BAD_PARAM_ERROR) ; switch (a_dir) { case DIR_TOP: num_val = &a_style->num_props[NUM_PROP_BORDER_TOP].sv ; - parent_num_val = - &a_style->parent_style->num_props[NUM_PROP_BORDER_TOP].sv ; break ; case DIR_RIGHT: num_val = &a_style->num_props[NUM_PROP_BORDER_RIGHT].sv ; - - parent_num_val = - &a_style->parent_style-> - num_props[NUM_PROP_BORDER_RIGHT].sv ; - break ; case DIR_BOTTOM: num_val = &a_style->num_props[NUM_PROP_BORDER_BOTTOM].sv ; - parent_num_val = - &a_style->parent_style-> - num_props[NUM_PROP_BORDER_BOTTOM].sv ; break ; case DIR_LEFT: num_val = &a_style->num_props[NUM_PROP_BORDER_LEFT].sv ; - parent_num_val = - &a_style->parent_style-> - num_props[NUM_PROP_BORDER_LEFT].sv ; break ; default: @@ -502,25 +489,6 @@ set_prop_border_x_width_from_value (CRStyle *a_style, return CR_UNKNOWN_TYPE_ERROR ; } - - switch (a_value->content.num->type) - { - case NUM_GENERIC: - case NUM_LENGTH_EM: - case NUM_LENGTH_EX: - case NUM_LENGTH_PX: - case NUM_LENGTH_IN: - case NUM_LENGTH_CM: - case NUM_LENGTH_MM: - case NUM_LENGTH_PT: - case NUM_LENGTH_PC: - status = cr_num_copy (num_val, a_value->content.num) ; - break ; - default : - status = CR_ERROR ; - break ; - } - return status ; } @@ -530,24 +498,20 @@ set_prop_border_x_style_from_value (CRStyle *a_style, CRTerm *a_value, enum CRDirection a_dir) { - g_return_val_if_fail (a_style && a_value, - CR_BAD_PARAM_ERROR) ; - enum CRStatus status = CR_OK ; enum CRBorderStyle *border_style_ptr, *parent_border_style_ptr ; - g_return_val_if_fail (a_value - && a_style->parent_style, + g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR) ; - + switch (a_dir) { case DIR_TOP: border_style_ptr = &a_style-> border_style_props[BORDER_STYLE_PROP_TOP] ; - parent_border_style_ptr = + parent_border_style_ptr = (a_style->parent_style)? &a_style->parent_style-> - border_style_props[BORDER_STYLE_PROP_TOP] ; + border_style_props[BORDER_STYLE_PROP_TOP]: NULL ; break ; @@ -555,25 +519,25 @@ set_prop_border_x_style_from_value (CRStyle *a_style, border_style_ptr = &a_style->border_style_props[BORDER_STYLE_PROP_RIGHT] ; - parent_border_style_ptr = + parent_border_style_ptr = (a_style->parent_style)? &a_style->parent_style-> - border_style_props[BORDER_STYLE_PROP_RIGHT] ; + border_style_props[BORDER_STYLE_PROP_RIGHT] : NULL ; break ; case DIR_BOTTOM: border_style_ptr = &a_style-> border_style_props[BORDER_STYLE_PROP_BOTTOM] ; - parent_border_style_ptr = + parent_border_style_ptr = (a_style->parent_style)? &a_style->parent_style-> - border_style_props[BORDER_STYLE_PROP_BOTTOM] ; + border_style_props[BORDER_STYLE_PROP_BOTTOM] : NULL; break ; case DIR_LEFT: border_style_ptr = &a_style-> border_style_props[BORDER_STYLE_PROP_LEFT] ; - parent_border_style_ptr = + parent_border_style_ptr = (a_style->parent_style)? &a_style->parent_style-> - border_style_props[BORDER_STYLE_PROP_LEFT] ; + border_style_props[BORDER_STYLE_PROP_LEFT] : NULL; break ; default: @@ -650,7 +614,8 @@ set_prop_border_x_style_from_value (CRStyle *a_style, a_value->content.str->str, strlen ("inherit"))) { - *border_style_ptr = *parent_border_style_ptr ; + if (parent_border_style_ptr) + *border_style_ptr = *parent_border_style_ptr ; } else { @@ -1236,7 +1201,7 @@ cr_style_set_style_from_decl (CRStyle *a_this, CRDeclaration *a_decl, break ; case PROP_ID_PADDING_BOTTOM: status = set_prop_padding_x_from_value - (a_this, value, DIR_RIGHT) ; + (a_this, value, DIR_BOTTOM) ; break ; case PROP_ID_PADDING_LEFT: @@ -1265,7 +1230,7 @@ cr_style_set_style_from_decl (CRStyle *a_this, CRDeclaration *a_decl, case PROP_ID_BORDER_LEFT_WIDTH: status = set_prop_border_x_width_from_value (a_this, value, - DIR_BOTTOM) ; + DIR_LEFT) ; break ; case PROP_ID_BORDER_TOP_STYLE: @@ -1313,7 +1278,7 @@ cr_style_set_style_from_decl (CRStyle *a_this, CRDeclaration *a_decl, case PROP_ID_MARGIN_LEFT: status = set_prop_margin_x_from_value (a_this, value, - DIR_TOP) ; + DIR_LEFT) ; break ; case PROP_ID_DISPLAY: diff --git a/tests/test7-main.c b/tests/test7-main.c index 3090f77..5afe9f5 100644 --- a/tests/test7-main.c +++ b/tests/test7-main.c @@ -53,7 +53,24 @@ const guchar *gv_xmlbuf = ; const guchar *gv_cssbuf = "INSTRUMENT { display: inline}" -"ARTICLE, HEADLINE, AUTHOR, PARA { display: block ; position: static; background-color: rgb(255,0,0)}" +"ARTICLE, HEADLINE, AUTHOR, PARA " +"{ " +" margin-top: 10px ;" +" margin-left: 10px ;" +" margin-bottom: 10px ;" +" margin-right: 10px ;" +" display: block ; " +" position: static; " +" background-color: rgb(255,0,0) ;" +" border-top-width: thick ;" +" border-top-style: solid ;" +" border-right-width: thick ;" +" border-right-style: solid ;" +" border-bottom-width: thick ;" +" border-bottom-style: solid ;" +" border-left-width: thick ;" +" border-left-style: solid ;" +"}" ; static enum CRStatus |