Commit Graph

40 Commits

Author SHA1 Message Date
Andreas Kling
0ebfc0a4c4 LibWeb: Move event handling & cursor from BrowsingContext to Navigable
This was a long standing FIXME since the introduction of navigables.
2024-04-26 20:01:58 +02:00
Kenneth Myhra
a3661fd7f2 LibWeb: Let queue_global_task() take a JS::HeapFunction
Changes the signature of queue_global_task() from AK:Function to
JS::HeapFunction to be more clear to the user of the function that this
is what it uses internally.
2024-04-20 18:11:01 +02:00
Aliaksandr Kalenik
a73bf1607f LibWeb: Mark initial about:blank as ready to run scripts after creation
This matches how other browsers behave.

Fixes https://github.com/SerenityOS/serenity/issues/23892
2024-04-11 18:41:20 +02:00
Aliaksandr Kalenik
94d72c174a LibWeb: Allow executing scripts for iframes with src=about:blank
Fixes https://github.com/SerenityOS/serenity/issues/23836
2024-04-08 21:27:34 +02:00
Aliaksandr Kalenik
2c86633c51 LibWeb: Fix out of order spec step numbers in "create child navigable"
No behaviour change.
2024-04-06 21:57:55 +02:00
Aliaksandr Kalenik
11011cf250 LibWeb: Don't rely on SHTQ::process() in process_the_iframe_attributes
`HTMLIFrameElement::inserted()` does following:
1. Init a new navigable. This step appends a task on session history
   traversal queue (SHTQ) that creates a new nested history.
2. Process iframe's attributes

Processing of iframe's attributes might result in synchronous
navigation that fails to get active SHE if SHTQ task that creates
new nested history is not yet completed.

Before this change, a workaround involved forcing the processing of
SHTQ, which was terrible hack because it could occur in the middle of
another SHTQ task.

This change removes the need for "force SHTQ processing" by ensuring
that the processing of iframe's attributes is always executed after
the iframe's navigable nested history has been created.
2024-04-05 21:28:41 +02:00
Aliaksandr Kalenik
696cf7b9fb LibWeb: Fix "destroy the child navigable" to call Document::destroy()
f66d33423b was not sufficient to ensure
document destruction when a child navigable is destroyed. This is
because a navigable was remove from the set of all navigables too early
which led to `Navigable::navigable_with_active_document()` being unable
to find a navigable that is still in the process of destruction.

This change solves that by making all steps of a navigable destruction
to happen in afterAllDestruction callback.

Unfortunately, writing a test to verify document destruction is
challenging because no events are emitted to indicate that it has
happened.
2024-04-03 21:17:57 +02:00
Aliaksandr Kalenik
f66d33423b LibWeb: Fix spec bug in "destroy child navigable"
See for more details:
https://github.com/whatwg/html/issues/10242

Before this change it only worked because of another bug in
`EventLoop::spin_processing_tasks_with_source_until()`
where we execute tasks regardless of whether they are runnable or not.
2024-04-03 10:25:38 +02:00
Aliaksandr Kalenik
9098fa23a2 LibWeb: Catch up with the spec on document destroy, abort and unload
These changes do not solve hanging `location.reload()` and
`location.go()` but only align implementation with the latest edits in
the specification.

`WindowProxy-Get-after-detaching-from-browsing-context` test output is
affected because `iframe.remove();` no longer synchronously does
destruction of a document, but queues a task on event loop.

Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2024-04-01 13:23:58 +02:00
Aliaksandr Kalenik
b590d1b48b LibWeb: Transform SessionHistoryEntry from a struct to a class
No behaviour change intended.
2024-03-27 18:07:07 +01:00
Shannon Booth
e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00
Shannon Booth
9ce8189f21 Everywhere: Use unqualified AK::URL
Now possible in LibWeb now that there is no longer a Web::URL.
2024-02-25 08:54:31 +01:00
Bastiaan van der Plaat
a681429dff LibWeb: Remove DOM element deprecated_get_attribute() 2024-01-19 13:12:54 -07:00
Andrew Kaster
d6d1485720 LibWeb: Bring destroy the child navigable comments closer to spec 2024-01-19 11:47:59 +01:00
Shannon Booth
0695236408 LibWeb: Use cached element name and id where possible
Instead of looking up in the named node map, we can simply use the
cached name and ID on the element.
2024-01-13 12:05:36 +01:00
Andreas Kling
0a05be69cf LibWeb: Update create_new_child_navigable() after spec fix
Now that https://github.com/whatwg/html/issues/9686 is fixed, let's
fix it the exact same way in our implementation. :^)
2024-01-02 21:47:36 +01:00
Vladimir Shakhov
e2391105a1 LibWeb: Call process_session_history_traversal_queue on history update
Spec declares that the updates to history should be synchronous on
initial page load and on history pushState/replaceState.
2023-12-15 22:11:49 +01:00
Andreas Kling
7c95ebc302 LibWeb: Make Document::page() return a Page&
Now that Document always has a Page, and always keeps it alive, we can
make this return a Page&, exposing various unnecessary null checks.
2023-12-15 22:04:46 +01:00
Sam Atkins
7f509317fd LibWeb: Allow NavigableContainers to report whether to delay load event
Four elements match the "potentially delay the load event" check in the
spec: `<embed>`, `<frame>`, `<iframe>`, and `<object>`. These four are
the same set of elements that are NavigableContainers (or will be once
we implement them) so let's put this logic there.

Note that other things can delay the load event, this is just the name
the spec gives to this particular behaviour.
2023-12-01 10:28:02 +01:00
Aliaksandr Kalenik
2f5ff14984 LibWeb: Fix spec implementation mistakes in destroy_the_child_navigable
Fixes two places in child navigable destroy procedure where we used
content navigable instead of container's navigable.

