mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 13:05:09 +00:00
LibWeb: Implement the HTMLMediaElement crossOrigin attribute
This commit is contained in:
parent
7833b321a3
commit
f8d6a67294
3 changed files with 24 additions and 2 deletions
|
@ -91,6 +91,14 @@ void HTMLMediaElement::parse_attribute(DeprecatedFlyString const& name, Deprecat
|
||||||
|
|
||||||
if (name == HTML::AttributeNames::src)
|
if (name == HTML::AttributeNames::src)
|
||||||
load_element().release_value_but_fixme_should_propagate_errors();
|
load_element().release_value_but_fixme_should_propagate_errors();
|
||||||
|
else if (name == HTML::AttributeNames::crossorigin)
|
||||||
|
m_crossorigin = cors_setting_attribute_from_keyword(String::from_deprecated_string(value).release_value_but_fixme_should_propagate_errors());
|
||||||
|
}
|
||||||
|
|
||||||
|
void HTMLMediaElement::did_remove_attribute(DeprecatedFlyString const& name)
|
||||||
|
{
|
||||||
|
if (name == HTML::AttributeNames::crossorigin)
|
||||||
|
m_crossorigin = cors_setting_attribute_from_keyword({});
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/media.html#dom-media-buffered
|
// https://html.spec.whatwg.org/multipage/media.html#dom-media-buffered
|
||||||
|
@ -572,8 +580,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::fetch_resource(AK::URL const& url_re
|
||||||
|
|
||||||
// 3. Let request be the result of creating a potential-CORS request given current media resource's URL record, destination, and the current state
|
// 3. Let request be the result of creating a potential-CORS request given current media resource's URL record, destination, and the current state
|
||||||
// of media element's crossorigin content attribute.
|
// of media element's crossorigin content attribute.
|
||||||
// FIXME: Parse the media element's crossorigin content attribute.
|
auto request = create_potential_CORS_request(vm, url_record, destination, m_crossorigin);
|
||||||
auto request = create_potential_CORS_request(vm, url_record, destination, CORSSettingAttribute::Anonymous);
|
|
||||||
|
|
||||||
// 4. Set request's client to the media element's node document's relevant settings object.
|
// 4. Set request's client to the media element's node document's relevant settings object.
|
||||||
request->set_client(&document().relevant_settings_object());
|
request->set_client(&document().relevant_settings_object());
|
||||||
|
@ -640,6 +647,15 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::fetch_resource(AK::URL const& url_re
|
||||||
// ability to cache data.
|
// ability to cache data.
|
||||||
|
|
||||||
// 5. Otherwise, incrementally read response's body given updateMedia, processEndOfMedia, an empty algorithm, and global.
|
// 5. Otherwise, incrementally read response's body given updateMedia, processEndOfMedia, an empty algorithm, and global.
|
||||||
|
|
||||||
|
// FIXME: Spec issue: If the response is CORS-cross-origin, we need to read from its internal response instead.
|
||||||
|
// https://github.com/whatwg/html/issues/3483
|
||||||
|
// https://github.com/whatwg/html/issues/9066
|
||||||
|
if (response->type() == Fetch::Infrastructure::Response::Type::Opaque || response->type() == Fetch::Infrastructure::Response::Type::OpaqueRedirect) {
|
||||||
|
auto& filtered_response = static_cast<Fetch::Infrastructure::FilteredResponse&>(*response);
|
||||||
|
response = filtered_response.internal_response();
|
||||||
|
}
|
||||||
|
|
||||||
VERIFY(response->body().has_value());
|
VERIFY(response->body().has_value());
|
||||||
auto empty_algorithm = [](auto&) {};
|
auto empty_algorithm = [](auto&) {};
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <AK/Variant.h>
|
#include <AK/Variant.h>
|
||||||
#include <LibJS/Heap/MarkedVector.h>
|
#include <LibJS/Heap/MarkedVector.h>
|
||||||
#include <LibJS/SafeFunction.h>
|
#include <LibJS/SafeFunction.h>
|
||||||
|
#include <LibWeb/HTML/CORSSettingAttribute.h>
|
||||||
#include <LibWeb/HTML/EventLoop/Task.h>
|
#include <LibWeb/HTML/EventLoop/Task.h>
|
||||||
#include <LibWeb/HTML/HTMLElement.h>
|
#include <LibWeb/HTML/HTMLElement.h>
|
||||||
#include <LibWeb/WebIDL/DOMException.h>
|
#include <LibWeb/WebIDL/DOMException.h>
|
||||||
|
@ -89,6 +90,7 @@ private:
|
||||||
using ByteRange = Variant<EntireResource>; // FIXME: This will need to include "until end" and an actual byte range.
|
using ByteRange = Variant<EntireResource>; // FIXME: This will need to include "until end" and an actual byte range.
|
||||||
|
|
||||||
virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override;
|
virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override;
|
||||||
|
virtual void did_remove_attribute(DeprecatedFlyString const&) override;
|
||||||
|
|
||||||
Task::Source media_element_event_task_source() const { return m_media_element_event_task_source.source; }
|
Task::Source media_element_event_task_source() const { return m_media_element_event_task_source.source; }
|
||||||
|
|
||||||
|
@ -137,6 +139,9 @@ private:
|
||||||
// https://html.spec.whatwg.org/multipage/media.html#media-element-event-task-source
|
// https://html.spec.whatwg.org/multipage/media.html#media-element-event-task-source
|
||||||
UniqueTaskSource m_media_element_event_task_source {};
|
UniqueTaskSource m_media_element_event_task_source {};
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/media.html#dom-media-crossorigin
|
||||||
|
CORSSettingAttribute m_crossorigin { CORSSettingAttribute::NoCORS };
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/media.html#dom-media-networkstate
|
// https://html.spec.whatwg.org/multipage/media.html#dom-media-networkstate
|
||||||
NetworkState m_network_state { NetworkState::Empty };
|
NetworkState m_network_state { NetworkState::Empty };
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ interface HTMLMediaElement : HTMLElement {
|
||||||
|
|
||||||
// network state
|
// network state
|
||||||
[Reflect, CEReactions] attribute DOMString src;
|
[Reflect, CEReactions] attribute DOMString src;
|
||||||
|
[Reflect=crossorigin, CEReactions] attribute DOMString? crossOrigin;
|
||||||
const unsigned short NETWORK_EMPTY = 0;
|
const unsigned short NETWORK_EMPTY = 0;
|
||||||
const unsigned short NETWORK_IDLE = 1;
|
const unsigned short NETWORK_IDLE = 1;
|
||||||
const unsigned short NETWORK_LOADING = 2;
|
const unsigned short NETWORK_LOADING = 2;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue