changeset 591:a5ef7f8d14c5

remove previously introduced shortcut properties as they break the cascade
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Fri, 14 Nov 2008 16:35:29 +0100
parents eb1072890045
children 102e682c1196
files src/css.hh src/cssparser.cc src/styleengine.cc src/table.cc
diffstat 4 files changed, 63 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/src/css.hh	Fri Nov 14 16:16:25 2008 +0100
+++ b/src/css.hh	Fri Nov 14 16:35:29 2008 +0100
@@ -60,7 +60,6 @@
          CSS_PROPERTY_BORDER_BOTTOM_STYLE,
          CSS_PROPERTY_BORDER_BOTTOM_WIDTH,
          CSS_PROPERTY_BORDER_COLLAPSE,
-         CSS_PROPERTY_BORDER_COLOR,
          CSS_PROPERTY_BORDER_LEFT_COLOR,
          CSS_PROPERTY_BORDER_LEFT_STYLE,
          CSS_PROPERTY_BORDER_LEFT_WIDTH,
@@ -68,11 +67,9 @@
          CSS_PROPERTY_BORDER_RIGHT_STYLE,
          CSS_PROPERTY_BORDER_RIGHT_WIDTH,
          CSS_PROPERTY_BORDER_SPACING,
-         CSS_PROPERTY_BORDER_STYLE,
          CSS_PROPERTY_BORDER_TOP_COLOR,
          CSS_PROPERTY_BORDER_TOP_STYLE,
          CSS_PROPERTY_BORDER_TOP_WIDTH,
-         CSS_PROPERTY_BORDER_WIDTH,
          CSS_PROPERTY_BOTTOM,
          CSS_PROPERTY_CAPTION_SIDE,
          CSS_PROPERTY_CLEAR,
@@ -100,7 +97,6 @@
          CSS_PROPERTY_LIST_STYLE_IMAGE,
          CSS_PROPERTY_LIST_STYLE_POSITION,
          CSS_PROPERTY_LIST_STYLE_TYPE,
-         CSS_PROPERTY_MARGIN,
          CSS_PROPERTY_MARGIN_BOTTOM,
          CSS_PROPERTY_MARGIN_LEFT,
          CSS_PROPERTY_MARGIN_RIGHT,
@@ -115,7 +111,6 @@
          CSS_PROPERTY_OUTLINE_STYLE,
          CSS_PROPERTY_OUTLINE_WIDTH,
          CSS_PROPERTY_OVERFLOW,
-         CSS_PROPERTY_PADDING,
          CSS_PROPERTY_PADDING_BOTTOM,
          CSS_PROPERTY_PADDING_LEFT,
          CSS_PROPERTY_PADDING_RIGHT,
--- a/src/cssparser.cc	Fri Nov 14 16:16:25 2008 +0100
+++ b/src/cssparser.cc	Fri Nov 14 16:35:29 2008 +0100
@@ -75,7 +75,6 @@
    { "border-bottom-style", CSS_TYPE_ENUM, Css_border_style_enum_vals },
    { "border-bottom-width", CSS_TYPE_LENGTH, NULL },
    { "border-collapse", CSS_TYPE_UNUSED, NULL },
-   { "border-color", CSS_TYPE_UNUSED, NULL },
    { "border-left-color", CSS_TYPE_COLOR, NULL },
    { "border-left-style", CSS_TYPE_ENUM, Css_border_style_enum_vals },
    { "border-left-width", CSS_TYPE_LENGTH, NULL },
@@ -83,11 +82,9 @@
    { "border-right-style", CSS_TYPE_ENUM, Css_border_style_enum_vals },
    { "border-right-width", CSS_TYPE_LENGTH, NULL },
    { "border-spacing", CSS_TYPE_LENGTH, NULL },
-   { "border-style", CSS_TYPE_UNUSED, NULL },
    { "border-top-color", CSS_TYPE_COLOR, NULL },
    { "border-top-style", CSS_TYPE_ENUM, Css_border_style_enum_vals },
    { "border-top-width", CSS_TYPE_LENGTH, NULL },
-   { "border-width", CSS_TYPE_UNUSED, NULL },
    { "bottom", CSS_TYPE_UNUSED, NULL },
    { "caption-side", CSS_TYPE_UNUSED, NULL },
    { "clear", CSS_TYPE_UNUSED, NULL },
@@ -115,7 +112,6 @@
    { "list-style-image", CSS_TYPE_UNUSED, NULL },
    { "list-style-position", CSS_TYPE_UNUSED, NULL },
    { "list-style-type", CSS_TYPE_ENUM, Css_list_style_type_enum_vals },
-   { "margin", CSS_TYPE_UNUSED, NULL },
    { "margin-bottom", CSS_TYPE_LENGTH, NULL },
    { "margin-left", CSS_TYPE_LENGTH, NULL },
    { "margin-right", CSS_TYPE_LENGTH, NULL },
