Bug 1674863 Part 3 - Add GetIntrinsicSize() override for nsVideoFrame. r=emilio

Also, delete unused rendering context parameter for
GetVideoIntrinsicSize().

Differential Revision: https://phabricator.services.mozilla.com/D95579
This commit is contained in:
Ting-Yu Lin 2020-11-03 19:54:51 +00:00
Родитель 8cd9090bc6
Коммит e841fbf716
7 изменённых файлов: 78 добавлений и 9 удалений

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

@ -567,12 +567,9 @@ nsIFrame::SizeComputationResult nsVideoFrame::ComputeSize(
aBorderPadding, aFlags);
}
nsSize size = GetVideoIntrinsicSize(aRenderingContext);
IntrinsicSize intrinsicSize(size.width, size.height);
return {ComputeSizeWithIntrinsicDimensions(
aRenderingContext, aWM, intrinsicSize, GetAspectRatio(), aCBSize,
aMargin, aBorderPadding, aFlags),
aRenderingContext, aWM, GetIntrinsicSize(), GetAspectRatio(),
aCBSize, aMargin, aBorderPadding, aFlags),
AspectRatioUsage::None};
}
@ -581,7 +578,7 @@ nscoord nsVideoFrame::GetMinISize(gfxContext* aRenderingContext) {
DISPLAY_MIN_INLINE_SIZE(this, result);
if (HasVideoElement()) {
nsSize size = GetVideoIntrinsicSize(aRenderingContext);
nsSize size = GetVideoIntrinsicSize();
result = GetWritingMode().IsVertical() ? size.height : size.width;
} else {
// We expect last and only child of audio elements to be control if
@ -603,7 +600,7 @@ nscoord nsVideoFrame::GetPrefISize(gfxContext* aRenderingContext) {
DISPLAY_PREF_INLINE_SIZE(this, result);
if (HasVideoElement()) {
nsSize size = GetVideoIntrinsicSize(aRenderingContext);
nsSize size = GetVideoIntrinsicSize();
result = GetWritingMode().IsVertical() ? size.height : size.width;
} else {
// We expect last and only child of audio elements to be control if
@ -674,7 +671,7 @@ bool nsVideoFrame::ShouldDisplayPoster() const {
return true;
}
nsSize nsVideoFrame::GetVideoIntrinsicSize(gfxContext* aRenderingContext) {
nsSize nsVideoFrame::GetVideoIntrinsicSize() const {
// 'contain:size' replaced elements have intrinsic size 0,0.
if (StyleDisplay()->IsContainSize()) {
return nsSize(0, 0);
@ -694,6 +691,10 @@ nsSize nsVideoFrame::GetVideoIntrinsicSize(gfxContext* aRenderingContext) {
return CSSPixel::ToAppUnits(kFallbackIntrinsicSizeInPixels);
}
IntrinsicSize nsVideoFrame::GetIntrinsicSize() {
return IntrinsicSize(GetVideoIntrinsicSize());
}
void nsVideoFrame::UpdatePosterSource(bool aNotify) {
NS_ASSERTION(HasVideoElement(), "Only call this on <video> elements.");
HTMLVideoElement* element = static_cast<HTMLVideoElement*>(GetContent());

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

@ -54,7 +54,8 @@ class nsVideoFrame final : public nsContainerFrame,
const Maybe<OnNonvisible>& aNonvisibleAction = Nothing()) override;
/* get the size of the video's display */
nsSize GetVideoIntrinsicSize(gfxContext* aRenderingContext);
nsSize GetVideoIntrinsicSize() const;
mozilla::IntrinsicSize GetIntrinsicSize() override;
mozilla::AspectRatio GetIntrinsicRatio() const override;
SizeComputationResult ComputeSize(gfxContext* aRenderingContext,
mozilla::WritingMode aWM,

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

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
body>div { margin: 50px 20px; width: 400px; height: 500px; border: 5px solid blue; }
.abc { display: inline-block; border: 2px solid red; inline-size: 30px;
writing-mode: vertical-rl; position: absolute; right: 0; top: 0; }
.test { background: #aaa; position: absolute; right: 0; top: 0; width: 2em; height: 100%; }
.rel { position: relative; }
video {
position: absolute; right: 0; top: 34px;
background: yellow; border: 5px solid green;
width: 300px; height: 150px;
}
</style>
<body>
<div class="rel">
<div class="test"><span class="abc">abc</span><video src=""></video></div>
</div>

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

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
body>div { margin: 50px 20px; width: 400px; height: 500px; border: 5px solid blue; }
.abc { display: inline-block; border: 2px solid red; inline-size: 30px; }
.test { background: #aaa; width: 2em; }
.vrl { writing-mode: vertical-rl; }
.rel { position: relative; }
video { position: absolute; background: yellow; border: 5px solid green; }
</style>
<body>
<div class="vrl">
<div class="test"><span class="abc">abc</span><video src=""></video></div>
</div>

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

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
body>div { margin: 50px 20px; width: 400px; height: 500px; border: 5px solid blue; }
.abc { display: inline-block; border: 2px solid red; inline-size: 30px; }
.test { background: #aaa; width: 2em; }
.vrl { writing-mode: vertical-rl; }
.rel { position: relative; }
video { position: absolute; background: yellow; border: 5px solid green; }
</style>
<body>
<div class="vrl rel">
<div class="test"><span class="abc">abc</span><video src=""></video></div>
</div>

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

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
body>div { margin: 50px 20px; width: 400px; height: 500px; border: 5px solid blue; }
.abc { display: inline-block; border: 2px solid red; inline-size: 30px; }
.test { background: #aaa; width: 2em; }
.vrl { writing-mode: vertical-rl; }
.rel { position: relative; }
video { position: absolute; background: yellow; border: 5px solid green; }
</style>
<body>
<div class="vrl">
<div class="test rel"><span class="abc">abc</span><video src=""></video></div>
</div>

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

@ -22,3 +22,6 @@ fails == 1183431-orthogonal-modes-6a.html 1183431-orthogonal-modes-6-ref.html #
== 1183431-orthogonal-modes-8a.html 1183431-orthogonal-modes-8-ref.html
== 1183431-orthogonal-modes-8b.html 1183431-orthogonal-modes-8-ref.html
== 1183431-orthogonal-modes-8c.html 1183431-orthogonal-modes-8-ref.html
== 1183431-orthogonal-modes-9a.html 1183431-orthogonal-modes-9-ref.html
== 1183431-orthogonal-modes-9b.html 1183431-orthogonal-modes-9-ref.html
== 1183431-orthogonal-modes-9c.html 1183431-orthogonal-modes-9-ref.html