Bug 16002 - Load SVG (and other) UA StyleSheets dynamically when needed
: Load SVG (and other) UA StyleSheets dynamically when needed
Status: RESOLVED FIXED
: WebKit
CSS
: 528+ (Nightly build)
: Macintosh Mac OS X 10.4
: P2 Normal
Assigned To:
:
:
:
: 15302
  Show dependency treegraph
 
Reported: 2007-11-15 11:54 PST by
Modified: 2007-12-02 12:21 PST (History)


Attachments
First attempt (6.60 KB, patch)
2007-12-02 08:05 PST, Rob Buis
darin: review-
Review Patch | Details | Formatted Diff | Diff
Fixing the global ctor problem (6.60 KB, patch)
2007-12-02 10:03 PST, Rob Buis
darin: review-
Review Patch | Details | Formatted Diff | Diff
Really fix the global ctor problem (6.78 KB, patch)
2007-12-02 10:43 PST, Rob Buis
darin: review+
Review Patch | Details | Formatted Diff | Diff


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2007-11-15 11:54:51 PST
Load SVG (and other) UA StyleSheets dynamically when needed

Hyatt would like to see a solution like this land before landing MathML support.
------- Comment #1 From 2007-12-02 08:05:00 PST -------
Created an attachment (id=17645) [details]
First attempt

This patch implements the lazy loading of the svg sheet. I think it is the only UA sheet yet which can be treated that way. Note that the const MediaQueryEvaluator
stuff is not essential, just seems clearer to me.
Cheers,

Rob.
------- Comment #2 From 2007-12-02 08:59:49 PST -------
(From update of attachment 17645 [details])
+static const MediaQueryEvaluator screenEval("screen");
+static const MediaQueryEvaluator printEval("print");

We can't have global objects with constructors like these in WebKit -- causes a performance problem, especially on Mac OS X. You can instead put create functions that return the objects.

+#if ENABLE(SVG)
+    if (e->isSVGElement() && !svgSheet) {
+        // SVG rules.
+        svgSheet = parseUASheet(svgUserAgentStyleSheet);
+        defaultStyle->addRulesFromSheet(svgSheet, &screenEval);
+        defaultPrintStyle->addRulesFromSheet(svgSheet, &printEval);
+    }
+#endif
     int firstUARule = -1, lastUARule = -1;

I think you need a blank line after the #endif

review- because of the global initializers
------- Comment #3 From 2007-12-02 10:03:47 PST -------
Created an attachment (id=17652) [details]
Fixing the global ctor problem

This should fix the global ctor efficiency problem.
Cheers,

Rob.
------- Comment #4 From 2007-12-02 10:17:58 PST -------
(From update of attachment 17652 [details])
How does this fix the global constructor problem? I don't see any change in that part of the patch. Maybe you accidentally re-posted the same patch?
------- Comment #5 From 2007-12-02 10:40:52 PST -------
Hi Darin,

(In reply to comment #4)
> (From update of attachment 17652 [details] [edit])
> How does this fix the global constructor problem? I don't see any change in
> that part of the patch. Maybe you accidentally re-posted the same patch?

Oops, you are right :( Will put up the one I intended.
Cheers,

Rob.
------- Comment #6 From 2007-12-02 10:43:25 PST -------
Created an attachment (id=17653) [details]
Really fix the global ctor problem

This is the patch I meant to address Darins issues with my first attempt, ignore the previous attachment.
Cheers,

Rob.
------- Comment #7 From 2007-12-02 10:50:28 PST -------
(From update of attachment 17653 [details])
Looks fine, but I'm not happy with the trailing underscore naming scheme. In the past we've used the word static, like:

     static const MediaQueryEvaluator staticPrintEval("print");

Looks good. r=me
------- Comment #8 From 2007-12-02 12:21:09 PST -------
Landed in r28321.