changeset 644:9e4ad941cbdc

add wordStyle() method to StyleEngine
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Thu, 04 Dec 2008 18:39:19 +0100
parents eb0279297fde
children 560b746a3b4d
files src/styleengine.cc src/styleengine.hh
diffstat 2 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/styleengine.cc	Thu Dec 04 18:04:14 2008 +0100
+++ b/src/styleengine.cc	Thu Dec 04 18:39:19 2008 +0100
@@ -42,6 +42,7 @@
 }
 
 StyleEngine::~StyleEngine () {
+   /* \todo clear stack if not empty */
    delete stack;
    delete cssContext;
 }
@@ -126,6 +127,8 @@
 
    if (n->style)
       n->style->unref ();
+   if (n->wordStyle)
+      n->wordStyle->unref ();
    if (n->id)
       dFree ((void*) n->id); 
    if (n->klass)
@@ -362,6 +365,13 @@
    return stack->getRef (stack->size () - 1)->style;
 }
 
+Style * StyleEngine::wordStyle0 (CssPropertyList *nonCssProperties) {
+   StyleAttrs attrs = *style ();
+   attrs.resetValues ();
+   stack->getRef (stack->size () - 1)->wordStyle = Style::create (layout, &attrs);
+   return stack->getRef (stack->size () - 1)->wordStyle;
+}
+
 void StyleEngine::parse (const char *buf, int buflen,
                          int order_count, CssOrigin origin) {
 
--- a/src/styleengine.hh	Thu Dec 04 18:04:14 2008 +0100
+++ b/src/styleengine.hh	Thu Dec 04 18:39:19 2008 +0100
@@ -11,6 +11,7 @@
       class Node : public DoctreeNode {
          public:
             dw::core::style::Style *style;
+            dw::core::style::Style *wordStyle;
             const char *styleAttribute;
             bool inheritBackgroundColor;
       };
@@ -20,6 +21,7 @@
       CssContext *cssContext;
 
       dw::core::style::Style *style0 (CssPropertyList *nonCssHints = NULL);
+      dw::core::style::Style *wordStyle0 (CssPropertyList *nonCssHints = NULL);
       void apply (dw::core::style::StyleAttrs *attrs, CssPropertyList *props);
       int computeValue (CssLength value, dw::core::style::Font *font);
 
@@ -56,6 +58,14 @@
          else
             return style0 ();
       };
+      inline dw::core::style::Style *wordStyle () {
+         dw::core::style::Style *s = stack->getRef (stack->size () - 1)->wordStyle;
+         if (s)
+            return s;
+         else
+            return wordStyle0 ();
+      };
+
 };
 
 #endif