Commit Graph

1356 Commits

Author SHA1 Message Date
Timothy Flynn
85b8971a80 Ladybird+LibWeb+WebContent: Port the did_request_cookie IPC to String 2024-01-26 20:22:39 +01:00
Andreas Kling
413eb19579 LibWeb: Skip UTF-8 validation in Node::descendant_text_content()
Since we're just concatenating a bunch of strings that are already
UTF-8, we don't need to check that the result is also UTF-8.
2024-01-24 07:55:13 +01:00
Aliaksandr Kalenik
b9bbe4c166 LibWeb: Remove unnecessary layout tree disconnection during teardown
This code appears to be leftover from times when layout and paintable
trees were not GC-allocated.
2024-01-23 18:48:51 +01:00
Aliaksandr Kalenik
02d5ed44cb LibWeb: Stub Range::get_client_rects()
Fixes "Application error: a client-side exception has occurred (see
the browser console for more information)." on https://kotlinlang.org/
2024-01-20 08:56:52 +01:00
Bastiaan van der Plaat
a681429dff LibWeb: Remove DOM element deprecated_get_attribute() 2024-01-19 13:12:54 -07:00
Bastiaan van der Plaat
c477f90df7 LibWeb: Remove DOM element deprecated_tag_name() 2024-01-19 13:12:54 -07:00
Andrew Kaster
32fe7db69f LibWeb: Make UIEvents from the chrome the only default trusted Events 2024-01-19 11:47:59 +01:00
Andrew Kaster
6c1944ee61 LibWeb: Flesh out apply the history step to setup the navigation API
We now populate the navigation history entries in the navigation API and
fire more navigation events as appropriate.
2024-01-19 11:47:59 +01:00
Andrew Kaster
a8091c009b LibWeb: Add assorted AOs related to populating the navigation API's SHEs 2024-01-19 11:47:59 +01:00
Bastiaan van der Plaat
5f5ac48908 LibWeb: Format all .idl files to use four space indentation 2024-01-18 14:00:06 +01:00
Aliaksandr Kalenik
7c2713c14f LibWeb: Move set_needs_display() from layout node to paintable
For this method, there is no need to go through the layout node when we
can directly reach the paintable.
2024-01-15 09:00:35 +01:00
Shannon Booth
3910efb80b LibWeb: Implement Element.removeAttributeNS 2024-01-14 16:10:18 -07:00
Shannon Booth
7a26a889cb LibWeb: Implement Element.getAttributeNodeNS 2024-01-14 16:10:18 -07:00
Andreas Kling
b0afe8463a LibWeb: Make Node::paintable_box() go directly to the paintable
No need to go via the layout tree here, that's a vestige of an earlier
architecture limitation.
2024-01-13 12:33:53 +01:00
Shannon Booth
e6861cb5ef LibWeb: Port Element::insert_adjacent from ByteString 2024-01-13 12:05:36 +01:00
Shannon Booth
bd2fe3dcaa LibWeb: Use FlyString in Document::get_elements_by_name 2024-01-13 12:05:36 +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
Shannon Booth
41f84deb9f LibWeb: Port Element::name to a cached FlyString
Also removing some handling of OOM while we are in the area.
2024-01-13 12:05:36 +01:00
Shannon Booth
cb9118efe3 LibWeb: Use cached Element::id in HTMLFormControlsCollection 2024-01-13 12:05:36 +01:00
Andreas Kling
c3059701b0 LibWeb: Avoid style invalidation when entire document has invalid style
If the entire document is invalidated, we know a full style update is
coming soon, and there's no need to try and invalidate a smaller part.

This avoids a *lot* of work on some pages. As an example, we are able to
skip ~1.5 million style invalidations on https://html.spec.whatwg.org/
2024-01-13 11:49:04 +01:00
Shannon Booth
785fa60cca LibWeb: Implement Element.getAttributeNS 2024-01-13 08:33:10 +01:00
Shannon Booth
8cf783b260 LibWeb: Fix normalizing namespace in NamedNodeMap::get_attribute_ns
There was a typo which effectively meant that the namespace was always
being set to null when given.
2024-01-13 08:33:10 +01:00
Shannon Booth
636a85f04e LibWeb: Use Optional<FlyString> directly in Document & DOMImplementation
Use the [FlyString] extended attribute to allow these functions to take
an Optional<FlyString> directly, allowing us to tidy up some conversions
from Optional<String>.
2024-01-13 08:33:10 +01:00
Andreas Kling
f0722671c3 LibWeb: Cache the viewport rect across all of style computation
Fetching the viewport rect is currently somewhat expensive, since it
requires finding the navigable the document is active in.

