Bug 76282 - ForeignObject content is zoomed two times
Summary: ForeignObject content is zoomed two times
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Florin Malita
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-13 09:33 PST by Florin Malita
Modified: 2012-03-24 21:08 PDT (History)
6 users (show)

See Also:


Attachments
FO content zoomed twice (770 bytes, image/svg+xml)
2012-01-13 09:33 PST, Florin Malita
no flags Details
Patch (5.61 KB, patch)
2012-03-21 13:51 PDT, Florin Malita
no flags Details | Formatted Diff | Diff
Patch (154.52 KB, patch)
2012-03-23 12:32 PDT, Florin Malita
no flags Details | Formatted Diff | Diff
Patch (154.79 KB, patch)
2012-03-24 08:32 PDT, Florin Malita
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Florin Malita 2012-01-13 09:33:46 PST
Created attachment 122441 [details]
FO content zoomed twice

The zoom factor is applied twice to FO-embedded elements. This affects both SVG and HTML content, but for different reasons:

* When embedding foreign SVG content, we end up with two RenderSVGRoot nodes on the render path:
  RenderSVGRoot {svg}
    RenderSVGForeignObject {foreignObject}
      RenderSVGRoot {svg}
        RenderSVGRect {rect}
        ...

Each RenderSVGRoot::paint() applies the zoom factor to its current canvas context - hence the duplicate zooming: http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp#L310 , http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp#L355

* When embedding foreign HTML content, the CSS properties appear to be pre-scaled by the zoom factor (http://trac.webkit.org/browser/trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp#L334), so the zoom introduced by RenderSVGRoot up the tree is compounding the effect.


See the attached test for an example; try zooming in/out a few times and observe how the FO content is scaled twice.
The test works correctly in FF8+.
Comment 1 Florin Malita 2012-03-21 13:51:50 PDT
Created attachment 133107 [details]
Patch
Comment 2 Nikolas Zimmermann 2012-03-22 01:31:38 PDT
Comment on attachment 133107 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=133107&action=review

Good catch, I'd like to r+ this, though the test should be extended to cover text as well, or a new test should be added. Its possible that theres still a bug related to non-shapes drawing in fO trees.

> LayoutTests/svg/zoom/page/zoom-foreign-content.svg:2
> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onload="runRepaintTest()">

For the record: in theory this could use a reftest, if we'd zoom the subtrees by specifying zoom CSS properties, though for testing zooming the preferred way is to use the DRT functionality, as that uses the same code path, as if you'd zoom in eg. Safari. So using a pixel+repaint test is just right for this case.

> LayoutTests/svg/zoom/page/zoom-foreign-content.svg:7
> +            <rect width="99" height="99" fill="red"/>

I'd like to see another test that includes text in the SVG subtree (and maybe also in the HTML subtree). As <text> depends on the accumulated transforms up to RenderSVGRoot, we should verify this works as well, including zooming.
Comment 3 Florin Malita 2012-03-22 09:16:11 PDT
(In reply to comment #2)
> (From update of attachment 133107 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=133107&action=review
> 
> Good catch, I'd like to r+ this, though the test should be extended to cover text as well, or a new test should be added. Its possible that theres still a bug related to non-shapes drawing in fO trees.

There's already a test covering zooming of FO text: svg/zoom/{page,text}/zoom-foreignObject.svg

Should I go ahead and add more coverage to it (SVG text maybe)? I was hoping to avoid having to deal with a gazillion platform rebaselines :)
Comment 4 Florin Malita 2012-03-23 12:32:23 PDT
Created attachment 133535 [details]
Patch
Comment 5 Nikolas Zimmermann 2012-03-24 01:44:05 PDT
Comment on attachment 133535 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=133535&action=review

Looks great, r=me, with one comment:

> LayoutTests/platform/mac/Skipped:566
> +# Rebaseline needed after https://bugs.webkit.org/show_bug.cgi?id=76282
> +svg/zoom/page/zoom-foreignObject.svg
> +svg/zoom/text/zoom-foreignObject.svg

You can use platform/mac/test_expectations.txt as well btw, so there's no need to skip those tests!
Comment 6 Florin Malita 2012-03-24 08:32:31 PDT
Created attachment 133635 [details]
Patch
Comment 7 Florin Malita 2012-03-24 08:34:04 PDT
(In reply to comment #5)
> You can use platform/mac/test_expectations.txt as well btw, so there's no need to skip those tests!

Good to know! Still figuring out which platforms observe the expectations files :)
Comment 8 WebKit Review Bot 2012-03-24 21:08:24 PDT
Comment on attachment 133635 [details]
Patch

Clearing flags on attachment: 133635

Committed r112022: <http://trac.webkit.org/changeset/112022>
Comment 9 WebKit Review Bot 2012-03-24 21:08:29 PDT
All reviewed patches have been landed.  Closing bug.