aboutsummaryrefslogtreecommitdiff
path: root/src/styleengine.cc
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-01-17 16:48:27 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-01-17 16:48:27 +0100
commit679090b3c7776ee024edce97800c51bd3e59ead2 (patch)
tree40167319d7a5bc1e46b321613cf1b0ec56940ec2 /src/styleengine.cc
parent650710395c696eb51fc46a6a7cf4c040db77b2ce (diff)
implement parsing of CSS data from style attribute
E.g. <body style="background-color: red; font-family: arial; font-size: 30mm"> Hello World </body>
Diffstat (limited to 'src/styleengine.cc')
-rw-r--r--src/styleengine.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/styleengine.cc b/src/styleengine.cc
index 72709b78..fd160f29 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -391,8 +391,9 @@ bool StyleEngine::computeLength (dw::core::style::Length *dest,
* This method is private. Call style() to get a current style object.
*/
Style * StyleEngine::style0 (CssPropertyList *nonCssProperties) {
- CssPropertyList props;
- CssPropertyList *tagStyleProps = NULL; /** \todo implementation */
+ CssPropertyList props, *styleAttributeProps = NULL;
+ const char *styleAttribute =
+ stack->getRef (stack->size () - 1)->styleAttribute;
// get previous style from the stack
StyleAttrs attrs = *stack->getRef (stack->size () - 2)->style;
@@ -402,9 +403,19 @@ Style * StyleEngine::style0 (CssPropertyList *nonCssProperties) {
if (stack->getRef (stack->size () - 2)->inheritBackgroundColor)
attrs.backgroundColor =
stack->getRef (stack->size () - 2)->style->backgroundColor;
-
- cssContext->apply (&props, this, tagStyleProps, nonCssProperties);
+ // parse style information from style="" attribute, if it exists
+ if (styleAttribute)
+ styleAttributeProps =
+ a_Css_parse_declaration (styleAttribute, strlen (styleAttribute));
+
+ // merge style information
+ cssContext->apply (&props, this, styleAttributeProps, nonCssProperties);
+
+ if (styleAttributeProps)
+ delete styleAttributeProps;
+
+ // apply style
apply (&attrs, &props);
stack->getRef (stack->size () - 1)->style = Style::create (layout, &attrs);