Bug 1836128 - Implement source media for media elements and reference/update relevant platform tests r=padenot

Differential Revision: https://phabricator.services.mozilla.com/D189416
This commit is contained in:
scottjehl 2023-10-03 13:52:06 +00:00
Родитель 95c859963f
Коммит 29b1ce9751
3 изменённых файлов: 18 добавлений и 5 удалений

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

@ -2836,9 +2836,24 @@ void HTMLMediaElement::LoadFromSourceChildren() {
return;
}
}
nsAutoString media;
child->GetAttr(nsGkAtoms::media, media);
HTMLSourceElement* childSrc = HTMLSourceElement::FromNode(child);
MOZ_ASSERT(childSrc, "Expect child to be HTMLSourceElement");
if (childSrc && !childSrc->MatchesCurrentMedia()) {
AutoTArray<nsString, 2> params = {media, src};
ReportLoadError("MediaLoadSourceMediaNotMatched", params);
DealWithFailedElement(child);
LOG(LogLevel::Debug,
("%p Media did not match from <source>=%s type=%s media=%s", this,
NS_ConvertUTF16toUTF8(src).get(), NS_ConvertUTF16toUTF8(type).get(),
NS_ConvertUTF16toUTF8(media).get()));
return;
}
LOG(LogLevel::Debug,
("%p Trying load from <source>=%s type=%s", this,
NS_ConvertUTF16toUTF8(src).get(), NS_ConvertUTF16toUTF8(type).get()));
("%p Trying load from <source>=%s type=%s media=%s", this,
NS_ConvertUTF16toUTF8(src).get(), NS_ConvertUTF16toUTF8(type).get(),
NS_ConvertUTF16toUTF8(media).get()));
nsCOMPtr<nsIURI> uri;
NewURIFromString(src, getter_AddRefs(uri));

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

@ -1,3 +0,0 @@
[resource-selection-source-media-env-change.html]
[the <source> media attribute: no reaction to environment change]
expected: FAIL

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

@ -13,6 +13,7 @@ const rAF = () => new Promise(resolve => requestAnimationFrame(resolve));
const hash = str => str.substr(str.lastIndexOf('#'));
(async () => {
const v = document.querySelector('video');
v.getBoundingClientRect(); // force layout flush. ensure viewport dimensions are up-to-date
v.append(createSource('delayed-broken-video.py#a', '(min-width: 200px)'));
v.append(createSource('delayed-broken-video.py#b'));
await rAF();