changeset 506:03de2284bfa6

switch to original enum names from dillo-0.8.0-css-3
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Wed, 29 Oct 2008 18:19:19 +0100
parents a3b15690d2f4
children 3f1ce4a2e260
files src/css.cc src/css.hh src/styleengine.hh
diffstat 3 files changed, 107 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
--- a/src/css.cc	Wed Oct 29 17:54:18 2008 +0100
+++ b/src/css.cc	Wed Oct 29 18:19:19 2008 +0100
@@ -13,12 +13,11 @@
 #include "css.hh"
 
 void CssPropertyList::set (CssProperty::Name name, CssProperty::Value value) {
-   for (int i = 0; i < size (); i++) {
+   for (int i = 0; i < size (); i++)
       if (getRef (i)->name == name) {
          getRef (i)->value = value;
          return;
       }
-   }
 
    increase ();
    getRef (size () - 1)->name = name;
@@ -36,7 +35,6 @@
 }
 
 void CssRule::apply (CssPropertyList *props, Doctree *docTree) {
-
    if (selector->match (docTree))
       this->props->apply (props);
 }
@@ -54,10 +52,10 @@
 void CssContext::apply (CssPropertyList *props, Doctree *docTree,
          CssPropertyList *tagStyle, CssPropertyList *nonCss) {
 
-   sheet[USER_AGENT].apply (props, docTree);
+   sheet[CSS_PRIMARY_USER_AGENT].apply (props, docTree);
    if (nonCss)
         nonCss->apply (props);
-   for (int o = USER; o <= USER_IMPORTANT; o++)
+   for (int o = CSS_PRIMARY_USER; o <= CSS_PRIMARY_USER_IMPORTANT; o++)
       sheet[o].apply (props, docTree);
    if (tagStyle)
         nonCss->apply (props);
--- a/src/css.hh	Wed Oct 29 17:54:18 2008 +0100
+++ b/src/css.hh	Wed Oct 29 18:19:19 2008 +0100
@@ -23,90 +23,90 @@
       } Value;
 
       typedef enum {
-         BACKGROUND_ATTACHMENT,
-         BACKGROUND_COLOR,
-         BACKGROUND_IMAGE,
-         BACKGROUND_POSITION,
-         BACKGROUND_REPEAT,
-         BORDER_BOTTOM_COLOR,
-         BORDER_BOTTOM_STYLE,
-         BORDER_BOTTOM_WIDTH,
-         BORDER_COLLAPSE,
-         BORDER_LEFT_COLOR,
-         BORDER_LEFT_STYLE,
-         BORDER_LEFT_WIDTH,
-         BORDER_RIGHT_COLOR,
-         BORDER_RIGHT_STYLE,
-         BORDER_RIGHT_WIDTH,
-         BORDER_SPACING,
-         BORDER_TOP_COLOR,
-         BORDER_TOP_STYLE,
-         BORDER_TOP_WIDTH,
-         BOTTOM,
-         CAPTION_SIDE,
-         CLEAR,
-         CLIP,
-         COLOR,
-         CONTENT,
-         COUNTER_INCREMENT,
-         COUNTER_RESET,
-         CURSOR,
-         DIRECTION,
-         DISPLAY,
-         EMPTY_CELLS,
-         FLOAT,
-         FONT_FAMILY,
-         FONT_SIZE,
-         FONT_SIZE_ADJUST,
-         FONT_STRETCH,
-         FONT_STYLE,
-         FONT_VARIANT,
-         FONT_WEIGHT,
-         HEIGHT,
-         LEFT,
-         LETTER_SPACING,
-         LINE_HEIGHT,
-         LIST_STYLE_IMAGE,
-         LIST_STYLE_POSITION,
-         LIST_STYLE_TYPE,
-         MARGIN_BOTTOM,
-         MARGIN_LEFT,
-         MARGIN_RIGHT,
-         MARGIN_TOP,
-         MARKER_OFFSET,
-         MARKS,
-         MAX_HEIGHT,
-         MAX_WIDTH,
-         MIN_HEIGHT,
-         MIN_WIDTH,
-         OUTLINE_COLOR,
-         OUTLINE_STYLE,
-         OUTLINE_WIDTH,
-         OVERFLOW,
-         PADDING_BOTTOM,
-         PADDING_LEFT,
-         PADDING_RIGHT,
-         PADDING_TOP,
-         POSITION,
-         QUOTES,
-         RIGHT,
-         TEXT_ALIGN,
-         TEXT_DECORATION,
-         TEXT_SHADOW,
-         TEXT_TRANSFORM,
-         TOP,
-         UNICODE_BIDI,
-         VERTICAL_ALIGN,
-         VISIBILITY,
-         WHITE_SPACE,
-         TEXT_INDENT,
-         WIDTH,
-         WORD_SPACING,
-         Z_INDEX,
-         X_LINK,
-         X_COLSPAN,
-         X_ROWSPAN,
-         LAST
+         CSS_PROPERTY_BACKGROUND_ATTACHMENT,
+         CSS_PROPERTY_BACKGROUND_COLOR,
+         CSS_PROPERTY_BACKGROUND_IMAGE,
+         CSS_PROPERTY_BACKGROUND_POSITION,
+         CSS_PROPERTY_BACKGROUND_REPEAT,
+         CSS_PROPERTY_BORDER_BOTTOM_COLOR,
+         CSS_PROPERTY_BORDER_BOTTOM_STYLE,
+         CSS_PROPERTY_BORDER_BOTTOM_WIDTH,
+         CSS_PROPERTY_BORDER_COLLAPSE,
+         CSS_PROPERTY_BORDER_LEFT_COLOR,
+         CSS_PROPERTY_BORDER_LEFT_STYLE,
+         CSS_PROPERTY_BORDER_LEFT_WIDTH,
+         CSS_PROPERTY_BORDER_RIGHT_COLOR,
+         CSS_PROPERTY_BORDER_RIGHT_STYLE,
+         CSS_PROPERTY_BORDER_RIGHT_WIDTH,
+         CSS_PROPERTY_BORDER_SPACING,
+         CSS_PROPERTY_BORDER_TOP_COLOR,
+         CSS_PROPERTY_BORDER_TOP_STYLE,
+         CSS_PROPERTY_BORDER_TOP_WIDTH,
+         CSS_PROPERTY_BOTTOM,
+         CSS_PROPERTY_CAPTION_SIDE,
+         CSS_PROPERTY_CLEAR,
+         CSS_PROPERTY_CLIP,
+         CSS_PROPERTY_COLOR,
+         CSS_PROPERTY_CONTENT,
+         CSS_PROPERTY_COUNTER_INCREMENT,
+         CSS_PROPERTY_COUNTER_RESET,
+         CSS_PROPERTY_CURSOR,
+         CSS_PROPERTY_DIRECTION,
+         CSS_PROPERTY_DISPLAY,
+         CSS_PROPERTY_EMPTY_CELLS,
+         CSS_PROPERTY_FLOAT,
+         CSS_PROPERTY_FONT_FAMILY,
+         CSS_PROPERTY_FONT_SIZE,
+         CSS_PROPERTY_FONT_SIZE_ADJUST,
+         CSS_PROPERTY_FONT_STRETCH,
+         CSS_PROPERTY_FONT_STYLE,
+         CSS_PROPERTY_FONT_VARIANT,
+         CSS_PROPERTY_FONT_WEIGHT,
+         CSS_PROPERTY_HEIGHT,
+         CSS_PROPERTY_LEFT,
+         CSS_PROPERTY_LETTER_SPACING,
+         CSS_PROPERTY_LINE_HEIGHT,
+         CSS_PROPERTY_LIST_STYLE_IMAGE,
+         CSS_PROPERTY_LIST_STYLE_POSITION,
+         CSS_PROPERTY_LIST_STYLE_TYPE,
+         CSS_PROPERTY_MARGIN_BOTTOM,
+         CSS_PROPERTY_MARGIN_LEFT,
+         CSS_PROPERTY_MARGIN_RIGHT,
+         CSS_PROPERTY_MARGIN_TOP,
+         CSS_PROPERTY_MARKER_OFFSET,
+         CSS_PROPERTY_MARKS,
+         CSS_PROPERTY_MAX_HEIGHT,
+         CSS_PROPERTY_MAX_WIDTH,
+         CSS_PROPERTY_MIN_HEIGHT,
+         CSS_PROPERTY_MIN_WIDTH,
+         CSS_PROPERTY_OUTLINE_COLOR,
+         CSS_PROPERTY_OUTLINE_STYLE,
+         CSS_PROPERTY_OUTLINE_WIDTH,
+         CSS_PROPERTY_OVERFLOW,
+         CSS_PROPERTY_PADDING_BOTTOM,
+         CSS_PROPERTY_PADDING_LEFT,
+         CSS_PROPERTY_PADDING_RIGHT,
+         CSS_PROPERTY_PADDING_TOP,
+         CSS_PROPERTY_POSITION,
+         CSS_PROPERTY_QUOTES,
+         CSS_PROPERTY_RIGHT,
+         CSS_PROPERTY_TEXT_ALIGN,
+         CSS_PROPERTY_TEXT_DECORATION,
+         CSS_PROPERTY_TEXT_SHADOW,
+         CSS_PROPERTY_TEXT_TRANSFORM,
+         CSS_PROPERTY_TOP,
+         CSS_PROPERTY_UNICODE_BIDI,
+         CSS_PROPERTY_VERTICAL_ALIGN,
+         CSS_PROPERTY_VISIBILITY,
+         CSS_PROPERTY_WHITE_SPACE,
+         CSS_PROPERTY_TEXT_INDENT,
+         CSS_PROPERTY_WIDTH,
+         CSS_PROPERTY_WORD_SPACING,
+         CSS_PROPERTY_Z_INDEX,
+         CSS_PROPERTY_X_LINK,
+         CSS_PROPERTY_X_COLSPAN,
+         CSS_PROPERTY_X_ROWSPAN,
+         CSS_PROPERTY_LAST
       } Name;
 
       Name name;
