New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 659214 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Oct 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Background style under svg foreign object affects the background of the root viewport

Project Member Reported by wangxianzhu@chromium.org, Oct 25 2016

Issue description

<svg width="100" height="100">
  <foreignObject>
    <body style="background-color: blue"></body>
  </foreignObject>
</svg>

The whole root viewport will be painted blue.
 
I'm willing to bet that this is due to the rule where the body background is transferred to the html if the html has no background of its own. We're finding the foreign object body and treating it like the page body.

I don't think this should happen, although maybe one could argue for it. Does the same thing happen if there is more in the SVG than just the foreign object? Does it happen if the SVG is within a html doc (I doubt it does).
Components: -Blink>SVG -Blink>Paint Blink>HTML>Parser
> Does the same thing happen if there is more in the SVG than just the foreign object?
Yes.

> Does it happen if the SVG is within a html doc (I doubt it does).
Yes. It happens even if the html doc has <html> and <body> elements (http://jsbin.com/jadame/1).
It doesn't happen if the top-level <body> has any non-empty style.

http://jsbin.com/jadame/2 is a weirder: the top-level <html> has background which is used to paint the viewport background, but the inner <body>'s background style is used to paint the top-level <body>'s background. This also doesn't happen if the top-level <body> has any non-empty style.

After examining the DOM tree and layout tree, I believe this is a parser issue. We don't create Element for the inner <body>, but seem to copy any attribute of the inner <body> to the top-level <body> if the top-level <body> doesn't have the attribute.

Comment 3 by f...@opera.com, Oct 26 2016

Yes, this sounds like:

https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody case 'A start tag whose tag name is "body"':

"Otherwise, ...; then, for each attribute on the token, check to see if the attribute is already present on the body element (the second element) on the stack of open elements, and if it is not, add the attribute and its corresponding value to that element."

Comment 4 by f...@opera.com, Oct 26 2016

So, the behavior is expected (to some degree at least), and also shared by FF.
Status: WontFix (was: Available)
Perhaps we should just omit <body> under <forienObject>.

Sign in to add a comment