@@ -130,7 +126,6 @@
    { "outline-style", CSS_TYPE_UNUSED, NULL },
    { "outline-width", CSS_TYPE_UNUSED, NULL },
    { "overflow", CSS_TYPE_UNUSED, NULL },
-   { "padding", CSS_TYPE_UNUSED, NULL },
    { "padding-bottom", CSS_TYPE_LENGTH, NULL },
    { "padding-left", CSS_TYPE_LENGTH, NULL },
    { "padding-right", CSS_TYPE_LENGTH, NULL },
--- a/src/styleengine.cc	Fri Nov 14 16:16:25 2008 +0100
+++ b/src/styleengine.cc	Fri Nov 14 16:35:29 2008 +0100
@@ -153,16 +153,22 @@
             attrs->backgroundColor =
                Color::createSimple (layout, p->value.intVal);
             break; 
+         case CssProperty::CSS_PROPERTY_BORDER_TOP_COLOR:
+            attrs->borderColor.top =
+              Color::createSimple (layout, p->value.intVal);
+            break; 
          case CssProperty::CSS_PROPERTY_BORDER_BOTTOM_COLOR:
             attrs->borderColor.bottom =
               Color::createSimple (layout, p->value.intVal);
             break; 
-         case CssProperty::CSS_PROPERTY_BORDER_COLOR:
-            attrs->setBorderColor (Color::createSimple (layout, p->value.intVal));
+         case CssProperty::CSS_PROPERTY_BORDER_LEFT_COLOR:
+            attrs->borderColor.left =
+              Color::createSimple (layout, p->value.intVal);
             break; 
-         case CssProperty::CSS_PROPERTY_BORDER_STYLE:
-            attrs->setBorderStyle ((BorderStyle) p->value.intVal);
-            break;
+         case CssProperty::CSS_PROPERTY_BORDER_RIGHT_COLOR:
+            attrs->borderColor.right =
+              Color::createSimple (layout, p->value.intVal);
+            break; 
          case CssProperty::CSS_PROPERTY_BORDER_BOTTOM_STYLE:
             attrs->borderStyle.bottom = (BorderStyle) p->value.intVal;
             break;
@@ -175,9 +181,6 @@
          case CssProperty::CSS_PROPERTY_BORDER_TOP_STYLE:
             attrs->borderStyle.top = (BorderStyle) p->value.intVal;
             break;
-         case CssProperty::CSS_PROPERTY_BORDER_WIDTH:
-            attrs->borderWidth.setVal (computeValue (p->value.intVal, attrs->font));
-            break;
          case CssProperty::CSS_PROPERTY_BORDER_BOTTOM_WIDTH:
             attrs->borderWidth.bottom = computeValue (p->value.intVal, attrs->font);
             break;
@@ -203,9 +206,6 @@
          case CssProperty::CSS_PROPERTY_LIST_STYLE_TYPE:
             attrs->listStyleType = (ListStyleType) p->value.intVal;
             break;
-         case CssProperty::CSS_PROPERTY_MARGIN:
-            attrs->margin.setVal (computeValue (p->value.intVal, attrs->font));
-            break;
          case CssProperty::CSS_PROPERTY_MARGIN_BOTTOM:
             attrs->margin.bottom = computeValue (p->value.intVal, attrs->font);
             break;
@@ -218,9 +218,6 @@
          case CssProperty::CSS_PROPERTY_MARGIN_TOP:
             attrs->margin.top = computeValue (p->value.intVal, attrs->font);
             break;
-         case CssProperty::CSS_PROPERTY_PADDING:
-            attrs->padding.setVal (computeValue (p->value.intVal, attrs->font));
-            break;
          case CssProperty::CSS_PROPERTY_TEXT_ALIGN:
             attrs->textAlign = (TextAlignType) p->value.intVal;
             break;
--- a/src/table.cc	Fri Nov 14 16:16:25 2008 +0100
+++ b/src/table.cc	Fri Nov 14 16:35:29 2008 +0100
@@ -47,6 +47,7 @@
    CssPropertyList props, *table_cell_props;
    const char *attrbuf;
    int32_t border = -1, cellspacing = -1, cellpadding = -1, bgcolor = -1;
+   int cssLength;
 #endif
 
    DW2TB(html->dw)->addParbreak (0, html->styleEngine->style ());
@@ -59,18 +60,28 @@
    if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "cellpadding")))
       cellpadding = strtol (attrbuf, NULL, 10);
 
