diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2011-08-02 23:25:49 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2011-08-02 23:25:49 +0200 |
commit | 23185b807ebdbed2b792dcb4abe729d2e7d17ba7 (patch) | |
tree | d5d0b47a5651328864407141ea51303ed5a2bf41 /src | |
parent | 36a5a683ff482bf45ade423d6f1dafa3c9627c81 (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>
Diffstat (limited to 'src')
-rw-r--r-- | src/css.cc | 32 | ||||
-rw-r--r-- | src/css.hh | 3 |
2 files changed, 7 insertions, 28 deletions
@@ -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]; } /** @@ -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; |