We can avoid the cost of repeated calls by simply allowing StyleComputer
to cache the viewport rect at the start of style computation.
2024-01-12 14:12:04 +01:00
Andrew Kaster
521ed0e911 LibWeb: Delete LegacyPlatformObject and move behavior to PlatformObject
We have two known PlatformObjects that need to implement some of the
behavior of LegacyPlatformObjects to date: Window, and HTMLFormElement.

To make this not require double (or virtual) inheritance of
PlatformObject, move the behavior of LegacyPlatformObject into
PlatformObject. The selection of LegacyPlatformObject behavior is done
with a new bitfield of feature flags instead of a dozen virtual
functions that return bool. This change simplifies every class involved
in the diff with the notable exception of Window, which now needs some
ugly const casts to implement named property access.
2024-01-12 09:11:18 +01:00
Bastiaan van der Plaat
e33ae9a58b LibWeb: Improve media document styling to center image 2024-01-07 10:16:24 +01:00
Andreas Kling
302752d092 LibWeb: Ignore layout/paint invalidations in subtree under display:none
The entire subtree of an element with display:none is irrelevant for
purposes of layout and/or paint invalidation.

We now simply ignore invalidation triggers inside such subtrees.

This avoids a *lot* of redundant busywork when running CSS animations
inside not-even-rendered content. As an example, this avoids repainting
YouTube embeds repeatedly due to animating-but-hidden progress
indicators.

Note that the subtree *root* (i.e the `display:none` element itself)
still gets to trigger invalidation, since we may need to rebuild the
layout tree when the `display` property changes.
2024-01-04 21:19:32 +01:00
Shannon Booth
cd156bad6b LibWeb: Create XMLDocuments in DOMImplementation.createDocument 2024-01-04 11:23:20 +01:00
Shannon Booth
36c145b197 LibWeb: Fix crash in DOMImplementation.createDocument for null namespace
We were blindly assuming that the namespace was non-null instead of
simply passing it through.
2024-01-04 11:23:20 +01:00
Shannon Booth
a028c87069 LibWeb: Add a default URL of about:blank to DOM::XMLDocument
This matches DOM::Document.
2024-01-04 11:23:20 +01:00
Shannon Booth
e9dfa61588 LibWeb: Use UTF-16 code unit offsets in Range::to_string
Similar to another problem we had in CharacterData, we were assuming
that the offsets were raw utf8 byte offsets into the data, instead of
utf16 code units. Fix this by using the substring helpers in
CharacterData to get the text data from the Range.

There are more instances of this issue around the place that we will
need to track down and add tests for, but this fixes one of them :^)

For the test included in this commit, we were previously returning:

llo💨😮

Instead of the expected:

llo💨😮 Wo
2024-01-04 10:10:44 +01:00
Shannon Booth
ee431e6911 LibWeb: Use WebIDL typedefs in Range/AbstractRange
In the public APIs which have their types exposed through IDL.
2024-01-04 10:10:44 +01:00
Shannon Booth
fa1ef30985 LibWeb: Port Element::set_attribute_value from ByteString
Also making set_attribute_ns take a String instead of a FlyString as
this is only used as an Attr value and no FlyString properties are used.
2024-01-03 10:13:47 +01:00
Shannon Booth
285bca1633 LibWeb: Use Optional<FlyString> const& in Element and NamedNodeMap
This is enabled with the newly added IDL generator support for
FlyStrings.
2024-01-03 10:13:47 +01:00
Shannon Booth
f32185420d LibWeb: Use FlyString where possible in NamedNodeMap
We cannot port over Optional<FlyString> until the IDL generator supports
passing that through as an argument (as opposed to an Optional<String>).

