Commit Graph

116 Commits

Author SHA1 Message Date
Timothy Flynn
b9e4dc2cb7 LibWeb: Implement the HTMLMediaElement volume and muted IDL attributes 2023-06-16 13:50:15 +02:00
Timothy Flynn
0c4b28faf3 LibWeb: Dispatch an addtrack event for newly created audio tracks 2023-06-14 17:54:40 +02:00
Timothy Flynn
6520a9a849 LibWeb: Support TrackEvent instances with an AudioTrack track type 2023-06-14 17:54:40 +02:00
Timothy Flynn
ac2238ee70 LibWeb: Begin implementing the HTMLAudioElement for audio playback
This uses LibAudio to attempt to decode resoures downloaded with <audio>
elements, and draws some basic media controls for the element.
2023-06-13 06:14:01 +02:00
Timothy Flynn
c89fd6dff0 LibWeb: Implement the AudioTrack and AudioTrackList interfaces
These are used to own and manage the playing of audio data.
2023-06-13 06:14:01 +02:00
Hendiadyoin1
eeb15fc10b LibWeb: Stop lying about string types 2023-06-13 01:49:02 +02:00
Timothy Flynn
8ff8309202 LibWeb: Update workarounds for fetching CORS cross-origin responses
Now that the processResponseConsumeBody algorithm receives the internal
response body of the fetched object, we do not need to go out of our way
to read its body from outside of fetch.

However, several elements do still need to manually inspect the internal
response for other data, such as response headers and status. Note that
HTMLScriptElement already does the new workaround as a proper spec step.
2023-05-29 17:12:46 +02:00
kleines Filmröllchen
fc5cab5c21 Everywhere: Use MonotonicTime instead of Duration
This is easily identifiable by anyone who uses Duration::now_monotonic,
and any downstream users of that data.
2023-05-24 23:18:07 +02:00
kleines Filmröllchen
213025f210 AK: Rename Time to Duration
That's what this class really is; in fact that's what the first line of
the comment says it is.

This commit does not rename the main files, since those will contain
other time-related classes in a little bit.
2023-05-24 23:18:07 +02:00
Timothy Flynn
b865277275 LibWeb: Wait for media candidates without endlessly queueing microtasks
Rather than queueing microtasks ad nauseam to check if a media element
has a new source candidate, let the media element tell us when it might
have a new child to inspect. This removes endless CPU churn in cases
where there is never a candidate that we can play.
2023-05-22 15:11:08 +02:00
Sam Atkins
9c2d496dbe LibWeb: Make processBodyError take an optional exception
Changed here:
018ac19838
2023-05-15 16:28:16 +02:00
Timothy Flynn
c161a0fc49 LibWeb: Implement the HTMLMediaElement child <source> selection steps
Rather than setting the src attribute on the HTMLMediaElement, websites
may append a list of HTMLSourceElement nodes to the media element. There
is a series of "try the next source" steps to attempt to fetch/load each
source until we find one that works.
2023-05-13 15:51:44 +02:00
Andreas Kling
70db40c9b0 LibWeb: Don't include Layout/Node.h from DOM/Element.h
This required moving the CSS::StyleProperty destruct out of line.
2023-05-08 09:29:44 +02:00
Timothy Flynn
ac8b892a25 LibWeb: Pause HTMLMediaElement when its document becomes inactive
For example, when navigating to another page, this ensures any media
resource will not continue playing.
2023-05-04 16:48:10 +02:00
Timothy Flynn
88b8969443 LibWeb: Implement steps for removing an HTMLMediaElement from a document 2023-05-04 16:48:10 +02:00
Timothy Flynn
78ad471367 LibWeb: Remove custom playback timer from HTMLMediaElement
After the EventLoop changes, we do not need to override LibVideo's timer
with a Qt timer for Ladybird. The timer callback provided here also does
not need the JS::SafeFunction wrapper that Platform::Timer provides.
2023-04-25 18:02:22 +02:00
Timothy Flynn
32e2207b55 LibWeb: Implement the HTMLMediaElement fastSeek method 2023-04-24 07:55:54 +02:00
Timothy Flynn
848078aedd LibWeb: Propagate LibVideo decoder errors to the HTMLMediaElement 2023-04-23 16:22:45 +02:00
Timothy Flynn
9c940608fd LibWeb: Implement the HTMLMediaElement error attribute 2023-04-23 16:22:45 +02:00
Timothy Flynn
b384f2009d LibWeb: Implement the HTMLMediaElement show-poster flag
Note that this doesn't do much yet, as the HTMLVideoElement does not
handle its poster attribute as of this commit.
2023-04-21 07:54:36 +02:00
Timothy Flynn
12c15641c1 LibWeb: Implement the HTMLMediaElement "potentially playing" concept 2023-04-21 07:54:36 +02:00
Timothy Flynn
9f71799456 LibWeb: Make HTMLMediaElement's attribute change handlers protected
These will be need to be overridden by HTMLVideoElement. We also need to
be sure to invoke HTMLMediaElement's base class's did_remove_attribute.
2023-04-21 07:54:36 +02:00
Timothy Flynn
d2f9645cc0 LibWeb: Properly stop, rather than terminate, ongoing media fetches
We are currently using the fetch controller's terminate() method to stop
ongoing fetches when the HTMLMediaElement load algorithm is invoked.
This method ultimately causes the fetch response to be a network error,
which we propagate through the HTMLMediaElement's error event. This can
cause websites, such as Steam, to avoid attempting to play any video.

