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

See Also:


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

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel 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 Rob Buis 2007-12-02 08:05:00 PST
Created attachment 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 Darin Adler 2007-12-02 08:59:49 PST
Comment on attachment 17645 [details]
First attempt

+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 Rob Buis 2007-12-02 10:03:47 PST
Created attachment 17652 [details]
Fixing the global ctor problem

This should fix the global ctor efficiency problem.
Cheers,

Rob.
Comment 4 Darin Adler 2007-12-02 10:17:58 PST
Comment on attachment 17652 [details]
Fixing the global ctor problem

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 Rob Buis 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 Rob Buis 2007-12-02 10:43:25 PST
Created attachment 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 Darin Adler 2007-12-02 10:50:28 PST
Comment on attachment 17653 [details]
Really fix the global ctor problem

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 Rob Buis 2007-12-02 12:21:09 PST
Landed in r28321.