diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/css.cc | 10 | ||||
-rw-r--r-- | src/css.hh | 1 | ||||
-rw-r--r-- | src/dillo.cc | 2 | ||||
-rw-r--r-- | src/styleengine.cc | 6 | ||||
-rw-r--r-- | src/styleengine.hh | 3 |
5 files changed, 16 insertions, 6 deletions
@@ -498,8 +498,11 @@ void CssStyleSheet::apply (CssPropertyList *props, Doctree *docTree, } } +CssStyleSheet CssContext::userAgentSheet; + CssContext::CssContext () { pos = 0; + matchCache[CSS_PRIMARY_USER_AGENT].setSize (userAgentSheet.matchCacheOffset, -1); } /** @@ -516,8 +519,8 @@ void CssContext::apply (CssPropertyList *props, Doctree *docTree, CssPropertyList *tagStyle, CssPropertyList *tagStyleImportant, CssPropertyList *nonCssHints) { - sheet[CSS_PRIMARY_USER_AGENT].apply (props, docTree, node, - &matchCache[CSS_PRIMARY_USER_AGENT]); + userAgentSheet.apply (props, docTree, node, + &matchCache[CSS_PRIMARY_USER_AGENT]); sheet[CSS_PRIMARY_USER].apply (props, docTree, node, &matchCache[CSS_PRIMARY_USER]); @@ -551,6 +554,9 @@ void CssContext::addRule (CssSelector *sel, CssPropertyList *props, !rule->isSafe ()) { MSG_WARN ("Ignoring unsafe author style that might reveal browsing history\n"); delete rule; + } else if (order == CSS_PRIMARY_USER_AGENT) { + userAgentSheet.addRule (rule); + matchCache[CSS_PRIMARY_USER_AGENT].setSize (userAgentSheet.matchCacheOffset, -1); } else { sheet[order].addRule (rule); matchCache[order].setSize (sheet[order].matchCacheOffset, -1); @@ -498,6 +498,7 @@ class CssStyleSheet { */ class CssContext { private: + static CssStyleSheet userAgentSheet; CssStyleSheet sheet[CSS_PRIMARY_USER_IMPORTANT + 1]; MatchCache matchCache[CSS_PRIMARY_USER_IMPORTANT + 1]; int pos; diff --git a/src/dillo.cc b/src/dillo.cc index 5a67946b..d73b855a 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -52,6 +52,7 @@ #include "cookies.h" #include "domain.h" #include "auth.h" +#include "styleengine.hh" #include "lout/debug.hh" #include "dw/fltkcore.hh" @@ -472,6 +473,7 @@ int main(int argc, char **argv) a_Cookies_init(); a_Auth_init(); a_UIcmd_init(); + StyleEngine::init(); dw::Textblock::setPenaltyHyphen (prefs.penalty_hyphen); dw::Textblock::setPenaltyHyphen2 (prefs.penalty_hyphen_2); diff --git a/src/styleengine.cc b/src/styleengine.cc index 64861973..25e2e600 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -65,7 +65,6 @@ StyleEngine::StyleEngine (dw::core::Layout *layout) { doctree = new Doctree (); stack = new lout::misc::SimpleVector <Node> (1); cssContext = new CssContext (); - buildUserAgentStyle (); buildUserStyle (); this->layout = layout; importDepth = 0; @@ -939,7 +938,7 @@ void StyleEngine::parse (DilloHtml *html, DilloUrl *url, const char *buf, * The user agent style defines how dillo renders HTML in the absence of * author or user styles. */ -void StyleEngine::buildUserAgentStyle () { +void StyleEngine::init () { const char *cssBuf = "body {margin: 5px}" "big {font-size: 1.17em}" @@ -996,7 +995,8 @@ void StyleEngine::buildUserAgentStyle () { */ "table, caption {font-size: medium; font-weight: normal}"; - CssParser::parse (NULL, NULL, cssContext, cssBuf, strlen (cssBuf), + CssContext context; + CssParser::parse (NULL, NULL, &context, cssBuf, strlen (cssBuf), CSS_ORIGIN_USER_AGENT); } diff --git a/src/styleengine.hh b/src/styleengine.hh index 714553ff..bec4875b 100644 --- a/src/styleengine.hh +++ b/src/styleengine.hh @@ -38,7 +38,6 @@ class StyleEngine { void stackPush (); void stackPop (); - void buildUserAgentStyle (); void buildUserStyle (); dw::core::style::Style *style0 (int i, BrowserWindow *bw, DilloUrl *url); dw::core::style::Style *wordStyle0 (BrowserWindow *bw, DilloUrl *url); @@ -64,6 +63,8 @@ class StyleEngine { dw::core::style::Font *font); public: + static void init (); + StyleEngine (dw::core::Layout *layout); ~StyleEngine (); |