mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-20 08:51:04 +00:00
Bug 1162418 - Try to find a suitable non-zero dimension to use when containing block's inline-size depends on an SVG element which is specified as a percentage of its container. r=jwatt
This commit is contained in:
parent
cafe2dfc67
commit
6bf6268612
@ -168,15 +168,33 @@ nsSVGOuterSVGFrame::GetPrefISize(nsRenderingContext *aRenderingContext)
|
||||
DISPLAY_PREF_WIDTH(this, result);
|
||||
|
||||
SVGSVGElement *svg = static_cast<SVGSVGElement*>(mContent);
|
||||
nsSVGLength2 &width = svg->mLengthAttributes[SVGSVGElement::ATTR_WIDTH];
|
||||
WritingMode wm = GetWritingMode();
|
||||
const nsSVGLength2& isize = wm.IsVertical()
|
||||
? svg->mLengthAttributes[SVGSVGElement::ATTR_HEIGHT]
|
||||
: svg->mLengthAttributes[SVGSVGElement::ATTR_WIDTH];
|
||||
|
||||
if (width.IsPercentage()) {
|
||||
// It looks like our containing block's width may depend on our width. In
|
||||
// that case our behavior is undefined according to CSS 2.1 section 10.3.2,
|
||||
// so return zero.
|
||||
if (isize.IsPercentage()) {
|
||||
// It looks like our containing block's isize may depend on our isize. In
|
||||
// that case our behavior is undefined according to CSS 2.1 section 10.3.2.
|
||||
// As a last resort, we'll fall back to returning zero.
|
||||
result = nscoord(0);
|
||||
|
||||
// Returning zero may be unhelpful, however, as it leads to unexpected
|
||||
// disappearance of %-sized SVGs in orthogonal contexts, where our
|
||||
// containing block wants to shrink-wrap. So let's look for an ancestor
|
||||
// with non-zero size in this dimension, and use that as a (somewhat
|
||||
// arbitrary) result instead.
|
||||
nsIFrame *parent = GetParent();
|
||||
while (parent) {
|
||||
nscoord parentISize = parent->GetLogicalSize(wm).ISize(wm);
|
||||
if (parentISize > 0 && parentISize != NS_UNCONSTRAINEDSIZE) {
|
||||
result = parentISize;
|
||||
break;
|
||||
}
|
||||
parent = parent->GetParent();
|
||||
}
|
||||
} else {
|
||||
result = nsPresContext::CSSPixelsToAppUnits(width.GetAnimValue(svg));
|
||||
result = nsPresContext::CSSPixelsToAppUnits(isize.GetAnimValue(svg));
|
||||
if (result < 0) {
|
||||
result = nscoord(0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user