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+

Eric Seidel (no email)
Reported 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.
Attachments
First attempt (6.60 KB, patch)
2007-12-02 08:05 PST, Rob Buis
darin: review-
Fixing the global ctor problem (6.60 KB, patch)
2007-12-02 10:03 PST, Rob Buis
darin: review-
Really fix the global ctor problem (6.78 KB, patch)
2007-12-02 10:43 PST, Rob Buis
darin: review+
Rob Buis
Comment 1 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.
Darin Adler
Comment 2 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
Rob Buis
Comment 3 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.
Darin Adler
Comment 4 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?
Rob Buis
Comment 5 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.
Rob Buis
Comment 6 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.
Darin Adler
Comment 7 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
Rob Buis
Comment 8 2007-12-02 12:21:09 PST
Landed in r28321.
Note You need to log in before you can comment on or make changes to this bug.