mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 726904: Make nsVideoFrame::GetVideoIntrinsicSize return the video size before the poster size. r=cpearce
This commit is contained in:
parent
6ad81bbb5c
commit
a51913e89c
@ -83,9 +83,9 @@ public:
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
// Returns the current video frame width and height.
|
||||
// If there is no video frame, returns the given default size.
|
||||
nsIntSize GetVideoSize(nsIntSize defaultSize);
|
||||
// Set size with the current video frame's height and width.
|
||||
// If there is no video frame, returns NS_ERROR_FAILURE.
|
||||
nsresult GetVideoSize(nsIntSize* size);
|
||||
|
||||
virtual nsresult SetAcceptHeader(nsIHttpChannel* aChannel);
|
||||
|
||||
|
@ -112,9 +112,15 @@ nsHTMLVideoElement::~nsHTMLVideoElement()
|
||||
{
|
||||
}
|
||||
|
||||
nsIntSize nsHTMLVideoElement::GetVideoSize(nsIntSize aDefaultSize)
|
||||
nsresult nsHTMLVideoElement::GetVideoSize(nsIntSize* size)
|
||||
{
|
||||
return mMediaSize.width == -1 && mMediaSize.height == -1 ? aDefaultSize : mMediaSize;
|
||||
if (mMediaSize.width == -1 && mMediaSize.height == -1) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
size->height = mMediaSize.height;
|
||||
size->width = mMediaSize.width;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -283,6 +283,7 @@ _TEST_FILES += \
|
||||
test_audio_event_adopt.html \
|
||||
test_framebuffer.html \
|
||||
test_referer.html \
|
||||
test_bug726904.html \
|
||||
test_bug686137.html \
|
||||
$(NULL)
|
||||
else
|
||||
|
@ -8,7 +8,7 @@ var gSmallTests = [
|
||||
{ name:"small-shot.ogg", type:"audio/ogg", duration:0.276 },
|
||||
{ name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
|
||||
{ name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.233 },
|
||||
{ name:"seek.webm", type:"video/webm", duration:3.966 },
|
||||
{ name:"seek.webm", type:"video/webm", width:320, height:240, duration:3.966 },
|
||||
{ name:"detodos.opus", type:"audio/ogg; codecs=opus", duration:2.9135 },
|
||||
{ name:"bogus.duh", type:"bogus/duh" }
|
||||
];
|
||||
|
53
content/media/test/test_bug726904.html
Normal file
53
content/media/test/test_bug726904.html
Normal file
@ -0,0 +1,53 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=726904
|
||||
-->
|
||||
|
||||
<head>
|
||||
<title>Media test: default video size</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body onload="bodyLoaded();">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=726904">Mozilla Bug 726904</a>
|
||||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var v1 = document.createElement("video"),
|
||||
v2 = document.createElement("video"),
|
||||
poster = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAAAAACl1GkQAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAALJJREFUeNrtwQENAAAAwqD3T20ON6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHg0cq4AATRk8BYAAAAASUVORK5CYII",
|
||||
resource = getPlayableVideo(gSmallTests);
|
||||
|
||||
function bodyLoaded(){
|
||||
is(v1.videoWidth, resource.width, "Intrinsic width should match video width");
|
||||
is(v1.videoHeight, resource.height, "Intrinsic height should match video height");
|
||||
is(v2.clientWidth, 400, "clientWidth should be 400");
|
||||
is(v2.clientHeight, 400, "clientHeight should be 400");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
if (resource) {
|
||||
v1.poster = v2.poster = poster;
|
||||
|
||||
v1.src = v2.src = "http://mochi.test:8888/tests/content/media/test/" + resource.name;
|
||||
|
||||
v1.preload = "auto";
|
||||
v2.preload = "none";
|
||||
|
||||
v1.muted = v2.muted = true;
|
||||
|
||||
document.body.appendChild(v1);
|
||||
document.body.appendChild(v2);
|
||||
} else {
|
||||
todo(false, "No types supported");
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -190,9 +190,10 @@ nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||
{
|
||||
nsRect area = GetContentRect() - GetPosition() + aItem->ToReferenceFrame();
|
||||
nsHTMLVideoElement* element = static_cast<nsHTMLVideoElement*>(GetContent());
|
||||
nsIntSize videoSize = element->GetVideoSize(nsIntSize(0, 0));
|
||||
if (videoSize.width <= 0 || videoSize.height <= 0 || area.IsEmpty())
|
||||
nsIntSize videoSize;
|
||||
if (NS_FAILED(element->GetVideoSize(&videoSize)) || area.IsEmpty()) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsRefPtr<ImageContainer> container = element->GetImageContainer();
|
||||
if (!container)
|
||||
@ -525,19 +526,7 @@ nsVideoFrame::GetVideoIntrinsicSize(nsRenderingContext *aRenderingContext)
|
||||
{
|
||||
// Defaulting size to 300x150 if no size given.
|
||||
nsIntSize size(300, 150);
|
||||
|
||||
if (ShouldDisplayPoster()) {
|
||||
// Use the poster image frame's size.
|
||||
nsIFrame *child = mFrames.FirstChild();
|
||||
if (child && child->GetType() == nsGkAtoms::imageFrame) {
|
||||
nsImageFrame* imageFrame = static_cast<nsImageFrame*>(child);
|
||||
nsSize imgsize;
|
||||
if (NS_SUCCEEDED(imageFrame->GetIntrinsicImageSize(imgsize))) {
|
||||
return imgsize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!HasVideoElement()) {
|
||||
if (!aRenderingContext || !mFrames.FirstChild()) {
|
||||
// We just want our intrinsic ratio, but audio elements need no
|
||||
@ -553,7 +542,15 @@ nsVideoFrame::GetVideoIntrinsicSize(nsRenderingContext *aRenderingContext)
|
||||
}
|
||||
|
||||
nsHTMLVideoElement* element = static_cast<nsHTMLVideoElement*>(GetContent());
|
||||
size = element->GetVideoSize(size);
|
||||
if (NS_FAILED(element->GetVideoSize(&size)) && ShouldDisplayPoster()) {
|
||||
// Use the poster image frame's size.
|
||||
nsIFrame *child = mPosterImage->GetPrimaryFrame();
|
||||
nsImageFrame* imageFrame = do_QueryFrame(child);
|
||||
nsSize imgsize;
|
||||
if (NS_SUCCEEDED(imageFrame->GetIntrinsicImageSize(imgsize))) {
|
||||
return imgsize;
|
||||
}
|
||||
}
|
||||
|
||||
return nsSize(nsPresContext::CSSPixelsToAppUnits(size.width),
|
||||
nsPresContext::CSSPixelsToAppUnits(size.height));
|
||||
@ -599,6 +596,7 @@ bool nsVideoFrame::HasVideoData()
|
||||
if (!HasVideoElement())
|
||||
return false;
|
||||
nsHTMLVideoElement* element = static_cast<nsHTMLVideoElement*>(GetContent());
|
||||
nsIntSize size = element->GetVideoSize(nsIntSize(0,0));
|
||||
nsIntSize size(0, 0);
|
||||
element->GetVideoSize(&size);
|
||||
return size != nsIntSize(0,0);
|
||||
}
|
||||
|
BIN
layout/reftests/ogg-video/blue140x100.png
Normal file
BIN
layout/reftests/ogg-video/blue140x100.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 277 B |
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body style="background:white;">
|
||||
<!-- Test if poster frame displays correctly when poster is different size. -->
|
||||
<video src="black140x100.ogv" poster="blue250x200.png"></video>
|
||||
<!-- Ensure video element displays at poster size when video's intrinsic size isn't available. -->
|
||||
<video preload="none" src="black140x100.ogv" poster="blue250x200.png"></video>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -11,7 +11,7 @@ function runTest() {
|
||||
|
||||
var addPoster = function() {
|
||||
v.removeEventListener('loadeddata', addPoster, false);
|
||||
v.poster = "blue250x200.png";
|
||||
v.poster = "blue140x100.png";
|
||||
v.addEventListener('loadeddata', endTest, false);
|
||||
v.load();
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ function runTest() {
|
||||
|
||||
var addPoster = function() {
|
||||
v.removeEventListener('playing', addPoster,false);
|
||||
v.poster = "blue250x200.png";
|
||||
v.poster = "blue140x100.png";
|
||||
v.addEventListener('loadeddata', endTest, false);
|
||||
v.load();
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
<body style="background:white;">
|
||||
<video src="black140x100.ogv"
|
||||
poster="green70x30.png"
|
||||
preload="auto"
|
||||
preload="none"
|
||||
style="border: solid blue 2px;">
|
||||
</video>
|
||||
</body>
|
||||
|
@ -3,9 +3,9 @@
|
||||
<body style="background:white;">
|
||||
<!-- Test that poster frame changes when you change the poster attribute. -->
|
||||
<video src="black140x100.ogv"
|
||||
preload="auto"
|
||||
preload="none"
|
||||
id="v"
|
||||
onload="document.getElementById('v').poster = 'red160x120.png'; setTimeout(function(){document.documentElement.className = '';}, 0);"
|
||||
onload="document.getElementById('v').poster = 'red140x100.png'; setTimeout(function(){document.documentElement.className = '';}, 0);"
|
||||
poster="blue250x200.png"></video>
|
||||
</body>
|
||||
</html>
|
||||
|
6
layout/reftests/ogg-video/poster-ref-blue140x100.html
Normal file
6
layout/reftests/ogg-video/poster-ref-blue140x100.html
Normal file
@ -0,0 +1,6 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body style="background:white;">
|
||||
<img src="blue140x100.png" alt="poster">
|
||||
</body>
|
||||
</html>
|
@ -1,6 +1,6 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body style="background:white;">
|
||||
<img src="red160x120.png" alt="poster">
|
||||
<img src="red140x100.png" alt="poster">
|
||||
</body>
|
||||
</html>
|
BIN
layout/reftests/ogg-video/red140x100.png
Normal file
BIN
layout/reftests/ogg-video/red140x100.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 274 B |
@ -24,10 +24,10 @@ skip-if(Android) == poster-3.html poster-ref-black140x100.html
|
||||
skip-if(Android) == poster-4.html poster-ref-black140x100.html
|
||||
skip-if(Android) == poster-5.html poster-ref-black140x100.html
|
||||
skip-if(Android) == poster-6.html poster-ref-black140x100.html
|
||||
skip-if(Android) == poster-7.html poster-ref-red160x120.html
|
||||
skip-if(Android) == poster-7.html poster-ref-red140x100.html
|
||||
skip-if(Android) == poster-8.html poster-ref-black140x100.html
|
||||
skip-if(Android) == poster-10.html poster-ref-blue250x200.html
|
||||
skip-if(Android) == poster-11.html poster-ref-blue250x200.html
|
||||
skip-if(Android) == poster-12.html poster-ref-blue250x200.html
|
||||
skip-if(Android) == poster-10.html poster-ref-blue140x100.html
|
||||
skip-if(Android) == poster-11.html poster-ref-blue140x100.html
|
||||
skip-if(Android) == poster-12.html poster-ref-blue140x100.html
|
||||
skip-if(Android) == poster-13.html poster-ref-blue400x300.html
|
||||
skip-if(Android) == poster-15.html poster-ref-green70x30.html
|
||||
|
BIN
layout/reftests/webm-video/blue140x100.png
Normal file
BIN
layout/reftests/webm-video/blue140x100.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 277 B |
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body style="background:white;">
|
||||
<!-- Test if poster frame displays correctly when poster is different size. -->
|
||||
<video src="black140x100.webm" poster="blue250x200.png"></video>
|
||||
<!-- Ensure video element displays at poster size when video's intrinsic size isn't available -->
|
||||
<video preload="none" src="black140x100.webm" poster="blue250x200.png"></video>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -11,7 +11,7 @@ function runTest() {
|
||||
|
||||
var addPoster = function() {
|
||||
v.removeEventListener('loadeddata', addPoster, false);
|
||||
v.poster = "blue250x200.png";
|
||||
v.poster = "blue140x100.png";
|
||||
v.addEventListener('loadeddata', endTest, false);
|
||||
v.load();
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ function runTest() {
|
||||
|
||||
var addPoster = function() {
|
||||
v.removeEventListener('playing', addPoster,false);
|
||||
v.poster = "blue250x200.png";
|
||||
v.poster = "blue140x100.png";
|
||||
v.addEventListener('loadeddata', endTest, false);
|
||||
v.load();
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
<body style="background:white;">
|
||||
<video src="black140x100.webm"
|
||||
poster="green70x30.png"
|
||||
preload="auto"
|
||||
preload="none"
|
||||
style="border: solid blue 2px;">
|
||||
</video>
|
||||
</body>
|
||||
|
@ -3,9 +3,9 @@
|
||||
<body style="background:white;">
|
||||
<!-- Test that poster frame changes when you change the poster attribute. -->
|
||||
<video src="black140x100.webm"
|
||||
preload="auto"
|
||||
preload="none"
|
||||
id="v"
|
||||
onload="document.getElementById('v').poster = 'red160x120.png'; setTimeout(function(){document.documentElement.className = '';}, 0);"
|
||||
onload="document.getElementById('v').poster = 'red140x100.png'; setTimeout(function(){document.documentElement.className = '';}, 0);"
|
||||
poster="blue250x200.png"></video>
|
||||
</body>
|
||||
</html>
|
||||
|
6
layout/reftests/webm-video/poster-ref-blue140x100.html
Normal file
6
layout/reftests/webm-video/poster-ref-blue140x100.html
Normal file
@ -0,0 +1,6 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body style="background:white;">
|
||||
<img src="blue140x100.png" alt="poster">
|
||||
</body>
|
||||
</html>
|
6
layout/reftests/webm-video/poster-ref-red140x100.html
Normal file
6
layout/reftests/webm-video/poster-ref-red140x100.html
Normal file
@ -0,0 +1,6 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body style="background:white;">
|
||||
<img src="red140x100.png" alt="poster">
|
||||
</body>
|
||||
</html>
|
BIN
layout/reftests/webm-video/red140x100.png
Normal file
BIN
layout/reftests/webm-video/red140x100.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 274 B |
@ -24,11 +24,11 @@ skip-if(Android) == poster-3.html poster-ref-black140x100.html
|
||||
skip-if(Android) == poster-4.html poster-ref-black140x100.html
|
||||
skip-if(Android) == poster-5.html poster-ref-black140x100.html
|
||||
skip-if(Android) == poster-6.html poster-ref-black140x100.html
|
||||
skip-if(Android) == poster-7.html poster-ref-red160x120.html
|
||||
skip-if(Android) == poster-7.html poster-ref-red140x100.html
|
||||
skip-if(Android) == poster-8.html poster-ref-black140x100.html
|
||||
skip-if(Android) == poster-10.html poster-ref-blue250x200.html
|
||||
skip-if(Android) == poster-11.html poster-ref-blue250x200.html
|
||||
skip-if(Android) == poster-12.html poster-ref-blue250x200.html
|
||||
skip-if(Android) == poster-10.html poster-ref-blue140x100.html
|
||||
skip-if(Android) == poster-11.html poster-ref-blue140x100.html
|
||||
skip-if(Android) == poster-12.html poster-ref-blue140x100.html
|
||||
skip-if(Android) == poster-13.html poster-ref-blue400x300.html
|
||||
skip-if(Android) == poster-15.html poster-ref-green70x30.html
|
||||
== bug686957.html bug686957-ref.html
|
||||
|
Loading…
Reference in New Issue
Block a user