RESOLVED FIXED 71780
Introduce SVGLengthContext, to allow to resolve relative units to arbitary viewports
https://bugs.webkit.org/show_bug.cgi?id=71780
Summary Introduce SVGLengthContext, to allow to resolve relative units to arbitary vi...
Nikolas Zimmermann
Reported 2011-11-08 01:02:46 PST
Currently SVGLength::value(const SVGElement* context) is used all over WebCore to resolve SVGLengths to floats. While working on bug 10403 I discovered following problem with feImage, explained by this snippet: <svg width="800" height="800"> <defs> <circle cx="50%" cy="50%" r="10%" fill="green" id="circle"/> </defs> <filter x="0%" y="0%" width="100%" height="100%" primitiveUnits="objectBoundingBox" id="filter"> <feImage xlink;href="#circle"/> </filter> <rect width="400" height="300" filter="url(#filter")> </svg> A filter is constructed where primitiveUnits are objectBoundingBox, unlike the default userSpaceOnUse. This implies that any relative value used in the feImage filter effect, should be resolved against the "filter subregion bounding box" of the effect. As I specified x="0%" y="0%" width="100%" height="100%" on the filter, which overrides the default of x/y="-10%" width/height="120%", the "filter subregion bounding box" is equivalent to 0x0-400x300, as that is the objectBoundingBox of the <rect> element where the <filter> applies to. So what do we expect? feImage should create an ImageBuffer with the size of the boundingBox of the <circle> resolved against the "filter subregion bounding box", aka. bbox rect x=150 y=100 w=100 h=100. That implies the rendering should be the same when using userSpaceOnUse but <circle cx="200" cy="150" r="50">. What happens currently? FEImage asks for the objectBoundingBox of the renderer of the <circle>, which will return the bbox rect x=360 y=360 w=80 h=80. That implies the rendering looks like as if we used userSpaceOnUse but <circle cx="400" cy="400" r="40">. Obviously the percentage values were resolved against the viewport of the outermost <svg> renderer. That's our default behaviour and correct in most cases, but we have no way to override this, that means it's very hard to get feImage right at the moment, without having the ability to get a Path out of the SVGCircleElement that's resolved against a custom viewport. In the following patch I'm introducing SVGLengthContext, which is passed to SVGLength instead "const SVGElement* context". It holds an additional FloatRect for the custom viewport.
Attachments
Patch (68.81 KB, patch)
2011-11-08 03:16 PST, Nikolas Zimmermann
no flags
Patch v2 (70.10 KB, patch)
2011-11-08 04:01 PST, Nikolas Zimmermann
zherczeg: review+
Nikolas Zimmermann
Comment 1 2011-11-08 03:16:04 PST
WebKit Review Bot
Comment 2 2011-11-08 03:17:33 PST
Attachment 114027 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/CMakeLists.txt', u'Source/W..." exit_code: 1 Source/WebCore/svg/SVGLengthContext.h:73: The parameter name "mode" adds no information, so it should be removed. [readability/parameter_name] [5] Source/WebCore/svg/SVGLengthContext.h:74: The parameter name "mode" adds no information, so it should be removed. [readability/parameter_name] [5] Source/WebCore/svg/SVGLength.h:57: The parameter name "mode" adds no information, so it should be removed. [readability/parameter_name] [5] Source/WebCore/svg/SVGLength.h:57: The parameter name "type" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 4 in 26 files If any of these errors are false positives, please file a bug against check-webkit-style.
Nikolas Zimmermann
Comment 3 2011-11-08 04:01:24 PST
Created attachment 114035 [details] Patch v2
Zoltan Herczeg
Comment 4 2011-11-08 04:44:35 PST
Comment on attachment 114035 [details] Patch v2 r=me
Nikolas Zimmermann
Comment 5 2011-11-08 06:15:41 PST
Thanks, landed in r99561.
Note You need to log in before you can comment on or make changes to this bug.