@@ -161,15 +161,15 @@
 class CssContext {
    public:
       typedef enum {
-         USER_AGENT,
-         USER,
-         AUTHOR,
-         AUTHOR_IMPORTANT,
-         USER_IMPORTANT
+         CSS_PRIMARY_USER_AGENT,
+         CSS_PRIMARY_USER,
+         CSS_PRIMARY_AUTHOR,
+         CSS_PRIMARY_AUTHOR_IMPORTANT,
+         CSS_PRIMARY_USER_IMPORTANT
       } PrimaryOrder;
 
    private:
-      CssStyleSheet sheet[USER_IMPORTANT + 1];
+      CssStyleSheet sheet[CSS_PRIMARY_USER_IMPORTANT + 1];
 
    public:
       void addRule (CssRule *rule, PrimaryOrder order);
--- a/src/styleengine.hh	Wed Oct 29 17:54:18 2008 +0100
+++ b/src/styleengine.hh	Wed Oct 29 18:19:19 2008 +0100
@@ -3,38 +3,46 @@
 
 #include "dw/core.hh"
 #include "doctree.hh"
+#include "css.hh"
 
 class StyleEngine : public Doctree {
    private:
       class Node : public DoctreeNode {
          public:
             dw::core::style::Style *style;
-
-
       };
 
       lout::misc::SimpleVector <Node> *stack;
 
+      dw::core::style::Style *style0 ();
+
    public:
       StyleEngine ();
       ~StyleEngine ();
    
       /* Doctree interface */
-      const DoctreeNode *top () {
+      inline const DoctreeNode *top () {
          return stack->getRef (stack->size () - 1);
       };
-      const DoctreeNode *parent (const DoctreeNode *n) {
+
+      inline const DoctreeNode *parent (const DoctreeNode *n) {
          if (n->depth > 0)
             return stack->getRef (n->depth - 1);
          else
             return NULL;
       };
 
-      void startElement (int tag, const char *id, const char *klass, const char *style);
+      void startElement (int tag, const char *id, const char *klass,
+         const char *style);
       void endElement (int tag);
+      void setNonCssProperties (CssPropertyList *props);
 
       inline dw::core::style::Style *style () {
-         return stack->getRef (stack->size () - 1)->style;
+         dw::core::style::Style *s = stack->getRef (stack->size () - 1)->style;
+         if (s)
+            return s;
+         else
+            return style0 ();
       };
 };