Closed Bug 620468 Opened 10 years ago Closed 9 years ago

"ASSERTION: viewport width must be nonnegative"

Categories

(Core :: SVG, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: jruderman, Assigned: heycam)

References

(Blocks 1 open bug)

Details

(Keywords: assertion, regression, testcase)

Attachments

(3 files)

Attached image testcase
###!!! ASSERTION: viewport width must be nonnegative!: 'aViewportWidth >= 0', file layout/svg/base/src/nsSVGUtils.cpp, line 797
Attached file stack trace
This is a new assertion that I added in bug 272288 yesterday, to tighten up assumptions in nsSVGUtils::GetViewBoxTransform.

Negative widths aren't valid for <image> or <svg>, according to the spec:
 "A negative value is an error (see Error processing)"
 http://www.w3.org/TR/SVG11/struct.html#ImageElementWidthAttribute
 http://www.w3.org/TR/SVG11/struct.html#SVGElementWidthAttribute

Not sure if we currently trigger error-handling-code for this case...  If we don't want to bail out earlier than this, we could always just pass "max(0, width)" instead of "width" into nsSVGUtils::GetViewBoxTransform for cases like this.
We don't trigger error handling code as we don't distinguish between different types of length when we parse them. i.e. width (no negatives allowed) and x (negatives OK).

We just want to bail as early as possible in a way that makes mRect in nsSVGPathGeometryFrame the empty rect.
i.e. calling  nsSVGUtils::GetViewBoxTransform is pretty pointless if width <= 0 as we're not going to draw anything.
Assignee: nobody → cam
Status: NEW → ASSIGNED
Attachment #598633 - Flags: review?(longsonr) → review+
https://hg.mozilla.org/mozilla-central/rev/94423051f0fd
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
You need to log in before you can comment on or make changes to this bug.