With this change, iframe's nested histories are actually destroyed
along with the document that created them.
2023-10-19 16:54:17 -04:00
Ali Mohammad Pur
aeee98b3a1 AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
2023-10-13 18:33:21 +03:30
Aliaksandr Kalenik
44f7d7406c LibWeb: Use struct to pass Navigable::navigate() params
Using structs makes the navigate() calls looks cleaner. No change
in behavior is intended.
2023-10-12 03:25:06 +02:00
Andrew Kaster
7e277797ad LibWeb: Add about base url to the various AOs that construct documents
And some assorted cleanup along the way. The browsing context and
document AOs in particular need re-alignment with the spec.
2023-09-22 19:45:11 -06:00
Aliaksandr Kalenik
9b16e5373d LibWeb: Process session history queue after initial iframe navigation
This is not in the spec, but we need to make sure that "apply the
history step" for initial navigation to about:blank in iframe is
applied before subsequent navigations. Otherwise, "set ongoing
navigation" call during "about:blank" traversal might abort subsequent
ongoing navigation which is not expected to happen.
2023-09-16 16:53:32 +02:00
Aliaksandr Kalenik
67f5c027fe LibWeb: Use saved navigable pointer in destroy_the_child_navigable
During the destruction of a navigable, we need to use the pointer to
the navigable that was saved at the beginning of the function. This
is because `Node::navigable()` will return a nullptr in subsequent
steps after the navigable's document becomes inactive.
2023-09-16 16:53:32 +02:00
Aliaksandr Kalenik
cf985afdcb LibWeb: Look for targetStepSHE in parent while creating child navigable
Reported issue in the spec https://github.com/whatwg/html/issues/9686
2023-09-16 16:53:32 +02:00
Aliaksandr Kalenik
6942bdcfce LibWeb: Update top_level_browsing_context() to use navigables 2023-09-16 16:53:32 +02:00
Aliaksandr Kalenik
912cf89727 LibWeb: Update HTMLIFrameElement to use navigables 2023-09-16 16:53:32 +02:00
Aliaksandr Kalenik
c437f16cc1 LibWeb: Early return navigation process if navigable has been destroyed
If a navigable has been destroyed during a navigation process, we
should early return from it. The introduced checks are not in
the spec because, as explained in
https://github.com/whatwg/html/issues/9690 the spec is not written
with such a level of detail.
2023-09-15 18:27:17 +02:00
Aliaksandr Kalenik
2445205e9d LibWeb: Align session history step application code with latest spec
Replaces direct "apply the history step" calls with new functions from
the spec:
- "update for navigable creation/destruction"
- "apply the push/replace history step"
- "apply the reload history step"
2023-09-15 18:27:17 +02:00
Shannon Booth
0f6782fae6 LibWeb: Rename Element::attribute to Element::deprecated_attribute
This should allow us to add a Element::attribute which returns an
Optional<String>. Eventually all callers should be ported to switch from
the DeprecatedString version, but in the meantime, this should allow us
to port some more IDL interfaces away from DeprecatedString.
2023-09-05 20:36:09 -04:00
Andrew Kaster
a565021147 LibWeb: De-duplicate definition of url_matches_about_blank
We don't need two static methods for this.
2023-08-29 09:39:57 +02:00
Aliaksandr Kalenik
b05bd889e1 LibWeb: Add missing navigable in NavigableContainer::visit_edges() 2023-08-14 17:46:46 +02:00
Aliaksandr Kalenik
08788072c1 LibWeb: Add SessionHistoryTraversalQueue 2023-08-14 17:46:46 +02:00
Shannon Booth
55a01e72ca AK: Port URL username/password from DeprecatedString to String
And for cases that just need to check whether the password/username is
empty, add a raw_{password,username} helper to avoid any allocation.
2023-08-13 15:03:53 -06:00
Shannon Booth
8751be09f9 AK: Serialize URL hosts with 'concept-host-serializer'
In order to follow spec text to achieve this, we need to change the
underlying representation of a host in AK::URL to deserialized format.
Before this, we were parsing the host and then immediately serializing
it again.

Making that change resulted in a whole bunch of fallout.

After this change, callers can access the serialized data through
this concept-host-serializer. The functional end result of this
change is that IPv6 hosts are now correctly serialized to be
surrounded with '[' and ']'.
2023-07-31 05:18:51 +02:00
Aliaksandr Kalenik
41f9dcd89b LibWeb: Implement "create a new child navigable" and supporting code
Implements https://html.spec.whatwg.org/multipage/document-sequences.html#create-a-new-child-navigable

Co-authored-by: Andreas Kling <kling@serenityos.org>
2023-07-11 06:48:25 +02:00
Aliaksandr Kalenik
934cb601c2 LibWeb: Implement "destroy the child navigable" on navigable containers
Co-authored-by: Andreas Kling <kling@serenityos.org>
2023-06-23 17:24:32 +02:00
Aliaksandr Kalenik
d85bdd3ac5 LibWeb: Add API for finding NavigableContainer by content navigable
This is only needed because currently spec doesn't explicitly define
that navigable should have a pointer to associated container and when
this pointer should be set.
2023-06-23 16:20:29 +02:00
Andreas Kling
d8ccc2d54e LibWeb: Rename BrowsingContextContainer => NavigableContainer
The "browsing context container" concept in the HTML spec has been
replaced with "navigable container". Renaming this is the first step of
many towards implementing the new world.

Co-authored-by: Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
2023-04-19 18:26:45 +02:00