Mercurial > dillo_port1.3
changeset 2084:5b8e5855ab8e
support !important in style attributes
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> |
---|---|
date | Tue, 07 Jun 2011 12:06:52 +0200 |
parents | 796ee3ef6426 |
children | 7c04f8d91d24 |
files | ChangeLog config.h.in src/css.cc src/css.hh src/cssparser.cc src/cssparser.hh src/styleengine.cc src/styleengine.hh |
diffstat | 8 files changed, 34 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Jun 05 02:16:06 2011 +0000 +++ b/ChangeLog Tue Jun 07 12:06:52 2011 +0200 @@ -27,6 +27,7 @@ +- Reintroduce bg_color dillorc option. - Make Dillo compile with Clang. - Fix Textblock flushing. + - Support !important in style attributes. Patches: Johannes Hofmann +- Implement line-height. - Draw image maps when image not loaded.
--- a/config.h.in Sun Jun 05 02:16:06 2011 +0000 +++ b/config.h.in Tue Jun 07 12:06:52 2011 +0200 @@ -78,9 +78,6 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME -/* Define to the home page for this package. */ -#undef PACKAGE_URL - /* Define to the version of this package. */ #undef PACKAGE_VERSION @@ -106,7 +103,7 @@ #undef VERSION /* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>, - <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the + <pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the #define below would cause a syntax error. */ #undef _UINT32_T
--- a/src/css.cc Sun Jun 05 02:16:06 2011 +0000 +++ b/src/css.cc Tue Jun 07 12:06:52 2011 +0200 @@ -535,7 +535,8 @@ */ void CssContext::apply (CssPropertyList *props, Doctree *docTree, DoctreeNode *node, - CssPropertyList *tagStyle, CssPropertyList *nonCssHints) { + CssPropertyList *tagStyle, CssPropertyList *tagStyleImportant, + CssPropertyList *nonCssHints) { if (sheet[CSS_PRIMARY_USER_AGENT]) sheet[CSS_PRIMARY_USER_AGENT]->apply (props, docTree, node); @@ -554,6 +555,9 @@ if (sheet[CSS_PRIMARY_AUTHOR_IMPORTANT]) sheet[CSS_PRIMARY_AUTHOR_IMPORTANT]->apply (props, docTree, node); + if (tagStyleImportant) + tagStyleImportant->apply (props); + if (sheet[CSS_PRIMARY_USER_IMPORTANT]) sheet[CSS_PRIMARY_USER_IMPORTANT]->apply (props, docTree, node); }
--- a/src/css.hh Sun Jun 05 02:16:06 2011 +0000 +++ b/src/css.hh Tue Jun 07 12:06:52 2011 +0200 @@ -475,7 +475,8 @@ CssPrimaryOrder order); void apply (CssPropertyList *props, Doctree *docTree, DoctreeNode *node, - CssPropertyList *tagStyle, CssPropertyList *nonCssHints); + CssPropertyList *tagStyle, CssPropertyList *tagStyleImportant, + CssPropertyList *nonCssHints); }; #endif
--- a/src/cssparser.cc Sun Jun 05 02:16:06 2011 +0000 +++ b/src/cssparser.cc Tue Jun 07 12:06:52 2011 +0200 @@ -1590,22 +1590,16 @@ } } -CssPropertyList *CssParser::parseDeclarationBlock(const char *buf, int buflen) +void CssParser::parseDeclarationBlock(const char *buf, int buflen, + CssPropertyList *props, + CssPropertyList *propsImortant) { - CssPropertyList *props = new CssPropertyList (true); CssParser parser (NULL, CSS_ORIGIN_AUTHOR, buf, buflen); parser.withinBlock = true; do - parser.parseDeclaration(props, NULL); + parser.parseDeclaration(props, propsImortant); while (!(parser.ttype == CSS_TK_END || (parser.ttype == CSS_TK_CHAR && parser.tval[0] == '}'))); - - if (props->size () == 0) { - delete props; - props = NULL; - } - - return props; }
--- a/src/cssparser.hh Sun Jun 05 02:16:06 2011 +0000 +++ b/src/cssparser.hh Tue Jun 07 12:06:52 2011 +0200 @@ -47,8 +47,9 @@ void ignoreStatement(); public: - static CssPropertyList *parseDeclarationBlock(const char *buf, - int buflen); + static void parseDeclarationBlock(const char *buf, int buflen, + CssPropertyList *props, + CssPropertyList *propsImortant); static void parse(DilloHtml *html, DilloUrl *url, CssContext *context, const char *buf, int buflen, CssOrigin origin); static const char *propertyNameString(CssPropertyName name);
--- a/src/styleengine.cc Sun Jun 05 02:16:06 2011 +0000 +++ b/src/styleengine.cc Tue Jun 07 12:06:52 2011 +0200 @@ -52,6 +52,7 @@ n->wordStyle = NULL; n->backgroundStyle = NULL; n->styleAttrProperties = NULL; + n->styleAttrPropertiesImportant = NULL; n->nonCssProperties = NULL; n->inheritBackgroundColor = false; } @@ -82,6 +83,7 @@ stack->increase (); Node *n = stack->getRef (stack->size () - 1); n->styleAttrProperties = NULL; + n->styleAttrPropertiesImportant = NULL; n->nonCssProperties = NULL; n->style = NULL; n->wordStyle = NULL; @@ -138,10 +140,14 @@ Node *n = stack->getRef (stack->size () - 1); assert (n->styleAttrProperties == NULL); // parse style information from style="" attribute, if it exists - if (styleAttr && prefs.parse_embedded_css) - n->styleAttrProperties = - CssParser::parseDeclarationBlock (styleAttr, - strlen (styleAttr)); + if (styleAttr && prefs.parse_embedded_css) { + n->styleAttrProperties = new CssPropertyList (true); + n->styleAttrPropertiesImportant = new CssPropertyList (true); + + CssParser::parseDeclarationBlock (styleAttr, strlen (styleAttr), + n->styleAttrProperties, + n->styleAttrPropertiesImportant); + } }; /** @@ -213,6 +219,8 @@ if (n->styleAttrProperties) delete n->styleAttrProperties; + if (n->styleAttrPropertiesImportant) + delete n->styleAttrPropertiesImportant; if (n->nonCssProperties) delete n->nonCssProperties; if (n->style) @@ -706,7 +714,8 @@ * This method is private. Call style() to get a current style object. */ Style * StyleEngine::style0 (int i) { - CssPropertyList props, *styleAttrProperties, *nonCssProperties; + CssPropertyList props, *styleAttrProperties, *styleAttrPropertiesImportant; + CssPropertyList *nonCssProperties; // get previous style from the stack StyleAttrs attrs = *stack->getRef (i - 1)->style; @@ -723,11 +732,13 @@ preprocessAttrs (&attrs); styleAttrProperties = stack->getRef (i)->styleAttrProperties; + styleAttrPropertiesImportant = stack->getRef(i)->styleAttrPropertiesImportant; nonCssProperties = stack->getRef (i)->nonCssProperties; // merge style information cssContext->apply (&props, doctree, stack->getRef(i)->doctreeNode, - styleAttrProperties, nonCssProperties); + styleAttrProperties, styleAttrPropertiesImportant, + nonCssProperties); // apply style apply (i, &attrs, &props);
--- a/src/styleengine.hh Sun Jun 05 02:16:06 2011 +0000 +++ b/src/styleengine.hh Tue Jun 07 12:06:52 2011 +0200 @@ -21,6 +21,7 @@ private: struct Node { CssPropertyList *styleAttrProperties; + CssPropertyList *styleAttrPropertiesImportant; CssPropertyList *nonCssProperties; dw::core::style::Style *style; dw::core::style::Style *wordStyle;