mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1554568 - Should resolve font-size of inner svg from itself r=longsonr
Resolving length for inner <svg> is exactly the same as other ordinary element. We should not pass the context to `GetAnimValue()`, otherwise font-size will be obtained from the enclosing viewport of the inner <svg> rather than the inner <svg> itself. Differential Revision: https://phabricator.services.mozilla.com/D32657 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
3c7a906413
commit
d246402be3
@ -171,9 +171,9 @@ void SVGViewportElement::ChildrenOnlyTransformChanged(uint32_t aFlags) {
|
||||
gfx::Matrix SVGViewportElement::GetViewBoxTransform() const {
|
||||
float viewportWidth, viewportHeight;
|
||||
if (IsInner()) {
|
||||
SVGViewportElement* ctx = GetCtx();
|
||||
viewportWidth = mLengthAttributes[ATTR_WIDTH].GetAnimValue(ctx);
|
||||
viewportHeight = mLengthAttributes[ATTR_HEIGHT].GetAnimValue(ctx);
|
||||
SVGElement* self = const_cast<SVGViewportElement*>(this);
|
||||
viewportWidth = mLengthAttributes[ATTR_WIDTH].GetAnimValue(self);
|
||||
viewportHeight = mLengthAttributes[ATTR_HEIGHT].GetAnimValue(self);
|
||||
} else {
|
||||
viewportWidth = mViewportWidth;
|
||||
viewportHeight = mViewportHeight;
|
||||
@ -211,12 +211,15 @@ float SVGViewportElement::GetLength(uint8_t aCtxType) {
|
||||
w = viewbox->width;
|
||||
h = viewbox->height;
|
||||
} else if (IsInner()) {
|
||||
SVGViewportElement* ctx = GetCtx();
|
||||
// Resolving length for inner <svg> is exactly the same as other
|
||||
// ordinary element. We shouldn't use the SVGViewportElement overload
|
||||
// of GetAnimValue().
|
||||
SVGElement* self = this;
|
||||
if (shouldComputeWidth) {
|
||||
w = mLengthAttributes[ATTR_WIDTH].GetAnimValue(ctx);
|
||||
w = mLengthAttributes[ATTR_WIDTH].GetAnimValue(self);
|
||||
}
|
||||
if (shouldComputeHeight) {
|
||||
h = mLengthAttributes[ATTR_HEIGHT].GetAnimValue(ctx);
|
||||
h = mLengthAttributes[ATTR_HEIGHT].GetAnimValue(self);
|
||||
}
|
||||
} else if (ShouldSynthesizeViewBox()) {
|
||||
if (shouldComputeWidth) {
|
||||
|
@ -16,6 +16,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=342513
|
||||
</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="1" id="svg">
|
||||
</svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="400" font-size="5">
|
||||
<svg font-size="10" width="20em" height="20em">
|
||||
<rect id="r1" x="5em" y="6em" width="20%" height="30%" />
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
@ -37,6 +42,10 @@ function run() {
|
||||
// the valueInSpecifiedUnits should now be 50%
|
||||
is(Math.round(svgDoc.width.baseVal.valueInSpecifiedUnits), 50, "valueInSpecifiedUnits after convertToSpecifiedUnits");
|
||||
|
||||
let r1 = document.getElementById("r1");
|
||||
is(r1.width.baseVal.value, 40, "width in em for elements inside inner <svg> should be resolved against the inner <svg>");
|
||||
is(r1.height.baseVal.value, 60, "height in em for elements inside inner <svg> should be resolved against the inner <svg>");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user