diff options
author | Sebastian Geerken <devnull@localhost> | 2012-11-06 12:27:39 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2012-11-06 12:27:39 +0100 |
commit | 2b5f65a0354aca9496373a55b4cfb5286c1b041c (patch) | |
tree | a984d6ff9d9b0941293cd5295fffc8ad64b22cf4 /src | |
parent | 163ea78f0fe31ed999d94407c780af7efa520b68 (diff) | |
parent | 2e217082100a213c5d716d84dbf696826de64379 (diff) |
Merge.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/domainrc | 31 | ||||
-rw-r--r-- | src/styleengine.cc | 90 | ||||
-rw-r--r-- | src/styleengine.hh | 2 |
4 files changed, 78 insertions, 49 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 05bbe00e..ceba3e01 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -123,5 +123,5 @@ dillo_SOURCES = \ xembed.cc \ xembed.hh -EXTRA_DIST = chg srch keysrc -sysconf_DATA = keysrc +dist_sysconf_DATA = domainrc keysrc +EXTRA_DIST = chg srch diff --git a/src/domainrc b/src/domainrc new file mode 100644 index 00000000..44380fd0 --- /dev/null +++ b/src/domainrc @@ -0,0 +1,31 @@ +# domainrc - Dillo cross-domain request rules file. +# +# Here you can tell Dillo what to do when one site wants to retrieve resources +# (e.g., images, style sheets, redirection) from a different site. +# +# Lines that begin with a '#' are comments. + +# Default rule can be "accept" or "deny". + +default accept + + +# Now we list exceptions to the default. The format is: +# +# source destination +# +# There are three ways that you can specify a source or destination domain: +# +# 1. * - wildcard will match any domain +# 2. example.com - match the specific host example.com +# 3. .example.com - match example.com and any of its subdomains + +# Let's block some of the most notorious ad sites and trackers. + +* .admt.com +* .adnxs.com +* .crwdcntrl.com +* .doubleclick.net +* .quantserve.com +* .scorecardresearch.com +* .yieldmanager.com diff --git a/src/styleengine.cc b/src/styleengine.cc index b7814cde..48092c23 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -31,8 +31,8 @@ StyleEngine::StyleEngine (dw::core::Layout *layout) { this->layout = layout; importDepth = 0; - stack->increase (); - Node *n = stack->getRef (stack->size () - 1); + stackPush (); + Node *n = stack->getLastRef (); /* Create a dummy font, attribute, and tag for the bottom of the stack. */ font_attrs.name = prefs.font_sans_serif; @@ -52,48 +52,53 @@ StyleEngine::StyleEngine (dw::core::Layout *layout) { style_attrs.backgroundColor = Color::create (layout, 0xffffff); n->style = Style::create (layout, &style_attrs); - n->wordStyle = NULL; - n->backgroundStyle = NULL; - n->styleAttrProperties = NULL; - n->styleAttrPropertiesImportant = NULL; - n->nonCssProperties = NULL; - n->inheritBackgroundColor = false; } StyleEngine::~StyleEngine () { while (doctree->top ()) endElement (doctree->top ()->element); - assert (stack->size () == 1); // dummy node on the bottom of the stack + + stackPop (); // dummy node on the bottom of the stack + assert (stack->size () == 0); + + delete stack; + delete doctree; + delete cssContext; +} + +void StyleEngine::stackPush () { + static const Node emptyNode = { + NULL, NULL, NULL, NULL, NULL, NULL, false, NULL + }; + + stack->setSize (stack->size () + 1, emptyNode); +} + +void StyleEngine::stackPop () { Node *n = stack->getRef (stack->size () - 1); + + delete n->styleAttrProperties; + delete n->styleAttrPropertiesImportant; + delete n->nonCssProperties; if (n->style) n->style->unref (); if (n->wordStyle) n->wordStyle->unref (); if (n->backgroundStyle) n->backgroundStyle->unref (); - delete stack; - delete doctree; - delete cssContext; + stack->setSize (stack->size () - 1); } /** * \brief tell the styleEngine that a new html element has started. */ void StyleEngine::startElement (int element) { - if (stack->getRef (stack->size () - 1)->style == NULL) - style0 (stack->size () - 1); - - stack->increase (); - Node *n = stack->getRef (stack->size () - 1); - n->styleAttrProperties = NULL; - n->styleAttrPropertiesImportant = NULL; - n->nonCssProperties = NULL; - n->style = NULL; - n->wordStyle = NULL; - n->backgroundStyle = NULL; - n->inheritBackgroundColor = false; + style (); // ensure that style of current node is computed + stackPush (); + Node *n = stack->getLastRef (); DoctreeNode *dn = doctree->push (); + dn->element = element; n->doctreeNode = dn; } @@ -160,19 +165,25 @@ void StyleEngine::setStyle (const char *styleAttr) { */ void StyleEngine::inheritNonCssHints () { Node *pn = stack->getRef (stack->size () - 2); - Node *n = stack->getRef (stack->size () - 1); - if (pn->nonCssProperties) - n->nonCssProperties = new CssPropertyList (*pn->nonCssProperties, true); + if (pn->nonCssProperties) { + Node *n = stack->getRef (stack->size () - 1); + CssPropertyList *origNonCssProperties = n->nonCssProperties; + + n->nonCssProperties = new CssPropertyList(*pn->nonCssProperties, true); + + if (origNonCssProperties) // original nonCssProperties have precedence + origNonCssProperties->apply (n->nonCssProperties); + + delete origNonCssProperties; + } } void StyleEngine::clearNonCssHints () { Node *n = stack->getRef (stack->size () - 1); - if (n->nonCssProperties) { - delete n->nonCssProperties; - n->nonCssProperties = NULL; - } + delete n->nonCssProperties; + n->nonCssProperties = NULL; } /** @@ -218,23 +229,8 @@ void StyleEngine::setPseudoVisited () { void StyleEngine::endElement (int element) { assert (element == doctree->top ()->element); - Node *n = stack->getRef (stack->size () - 1); - - if (n->styleAttrProperties) - delete n->styleAttrProperties; - if (n->styleAttrPropertiesImportant) - delete n->styleAttrPropertiesImportant; - if (n->nonCssProperties) - delete n->nonCssProperties; - if (n->style) - n->style->unref (); - if (n->wordStyle) - n->wordStyle->unref (); - if (n->backgroundStyle) - n->backgroundStyle->unref (); - + stackPop (); doctree->pop (); - stack->setSize (stack->size () - 1); } void StyleEngine::preprocessAttrs (dw::core::style::StyleAttrs *attrs) { diff --git a/src/styleengine.hh b/src/styleengine.hh index 7cca1475..237008a6 100644 --- a/src/styleengine.hh +++ b/src/styleengine.hh @@ -36,6 +36,8 @@ class StyleEngine { Doctree *doctree; int importDepth; + void stackPush (); + void stackPop (); void buildUserAgentStyle (); void buildUserStyle (); dw::core::style::Style *style0 (int i); |