The spec does not actually specify what it means to "stop" or "cancel" a
fetching process. But we should not use terminate() as that is a defined
spec method, and the spec does tend to indicate when that method should
be used (e.g. as it does in XMLHttpRequest).
2023-04-20 06:19:41 +02:00
Timothy Flynn
1fb0c7826b LibWeb: Do not handle media ready state changes for empty network states
This was missed in the header text of the ready state transition spec.
2023-04-20 06:19:41 +02:00
Timothy Flynn
27fd31b2ad LibWeb: Implement the HTMLMediaElement delaying-the-load-event flag 2023-04-20 06:19:41 +02:00
Timothy Flynn
1a67b86b76 LibWeb: Implement the HTMLMediaElement currentSrc attribute 2023-04-20 06:19:41 +02:00
Timothy Flynn
f8d6a67294 LibWeb: Implement the HTMLMediaElement crossOrigin attribute 2023-04-19 07:57:52 +02:00
Timothy Flynn
7833b321a3 LibWeb: Stub out the HTMLMediaElement buffered attribute
This is needed by https://store.steampowered.com. For now, we return an
empty TimeRanges object.
2023-04-19 07:57:52 +02:00
Timothy Flynn
229cc67fee LibWeb: Implement HTMLMediaElement's autoplay attribute 2023-04-18 16:30:02 +02:00
Timothy Flynn
5a98a5529f LibWeb: Begin implementing media resource seeking 2023-04-17 01:16:04 +02:00
Timothy Flynn
c08755836d LibWeb: Fix a couple of HTMLMediaElement spec links 2023-04-17 01:16:04 +02:00
Nico Weber
f56b897622 Everywhere: Fix a few typos
Some even user-visible!
2023-04-12 19:37:35 +02:00
Timothy Flynn
4797f07883 LibWeb: Begin detecting the end of an HTMLMediaElement media resource 2023-04-11 19:27:55 +02:00
Timothy Flynn
3d9106b1b5 LibWeb: Begin tracking HTMLMediaElement playback positions
There are several playback positions to be tracked, depending on the
state of the media element.
2023-04-11 19:27:55 +02:00
Timothy Flynn
6b51c3c1ce LibWeb: Report HTMLMediaElement duration with sub-second accuracy
We currently use Time::to_seconds() to report a video's duration. The
video, however, may have a sub-second duration. For example, the video
used by the video test page is 12.05 seconds long.
2023-04-11 19:27:55 +02:00
Timothy Flynn
2ef4a51c39 LibWeb: Move dispatching timeupdate events to a helper for tracking
For some media APIs, we will need to know whether we are currently in an
event handler for the timeupdate event, and the last time we fired the
event.
2023-04-11 19:27:55 +02:00
Timothy Flynn
edf85d39c6 LibWeb: Port HTMLVideoElement to play videos with Video::PlaybackManager
This has several advantages over the current manual demuxing currently
being performed. PlaybackManager hides the specific demuxer being used,
which will allow more codecs to be added transparently to LibWeb. It
also provides buffering and controls playback rate for us.

