зеркало из https://github.com/mozilla/gecko-dev.git
Bug 668163 - Map 'width' and 'height' on <svg> into style to stop <svg>'s computed width/height falling back to 150px x 300px when they're set to explicit percentage values that can be resolved (regression from bug 611099). r=dbaron.
This commit is contained in:
Родитель
992a5bdbde
Коммит
b2807a33da
|
@ -1112,6 +1112,24 @@ nsSVGElement::UpdateContentStyleRule()
|
|||
if (!attrName->IsAtom() || !IsAttributeMapped(attrName->Atom()))
|
||||
continue;
|
||||
|
||||
if (Tag() == nsGkAtoms::svg) {
|
||||
// Special case: we don't want <svg> 'width'/'height' mapped into style
|
||||
// if the attribute value isn't a valid <length> according to SVG (which
|
||||
// only supports a subset of the CSS <length> values). We don't enforce
|
||||
// this by checking the attribute value in nsSVGSVGElement::
|
||||
// IsAttributeMapped since we don't want that method to depend on the
|
||||
// value of the attribute that is being checked. Rather we just prevent
|
||||
// the actual mapping here, as necessary.
|
||||
if (attrName->Atom() == nsGkAtoms::width &&
|
||||
!GetAnimatedLength(nsGkAtoms::width)->HasBaseVal()) {
|
||||
continue;
|
||||
}
|
||||
if (attrName->Atom() == nsGkAtoms::height &&
|
||||
!GetAnimatedLength(nsGkAtoms::height)->HasBaseVal()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString value;
|
||||
mAttrsAndChildren.AttrAt(i)->ToString(value);
|
||||
mappedAttrParser.ParseMappedAttrValue(attrName->Atom(), value);
|
||||
|
@ -1314,6 +1332,20 @@ nsSVGElement::DidAnimateLength(PRUint8 aAttrEnum)
|
|||
}
|
||||
}
|
||||
|
||||
nsSVGLength2*
|
||||
nsSVGElement::GetAnimatedLength(const nsIAtom *aAttrName)
|
||||
{
|
||||
LengthAttributesInfo lengthInfo = GetLengthInfo();
|
||||
|
||||
for (PRUint32 i = 0; i < lengthInfo.mLengthCount; i++) {
|
||||
if (aAttrName == *lengthInfo.mLengthInfo[i].mName) {
|
||||
return &lengthInfo.mLengths[i];
|
||||
}
|
||||
}
|
||||
NS_ABORT_IF_FALSE(false, "no matching length found");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGElement::GetAnimatedLengthValues(float *aFirst, ...)
|
||||
{
|
||||
|
|
|
@ -195,6 +195,7 @@ public:
|
|||
virtual void DidAnimateTransformList();
|
||||
virtual void DidAnimateString(PRUint8 aAttrEnum);
|
||||
|
||||
nsSVGLength2* GetAnimatedLength(const nsIAtom *aAttrName);
|
||||
void GetAnimatedLengthValues(float *aFirst, ...);
|
||||
void GetAnimatedNumberValues(float *aFirst, ...);
|
||||
void GetAnimatedIntegerValues(PRInt32 *aFirst, ...);
|
||||
|
|
|
@ -100,6 +100,9 @@ public:
|
|||
float GetAnimValue(nsSVGSVGElement* aCtx) const
|
||||
{ return mAnimVal / GetUnitScaleFactor(aCtx, mSpecifiedUnitType); }
|
||||
|
||||
bool HasBaseVal() const {
|
||||
return mIsBaseSet;
|
||||
}
|
||||
// Returns true if the animated value of this length has been explicitly
|
||||
// set (either by animation, or by taking on the base value which has been
|
||||
// explicitly set by markup or a DOM call), false otherwise.
|
||||
|
|
|
@ -883,6 +883,20 @@ nsSVGSVGElement::GetTimedDocumentRoot()
|
|||
NS_IMETHODIMP_(bool)
|
||||
nsSVGSVGElement::IsAttributeMapped(const nsIAtom* name) const
|
||||
{
|
||||
// We want to map the 'width' and 'height' attributes into style for
|
||||
// outer-<svg>, except when the attributes aren't set (since their default
|
||||
// values of '100%' can cause unexpected and undesirable behaviour for SVG
|
||||
// inline in HTML). We rely on nsSVGElement::UpdateContentStyleRule() to
|
||||
// prevent mapping of the default values into style (it only maps attributes
|
||||
// that are set). We also rely on a check in nsSVGElement::
|
||||
// UpdateContentStyleRule() to prevent us mapping the attributes when they're
|
||||
// given a <length> value that is not currently recognized by the SVG
|
||||
// specification.
|
||||
|
||||
if (!IsInner() && (name == nsGkAtoms::width || name == nsGkAtoms::height)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static const MappedAttributeEntry* const map[] = {
|
||||
sColorMap,
|
||||
sFEFloodMap,
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" class="reftest-wait">
|
||||
<head>
|
||||
|
||||
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=294086 -->
|
||||
|
||||
<title>Test: resize of container block height</title>
|
||||
|
||||
<!--
|
||||
This testcase checks that SVG embedded inline with a percentage height is
|
||||
updated correctly when its containing block is resized.
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
html, body, div {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%; /* inline style override on the div below */
|
||||
background: white;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
|
||||
function resize_div()
|
||||
{
|
||||
var XHTML_NS = 'http://www.w3.org/1999/xhtml';
|
||||
document.getElementsByTagNameNS(XHTML_NS, 'div').item(0).style.height = '100%';
|
||||
document.documentElement.removeAttribute('class');
|
||||
}
|
||||
|
||||
document.addEventListener("MozReftestInvalidate", resize_div, false);
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div style="height:50%;">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="5000" height="100%">
|
||||
<rect width="100%" height="100%" fill="blue"/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,52 +0,0 @@
|
|||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" class="reftest-wait">
|
||||
<head>
|
||||
|
||||
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=294086 -->
|
||||
|
||||
<title>Test: resize of container block width</title>
|
||||
|
||||
<!--
|
||||
This testcase checks that SVG embedded inline with a percentage width is
|
||||
updated correctly when its containing block is resized.
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
html, body, div {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
width: 100%; /* inline style override on the div below */
|
||||
height: 100%;
|
||||
background: white;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
|
||||
function resize_div()
|
||||
{
|
||||
var XHTML_NS = 'http://www.w3.org/1999/xhtml';
|
||||
document.getElementsByTagNameNS(XHTML_NS, 'div').item(0).style.width = '100%';
|
||||
document.documentElement.removeAttribute('class');
|
||||
}
|
||||
|
||||
document.addEventListener("MozReftestInvalidate", resize_div, false);
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div style="width:50%;">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="5000">
|
||||
<rect width="100%" height="100%" fill="blue"/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -303,10 +303,6 @@ random-if(Android) == object--auto-auto--px-px.html object--auto-auto--px
|
|||
|
||||
== dynamic--inline-css-height.xhtml pass.svg
|
||||
== dynamic--inline-css-width.xhtml pass.svg
|
||||
# These two don't have a whole lot of point anymore now that the meaning
|
||||
# of percentages has changed.
|
||||
== dynamic--inline-resize-cb-height.xhtml standalone-sanity-height-150px.svg
|
||||
== dynamic--inline-resize-cb-width.xhtml standalone-sanity-width-300px.svg
|
||||
skip == dynamic--inline-resize-window-height.xhtml pass.svg # XXX breaks the reftest run as the window height somehow is not restored
|
||||
skip == dynamic--inline-resize-window-width.xhtml pass.svg # Fails way too much
|
||||
fails random-if(Android) == dynamic--object-svg-unloaded.xhtml pass.svg
|
||||
|
|
|
@ -59,7 +59,7 @@ load 385552-2.svg
|
|||
load 385840-1.svg
|
||||
load 385852-1.svg
|
||||
load 386475-1.xhtml
|
||||
load 386566-1.svg
|
||||
asserts(1) load 386566-1.svg # Bug 713626
|
||||
load 386690-1.svg
|
||||
load 387290-1.svg
|
||||
load 402408-1.svg
|
||||
|
|
Загрузка…
Ссылка в новой задаче