Bug 6899

Summary: SVG <rect> does not respect display: none
Product: WebKit Reporter: Eric Seidel (no email) <eric>
Component: SVGAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P3    
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
Attachments:
Description Flags
simple test case
none
Patch to prevent rendering of svg elements for display=none
none
New patch which implements solution 1 as described by maciej
none
More complete patch eric: review+

Description Eric Seidel (no email) 2006-01-28 20:30:32 PST
SVG does not respect display: none

See attached test case.  This should be easy to fix.
Comment 1 Eric Seidel (no email) 2006-01-28 20:31:15 PST
Created attachment 6061 [details]
simple test case
Comment 2 Eric Seidel (no email) 2006-01-28 20:32:05 PST
This is a pretty fundemental rendering bug.  It might even be worthy of the SVG HitList, we wouldn't ship SVG w/o this.
Comment 3 Rob Buis 2006-03-07 12:44:58 PST
Created attachment 6924 [details]
Patch to prevent rendering of svg elements for display=none

This is a fix to the problem. Please let me know if
it is too simplistic and/or needs more work.
Cheers,

Rob.
Comment 4 Maciej Stachowiak 2006-03-07 16:49:25 PST
I think this fix would be ok, but an even better fix would be to make the renderIsNeeded method do the right thing. The default implementation in NodeImpl::renderIsNeeded should handle the display:none case. However, this breaks because of the way SVG supresses rendering for unknown elements and for certain SVG elements. SVGElementImpl has an override of renderIsNeeded which returns false, and then the elements that do render have another override that returns true. This drops the display:none handling.

Here are two possible fixes:

1) Slightly easier, but architecturally not as good IMO:

For all the SVGElementImpl subclasses that currently override renderIsNeeded to just return true, instead override them to call StyledElementImpl::rendererIsNeeded so they skip the forced false and fall through to NodeImpl's logic.

2) A bit more work, but architecturally better:

Make an SVGUnknownElementImpl or SVGGenericElementImpl or something like that, derived from SVGElementImpl, to be used for unknown elements in the SVG namespace. This would require some changes to the factory. Remove the renderIsNeeded override from SVGElementImpl. Remove all the true overrides. Add a false override to SVGUnknownElementImpl and any other classes that should never create a renderer. Alternately, for the latter, you could put a display: none rule in the svg.css stylesheet.
Comment 5 Rob Buis 2006-03-08 02:33:38 PST
Created attachment 6936 [details]
New patch which implements solution 1 as described by maciej

See description :)
Comment 6 Eric Seidel (no email) 2006-03-08 04:10:03 PST
Comment on attachment 6936 [details]
New patch which implements solution 1 as described by maciej

This looks fine.  This will need a change log (and the attached test case) when landing.   We also might consider someday reversing this rule such that all SVGStyleElementImpls which do not want renders implement rendererIsNeeded and return false, where all other renders just get the StyledElementImpl::renderIsNeeded behavior by default.
Comment 7 Rob Buis 2006-03-08 05:17:08 PST
Created attachment 6938 [details]
More complete patch
Comment 8 Eric Seidel (no email) 2006-03-08 11:47:41 PST
Comment on attachment 6938 [details]
More complete patch

Oops! tabs in your change log.  Otherwise very nice.  I'll fix the tabs as I land.
r=me.
Comment 9 Eric Seidel (no email) 2006-03-12 19:49:59 PST
I landed this a while back.