summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-08-02 23:25:49 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-08-02 23:25:49 +0200
commit23185b807ebdbed2b792dcb4abe729d2e7d17ba7 (patch)
treed5d0b47a5651328864407141ea51303ed5a2bf41
parent36a5a683ff482bf45ade423d6f1dafa3c9627c81 (diff)
don't reuse user- and useragent-stylesheet
The notMatchingBefore variable in CssSelector is modified as a page is styled. Thererfore we can't share a single copy of the user- and useragent-stylesheets between CssContexts. Testcase: <html> <body> <a href=whatever.html> <img alt=test src=whatever.jpg> </a> <div> <img src=something.jpg> </div> </body> </html> On reload the first image looses it's border. Tests with gettimeofday showed times below 1ms to create user- and useragent-styles on a Pentium-M 1.8 GHz laptop. reported-by: corvid <corvid@lavabit.com>
-rw-r--r--src/css.cc32
-rw-r--r--src/css.hh3
2 files changed, 7 insertions, 28 deletions
diff --git a/src/css.cc b/src/css.cc
index d8f086db..8b3e5371 100644
--- a/src/css.cc
+++ b/src/css.cc
@@ -489,39 +489,21 @@ void CssStyleSheet::apply (CssPropertyList *props,
}
}
-CssStyleSheet *CssContext::userAgentStyle;
-CssStyleSheet *CssContext::userStyle;
-CssStyleSheet *CssContext::userImportantStyle;
-
CssContext::CssContext () {
pos = 0;
- for (int o = CSS_PRIMARY_USER_AGENT; o < CSS_PRIMARY_LAST; o++)
- sheet[o] = NULL;
-
- if (userAgentStyle == NULL) {
- userAgentStyle = new CssStyleSheet ();
- userStyle = new CssStyleSheet ();
- userImportantStyle = new CssStyleSheet ();
-
- sheet[CSS_PRIMARY_USER_AGENT] = userAgentStyle;
- sheet[CSS_PRIMARY_USER] = userStyle;
- sheet[CSS_PRIMARY_USER_IMPORTANT] = userImportantStyle;
-
- buildUserAgentStyle ();
- buildUserStyle ();
- }
+ memset (sheet, 0, sizeof(sheet));
+ sheet[CSS_PRIMARY_USER_AGENT] = new CssStyleSheet ();
+ sheet[CSS_PRIMARY_USER] = new CssStyleSheet ();
+ sheet[CSS_PRIMARY_USER_IMPORTANT] = new CssStyleSheet ();
- sheet[CSS_PRIMARY_USER_AGENT] = userAgentStyle;
- sheet[CSS_PRIMARY_USER] = userStyle;
- sheet[CSS_PRIMARY_USER_IMPORTANT] = userImportantStyle;
+ buildUserAgentStyle ();
+ buildUserStyle ();
}
CssContext::~CssContext () {
for (int o = CSS_PRIMARY_USER_AGENT; o < CSS_PRIMARY_LAST; o++)
- if (sheet[o] != userAgentStyle && sheet[o] != userStyle &&
- sheet[o] != userImportantStyle)
- delete sheet[o];
+ delete sheet[o];
}
/**
diff --git a/src/css.hh b/src/css.hh
index 61c1d12f..20935dfd 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -458,9 +458,6 @@ class CssStyleSheet {
*/
class CssContext {
private:
- static CssStyleSheet *userAgentStyle;
- static CssStyleSheet *userStyle;
- static CssStyleSheet *userImportantStyle;
CssStyleSheet *sheet[CSS_PRIMARY_USER_IMPORTANT + 1];
int pos;