summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp5
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp22
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h9
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLVideoElement.idl2
4 files changed, 37 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
index 5102b2b7e4..f35f926d8c 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
@@ -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
// named resize at the media element.
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] {
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::resize.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
});
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp
index 97d73d2aa1..63e07b2a46 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp
@@ -24,4 +24,26 @@ JS::ThrowCompletionOr<void> HTMLVideoElement::initialize(JS::Realm& realm)
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;
+}
+
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h
index 41bb73e3de..6db467b49f 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h
@@ -16,10 +16,19 @@ class HTMLVideoElement final : public HTMLMediaElement {
public:
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:
HTMLVideoElement(DOM::Document&, DOM::QualifiedName);
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
+
+ u32 m_video_width { 0 };
+ u32 m_video_height { 0 };
};
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.idl
index 57fc11bd69..4e270ba3bf 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.idl
+++ b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.idl
@@ -6,6 +6,8 @@ interface HTMLVideoElement : HTMLMediaElement {
[HTMLConstructor] constructor();
+ readonly attribute unsigned long videoWidth;
+ readonly attribute unsigned long videoHeight;
[CEReactions, Reflect] attribute USVString poster;
[CEReactions, Reflect=playsinline] attribute boolean playsInline;