Closed Bug 428023 Opened 14 years ago Closed 14 years ago

Allow SVG without a viewBox to scroll when embedded by reference by a replaced element

Categories

(Core :: SVG, defect, P2)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: sagotsky, Assigned: jwatt)

References

()

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5

I'm working on a site which embeds a large svg document.  In firefox2, scrollbars appeared around the svg by default.  I can't get them to appear in firefox3 beta 5.  I've added svg { overflow:visible; } to my svg's css file.  

Note: it's entirely possible that this is my fault.  I'm having a very hard time googling for the problem because searches for svg and scrollbar give me demos of scrollbars implemented in svg, which is not what I'm looking for.

Also, I've seen this in Ubuntu hardy as well as windows XP.  

Reproducible: Always

Steps to Reproduce:
1. Visit svg.thuranni.net
2. See the grid?  It should have scrollbars around it
3. 
Actual Results:  
No scrollbars!

Expected Results:  
I expected scrollbars like what I see in firefox2.
Can you provide a simple (less than 1K) testcase please? Ensure the outer svg has width and height attributes.
Component: General → SVG
Product: Firefox → Core
QA Contact: general → general
The reason this is happening is because we've changed SVG to override the width and height of the SVG when it's embedded in <object>. This is necessary for the SVG to scale when you have a viewBox specified. Using:

javascript:alert(document.getElementsByTagName('object')[0].contentDocument.documentElement.getAttribute('viewBox'));

I see that you're not specifying a viewBox, and indeed, you don't want to in your use case.

I'm thinking I've probably seriously screwed up here on this aspect of the sizing work that I did. I'm not sure if it's too late to fix this though. :-/
Status: UNCONFIRMED → NEW
Ever confirmed: true
How would I go about using a viewBox?  I should point out that I'm not very well versed in SVG and I'm mostly just picking it up as I go.  I've been looking into scaling/zooming the whole image and a viewBox seemed like an option for that. (In reply to comment #2)  

I can work on a test case maybe tomorrow evening.  (In reply to comment #1)
Requesting blocking1.9.

In bug 294086 I fixed a long standing issue whereby we failed to override the width and height of SVG embedded by reference using HTML <object>. This bug prevented SVG from scaling to fit as it should. I seem to have been too aggressive in that work though, and we now override the width and height of SVG even when it doesn't have a viewBox specified (a viewBox is necessary to tell us how to scale to fit). This means I've broken an important use case. Users can now no longer use HTML <object> to embed SVG and have it scroll.

The fix is quick, easy, and very safe. I'll attach a patch shortly. I believe the amount of SVG content out there that will be broken by this change is easily high enough, and the use case I've prevented is important enough, to want to take this, even now.
Flags: blocking1.9?
OS: Windows XP → All
Priority: -- → P2
Hardware: PC → All
Version: unspecified → Trunk
Attached patch patchSplinter Review
Assignee: nobody → jwatt
Status: NEW → ASSIGNED
Attachment #314621 - Flags: superreview?(roc)
Attachment #314621 - Flags: review?(longsonr)
Flags: blocking1.9? → blocking1.9+
Attachment #314621 - Flags: review?(longsonr) → review+
(In reply to comment #3)
> I can work on a test case maybe tomorrow evening.  (In reply to comment #1)
> 

Looks like that is unnecessary now.

The patch here actually breaks some of the SVG sizing reftests, but only the tests checking that HTML <object> uses the intrinsic width/height of the SVG when the intrinsic width/height have percentage values. This was always a very dubious (probably useless) use case anyway, and certainly the scrolling use case is far more important. I'm happy to trade the one for the other. Other than that, all tests pass fine. My sr request therefore still stands.
Attachment #314621 - Flags: superreview?(roc) → superreview+
Comment on attachment 314621 [details] [diff] [review]
patch

Requesting approval. See comment 4 for severity and risk descriptions.
Attachment #314621 - Flags: approval1.9?
Checked in.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Summary: Scrollbars do not appear on large svg documents, even with overflow: visible → Allow SVG without a viewBox to scroll when embedded by reference by a replaced element
Depends on: 460639
You need to log in before you can comment on or make changes to this bug.