Bug 23111 - Backgrounds in HTML inside foreignObject don't draw
Summary: Backgrounds in HTML inside foreignObject don't draw
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-04 20:04 PST by Simon Fraser (smfr)
Modified: 2012-02-01 16:00 PST (History)
8 users (show)

See Also:


Attachments
Testcase (675 bytes, text/html)
2009-01-04 20:04 PST, Simon Fraser (smfr)
no flags Details
Another testcase (642 bytes, image/svg+xml)
2009-05-19 22:35 PDT, Simon Fraser (smfr)
no flags Details
Patch (5.09 KB, patch)
2012-02-01 14:57 PST, 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 Simon Fraser (smfr) 2009-01-04 20:04:32 PST
If HTML inside an SVG foreignObject has CSS backgrounds, they fail to draw.
Comment 1 Simon Fraser (smfr) 2009-01-04 20:04:54 PST
Created attachment 26419 [details]
Testcase
Comment 2 Simon Fraser (smfr) 2009-01-04 20:07:06 PST
The HTML backgrounds do draw, but get obliterated by the SVGRoot painting its background in the PaintPhaseForeground.

There are a bunch of issues here:
1. The RendererForeignObject should be a stacking context, and isn't
2. SVG renderers are not set up to have RenderLayers amongst them.
3. HTML rendering code has "body background is drawn by the root" logic that should not apply when the <body> is inside a <foreignObject>.
Comment 3 Eric Seidel (no email) 2009-01-04 20:12:32 PST
Are we also propagating all of the proper drawing phases out to the foreignObject content?  Your previous comment makes it sound like we are.  And yes, FOs should probably have a stacking context, even though stacking contexts make no sense in SVG's world.
Comment 4 Simon Fraser (smfr) 2009-01-04 20:28:01 PST
(In reply to comment #3)
> Are we also propagating all of the proper drawing phases out to the
> foreignObject content?  Your previous comment makes it sound like we are.

Yes, but the SVGRoot draws its background in the foreground phase, thus clobbering the HTML backgrounds.

> yes, FOs should probably have a stacking context, even though stacking 
> contexts make no sense in SVG's world.

I think we're either going to have to give RenderForeignObject a layer and make it a stacking context (which requires fixing up RenderSVGContainer to do some layer stuff), or we make RenderForeignObject::paint() do what FrameView::paintContents does, which is just paint the root layer.

Comment 5 Eric Seidel (no email) 2009-05-04 23:51:25 PDT
This looks like it works already in Safari 4?
Comment 6 Simon Fraser (smfr) 2009-05-19 22:35:48 PDT
Created attachment 30497 [details]
Another testcase

No, it doesn't work. See this testcase.
Comment 7 Eric Seidel (no email) 2009-05-19 22:50:27 PDT
That test case hits:
See /usr/include/servers/bootstrap_defs.h for the error codes.
ASSERTION FAILED: useTransforms
(/Projects/WebKit/WebCore/rendering/SVGRenderSupport.cpp:67 static void WebCore::SVGRenderBase::mapLocalToContainer(const WebCore::RenderObject*, WebCore::RenderBoxModelObject*, bool, bool, WebCore::TransformState&))
(when attempting to select text)
in ToT, which might suggest that there is just a painting error here.
Comment 8 Simon Fraser (smfr) 2009-05-19 22:56:48 PDT
That assertion happens only when you select, because it's computing selection rectangles. The basic background painting bug is still there. We need to make SVGForeignObject paint all the phases of the HTML I think.
Comment 9 Peter Murray 2011-12-08 08:55:41 PST
This was reported also against chrome at this bug:
http://code.google.com/p/chromium/issues/detail?id=35545

Is there any update on the status of this issue?  Perhaps a workaround that can be used to fool webkit into rendering these html backgrounds properly?
Comment 10 Simon Fraser (smfr) 2011-12-08 11:22:09 PST
I think bug 58417 may have fixed this.
Comment 11 Florin Malita 2012-02-01 14:50:13 PST
(In reply to comment #10)
> I think bug 58417 may have fixed this.

Almost there, but the second testcase is still failing. <body> background painting is not working for SVG docs due to the logic in RenderBox::paintBackground (Simon's point #3).

I have a small patch based on smfr's earlier FO stacking context work (https://bugs.webkit.org/show_bug.cgi?id=23113#c8) that takes care of that.
Comment 12 Florin Malita 2012-02-01 14:57:08 PST
Created attachment 125022 [details]
Patch
Comment 13 Eric Seidel (no email) 2012-02-01 15:23:50 PST
Comment on attachment 125022 [details]
Patch

This seems reasonable to me.
Comment 14 WebKit Review Bot 2012-02-01 16:00:14 PST
Comment on attachment 125022 [details]
Patch

Clearing flags on attachment: 125022

Committed r106510: <http://trac.webkit.org/changeset/106510>
Comment 15 WebKit Review Bot 2012-02-01 16:00:19 PST
All reviewed patches have been landed.  Closing bug.