Fixing bug 411146. Percentage dimensions on SVG in a foreignObject are broken. r=longsonr@gmail.com, sr=tor@acm.org, a1.9=mtschrep@gmail.com

This commit is contained in:
jwatt%jwatt.org 2008-01-09 09:34:52 +00:00
Родитель ec06c9c411
Коммит 66e80bab16
5 изменённых файлов: 94 добавлений и 6 удалений

Просмотреть файл

@ -738,10 +738,15 @@ nsSVGElement::GetOwnerSVGElement(nsIDOMSVGSVGElement * *aOwnerSVGElement)
parent = GetParent();
}
while (parent) {
nsCOMPtr<nsIDOMSVGSVGElement> SVGSVGElement = do_QueryInterface(parent);
if (SVGSVGElement) {
*aOwnerSVGElement = SVGSVGElement;
while (parent && parent->GetNameSpaceID() == kNameSpaceID_SVG) {
nsIAtom* tag = parent->Tag();
if (tag == nsGkAtoms::foreignObject) {
// SVG in a foreignObject must have its own <svg> (nsSVGOuterSVGFrame).
// Leave *aOwnerSVGElement nulled out, but don't throw.
return NS_OK;
}
if (tag == nsGkAtoms::svg) {
*aOwnerSVGElement = static_cast<nsSVGSVGElement*>(parent);
NS_ADDREF(*aOwnerSVGElement);
return NS_OK;
}
@ -761,8 +766,9 @@ nsSVGElement::GetOwnerSVGElement(nsIDOMSVGSVGElement * *aOwnerSVGElement)
// we don't have a parent SVG element...
// 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 (Tag() == nsGkAtoms::svg) {
return NS_OK;
}
// no owner found and we aren't the outermost SVG element either.
// this situation can e.g. occur during content tree teardown.

Просмотреть файл

@ -27,6 +27,8 @@ fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == opacity-and-gradient-01.svg pass.svg #
== rootElement-null-01.svg pass.svg
== stroke-width-percentage-01.svg pass.svg
fails == style-property-not-on-script-element-01.svg pass.svg
== svg-in-foreignObject-01.xhtml svg-in-foreignObject-01-ref.xhtml
== svg-in-foreignObject-02.xhtml svg-in-foreignObject-01-ref.xhtml # reuse -01-ref.xhtml
random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == text-font-weight-01.svg text-font-weight-01-ref.svg # bug 386713
== text-in-link-01.svg text-in-link-01-ref.svg
== text-style-01a.svg text-style-01-ref.svg

Просмотреть файл

@ -0,0 +1,24 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=411146 -->
<title>Reference for svg-in-foreignObject-01.xhtml</title>
<svg width="25%" height="25%">
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
</svg>
<svg x="25%" width="25%" height="25%">
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
</svg>
<svg y="25%" width="25%" height="25%">
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
</svg>
<svg x="25%" y="25%" width="25%" height="25%">
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
</svg>
</svg>

После

Ширина:  |  Высота:  |  Размер: 789 B

Просмотреть файл

@ -0,0 +1,27 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=411146 -->
<title>Test percentages dimensions for SVG inside a foreignObject</title>
<foreignObject width="50%" height="50%">
<svg xmlns="http://www.w3.org/2000/svg" width="50%" height="50%">
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
</svg>
</foreignObject>
<svg x="25%" width="25%" height="25%">
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
</svg>
<svg y="25%" width="25%" height="25%">
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
</svg>
<svg x="25%" y="25%" width="25%" height="25%">
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
</svg>
</svg>

После

Ширина:  |  Высота:  |  Размер: 911 B

Просмотреть файл

@ -0,0 +1,29 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=411146 -->
<title>Test percentages dimensions for SVG inside a foreignObject</title>
<foreignObject width="50%" height="50%">
<div xmlns="http://www.w3.org/1999/xhtml" style="width:100%;height:100%;">
<svg xmlns="http://www.w3.org/2000/svg" width="50%" height="50%">
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
</svg>
</div>
</foreignObject>
<svg x="25%" width="25%" height="25%">
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
</svg>
<svg y="25%" width="25%" height="25%">
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
</svg>
<svg x="25%" y="25%" width="25%" height="25%">
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
</svg>
</svg>

После

Ширина:  |  Высота:  |  Размер: 1009 B