Percentage dimensions on SVG in a foreignObject are broken

RESOLVED FIXED

Status

()

RESOLVED FIXED
11 years ago
11 years ago

People

(Reporter: jwatt, Assigned: jwatt)

Tracking

Trunk
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Assignee)

Description

11 years ago
Created attachment 295785 [details]
testcase

Percentage dimensions on SVG descendants of a foreignObject do not work correctly when the descendant <svg> has a percentage width/height. This is because we end up going one coordinate context too high. More specifically, when resolving the percentage dimensions for the ellipse inside the foreignObject in the testcase attached, we end up with a stack like this:

  nsSVGElement::GetOwnerSVGElement()
  nsSVGSVGElement::GetOwnerSVGElement()
  nsSVGElement::GetCtx()
  nsSVGSVGElement::GetLength()
  nsSVGLength2::GetAxisLength()
  nsSVGLength2::GetUnitScaleFactor()
  nsSVGLength2::GetAnimValue()
  nsSVGElement::GetAnimatedLengthValues()
  nsSVGEllipseElement::ConstructPath()

When nsSVGSVGElement::GetLength() is called on the <svg> descendant of the <foreignObject>, it calls GetCtx() to resolve its own percentage width/height. At this point we want GetCtx to return null so that we use mViewportWidth and mViewportHeight as set by nsSVGOuterSVGFrame. Unfortunately it returns the <svg> parent of the <foreignObject> and we end up resolving percentages against it.
(Assignee)

Updated

11 years ago
Status: NEW → ASSIGNED
(Assignee)

Comment 1

11 years ago
Created attachment 295918 [details] [diff] [review]
patch
Attachment #295918 - Flags: superreview?(tor)
Attachment #295918 - Flags: review?(longsonr)
Comment on attachment 295918 [details] [diff] [review]
patch

>   // are _we_ the outermost SVG element? If yes, return nsnull, but don't fail
>-  nsCOMPtr<nsIDOMSVGSVGElement> SVGSVGElement = do_QueryInterface((nsIDOMSVGElement*)this);
>-  if (SVGSVGElement) return NS_OK;
>+  if (this->Tag() == nsGkAtoms::svg) {

remove this-> there is a prior comment which makes it clear enough what is going on.

r=longsonr with that.
Attachment #295918 - Flags: review?(longsonr) → review+
(Assignee)

Comment 3

11 years ago
Oops, yeah. Thanks.

Updated

11 years ago
Attachment #295918 - Flags: superreview?(tor) → superreview+
(Assignee)

Comment 4

11 years ago
Comment on attachment 295918 [details] [diff] [review]
patch

Requesting approval1.9. Low risk change to fix percentage dimensions on SVG in a foreignObject.
Attachment #295918 - Flags: approval1.9?

Comment 5

11 years ago
Comment on attachment 295918 [details] [diff] [review]
patch

a1.9+ Awesome - and thanks for the reftests
Attachment #295918 - Flags: approval1.9? → approval1.9+
(Assignee)

Comment 6

11 years ago
Checked in.
Status: ASSIGNED → RESOLVED
Last Resolved: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.