From 891ba8ec637c42a173dd5b044de4e56f86a33fec Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sat, 15 Feb 2014 23:58:41 +0100 Subject: share user agent style between CssContext's --- src/css.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/css.cc') diff --git a/src/css.cc b/src/css.cc index 2285d45f..6edf2dbc 100644 --- a/src/css.cc +++ b/src/css.cc @@ -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); -- cgit v1.2.3