mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:28:11 +00:00
LibWeb: Implement HTMLVideoElement's video{Width,Height} attributes
This commit is contained in:
parent
becd70eccb
commit
725d7c3699
4 changed files with 37 additions and 1 deletions
|
@ -603,7 +603,10 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void()>
|
||||||
// 5. For video elements, set the videoWidth and videoHeight attributes, and queue a media element task given the media element to fire an event
|
// 5. For video elements, set the videoWidth and videoHeight attributes, and queue a media element task given the media element to fire an event
|
||||||
// named resize at the media element.
|
// named resize at the media element.
|
||||||
if (is<HTMLVideoElement>(*this)) {
|
if (is<HTMLVideoElement>(*this)) {
|
||||||
// FIXME: Set the videoWidth and videoHeight attributes.
|
auto& video_element = verify_cast<HTMLVideoElement>(*this);
|
||||||
|
video_element.set_video_width(video_track->pixel_width());
|
||||||
|
video_element.set_video_height(video_track->pixel_height());
|
||||||
|
|
||||||
queue_a_media_element_task([this] {
|
queue_a_media_element_task([this] {
|
||||||
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::resize.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
|
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::resize.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
|
||||||
});
|
});
|
||||||
|
|
|
@ -24,4 +24,26 @@ JS::ThrowCompletionOr<void> HTMLVideoElement::initialize(JS::Realm& realm)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/media.html#dom-video-videowidth
|
||||||
|
u32 HTMLVideoElement::video_width() const
|
||||||
|
{
|
||||||
|
// The videoWidth IDL attribute must return the intrinsic width of the video in CSS pixels. The videoHeight IDL
|
||||||
|
// attribute must return the intrinsic height of the video in CSS pixels. If the element's readyState attribute
|
||||||
|
// is HAVE_NOTHING, then the attributes must return 0.
|
||||||
|
if (ready_state() == ReadyState::HaveNothing)
|
||||||
|
return 0;
|
||||||
|
return m_video_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/media.html#dom-video-videoheight
|
||||||
|
u32 HTMLVideoElement::video_height() const
|
||||||
|
{
|
||||||
|
// The videoWidth IDL attribute must return the intrinsic width of the video in CSS pixels. The videoHeight IDL
|
||||||
|
// attribute must return the intrinsic height of the video in CSS pixels. If the element's readyState attribute
|
||||||
|
// is HAVE_NOTHING, then the attributes must return 0.
|
||||||
|
if (ready_state() == ReadyState::HaveNothing)
|
||||||
|
return 0;
|
||||||
|
return m_video_height;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,19 @@ class HTMLVideoElement final : public HTMLMediaElement {
|
||||||
public:
|
public:
|
||||||
virtual ~HTMLVideoElement() override;
|
virtual ~HTMLVideoElement() override;
|
||||||
|
|
||||||
|
void set_video_width(u32 video_width) { m_video_width = video_width; }
|
||||||
|
u32 video_width() const;
|
||||||
|
|
||||||
|
void set_video_height(u32 video_height) { m_video_height = video_height; }
|
||||||
|
u32 video_height() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTMLVideoElement(DOM::Document&, DOM::QualifiedName);
|
HTMLVideoElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||||
|
|
||||||
|
u32 m_video_width { 0 };
|
||||||
|
u32 m_video_height { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ interface HTMLVideoElement : HTMLMediaElement {
|
||||||
|
|
||||||
[HTMLConstructor] constructor();
|
[HTMLConstructor] constructor();
|
||||||
|
|
||||||
|
readonly attribute unsigned long videoWidth;
|
||||||
|
readonly attribute unsigned long videoHeight;
|
||||||
[CEReactions, Reflect] attribute USVString poster;
|
[CEReactions, Reflect] attribute USVString poster;
|
||||||
[CEReactions, Reflect=playsinline] attribute boolean playsInline;
|
[CEReactions, Reflect=playsinline] attribute boolean playsInline;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue