summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@src.gnome.org>2003-05-03 14:08:20 +0000
committerDodji Seketeli <dodji@src.gnome.org>2003-05-03 14:08:20 +0000
commita37a2fa4612807c2db3b83d2fa658f90a387c850 (patch)
treec0afef510e9fdd8829c556d3ad5710132e400191
parentb47fd11c9ed73f70b8621bedb3213f7b1f63af31 (diff)
downloadlibcroco-a37a2fa4612807c2db3b83d2fa658f90a387c850.tar.gz
) fixed a small bug in here.
* src/parser/cr-tknzr.c: (cr_tknzr_get_next_token ()) fixed a small bug in here. * src/layeng/cr-style.[ch]: Deeply Modified the layout of the CRStyle structure for 1/group all numerical properties together in a table. 2/group all color (rgb) properties together in another table. 3/group all border style properties together in another table. That way, accessing those properties is more efficient. 4/make sure that each properties can have 3 values: specified, computed and actual value as specified by the css2 spec. (I doubt actuall value is usefull here though). Modified the file to make this be coherent again. * src/layeng/cr-lay-eng.c : Made this coherent after the change of the CRStyle structure. (normalize_num ()):created this function to normalize numerical properties. (style_specified_2_computed_values ): new function to computed css2 "computed values" from specified values. This is required by the css2 spec in chap 6.1. (create_box_tree_real): updated this to make it call style_specified_2_computed_values () before actually building the box. Dodji.
-rw-r--r--ChangeLog28
-rw-r--r--src/layeng/cr-lay-eng.c409
-rw-r--r--src/layeng/cr-style.c412
-rw-r--r--src/layeng/cr-style.h190
-rw-r--r--src/parser/cr-tknzr.c2
5 files changed, 762 insertions, 279 deletions
diff --git a/ChangeLog b/ChangeLog
index 43d40e6..a53ffc9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2003-05-04 Dodji <dodji@seketeli.org>
+
+ * src/parser/cr-tknzr.c:
+ (cr_tknzr_get_next_token ()) fixed a small bug in here.
+
+ * src/layeng/cr-style.[ch]:
+ Deeply Modified the layout of the CRStyle structure for
+ 1/group all numerical properties together in a table.
+ 2/group all color (rgb) properties together in another table.
+ 3/group all border style properties together in another table.
+ That way, accessing those properties is more efficient.
+ 4/make sure that each properties can have 3 values:
+ specified, computed and actual value as specified by the css2 spec.
+ (I doubt actuall value is usefull
+ here though).
+ Modified the file to make this be coherent again.
+
+ * src/layeng/cr-lay-eng.c :
+ Made this coherent after the change of the CRStyle structure.
+
+ (normalize_num ()):created this function to
+ normalize numerical properties.
+ (style_specified_2_computed_values ):
+ new function to computed css2 "computed values" from specified values.
+ This is required by the css2 spec in chap 6.1.
+ (create_box_tree_real): updated this to make it call
+ style_specified_2_computed_values () before actually building the box.
+
2003-05-01 Dodji <dodji@seketeli.org>
* configure.in, csslint/Makefile.am, src/parser/Makefile.am, src/seleng/Makefile.am, src/layeng/Makefile.am:
diff --git a/src/layeng/cr-lay-eng.c b/src/layeng/cr-lay-eng.c
index 90034b8..ffda035 100644
--- a/src/layeng/cr-lay-eng.c
+++ b/src/layeng/cr-lay-eng.c
@@ -27,6 +27,7 @@
*/
#include <gnome.h>
+#include <gdk/gdk.h>
#include <string.h>
#include "cr-lay-eng.h"
#include "cr-sel-eng.h"
@@ -45,15 +46,33 @@ struct _CRLayEngPriv
gboolean update_parent_box_size ;
CRCascade *cascade ;
CRSelEng *sel_eng ;
+ gulong xdpi ;/*x resolution*/
+ gulong ydpi ; /*y resolution*/
} ;
+enum CRDirection
+{
+ DIR_UNKNOWN = 0,
+ DIR_VERTICAL,
+ DIR_HORIZONTAL
+} ;
+
static gboolean gv_layeng_initialized = FALSE ;
+static void
+init_anonymous_text_box (CRBox *a_box) ;
+
+static enum CRStatus
+style_specified_2_computed_values (CRLayEng *a_this,
+ CRStyle *a_style,
+ CRBox *a_parent_box) ;
+
static CRBox *
create_box_tree_real (CRLayEng * a_this,
xmlNode *a_root_node,
CRBox *a_parent_box) ;
+
static glong
get_box_bottommost_y (CRBox *a_this) ;
@@ -86,6 +105,12 @@ static enum CRStatus
adjust_parent_inner_edge_size (CRLayEng *a_this,
CRBox *a_cur_box) ;
+static enum CRStatus
+normalize_num (CRLayEng *a_this,
+ CRNum *a_dest_num,
+ CRNum *a_src_num,
+ enum CRDirection a_dir) ;
+
/**********************
*Private methods.
**********************/
@@ -100,40 +125,319 @@ adjust_parent_inner_edge_size (CRLayEng *a_this,
static void
init_anonymous_text_box (CRBox *a_box)
{
+ glong i = 0 ;
+
g_return_if_fail (a_box && a_box->style) ;
+
+ for (i = 0 ; i< NB_NUM_PROPS ; i++)
+ {
+ switch (i)
+ {
+ case NUM_PROP_PADDING_TOP:
+ case NUM_PROP_PADDING_RIGHT:
+ case NUM_PROP_PADDING_BOTTOM:
+ case NUM_PROP_PADDING_LEFT:
+ case NUM_PROP_BORDER_TOP:
+ case NUM_PROP_BORDER_RIGHT:
+ case NUM_PROP_BORDER_BOTTOM:
+ case NUM_PROP_BORDER_LEFT:
+ case NUM_PROP_MARGIN_TOP:
+ case NUM_PROP_MARGIN_RIGHT:
+ case NUM_PROP_MARGIN_BOTTOM:
+ case NUM_PROP_MARGIN_LEFT:
+ cr_num_set (&a_box->style->num_props[i].sv,
+ 0, NUM_LENGTH_PX) ;
+ break ;
+
+ default:
+ break ;
+ }
+
+ }
- cr_num_set (&a_box->style->padding_top, 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_box->style->padding_right, 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_box->style->padding_bottom, 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_box->style->padding_left, 0, NUM_LENGTH_PX) ;
-
- cr_num_set (&a_box->style->border_top, 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_box->style->border_right, 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_box->style->border_bottom, 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_box->style->border_left, 0, NUM_LENGTH_PX) ;
-
- cr_num_set (&a_box->style->margin_top, 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_box->style->margin_right, 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_box->style->margin_bottom, 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_box->style->margin_left, 0, NUM_LENGTH_PX) ;
-
- a_box->style->border_top_style = BORDER_STYLE_NONE ;
- a_box->style->border_right_style = BORDER_STYLE_NONE ;
- a_box->style->border_bottom_style = BORDER_STYLE_NONE ;
- a_box->style->border_left_style = BORDER_STYLE_NONE ;
-
- cr_num_set (&a_box->style->top.num, 0, NUM_LENGTH_PX) ;
- a_box->style->top.type = OFFSET_DEFINED ;
- cr_num_set (&a_box->style->right.num, 0, NUM_LENGTH_PX) ;
- a_box->style->right.type = OFFSET_DEFINED ;
- cr_num_set (&a_box->style->bottom.num, 0, NUM_LENGTH_PX) ;
- a_box->style->bottom.type = OFFSET_DEFINED ;
- cr_num_set (&a_box->style->left.num, 0, NUM_LENGTH_PX) ;
- a_box->style->left.type = OFFSET_DEFINED ;
+ for (i = 0 ; i< NB_BORDER_STYLE_PROPS ; i++)
+ {
+ a_box->style->border_style_props[i] = BORDER_STYLE_NONE ;
+ }
a_box->style->float_type = FLOAT_NONE ;
}
+
+static enum CRStatus
+normalize_num (CRLayEng *a_this,
+ CRNum *a_dest_num,
+ CRNum *a_src_num,
+ enum CRDirection a_dir)
+{
+ g_return_val_if_fail (a_this && a_dest_num
+ && a_src_num,
+ CR_BAD_PARAM_ERROR) ;
+
+ switch (a_src_num->type)
+ {
+ case NUM_LENGTH_PX:
+ cr_num_copy (a_dest_num, a_src_num) ;
+ /*a_dest_num->type = NUM_LENGTH_PX ;*/
+ break ;
+
+ case NUM_LENGTH_EM:
+ case NUM_LENGTH_EX:
+ break ;
+
+ case NUM_LENGTH_IN:
+ if (a_dir == DIR_HORIZONTAL)
+ {
+ a_dest_num->val = a_src_num->val
+ * PRIVATE (a_this)->xdpi ;
+ }
+ else if (a_dir == DIR_VERTICAL)
+ {
+ a_dest_num->val = a_src_num->val
+ * PRIVATE (a_this)->ydpi ;
+ }
+ else
+ {
+ cr_utils_trace_info ("Bad direction given") ;
+ return CR_BAD_PARAM_ERROR ;
+ }
+ a_dest_num->type = NUM_LENGTH_PX ;
+ break ;
+
+ case NUM_LENGTH_CM:
+ /*1 inch == 25.4 mm*/
+ if (a_dir == DIR_HORIZONTAL)
+ {
+ a_dest_num->val = a_src_num->val / 2.54 *
+ PRIVATE (a_this)->xdpi ;
+ }
+ else if (a_dir == DIR_VERTICAL)
+ {
+ a_dest_num->val = a_src_num->val / 2.54 *
+ PRIVATE (a_this)->ydpi ;
+ }
+ else
+ {
+ cr_utils_trace_info ("Bad direction given") ;
+ return CR_BAD_PARAM_ERROR ;
+ }
+
+ a_dest_num->type = NUM_LENGTH_PX ;
+ break ;
+
+ case NUM_LENGTH_MM:
+ /*1 inch == 25.4 mm*/
+ if (a_dir == DIR_HORIZONTAL)
+ {
+ a_dest_num->val = a_src_num->val / 25.4 *
+ PRIVATE (a_this)->xdpi ;
+ }
+ else if (a_dir == DIR_VERTICAL)
+ {
+ a_dest_num->val = a_src_num->val / 25.4 *
+ PRIVATE (a_this)->ydpi ;
+ }
+ else
+ {
+ cr_utils_trace_info ("Bad direction given") ;
+ return CR_BAD_PARAM_ERROR ;
+ }
+ a_dest_num->type = NUM_LENGTH_PX ;
+ break ;
+
+ case NUM_LENGTH_PT:
+ /*1 point == 1/72 inch*/
+ if (a_dir == DIR_HORIZONTAL)
+ {
+ a_dest_num->val = a_src_num->val *
+ PRIVATE (a_this)->xdpi / 72 ;
+ }
+ else if (a_dir == DIR_VERTICAL)
+ {
+ a_dest_num->val = a_src_num->val *
+ PRIVATE (a_this)->ydpi / 72 ;
+ }
+ else
+ {
+ cr_utils_trace_info ("Bad direction given") ;
+ return CR_BAD_PARAM_ERROR ;
+ }
+
+ a_dest_num->type = NUM_LENGTH_PX ;
+ break ;
+
+ case NUM_LENGTH_PC:
+ /*1 pica == 12 points*/
+ if (a_dir == DIR_HORIZONTAL)
+ {
+ a_dest_num->val = a_src_num->val *
+ PRIVATE (a_this)->xdpi / 72 * 12 ;
+ }
+ else if (a_dir == DIR_VERTICAL)
+ {
+ a_dest_num->val = a_src_num->val *
+ PRIVATE (a_this)->ydpi / 72 * 12 ;
+ }
+ else
+ {
+ cr_utils_trace_info ("Bad direction given") ;
+ return CR_BAD_PARAM_ERROR ;
+ }
+
+ a_dest_num->type = NUM_LENGTH_PX ;
+ break ;
+
+ case NUM_ANGLE_DEG:
+ a_dest_num->val = a_src_num->val ;
+
+ break ;
+ case NUM_ANGLE_RAD:
+ a_dest_num->val = a_src_num->val * 180 / 3.1415 ;
+ a_dest_num->type = NUM_ANGLE_DEG ;
+ break ;
+
+ case NUM_ANGLE_GRAD:
+ a_dest_num->val = a_src_num->val * 90 / 100 ;
+ a_dest_num->type = NUM_ANGLE_DEG ;
+ break ;
+
+ case NUM_TIME_MS:
+ a_dest_num->val = a_src_num->val ;
+
+ break ;
+
+ case NUM_TIME_S:
+ a_dest_num->val = a_src_num->val * 1000 ;
+ a_dest_num->type = NUM_TIME_MS ;
+ break ;
+
+ case NUM_FREQ_HZ:
+ a_dest_num->val = a_src_num->val ;
+ break ;
+
+ case NUM_FREQ_KHZ:
+ a_dest_num->val = a_src_num->val * 1000 ;
+ a_dest_num->type = NUM_FREQ_HZ ;
+ break ;
+
+ case NUM_PERCENTAGE:
+ cr_utils_trace_info ("a PERCENTAGE cannot be normalized") ;
+ return CR_BAD_PARAM_ERROR ;
+
+ default:
+
+ cr_num_copy (a_dest_num, a_src_num) ;
+ break ;
+ }
+
+ return CR_OK ;
+}
+
+static enum CRStatus
+style_specified_2_computed_values (CRLayEng *a_this,
+ CRStyle *a_style,
+ CRBox *a_parent_box)
+{
+ glong i = 0 ;
+ CRBoxEdge *parent_inner_edge = NULL;
+
+ g_return_val_if_fail (a_style && a_this,
+ CR_BAD_PARAM_ERROR) ;
+
+ /*
+ *walk thru the numerical properties (num_props) and
+ *compute their computed value.
+ */
+ for (i = 0 ; i < NB_NUM_PROPS ; i++)
+ {
+ switch (i)
+ {
+ case NUM_PROP_TOP:
+ case NUM_PROP_BOTTOM:
+ case NUM_PROP_PADDING_TOP:
+ case NUM_PROP_PADDING_BOTTOM:
+ case NUM_PROP_BORDER_TOP:
+ case NUM_PROP_BORDER_BOTTOM:
+ case NUM_PROP_MARGIN_TOP:
+ case NUM_PROP_MARGIN_BOTTOM:
+ if (a_style->num_props[i].sv.type == NUM_PERCENTAGE)
+ {
+ /*
+ *TODO: compute the computed value
+ *using the parent box size.
+ */
+ if (a_parent_box)
+ {
+ parent_inner_edge =
+ &a_parent_box->inner_edge ;
+ }
+
+ g_return_val_if_fail (parent_inner_edge,
+ CR_BAD_PARAM_ERROR) ;
+
+ a_style->num_props[i].cv.val =
+ parent_inner_edge->height *
+ a_style->num_props[i].sv.val / 100 ;
+ }
+ else
+ {
+ normalize_num (a_this,
+ &a_style->num_props[i].cv,
+ &a_style->num_props[i].sv,
+ DIR_VERTICAL) ;
+ }
+
+ break ;
+
+ case NUM_PROP_WIDTH:
+ case NUM_PROP_RIGHT:
+ case NUM_PROP_LEFT:
+ case NUM_PROP_PADDING_LEFT:
+ case NUM_PROP_PADDING_RIGHT:
+ case NUM_PROP_BORDER_LEFT:
+ case NUM_PROP_BORDER_RIGHT:
+ case NUM_PROP_MARGIN_LEFT:
+ case NUM_PROP_MARGIN_RIGHT:
+ if (a_style->num_props[i].sv.type == NUM_PERCENTAGE)
+ {
+ /*
+ *TODO: compute the computed value
+ *using the parent box size.
+ */
+ if (a_parent_box)
+ {
+ parent_inner_edge =
+ &a_parent_box->inner_edge ;
+ }
+
+ g_return_val_if_fail (parent_inner_edge,
+ CR_BAD_PARAM_ERROR) ;
+
+ a_style->num_props[i].cv.val =
+ parent_inner_edge->width *
+ a_style->num_props[i].sv.val / 100 ;
+ }
+ else
+ {
+ normalize_num (a_this,
+ &a_style->num_props[i].cv,
+ &a_style->num_props[i].sv,
+ DIR_HORIZONTAL) ;
+ }
+ break ;
+
+ default:
+ normalize_num (a_this,
+ &a_style->num_props[i].cv,
+ &a_style->num_props[i].sv,
+ DIR_UNKNOWN) ;
+ break ;
+ }
+ }
+
+ return CR_OK ;
+}
+
/**
*Creates a box sub tree from an xml node tree.
*@param a_this the current instance of #CRLayEng.
@@ -202,6 +506,9 @@ create_box_tree_real (CRLayEng * a_this,
*the positioning. The positioning will
*be updated later via the cr_box_layout() method.
*/
+ style_specified_2_computed_values
+ (a_this, style, a_parent_box) ;
+
cur_box = cr_box_new (style) ;
if (!cur_box)
{
@@ -479,20 +786,21 @@ compute_box_size (CRLayEng *a_this,
a_cur_box->border_edge.x =
a_cur_box->outer_edge.x
+
- a_cur_box->style->margin_left.val ;
+ a_cur_box->style->num_props[NUM_PROP_MARGIN_LEFT].cv.val ;
a_cur_box->border_edge.y =
a_cur_box->outer_edge.y
+
- a_cur_box->style->margin_top.val ;
+ a_cur_box->style->num_props[NUM_PROP_MARGIN_TOP].cv.val ;
a_cur_box->padding_edge.x =
a_cur_box->border_edge.x
+
- a_cur_box->style->border_left.val ;
+ a_cur_box->style->num_props[NUM_PROP_BORDER_LEFT].cv.val ;
+
a_cur_box->padding_edge.y =
a_cur_box->border_edge.y
+
- a_cur_box->style->border_top.val ;
+ a_cur_box->style->num_props[NUM_PROP_BORDER_TOP].cv.val ;
/*
*Step 2/
@@ -500,11 +808,11 @@ compute_box_size (CRLayEng *a_this,
a_cur_box->inner_edge.x =
a_cur_box->padding_edge.x
+
- a_cur_box->style->padding_left.val ;
+ a_cur_box->style->num_props[NUM_PROP_PADDING_LEFT].cv.val ;
a_cur_box->inner_edge.y =
a_cur_box->padding_edge.y
+
- a_cur_box->style->padding_left.val ;
+ a_cur_box->style->num_props[NUM_PROP_PADDING_LEFT].cv.val ;
/*
*Step 3.
@@ -566,25 +874,25 @@ compute_box_size (CRLayEng *a_this,
*(padding edge, border edge and outer edge)
******************************************/
a_cur_box->padding_edge.width = a_cur_box->inner_edge.width +
- a_cur_box->style->padding_right.val +
- a_cur_box->style->padding_left.val ;
+ a_cur_box->style->num_props[NUM_PROP_PADDING_RIGHT].cv.val +
+ a_cur_box->style->num_props[NUM_PROP_PADDING_LEFT].cv.val ;
a_cur_box->padding_edge.height = a_cur_box->inner_edge.height +
- a_cur_box->style->padding_top.val +
- a_cur_box->style->padding_bottom.val ;
+ a_cur_box->style->num_props[NUM_PROP_PADDING_TOP].cv.val +
+ a_cur_box->style->num_props[NUM_PROP_PADDING_BOTTOM].cv.val ;
a_cur_box->border_edge.width = a_cur_box->padding_edge.width +
- a_cur_box->style->border_right.val +
- a_cur_box->style->border_left.val ;
+ a_cur_box->style->num_props[NUM_PROP_BORDER_RIGHT].cv.val +
+ a_cur_box->style->num_props[NUM_PROP_BORDER_LEFT].cv.val ;
a_cur_box->border_edge.height = a_cur_box->padding_edge.height +
- a_cur_box->style->border_top.val +
- a_cur_box->style->border_bottom.val ;
+ a_cur_box->style->num_props[NUM_PROP_BORDER_TOP].cv.val +
+ a_cur_box->style->num_props[NUM_PROP_BORDER_BOTTOM].cv.val ;
a_cur_box->outer_edge.width = a_cur_box->border_edge.width +
- a_cur_box->style->margin_left.val +
- a_cur_box->style->margin_right.val ;
+ a_cur_box->style->num_props[NUM_PROP_MARGIN_LEFT].cv.val +
+ a_cur_box->style->num_props[NUM_PROP_MARGIN_RIGHT].cv.val ;
a_cur_box->outer_edge.height = a_cur_box->border_edge.height +
- a_cur_box->style->margin_top.val +
- a_cur_box->style->margin_bottom.val ;
+ a_cur_box->style->num_props[NUM_PROP_MARGIN_TOP].cv.val +
+ a_cur_box->style->num_props[NUM_PROP_MARGIN_BOTTOM].cv.val ;
return CR_OK ;
}
@@ -958,6 +1266,13 @@ cr_lay_eng_new (void)
}
memset (PRIVATE (result), 0, sizeof (CRLayEngPriv)) ;
+
+
+ PRIVATE (result)->xdpi = gdk_screen_width () /
+ gdk_screen_width_mm () * 25.4 ;
+ PRIVATE (result)->ydpi = gdk_screen_height () /
+ gdk_screen_height_mm () * 25.4 ;
+
return result ;
}
@@ -973,7 +1288,7 @@ cr_lay_eng_new (void)
enum CRStatus
cr_lay_eng_create_box_model (CRLayEng *a_this,
xmlDoc *a_doc,
- CRCascade *a_cascade,
+ CRCascade *a_cascade,
CRBoxModel **a_box_model)
{
xmlNode *root_node = NULL ;
diff --git a/src/layeng/cr-style.c b/src/layeng/cr-style.c
index 0e569c9..a90d79a 100644
--- a/src/layeng/cr-style.c
+++ b/src/layeng/cr-style.c
@@ -44,31 +44,31 @@
*/
enum CRPropertyID
{
- PROP_NOT_KNOWN,
- PROP_PADDING_TOP,
- PROP_PADDING_RIGHT,
- PROP_PADDING_BOTTOM,
- PROP_PADDING_LEFT,
- PROP_BORDER_TOP_WIDTH,
- PROP_BORDER_RIGHT_WIDTH,
- PROP_BORDER_BOTTOM_WIDTH,
- PROP_BORDER_LEFT_WIDTH,
- PROP_BORDER_TOP_STYLE,
- PROP_BORDER_RIGHT_STYLE,
- PROP_BORDER_BOTTOM_STYLE,
- PROP_BORDER_LEFT_STYLE,
- PROP_MARGIN_TOP,
- PROP_MARGIN_RIGHT,
- PROP_MARGIN_BOTTOM,
- PROP_MARGIN_LEFT,
- PROP_DISPLAY,
- PROP_POSITION,
- PROP_TOP,
- PROP_RIGHT,
- PROP_BOTTOM,
- PROP_LEFT,
- PROP_FLOAT,
- PROP_WIDTH
+ PROP_ID_NOT_KNOWN,
+ PROP_ID_PADDING_TOP,
+ PROP_ID_PADDING_RIGHT,
+ PROP_ID_PADDING_BOTTOM,
+ PROP_ID_PADDING_LEFT,
+ PROP_ID_BORDER_TOP_WIDTH,
+ PROP_ID_BORDER_RIGHT_WIDTH,
+ PROP_ID_BORDER_BOTTOM_WIDTH,
+ PROP_ID_BORDER_LEFT_WIDTH,
+ PROP_ID_BORDER_TOP_STYLE,
+ PROP_ID_BORDER_RIGHT_STYLE,
+ PROP_ID_BORDER_BOTTOM_STYLE,
+ PROP_ID_BORDER_LEFT_STYLE,
+ PROP_ID_MARGIN_TOP,
+ PROP_ID_MARGIN_RIGHT,
+ PROP_ID_MARGIN_BOTTOM,
+ PROP_ID_MARGIN_LEFT,
+ PROP_ID_DISPLAY,
+ PROP_ID_POSITION,
+ PROP_ID_TOP,
+ PROP_ID_RIGHT,
+ PROP_ID_BOTTOM,
+ PROP_ID_LEFT,
+ PROP_ID_FLOAT,
+ PROP_ID_WIDTH
} ;
@@ -77,38 +77,37 @@ typedef struct _CRPropertyDesc CRPropertyDesc ;
struct _CRPropertyDesc
{
const guchar * name ;
- enum CRPropertyID prop_id ;
+ enum CRPropertyID prop_id ;
} ;
static CRPropertyDesc gv_prop_table [] =
{
- {"padding-top", PROP_PADDING_TOP},
- {"padding-right", PROP_PADDING_RIGHT},
- {"padding-bottom", PROP_PADDING_BOTTOM},
- {"padding-left", PROP_PADDING_LEFT},
- {"border-top-width", PROP_BORDER_TOP_WIDTH},
- {"border-right-width", PROP_BORDER_RIGHT_WIDTH},
- {"border-bottom-width", PROP_BORDER_BOTTOM_WIDTH},
- {"border-left-width", PROP_BORDER_LEFT_WIDTH},
- {"border-top-style", PROP_BORDER_TOP_STYLE},
- {"border-right-style", PROP_BORDER_RIGHT_STYLE},
- {"border-bottom-style", PROP_BORDER_BOTTOM_STYLE},
- {"border-left-style", PROP_BORDER_LEFT_STYLE},
- {"margin-top", PROP_MARGIN_TOP},
- {"margin-right", PROP_MARGIN_RIGHT},
- {"margin-bottom", PROP_MARGIN_BOTTOM},
- {"margin-left", PROP_MARGIN_LEFT},
- {"display", PROP_DISPLAY},
- {"position", PROP_POSITION},
- {"top", PROP_TOP},
- {"right", PROP_RIGHT},
- {"bottom", PROP_BOTTOM},
- {"left", PROP_LEFT},
- {"float", PROP_FLOAT},
- {"width", PROP_WIDTH},
- {NULL, 0}
-
+ {"padding-top", PROP_ID_PADDING_TOP},
+ {"padding-right", PROP_ID_PADDING_RIGHT},
+ {"padding-bottom", PROP_ID_PADDING_BOTTOM},
+ {"padding-left", PROP_ID_PADDING_LEFT},
+ {"border-top-width", PROP_ID_BORDER_TOP_WIDTH},
+ {"border-right-width", PROP_ID_BORDER_RIGHT_WIDTH},
+ {"border-bottom-width", PROP_ID_BORDER_BOTTOM_WIDTH},
+ {"border-left-width", PROP_ID_BORDER_LEFT_WIDTH},
+ {"border-top-style", PROP_ID_BORDER_TOP_STYLE},
+ {"border-right-style", PROP_ID_BORDER_RIGHT_STYLE},
+ {"border-bottom-style", PROP_ID_BORDER_BOTTOM_STYLE},
+ {"border-left-style", PROP_ID_BORDER_LEFT_STYLE},
+ {"margin-top", PROP_ID_MARGIN_TOP},
+ {"margin-right", PROP_ID_MARGIN_RIGHT},
+ {"margin-bottom", PROP_ID_MARGIN_BOTTOM},
+ {"margin-left", PROP_ID_MARGIN_LEFT},
+ {"display", PROP_ID_DISPLAY},
+ {"position", PROP_ID_POSITION},
+ {"top", PROP_ID_TOP},
+ {"right", PROP_ID_RIGHT},
+ {"bottom", PROP_ID_BOTTOM},
+ {"left", PROP_ID_LEFT},
+ {"float", PROP_ID_FLOAT},
+ {"width", PROP_ID_WIDTH},
+ {NULL, 0}
} ;
/**
@@ -216,68 +215,60 @@ cr_style_init_properties (void)
static enum CRStatus
cr_style_set_props_to_defaults (CRStyle *a_this)
{
+ glong i = 0 ;
+
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ;
- cr_num_set (&a_this->padding_top,
- 0, NUM_LENGTH_PX) ;
-
- cr_num_set (&a_this->padding_top,
- 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_this->padding_right,
- 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_this->padding_bottom,
- 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_this->padding_left,
- 0, NUM_LENGTH_PX) ;
-
- cr_num_set (&a_this->border_top,
- 0, BORDER_MEDIUM) ;
- cr_num_set (&a_this->border_right,
- 0, BORDER_MEDIUM) ;
- cr_num_set (&a_this->border_bottom,
- 0, BORDER_MEDIUM) ;
- cr_num_set (&a_this->border_left,
- 0, BORDER_MEDIUM) ;
-
- /*default foreground color is black*/
- cr_rgb_set (&a_this->color, 0, 0, 0,
- FALSE) ;
- cr_rgb_set_from_rgb (&a_this->border_top_color,
- &a_this->color) ;
- cr_rgb_set_from_rgb (&a_this->border_right_color,
- &a_this->color) ;
- cr_rgb_set_from_rgb (&a_this->border_bottom_color,
- &a_this->color) ;
- cr_rgb_set_from_rgb (&a_this->border_left_color,
- &a_this->color) ;
-
- a_this->border_top_style = BORDER_STYLE_NONE ;
- a_this->border_right_style = BORDER_STYLE_NONE ;
- a_this->border_bottom_style = BORDER_STYLE_NONE ;
- a_this->border_left_style = BORDER_STYLE_NONE ;
-
- cr_num_set (&a_this->margin_top, 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_this->margin_right, 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_this->margin_bottom, 0, NUM_LENGTH_PX) ;
- cr_num_set (&a_this->margin_left, 0, NUM_LENGTH_PX) ;
+ for (i = 0 ; i < NB_NUM_PROPS ; i++)
+ {
+ switch (i)
+ {
+ case NUM_PROP_WIDTH:
+ case NUM_PROP_TOP:
+ case NUM_PROP_RIGHT:
+ case NUM_PROP_BOTTOM:
+ case NUM_PROP_LEFT:
+ cr_num_set (&a_this->num_props[i].sv,
+ 0, NUM_AUTO) ;
+ break ;
- a_this->display = DISPLAY_INLINE ;
- a_this->position = POSITION_STATIC ;
+ case NUM_PROP_PADDING_TOP:
+ case NUM_PROP_PADDING_RIGHT:
+ case NUM_PROP_PADDING_BOTTOM:
+ case NUM_PROP_PADDING_LEFT:
+ case NUM_PROP_BORDER_TOP:
+ case NUM_PROP_BORDER_RIGHT:
+ case NUM_PROP_BORDER_BOTTOM:
+ case NUM_PROP_BORDER_LEFT:
+ case NUM_PROP_MARGIN_TOP:
+ case NUM_PROP_MARGIN_RIGHT:
+ case NUM_PROP_MARGIN_BOTTOM:
+ case NUM_PROP_MARGIN_LEFT:
+ cr_num_set (&a_this->num_props[i].sv,
+ 0, NUM_LENGTH_PX) ;
+ break ;
- a_this->top.type = OFFSET_AUTO;
- cr_num_set (&a_this->top.num, 0, NUM_LENGTH_PX) ;
- a_this->right.type = OFFSET_AUTO;
- cr_num_set (&a_this->right.num, 0, NUM_LENGTH_PX) ;
- a_this->bottom.type = OFFSET_AUTO;
- cr_num_set (&a_this->bottom.num, 0, NUM_LENGTH_PX) ;
- a_this->left.type = OFFSET_AUTO;
- cr_num_set (&a_this->left.num, 0, NUM_LENGTH_PX) ;
+ default:
+ cr_utils_trace_info ("Unknown property") ;
+ break ;
+ }
+ }
- a_this->float_type = FLOAT_NONE ;
+ for (i = 0 ; i < NB_RGB_PROPS ; i++)
+ {
+ /*default color is black*/
+ cr_rgb_set (&a_this->rgb_props[i].sv, 0, 0, 0,
+ FALSE) ;
+ }
- a_this->width.type = WIDTH_AUTO ;
- cr_num_set (&a_this->width.num, 0, NUM_LENGTH_PX) ;
+ for (i = 0 ; i < NB_BORDER_STYLE_PROPS ; i++)
+ {
+ a_this->border_style_props[i] = BORDER_STYLE_NONE ;
+ }
+ a_this->display = DISPLAY_INLINE ;
+ a_this->position = POSITION_STATIC ;
+ a_this->float_type = FLOAT_NONE ;
a_this->parent_style = NULL ;
return CR_OK ;
@@ -298,7 +289,7 @@ cr_style_get_prop_id (const guchar * a_prop)
a_prop) ;
if (!raw_id)
{
- return PROP_NOT_KNOWN ;
+ return PROP_ID_NOT_KNOWN ;
}
return GPOINTER_TO_INT (raw_id) ;
}
@@ -311,9 +302,9 @@ set_prop_padding_x_from_value (CRStyle *a_style,
{
enum CRStatus status = CR_OK ;
CRNum *num_val = NULL, *parent_num_val = NULL ;
-
+
g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR) ;
-
+
if (a_value->type != TERM_NUMBER
&& a_value->type != TERM_IDENT)
return CR_BAD_PARAM_ERROR ;
@@ -321,23 +312,37 @@ set_prop_padding_x_from_value (CRStyle *a_style,
switch (a_dir)
{
case DIR_TOP:
- num_val = &a_style->padding_top ;
- parent_num_val = &a_style->parent_style->padding_top ;
+ num_val = &a_style->num_props[NUM_PROP_PADDING_TOP].sv ;
+ parent_num_val =
+ &a_style->parent_style->
+ num_props[NUM_PROP_PADDING_TOP].sv ;
break ;
case DIR_RIGHT:
- num_val = &a_style->padding_right ;
- parent_num_val = &a_style->parent_style->padding_right ;
+ num_val = &a_style->num_props[NUM_PROP_PADDING_RIGHT].sv ;
+ parent_num_val =
+ &a_style->parent_style->
+ num_props[NUM_PROP_PADDING_RIGHT].sv;
+
+ num_val = &a_style->num_props[NUM_PROP_PADDING_RIGHT].sv ;
+ parent_num_val =
+ &a_style->parent_style->
+ num_props[NUM_PROP_PADDING_RIGHT].sv ;
break ;
case DIR_BOTTOM:
- num_val = &a_style->padding_bottom ;
- parent_num_val = &a_style->parent_style->padding_bottom ;
+ num_val =
+ &a_style->num_props[NUM_PROP_PADDING_BOTTOM].sv ;
+ parent_num_val =
+ &a_style->parent_style->
+ num_props[NUM_PROP_PADDING_BOTTOM].sv ;
break ;
case DIR_LEFT:
- num_val = & a_style->padding_left ;
- parent_num_val = &a_style->parent_style->padding_left ;
+ num_val = & a_style->num_props[NUM_PROP_PADDING_LEFT].sv ;
+ parent_num_val =
+ &a_style->parent_style->
+ num_props[NUM_PROP_PADDING_LEFT].sv ;
break ;
default:
@@ -400,30 +405,33 @@ set_prop_border_x_width_from_value (CRStyle *a_style,
switch (a_dir)
{
case DIR_TOP:
- num_val = &a_style->border_top ;
+ num_val = &a_style->num_props[NUM_PROP_BORDER_TOP].sv ;
parent_num_val =
- &a_style->parent_style->border_top ;
+ &a_style->parent_style->num_props[NUM_PROP_BORDER_TOP].sv ;
break ;
case DIR_RIGHT:
num_val =
- &a_style->border_right ;
+ &a_style->num_props[NUM_PROP_BORDER_RIGHT].sv ;
parent_num_val =
- &a_style->parent_style->border_right;
+ &a_style->parent_style->
+ num_props[NUM_PROP_BORDER_RIGHT].sv ;
break ;
case DIR_BOTTOM:
- num_val = &a_style->border_bottom ;
- parent_num_val =
- &a_style->parent_style->border_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->border_left ;
+ num_val = &a_style->num_props[NUM_PROP_BORDER_LEFT].sv ;
parent_num_val =
- &a_style->parent_style->border_left;
+ &a_style->parent_style->
+ num_props[NUM_PROP_BORDER_LEFT].sv ;
break ;
default:
@@ -509,30 +517,37 @@ set_prop_border_x_style_from_value (CRStyle *a_style,
switch (a_dir)
{
case DIR_TOP:
- border_style_ptr = &a_style->border_top_style ;
+ border_style_ptr = &a_style->
+ border_style_props[BORDER_STYLE_PROP_TOP] ;
parent_border_style_ptr =
- &a_style->parent_style->border_top_style ;
+ &a_style->parent_style->
+ border_style_props[BORDER_STYLE_PROP_TOP] ;
break ;
case DIR_RIGHT:
border_style_ptr =
- &a_style->border_right_style ;
+ &a_style->border_style_props[BORDER_STYLE_PROP_RIGHT] ;
parent_border_style_ptr =
- &a_style->parent_style->border_right_style;
+ &a_style->parent_style->
+ border_style_props[BORDER_STYLE_PROP_RIGHT] ;
break ;
case DIR_BOTTOM:
- border_style_ptr = &a_style->border_bottom_style ;
+ border_style_ptr = &a_style->
+ border_style_props[BORDER_STYLE_PROP_BOTTOM] ;
parent_border_style_ptr =
- &a_style->parent_style->border_bottom_style;
+ &a_style->parent_style->
+ border_style_props[BORDER_STYLE_PROP_BOTTOM] ;
break ;
case DIR_LEFT:
- border_style_ptr = &a_style->border_left_style ;
+ border_style_ptr = &a_style->
+ border_style_props[BORDER_STYLE_PROP_LEFT] ;
parent_border_style_ptr =
- &a_style->parent_style->border_left_style;
+ &a_style->parent_style->
+ border_style_props[BORDER_STYLE_PROP_LEFT] ;
break ;
default:
@@ -632,29 +647,32 @@ set_prop_margin_x_from_value (CRStyle *a_style, CRTerm *a_value,
switch (a_dir)
{
case DIR_TOP:
- num_val = &a_style->margin_top ;
+ num_val = &a_style->num_props[NUM_PROP_MARGIN_TOP].sv ;
parent_num_val =
- &a_style->parent_style->margin_top ;
+ &a_style->parent_style->
+ num_props[NUM_PROP_MARGIN_TOP].sv ;
break ;
case DIR_RIGHT:
num_val =
- &a_style->margin_right ;
+ &a_style->num_props[NUM_PROP_MARGIN_RIGHT].sv ;
parent_num_val =
- &a_style->parent_style->margin_right ;
+ &a_style->parent_style->
+ num_props[NUM_PROP_MARGIN_RIGHT].sv ;
break ;
case DIR_BOTTOM:
- num_val = &a_style->margin_bottom ;
+ num_val = &a_style->num_props[NUM_PROP_MARGIN_BOTTOM].sv ;
parent_num_val =
- &a_style->parent_style->margin_bottom ;
+ &a_style->parent_style->num_props[NUM_PROP_MARGIN_BOTTOM].sv ;
break ;
case DIR_LEFT:
- num_val = &a_style->margin_left ;
+ num_val = &a_style->num_props[NUM_PROP_MARGIN_LEFT].sv ;
parent_num_val =
- &a_style->parent_style->margin_left ;
+ &a_style->parent_style->
+ num_props[NUM_PROP_MARGIN_LEFT].sv ;
break ;
default:
@@ -848,8 +866,8 @@ static enum CRStatus
set_prop_x_from_value (CRStyle *a_style, CRTerm *a_value,
enum CRDirection a_dir)
{
- CRBoxOffset *box_offset = NULL, *parent_box_offset = NULL ;
-
+ CRNum *box_offset = NULL, *parent_box_offset = NULL ;
+
g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR) ;
@@ -862,38 +880,45 @@ set_prop_x_from_value (CRStyle *a_style, CRTerm *a_value,
switch (a_dir)
{
case DIR_TOP:
- box_offset = &a_style->top ;
+ box_offset = &a_style->num_props[NUM_PROP_TOP].sv ;
if (a_style->parent_style)
- parent_box_offset = &a_style->parent_style->top ;
+ parent_box_offset =
+ &a_style->parent_style->
+ num_props[NUM_PROP_TOP].sv ;
break ;
+
case DIR_RIGHT:
- box_offset = &a_style->right ;
+ box_offset = &a_style->num_props[NUM_PROP_RIGHT].sv ;
if (a_style->parent_style)
- parent_box_offset = &a_style->parent_style->right ;
+ parent_box_offset = &a_style->parent_style->
+ num_props[NUM_PROP_RIGHT].sv ;
break ;
+
case DIR_BOTTOM:
- box_offset = &a_style->bottom ;
+ box_offset = &a_style->num_props[NUM_PROP_BOTTOM].sv ;
if (a_style->parent_style)
parent_box_offset =
- &a_style->parent_style->bottom;
+ &a_style->parent_style->
+ num_props[NUM_PROP_BOTTOM].sv ;
break ;
case DIR_LEFT:
- box_offset = &a_style->left ;
+ box_offset = &a_style->num_props[NUM_PROP_LEFT].sv ;
if (a_style->parent_style)
- parent_box_offset = &a_style->parent_style->left ;
+ parent_box_offset =
+ &a_style->parent_style->
+ num_props[NUM_PROP_LEFT].sv ;
break ;
default:
break ;
}
- box_offset->type = OFFSET_AUTO ;
+ box_offset->type = NUM_AUTO ;
if (a_value->type == TERM_NUMBER
&& a_value->content.num)
{
- cr_num_copy (&box_offset->num, a_value->content.num) ;
- box_offset->type = OFFSET_DEFINED ;
+ cr_num_copy (box_offset, a_value->content.num) ;
}
else if (a_value->type == TERM_IDENT
&& a_value->content.str
@@ -903,19 +928,18 @@ set_prop_x_from_value (CRStyle *a_style, CRTerm *a_value,
a_value->content.str->str,
strlen ("inherit")))
{
- cr_num_copy (&box_offset->num,
- &parent_box_offset->num) ;
- box_offset->type = OFFSET_DEFINED ;
+ cr_num_copy (box_offset,
+ parent_box_offset) ;
}
else if (!strncmp ("auto",
a_value->content.str->str,
strlen ("auto")))
{
- box_offset->type = OFFSET_AUTO ;
+ box_offset->type = NUM_AUTO ;
}
}
- return CR_OK ;
+ return CR_OK ;
}
@@ -970,7 +994,7 @@ set_prop_width (CRStyle *a_style, CRTerm *a_value)
g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR) ;
- a_style->width.type = WIDTH_AUTO ;
+ a_style->num_props[NUM_PROP_WIDTH].sv.type = NUM_AUTO ;
if (a_value->type == TERM_IDENT)
{
@@ -981,18 +1005,17 @@ set_prop_width (CRStyle *a_style, CRTerm *a_value)
a_value->content.str->str,
strlen ("auto")))
{
- a_style->width.type = WIDTH_AUTO ;
+ a_style->num_props[NUM_PROP_WIDTH].sv.type = NUM_AUTO ;
}
else if (!strncmp ("inherit",
a_value->content.str->str,
strlen ("inherit")))
{
- a_style->width.type =
- a_style->parent_style->width.type;
-
cr_num_copy
- (&a_style->width.num,
- &a_style->parent_style->width.num);
+ (&a_style->
+ num_props[NUM_PROP_WIDTH].sv,
+ &a_style->parent_style->
+ num_props[NUM_PROP_WIDTH].sv) ;
}
}
}
@@ -1000,9 +1023,8 @@ set_prop_width (CRStyle *a_style, CRTerm *a_value)
{
if (a_value->content.num)
{
- cr_num_copy (&a_style->width.num,
+ cr_num_copy (&a_style->num_props[NUM_PROP_WIDTH].sv,
a_value->content.num) ;
- a_style->width.type = WIDTH_DEFINED ;
}
}
@@ -1117,7 +1139,7 @@ cr_style_set_style_from_decl (CRStyle *a_this, CRDeclaration *a_decl,
CRTerm *value = NULL ;
enum CRStatus status = CR_OK ;
- enum CRPropertyID prop_id = PROP_NOT_KNOWN ;
+ enum CRPropertyID prop_id = PROP_ID_NOT_KNOWN ;
g_return_val_if_fail (a_this && a_decl
&& a_decl
@@ -1132,131 +1154,131 @@ cr_style_set_style_from_decl (CRStyle *a_this, CRDeclaration *a_decl,
value = a_decl->value ;
switch (prop_id)
{
- case PROP_PADDING_TOP:
+ case PROP_ID_PADDING_TOP:
status = set_prop_padding_x_from_value
(a_this, value, DIR_TOP) ;
break ;
- case PROP_PADDING_RIGHT:
+ case PROP_ID_PADDING_RIGHT:
status = set_prop_padding_x_from_value
(a_this, value, DIR_RIGHT) ;
break ;
- case PROP_PADDING_BOTTOM:
+ case PROP_ID_PADDING_BOTTOM:
status = set_prop_padding_x_from_value
(a_this, value, DIR_RIGHT) ;
break ;
- case PROP_PADDING_LEFT:
+ case PROP_ID_PADDING_LEFT:
status = set_prop_padding_x_from_value
(a_this, value, DIR_LEFT) ;
break ;
- case PROP_BORDER_TOP_WIDTH:
+ case PROP_ID_BORDER_TOP_WIDTH:
status =
set_prop_border_x_width_from_value (a_this, value,
DIR_TOP) ;
break ;
- case PROP_BORDER_RIGHT_WIDTH:
+ case PROP_ID_BORDER_RIGHT_WIDTH:
status =
set_prop_border_x_width_from_value (a_this, value,
DIR_RIGHT) ;
break ;
- case PROP_BORDER_BOTTOM_WIDTH:
+ case PROP_ID_BORDER_BOTTOM_WIDTH:
status =
set_prop_border_x_width_from_value (a_this, value,
DIR_BOTTOM) ;
break ;
- case PROP_BORDER_LEFT_WIDTH:
+ case PROP_ID_BORDER_LEFT_WIDTH:
status =
set_prop_border_x_width_from_value (a_this, value,
DIR_BOTTOM) ;
break ;
- case PROP_BORDER_TOP_STYLE:
+ case PROP_ID_BORDER_TOP_STYLE:
status =
set_prop_border_x_style_from_value (a_this, value,
DIR_TOP) ;
break ;
- case PROP_BORDER_RIGHT_STYLE:
+ case PROP_ID_BORDER_RIGHT_STYLE:
status =
set_prop_border_x_style_from_value (a_this, value,
DIR_RIGHT) ;
break ;
- case PROP_BORDER_BOTTOM_STYLE:
+ case PROP_ID_BORDER_BOTTOM_STYLE:
status =
set_prop_border_x_style_from_value (a_this, value,
DIR_BOTTOM) ;
break ;
- case PROP_BORDER_LEFT_STYLE:
+ case PROP_ID_BORDER_LEFT_STYLE:
status =
set_prop_border_x_style_from_value (a_this, value,
DIR_LEFT) ;
break ;
- case PROP_MARGIN_TOP:
+ case PROP_ID_MARGIN_TOP:
status =
set_prop_margin_x_from_value (a_this, value,
DIR_TOP) ;
break ;
- case PROP_MARGIN_RIGHT:
+ case PROP_ID_MARGIN_RIGHT:
status =
set_prop_margin_x_from_value (a_this, value,
DIR_RIGHT) ;
break ;
- case PROP_MARGIN_BOTTOM:
+ case PROP_ID_MARGIN_BOTTOM:
status =
set_prop_margin_x_from_value (a_this, value,
DIR_BOTTOM) ;
break ;
- case PROP_MARGIN_LEFT:
+ case PROP_ID_MARGIN_LEFT:
status =
set_prop_margin_x_from_value (a_this, value,
DIR_TOP) ;
break ;
- case PROP_DISPLAY:
+ case PROP_ID_DISPLAY:
status =
set_prop_display_from_value (a_this, value) ;
break ;
- case PROP_POSITION:
+ case PROP_ID_POSITION:
status = set_prop_position_from_value (a_this, value) ;
break ;
- case PROP_TOP:
+ case PROP_ID_TOP:
status = set_prop_x_from_value (a_this, value,
DIR_TOP) ;
break ;
- case PROP_RIGHT:
+ case PROP_ID_RIGHT:
status = set_prop_x_from_value (a_this, value,
DIR_RIGHT) ;
break ;
- case PROP_BOTTOM:
+ case PROP_ID_BOTTOM:
status = set_prop_x_from_value (a_this, value,
DIR_BOTTOM) ;
break ;
- case PROP_LEFT:
+ case PROP_ID_LEFT:
status = set_prop_x_from_value (a_this, value,
DIR_LEFT) ;
break ;
- case PROP_FLOAT:
+ case PROP_ID_FLOAT:
status = set_prop_float (a_this, value) ;
break ;
- case PROP_WIDTH:
+ case PROP_ID_WIDTH:
status = set_prop_width (a_this, value) ;
break ;
diff --git a/src/layeng/cr-style.h b/src/layeng/cr-style.h
index 7912a08..f7e14aa 100644
--- a/src/layeng/cr-style.h
+++ b/src/layeng/cr-style.h
@@ -119,6 +119,142 @@ struct _CRWidth
#define BORDER_MEDIUM 4
#define BORDER_THICK 6
+typedef struct _CRWidthPropVal CRWidthPropVal ;
+struct _CRWidthPropVal
+{
+ /**specified value*/
+ CRWidth sv ;
+ /**computed value*/
+ CRWidth cv ;
+ /**actual value*/
+ CRWidth av ;
+} ;
+
+/**
+ *A numerical css property value.
+ *This data type is actually split in 3 parts:
+ *1/the specified value
+ *2/the computed value
+ *3/the actual value.
+ *To understand the semantic of these three parts,
+ *see css2 spec chap 6.1 ("Specified, computed and actual values.").
+ */
+typedef struct _CRNumPropVal CRNumPropVal ;
+struct _CRNumPropVal
+{
+ /**specified value*/
+ CRNum sv ;
+ /**computed value*/
+ CRNum cv ;
+ /**actual value*/
+ CRNum av ;
+} ;
+
+/**
+ *An rgb css property value.
+ *This data type is actually split in 3 parts:
+ *1/the specified value
+ *2/the computed value
+ *3/the actual value.
+ *To understand the semantic of these three parts,
+ *see css2 spec chap 6.1 ("Specified, computed and actual values.").
+ */
+typedef struct _CRRgbPropVal CRRgbPropVal ;
+struct _CRRgbPropVal
+{
+ /**specified value*/
+ CRRgb sv ;
+ /**computed value*/
+ CRRgb cv ;
+ /**actual value*/
+ CRRgb av ;
+} ;
+
+/**
+ *A box offset css property value.
+ *This data type is actually split in 3 parts:
+ *1/the specified value
+ *2/the computed value
+ *3/the actual value.
+ *To understand the semantic of these three parts,
+ *see css2 spec chap 6.1 ("Specified, computed and actual values.").
+ */
+typedef struct _CRBoxOffsetPropVal CRBoxOffsetPropVal ;
+struct _CRBoxOffsetPropVal
+{
+ /**specified value*/
+ CRBoxOffset sv ;
+
+ /**computed value*/
+ CRRgb cv ;
+
+ /**actual value*/
+ CRRgb av ;
+} ;
+
+
+enum CRNumProp
+{
+ NUM_PROP_WIDTH = 0,
+
+ NUM_PROP_TOP,
+ NUM_PROP_RIGHT,
+ NUM_PROP_BOTTOM,
+ NUM_PROP_LEFT,
+
+ NUM_PROP_PADDING_TOP,
+ NUM_PROP_PADDING_RIGHT,
+ NUM_PROP_PADDING_BOTTOM,
+ NUM_PROP_PADDING_LEFT,
+
+ NUM_PROP_BORDER_TOP,
+ NUM_PROP_BORDER_RIGHT,
+ NUM_PROP_BORDER_BOTTOM,
+ NUM_PROP_BORDER_LEFT,
+
+ NUM_PROP_MARGIN_TOP,
+ NUM_PROP_MARGIN_RIGHT,
+ NUM_PROP_MARGIN_BOTTOM,
+ NUM_PROP_MARGIN_LEFT,
+
+ /*must be last*/
+ NB_NUM_PROPS
+} ;
+
+enum CRRgbProp
+{
+ RGB_PROP_TOP_COLOR = 0,
+ RGB_PROP_RIGHT_COLOR,
+ RGB_PROP_BOTTOM_COLOR,
+ RGB_PROP_LEFT_COLOR,
+
+ /*must be last*/
+ NB_RGB_PROPS
+} ;
+
+
+enum CRBorderStyleProp
+{
+ BORDER_STYLE_PROP_TOP = 0,
+ BORDER_STYLE_PROP_RIGHT,
+ BORDER_STYLE_PROP_BOTTOM,
+ BORDER_STYLE_PROP_LEFT,
+
+ /*must be last*/
+ NB_BORDER_STYLE_PROPS
+} ;
+
+enum CRBoxOffsetProp
+{
+ BOX_OFFSET_PROP_TOP = 0,
+ BOX_OFFSET_PROP_RIGHT,
+ BOX_OFFSET_PROP_BOTTOM,
+ BOX_OFFSET_PROP_LEFT,
+
+ /*must be last*/
+ NB_BOX_OFFSET_PROPS
+} ;
+
/**
*The css2 style class.
*Contains computed and actual values
@@ -128,35 +264,24 @@ struct _CRWidth
*/
struct _CRStyle
{
-
- /**padding properties, in pixel*/
- CRNum padding_top ;
- CRNum padding_right ;
- CRNum padding_bottom ;
- CRNum padding_left ;
-
- /**border properties*/
- CRNum border_top ;
- CRNum border_right ;
- CRNum border_bottom ;
- CRNum border_left ;
-
- CRRgb color ;
- CRRgb border_top_color ;
- CRRgb border_right_color ;
- CRRgb border_bottom_color ;
- CRRgb border_left_color ;
-
- enum CRBorderStyle border_top_style ;
- enum CRBorderStyle border_right_style ;
- enum CRBorderStyle border_bottom_style ;
- enum CRBorderStyle border_left_style ;
-
- /**margin properties, in pixel*/
- CRNum margin_top ;
- CRNum margin_right ;
- CRNum margin_bottom;
- CRNum margin_left ;
+ /**
+ *numerical properties.
+ *the properties are indexed by
+ *enum #CRNumProp.
+ */
+ CRNumPropVal num_props[NB_NUM_PROPS] ;
+
+ /**
+ *color properties.
+ *They are indexed by enum #CRRgbProp .
+ */
+ CRRgbPropVal rgb_props[NB_RGB_PROPS] ;
+
+ /**
+ *border style properties.
+ *They are indexed by enum #CRBorderStyleProp .
+ */
+ enum CRBorderStyle border_style_props[NB_BORDER_STYLE_PROPS] ;
/**box display type*/
enum CRDisplayType display ;
@@ -164,16 +289,9 @@ struct _CRStyle
/**the positioning scheme*/
enum CRPositionType position ;
- /**box offset*/
- CRBoxOffset top ;
- CRBoxOffset right ;
- CRBoxOffset bottom ;
- CRBoxOffset left ;
-
/**the float property*/
enum CRFloatType float_type ;
- CRWidth width ;
CRStyle *parent_style ;
gulong ref_count ;
} ;
diff --git a/src/parser/cr-tknzr.c b/src/parser/cr-tknzr.c
index e430709..cddedba 100644
--- a/src/parser/cr-tknzr.c
+++ b/src/parser/cr-tknzr.c
@@ -2564,7 +2564,7 @@ cr_tknzr_get_next_token (CRTknzr *a_this, CRToken **a_tk)
}
else if (next_bytes[0] == 'k'
&& next_bytes[1] == 'H'
- && next_bytes[1] == 'z')
+ && next_bytes[2] == 'z')
{
num->type = NUM_FREQ_KHZ ;
status = cr_token_set_freq