If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

xml:space="preserve" changes how foreignObject html is rendered

RESOLVED FIXED in Firefox 21

Status

()

Core
SVG
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: reg-bugzilla, Assigned: heycam)

Tracking

({regression})

18 Branch
mozilla21
regression
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox18 affected, firefox19-, firefox20-, firefox21- fixed)

Details

Attachments

(2 attachments)

(Reporter)

Description

5 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0
Build ID: 20130104151925

Steps to reproduce:

Insert a SVG with a foreign object containing HTML. Indent the HTML of the foreign object for better code readability. 


Actual results:

The whitespaces within the source code of the SVG's foreign object are displayed in the rendered page. This destroys the layout of the SVG with its foreign object.
It worked correctly in the version 17 of firefox. 


Expected results:

The white spaces used to indent the source code should be ignored when rendering the output.

Updated

5 years ago
Component: Untriaged → SVG
Product: Firefox → Core

Comment 1

5 years ago
Could you provide a minimal testcase, please.
Flags: needinfo?(reg-bugzilla)
Keywords: testcase-wanted
(Reporter)

Comment 2

5 years ago
Created attachment 703238 [details]
HTML-File with embedded SVG and Foreign Object not rendered correctly
Flags: needinfo?(reg-bugzilla)

Updated

5 years ago
Attachment #703238 - Attachment mime type: text/plain → text/html

Comment 3

5 years ago
Cameron, it seems the xml:space="preserve" now feeds into foreignObject child content. Any thoughts on if we should do anything and if so, what?
Keywords: testcase-wanted
(Assignee)

Comment 4

5 years ago
So this is due to the new UA style rule in svg.css:

  *[xml|space=preserve] {
    white-space: -moz-pre-discard-newlines;
  }

I admittedly did not consider how this might affect <foreignObject>s.  We could change -moz-pre-discard-newlines to mean "only preformatted but discarding newlines on SVG elements, but like 'normal' on other elements".  Or, we could add another rule

  foreignObject {
    white-space: normal;
  }

although this might be confusing if you wrote for example:

  <!doctype html>
  <body style="white-space: pre-line">
    <svg>
      ...
      <foreignObject>
        ...
      </foreignObject>
     </svg>
  </body>

Still, it might be acceptable, given that we really want to (at some point soon) convince people to use white-space rather than xml:space="".
(Assignee)

Comment 5

5 years ago
And ideally the solution we choose should be palatable enough to put in specs.

Comment 6

5 years ago
Regression range:

m-c
good=2012-10-03
bad=2012-10-04
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=635fcc11d2b1&tochange=4cb8f88213f5

Suspected bug:
Cameron McCormack — Bug 655877 - Part 23b: Add UA style sheet rules to map xml:space='preserve' to white-space:-moz-pre-discard-newlines on SVG text elements. r=jwatt
Blocks: 655877
Status: UNCONFIRMED → NEW
status-firefox18: --- → affected
tracking-firefox19: --- → ?
tracking-firefox20: --- → ?
tracking-firefox21: --- → ?
Ever confirmed: true
Keywords: regression
(Assignee)

Comment 7

5 years ago
I posted to www-svg to see if people there have opinions too.

http://www.w3.org/mid/50F7E238.7040000@mcc.id.au

Comment 8

5 years ago
This will be odd with either solution.

  <!doctype html>
  <body style="white-space: pre-line">
    <svg xml:space="preserve">
      ...
      <foreignObject>
        <p>Where did my white-space pre-line go?</p>
      </foreignObject>
     </svg>
  </body>

Comment 9

5 years ago
FWIW I like your second idea more.
It appears that this issue can be easily worked around server-side, and has not caused significant breakage on the web. We'd accept uplift of a low risk fix, once found.
tracking-firefox19: ? → -
tracking-firefox20: ? → -
tracking-firefox21: ? → -

Updated

5 years ago
Duplicate of this bug: 815235

Updated

5 years ago
Summary: SVG with foreign objects source code not correctly rendered → xml:space="preserve" changes how foreignObject html is rendered

Updated

5 years ago
OS: Windows 7 → All
Hardware: x86_64 → All
(Assignee)

Comment 12

5 years ago
Created attachment 706720 [details] [diff] [review]
patch

No reply on the mailing list.  Let's just do that second option for now.  If others in the WG prefer a different solution, we can change.
Assignee: nobody → cam
Status: NEW → ASSIGNED
Attachment #706720 - Flags: review?(longsonr)

Comment 13

5 years ago
Comment on attachment 706720 [details] [diff] [review]
patch

Please create reftests:

a) outer svg is xml:space="preserve" and fo has no white-space styles
b) outer svg is xml:space="preserve" and fo has white-space: "something != normal"
Attachment #706720 - Flags: review?(longsonr) → review+
(Assignee)

Comment 14

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/52f1e645ce34
Flags: in-testsuite+

Comment 15

5 years ago
I don't think you pushed the reftest files themselves!
(Assignee)

Comment 16

5 years ago
Forgot to "hg add" them...
(Assignee)

Comment 17

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/d4a40b1d2524

Thanks. :)
https://hg.mozilla.org/mozilla-central/rev/52f1e645ce34
https://hg.mozilla.org/mozilla-central/rev/d4a40b1d2524
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21

Updated

5 years ago
status-firefox21: --- → fixed
You need to log in before you can comment on or make changes to this bug.