-   if (border != -1)
-      props.set (CssProperty::CSS_PROPERTY_BORDER_WIDTH,
-         CSS_CREATE_LENGTH (border, CSS_LENGTH_TYPE_PX));
-   if (cellspacing != -1)
-      props.set (CssProperty::CSS_PROPERTY_BORDER_SPACING,
-         CSS_CREATE_LENGTH (cellspacing, CSS_LENGTH_TYPE_PX));
+   if (border != -1) {
+      cssLength = CSS_CREATE_LENGTH (border, CSS_LENGTH_TYPE_PX);
+      props.set (CssProperty::CSS_PROPERTY_BORDER_TOP_WIDTH, cssLength);
+      props.set (CssProperty::CSS_PROPERTY_BORDER_BOTTOM_WIDTH, cssLength);
+      props.set (CssProperty::CSS_PROPERTY_BORDER_LEFT_WIDTH, cssLength);
+      props.set (CssProperty::CSS_PROPERTY_BORDER_RIGHT_WIDTH, cssLength);
+   }
+
+   if (cellspacing != -1) {
+      cssLength = CSS_CREATE_LENGTH (cellspacing, CSS_LENGTH_TYPE_PX);
+      props.set (CssProperty::CSS_PROPERTY_BORDER_SPACING, cssLength);
+   }
 
    /* When dillo was started with the --debug-rendering option, there
     * is always a border around the table. */
-   if (dillo_dbg_rendering && border < 1)
-      props.set (CssProperty::CSS_PROPERTY_BORDER_WIDTH,
-         CSS_CREATE_LENGTH (1, CSS_LENGTH_TYPE_PX));
+   if (dillo_dbg_rendering && border < 1) {
+      cssLength = CSS_CREATE_LENGTH (1, CSS_LENGTH_TYPE_PX);
+      props.set (CssProperty::CSS_PROPERTY_BORDER_TOP_WIDTH, cssLength);
+      props.set (CssProperty::CSS_PROPERTY_BORDER_BOTTOM_WIDTH, cssLength);
+      props.set (CssProperty::CSS_PROPERTY_BORDER_LEFT_WIDTH, cssLength);
+      props.set (CssProperty::CSS_PROPERTY_BORDER_RIGHT_WIDTH, cssLength);
+   }
 
    if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "width")))
       props.set (CssProperty::CSS_PROPERTY_WIDTH,
@@ -86,7 +97,10 @@
    }
 
    /** \todo figure out how to handle shaded colors with CSS */
-   props.set (CssProperty::CSS_PROPERTY_BORDER_COLOR, 0x000000);
+   props.set (CssProperty::CSS_PROPERTY_BORDER_TOP_COLOR, 0x000000);
+   props.set (CssProperty::CSS_PROPERTY_BORDER_BOTTOM_COLOR, 0x000000);
+   props.set (CssProperty::CSS_PROPERTY_BORDER_LEFT_COLOR, 0x000000);
+   props.set (CssProperty::CSS_PROPERTY_BORDER_RIGHT_COLOR, 0x000000);
 
    if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) {
       bgcolor = a_Html_color_parse(html, attrbuf, -1);
@@ -102,17 +116,35 @@
 
    /* The style for the cells */
    table_cell_props = new CssPropertyList ();
-   if (border != -1)
-      table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_WIDTH,
-         CSS_CREATE_LENGTH (border, CSS_LENGTH_TYPE_PX));
-   if (dillo_dbg_rendering && border < 1)
-      table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_WIDTH, 
-         CSS_CREATE_LENGTH (1, CSS_LENGTH_TYPE_PX));
-   if (cellpadding != -1)
-      table_cell_props->set (CssProperty::CSS_PROPERTY_PADDING,
-         CSS_CREATE_LENGTH (cellpadding, CSS_LENGTH_TYPE_PX));
+   if (border != -1) {
+      cssLength = CSS_CREATE_LENGTH (border, CSS_LENGTH_TYPE_PX);
+      table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_TOP_WIDTH, cssLength);
+      table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_BOTTOM_WIDTH, cssLength);
+      table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_LEFT_WIDTH, cssLength);
+      table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_RIGHT_WIDTH, cssLength);
+   }
+
+   if (dillo_dbg_rendering && border < 1) {
+      cssLength = CSS_CREATE_LENGTH (1, CSS_LENGTH_TYPE_PX);
+      table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_TOP_WIDTH, cssLength);
+      table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_BOTTOM_WIDTH, cssLength);
+      table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_LEFT_WIDTH, cssLength);
+      table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_RIGHT_WIDTH, cssLength);
+   }
+
+   if (cellpadding != -1) {
+      cssLength = CSS_CREATE_LENGTH (cellpadding, CSS_LENGTH_TYPE_PX);
+      table_cell_props->set (CssProperty::CSS_PROPERTY_PADDING_TOP, cssLength);
+      table_cell_props->set (CssProperty::CSS_PROPERTY_PADDING_BOTTOM, cssLength);
+      table_cell_props->set (CssProperty::CSS_PROPERTY_PADDING_LEFT, cssLength);
+      table_cell_props->set (CssProperty::CSS_PROPERTY_PADDING_RIGHT, cssLength);
+   }
+
    /** \todo figure out how to handle shaded colors with CSS */
-   table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_COLOR, 0x000000);
+   table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_TOP_COLOR, 0x000000);
+   table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_BOTTOM_COLOR, 0x000000);
+   table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_LEFT_COLOR, 0x000000);
+   table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_RIGHT_COLOR, 0x000000);
 
    if (S_TOP(html)->table_cell_props)
       S_TOP(html)->table_cell_props->unref ();