зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1639963 - Support aspect-ratio for svg object and iframe (i.e. nsSubDocumentFrame). r=emilio
When <object> targets to a svg image, we use nsSubDocumentFrame. The intrinsic ratio should be overridden by aspect-ratio while computing its size on this frame. This update in nsSubDocumentFrame also works in iframe. Differential Revision: https://phabricator.services.mozilla.com/D79362
This commit is contained in:
Родитель
10e1d0f620
Коммит
0b7ae2d7e9
|
@ -633,12 +633,24 @@ IntrinsicSize nsSubDocumentFrame::GetIntrinsicSize() {
|
|||
|
||||
/* virtual */
|
||||
AspectRatio nsSubDocumentFrame::GetIntrinsicRatio() {
|
||||
const auto& aspectRatio = StylePosition()->mAspectRatio;
|
||||
if (!aspectRatio.auto_) {
|
||||
return aspectRatio.ratio.AsRatio().ToLayoutRatio();
|
||||
}
|
||||
|
||||
// FIXME(emilio): This should probably respect contain: size and return no
|
||||
// ratio in the case subDocRoot is non-null. Otherwise we do it by virtue of
|
||||
// using a zero-size below and reusing GetIntrinsicSize().
|
||||
if (nsIFrame* subDocRoot = ObtainIntrinsicSizeFrame()) {
|
||||
return subDocRoot->GetIntrinsicRatio();
|
||||
if (AspectRatio subDocRatio = subDocRoot->GetIntrinsicRatio()) {
|
||||
return subDocRatio;
|
||||
}
|
||||
}
|
||||
|
||||
if (aspectRatio.HasRatio()) {
|
||||
return aspectRatio.ratio.AsRatio().ToLayoutRatio();
|
||||
}
|
||||
|
||||
// NOTE(emilio): Even though we have an intrinsic size, we may not have an
|
||||
// intrinsic ratio. For example `<iframe style="width: 100px">` should not
|
||||
// shrink in the vertical axis to preserve the 300x150 ratio.
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
[replaced-element-002.tentative.html]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[replaced-element-006.tentative.html]
|
||||
expected: FAIL
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<title>CSS aspect-ratio: SVG object with intrinsic size (auto && ratio)</title>
|
||||
<link rel="author" title="Google LLC" href="https://www.google.com/">
|
||||
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio">
|
||||
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht" />
|
||||
|
||||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
|
||||
|
||||
<object type="image/svg+xml" data="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1 1' style='background-color: green'%3E%3C/svg%3E"
|
||||
style="width: 100px; aspect-ratio: auto 5/1;"></object>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<title>CSS aspect-ratio: SVG object without intrinsic size (auto && ratio)</title>
|
||||
<link rel="author" title="Mozilla" href="https://www.mozilla.org/">
|
||||
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio">
|
||||
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht" />
|
||||
|
||||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
|
||||
|
||||
<object type="image/svg+xml" data="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='background-color: green'%3E%3C/svg%3E"
|
||||
style="width: 100px; aspect-ratio: auto 1/1;"></object>
|
Загрузка…
Ссылка в новой задаче