Bug 16002

Summary: Load SVG (and other) UA StyleSheets dynamically when needed
Product: WebKit Reporter: Eric Seidel (no email) <eric>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.4   
Bug Depends on:    
Bug Blocks: 15302    
Attachments:
Description Flags
First attempt
darin: review-
Fixing the global ctor problem
darin: review-
Really fix the global ctor problem darin: review+

Description Eric Seidel (no email) 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.