Change to FlyString where possible, and resolve any fallout as a result.
2024-01-03 10:13:47 +01:00
Aliaksandr Kalenik
07928129dd LibWeb: Wait until new document becomes active before running scripts
Fixes https://github.com/SerenityOS/serenity/issues/22485

With this change WebContent does not crash when `location.reload()` is
invoked but `Navigable::reload()` still not working because of spec
issue (https://github.com/whatwg/html/issues/9869) so we can't add a
test yet.
2023-12-30 19:32:31 +01:00
Shannon Booth
462f97b28a LibWeb: Port Element::get_attribute_value from ByteString 2023-12-27 09:23:44 +01:00
MacDue
daecf741d4 LibWeb: Ensure DocumentObserver document_completely_loaded() is called
This stopped being called for anything without a navigable container
after 76a97d8, due to the early return. This broke SVG <use> elements
that reference elements defined later in the document.
2023-12-26 21:37:04 +01:00
Sam Atkins
5e2fc52b25 LibWeb: Remove old ad-hoc document-loading code
This also removes the code for displaying `gemini://` documents. We
currently don't load documents from that protocol anyway - we hit
`attempt_to_create_a_non_fetch_scheme_document()` in `Navigable.cpp`
which is just a stub. It looks like we should be handling those
separately from regular "fetch" documents, so that's a task for a
future person.
2023-12-26 18:35:29 +01:00
Sam Atkins
9733524f8a LibWeb: Load markdown documents using the spec mechanism
This basically just means it now goes through the
`create_document_for_inline_content()` function.
2023-12-26 18:35:29 +01:00
Sam Atkins
c5223ae77f LibWeb: Adjust create_document_for_inline_content() for future use
(Apologies for bad commit title, it's hard to explain in such a short
space!)

We're going to need to call this for producing markdown and gemini
documents, both of which need a Document and Realm to fetch the entire
response body, so that they can then generate their HTML. So this
commit modifies `create_document_for_inline_content()` to take a lambda
instead of a fixed HTML string, to support these uses.

Also, we always return a nonnull pointer, so make that the return type.

This is a move and change in the same commit, (Sorry!) but all the
changes are to the function signature and step 6.
2023-12-26 18:35:29 +01:00
Sam Atkins
ae8e040287 LibWeb: Bring media-document loading closer to spec
There's an unfortunate hack here. We have to load the media file's data
before we call `HTML::HTMLParser::the_end()` with our generated
document, otherwise the media element (`<img>`/`<audio>`/`<video>`)
never loads and that blocks the document's load event. The previous code
path also did this, which is perhaps why the bug was never noticed.
2023-12-26 18:35:29 +01:00
Sam Atkins
91d82ae17a LibWeb: Bring text-document parsing to spec 2023-12-26 18:35:29 +01:00
Sam Atkins
4dbca3e14a LibWeb: Bring XML-document loading to spec 2023-12-26 18:35:29 +01:00
Sam Atkins
6c74069c1e LibWeb: Bring HTML-document loading to spec 2023-12-26 18:35:29 +01:00
Sam Atkins
a20951fbc0 LibWeb: Support making a document active after it has completely loaded
So far, we always call make_active() before update_readiness
(Complete), but this will soon not be the case once we implement the
spec document-loading algorithms.

Co-authored-by: Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
2023-12-26 18:35:29 +01:00
Sam Atkins
ad8ccd4c52 LibWeb: Update spec comment for Document::create_and_initialize()
No functional changes.
2023-12-26 18:35:29 +01:00
Sam Atkins
933231ffd4 LibWeb: Spec-comment load_document()
This function is currently very ad-hoc. This commit adds comments which
are almost entirely FIXMEs, so that we can then start filling in the
details one step at a time.
2023-12-26 18:35:29 +01:00
Sam Atkins
40f7cab21e LibWeb: Implement Document::populate_with_html_head_and_body() 2023-12-26 18:35:29 +01:00
Sam Atkins
8dc8d57418 LibWeb: Make load_document()'s NavigationParams non-optional
There's no mention in the spec of this being optional, all the places
that call it always pass a NavigationParams directly, and we're
VERIFYing that it's got a value too!
2023-12-26 18:35:29 +01:00