Further, it will allow us to much more easily implement the "media
timeline" to render a timestamp and implement seeking.
2023-04-09 23:55:05 +02:00
Timothy Flynn
4f29cac715 LibWeb: Set the media ready state to HAVE_ENOUGH_DATA after fetching
Because we currently both fetch and process the media data in one chunk,
we have enough data for playback immediately.
2023-04-08 22:04:14 +02:00
Timothy Flynn
d99a075ff9 LibWeb: Implement HTMLMediaElement.play
This also includes the HTMLMediaElement's list of pending play promises,
which is coupled pretty tightly with HTMLMediaElement.play.
2023-04-08 22:04:14 +02:00
Timothy Flynn
b8a37ef809 LibWeb: Implement HTMLMediaElement.pause 2023-04-08 22:04:14 +02:00
Timothy Flynn
90921a4f16 LibWeb: Implement the HTMLMediaElement paused attribute
Note that the default value of the attribute is true. We were previously
autoplaying videos as soon as they loaded - this will prevent that from
happening until the paused attribute is set to false.
2023-04-08 22:04:14 +02:00
Timothy Flynn
e130525c24 LibWeb: Implement HTMLMediaElement.load 2023-04-08 22:04:14 +02:00
Kenneth Myhra
ad5cbdc51b LibWeb: Port {Mouse,UI,Wheel,}Event to new String
This ports MouseEvent, UIEvent, WheelEvent, and Event to new String.
They all had a dependency to T::create() in
WebDriverConnection::fire_an_event() and therefore had to be ported in
the same commit.
2023-04-07 22:41:01 +02:00
Timothy Flynn
725d7c3699 LibWeb: Implement HTMLVideoElement's video{Width,Height} attributes 2023-04-07 16:02:22 +02:00
Timothy Flynn
becd70eccb LibWeb: Begin implementing HTMLMediaElement's readyState attribute
It's not totally clear to me when all of these states are supposed to be
set. For example, nothing in the HTMLMediaElement spec says to "set the
readyState attribute to HAVE_ENOUGH_DATA". However, this will at least
advance the readyState to HAVE_METADATA, which is needed for other
useful attributes for debugging.
2023-04-07 16:02:22 +02:00
Timothy Flynn
e10e041882 LibWeb: Implement HTMLMediaElement's duration attribute 2023-04-07 16:02:22 +02:00
Timothy Flynn
5f9fc5aedc LibWeb: Indicate that we may be able to play video MIME types 2023-04-07 16:02:22 +02:00
Timothy Flynn
e2f32e6ab3 LibWeb: Parse and load the HTMLMediaElement's src attribute
The spec for loading a media element is quite huge. This implements just
enough to parse the attribute, fetch the corresponding media object, and
decode the media object (if it is a video). While doing so, this also
implements most network state tracking and firing DOM events that may be
observed via JavaScript.
2023-04-07 16:02:22 +02:00
Timothy Flynn
9f8da9798a LibWeb: Define steps to queue a media element task on a HTMLMediaElement 2023-04-07 16:02:22 +02:00
Timothy Flynn
2692db8699 LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errors
Note that as of this commit, there aren't any such throwers, and the
call site in Heap::allocate will drop exceptions on the floor. This
commit only serves to change the declaration of the overrides, make sure
they return an empty value, and to propagate OOM errors frm their base
initialize invocations.
2023-01-29 00:02:45 +00:00
Timothy Flynn
834202aeb9 LibWeb: Move setting of Web object prototypes to initialize()
This needs to happen before prototype/constructor intitialization can be
made lazy. Otherwise, GC could run during the C++ constructor and try to
collect the object currently being created.
2023-01-10 16:08:14 +01:00
Luke Wilde
1e9cc2e211 LibWeb: Stub HTMLMediaElement.pause
Required for rendering GIFs on Discord.
2022-12-10 00:21:10 +00:00
Luke Wilde
2c77364716 LibWeb: Add spec link to HTMLMediaElement::load 2022-12-10 00:21:10 +00:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Luke Wilde
377eb09492 LibWeb: Stub HTMLMediaElement.load 2022-10-28 16:17:08 +01:00
Andrew Kaster
56b381aac0 LibWeb: Cleanup unecessary uses and includes of HTML::Window
The big global refactor left some stragglers behind for atomicity.

Clean up the rest, and remove a ton of includes of LibWeb/HTML/Window.h
2022-10-01 21:05:32 +01:00
Andrew Kaster
f0c5f77f99 LibWeb: Remove unecessary dependence on Window from HTML classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct HTML classes.
2022-10-01 21:05:32 +01:00
Andreas Kling
ffad902c07 LibWeb: Use cached_web_prototype() as much as possible
Unlike ensure_web_prototype<T>(), the cached version doesn't require the
prototype type to be fully formed, so we can use it without including
the FooPrototype.h header. It's also a bit less verbose. :^)
2022-09-06 00:27:09 +02:00
Andreas Kling
6f433c8656 LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.

There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
2022-09-06 00:27:09 +02:00
Lenny Maiorani
c37820b898 Libraries: Use default constructors/destructors in LibWeb
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-17 17:23:49 +00:00
Linus Groh
a2e6abe159 LibWeb: Add HTMLMediaElement.canPlayType()
For the time being, the answer is no, or rather: "" :^)
2022-03-04 23:03:29 +01:00
Andreas Kling
1b6ed558bb LibWeb: Move QualifiedName into the Web::DOM namespace 2022-02-19 14:45:59 +01:00
Linus Groh
649d2faeab Everywhere: Use "the SerenityOS developers." in copyright headers
We had some inconsistencies before:

- Sometimes "The", sometimes "the"
- Sometimes trailing ".", sometimes no trailing "."

I picked the most common one (lowecase "the", trailing ".") and applied
it to all copyright headers.

By using the exact same string everywhere we can ensure nothing gets
missed during a global search (and replace), and that these
inconsistencies are not spread any further (as copyright headers are
commonly copied to new files).
2021-04-29 00:59:26 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
330c3fcb59 LibWeb: Use move semantics for QualifiedName more often 2021-02-07 11:20:15 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00