Commit Graph

8686 Commits

Author SHA1 Message Date
Andreas Kling
dd8504c68d LibWeb: Store "text for rendering" in TextPaintable
Instead of TextPaintable fragments being an offset+length view into the
layout node, they are now a view into the paintable instead.

This removes an awkward time window where we'd have bogus state in text
fragments after layout invalidation but before relayout. It also makes
the code slightly nicer in general, since there's less mixing of layout
and painting concepts.
2024-03-18 13:42:16 +01:00
Andreas Kling
2be47c3d7a LibWeb: Add fast_is<TextPaintable>() 2024-03-18 13:42:16 +01:00
Andreas Kling
1987318cc2 LibWeb: Move selection state from layout tree to paint tree
Where we paint the selection is obviously paint-related information,
so let's keep it in the paint tree.
2024-03-18 13:42:16 +01:00
Andreas Kling
d18a5b904d LibWeb: Remove unused LineBoxFragment member 2024-03-18 13:42:16 +01:00
Andreas Kling
9c5da0eed0 LibWeb: Remove unused PaintableFragment member 2024-03-18 13:42:16 +01:00
Andreas Kling
94e55768f6 LibWeb: Ensure layout is up-to-date before blinking the input cursor 2024-03-18 13:42:16 +01:00
Andreas Kling
a7d7c5b7b4 LibWeb: Don't force relayout after every keyboard input event
Instead, just rely on the invalidation and lazy relayout that happens as
a consequence of mutating the DOM.

This allows multiple keystrokes to coalesce into a single relayout if
necessary, dramatically improving performance when typing text into
form fields on complex pages.
2024-03-18 13:42:16 +01:00
Andreas Kling
c51a4cc007 LibWeb: Detach paintables from *all* DOM nodes before committing layout
Before this change, we were not detaching paintables from DOM nodes
within shadow subtrees.

This appears to be the main reason that keyboard editing was doing
immediate forced relayout: doing a full layout invalidation meant we'd
build a new layout tree, which then hid the problem with with
still-attached paintables.

By detaching them before committing a new layout, we make it possible
for keyboard editing to just use normal relayout, instead of full forced
invalidation & relayout.
2024-03-18 13:42:16 +01:00
Andreas Kling
a97e9f1d58 LibWeb: Don't mark CharacterData nodes for style update when changed
CharacterData nodes and their subclasses (most commonly Text) don't have
style, as style is specific to Elements. So there's no need to mark them
for a style update when their content is programmatically changed.
2024-03-18 13:42:16 +01:00
Tim Ledbetter
3a7a84f39b LibWeb: Limit progress element attribute values to the correct ranges
The max attribute is now clamped to ensure it is limited to positive
numbers and the value attribute is clamped to ensure it is non-negative.
2024-03-18 11:16:35 +01:00
Tim Ledbetter
ecbc686bc8 LibWeb: Allow progress element value to be set higher than the max value
Previously, we returned from the value setter if the specified value
was above the max value. This is not required, as the getter clamps the
returned value to the max value.
2024-03-18 11:16:35 +01:00
Tim Ledbetter
e795c24fdd LibWeb: Don't crash when modifying detached progress element attributes 2024-03-18 11:16:35 +01:00
MacDue
8057542dea LibGfx: Simplify path storage and tidy up APIs
Rather than make path segments virtual and refcounted let's store
`Gfx::Path`s as a list of `FloatPoints` and a separate list of commands.

This reduces the size of paths, for example, a `MoveTo` goes from 24
bytes to 9 bytes (one point + a single byte command), and removes a
layer of indirection when accessing segments. A nice little bonus is
transforming a path can now be done by applying the transform to all
points in the path (without looking at the commands).

Alongside this there's been a few minor API changes:

- `path.segments()` has been removed
  * All current uses could be replaced by a new `path.is_empty()` API
  * There's also now an iterator for looping over `Gfx::Path` segments
- `path.add_path(other_path)` has been removed
  * This was a duplicate of `path.append_path(other_path)`
- `path.ensure_subpath(point)` has been removed
  * Had one use and is equivalent to an `is_empty()` check + `move_to()`
- `path.close()` and `path.close_all_subpaths()` assume an implicit
  `moveto 0,0` if there's no `moveto` at the start of a path (for
  consistency with `path.segmentize_path()`).

Only the last point could change behaviour (though in LibWeb/SVGs all
paths start with a `moveto` as per the spec, it's only possible to
construct a path without a starting `moveto` via LibGfx APIs).
2024-03-18 07:09:37 +01:00
Kenneth Myhra
49d7719a04 LibWeb: Add and use serialize_enum() 2024-03-17 17:16:09 +01:00
Kenneth Myhra
94c6389fc0 LibWeb: Add {,de}serialization steps for DOMRect 2024-03-17 17:16:09 +01:00
Kenneth Myhra
9f5fa4f4a0 LibWeb: Add {,de}serialization steps for DOMRectReadonly 2024-03-17 17:16:09 +01:00
Kenneth Myhra
b7006b2423 LibWeb: Add {,de}serialization steps for DOMPoint 2024-03-17 17:16:09 +01:00
Kenneth Myhra
bf4fb39bfb LibWeb: Add {,de}serialization steps for DOMPointReadonly 2024-03-17 17:16:09 +01:00
Kenneth Myhra
8d2f7cfb58 LibWeb: Add {,de}serialization steps for DOMMatrix 2024-03-17 17:16:09 +01:00
Kenneth Myhra
181424377d LibWeb: Add {,de}serialization steps for DOMMatrixReadonly 2024-03-17 17:16:09 +01:00
Kenneth Myhra
57e7d6e989 LibWeb: Consolidate serialization of integral and floating point types
This consolidates serialization and deserialization of integral and
floating point types into two templated functions.
2024-03-17 17:16:09 +01:00
Bastiaan van der Plaat
4205ac778f LibWeb: Hide inner text of input element when showing placeholder 2024-03-17 10:20:36 -04:00
Bastiaan van der Plaat
b4bae912c9 LibWeb: Remove ByteString usage in input element placeholder_value() 2024-03-17 10:20:36 -04:00
Aliaksandr Kalenik
3fd1164171 LibWeb: Account for scroll offset in Element::get_client_rects() 2024-03-17 13:32:04 +01:00
Aliaksandr Kalenik
15524b97b6 LibWeb: Update paint-only props only when needed in get_client_rects()
There is no need to unconditionally resolve them whenever the function
is called.
2024-03-17 13:32:04 +01:00
Tim Ledbetter
e9383b9c86 LibWeb: Avoid division by zero when calculating SVG viewbox aspect ratio 2024-03-17 12:54:02 +01:00
Tim Ledbetter
b61aab66d9 LibWeb: Don't crash CPU painter if BorderRadiusSamplingConfig is invalid 2024-03-17 12:54:02 +01:00
Tim Ledbetter
a40c14462d LibWeb: Avoid division by zero when calculating scrollbar rect 2024-03-17 12:54:02 +01:00
Aliaksandr Kalenik
0afbd827e0 LibWeb: Skip page scrolling for wheel events consumed by scrollable box
Leftover from 90879a07ba
2024-03-17 09:33:16 +01:00
Timothy Flynn
a386ebde02 LibWeb: Do not return after ignoring a key event on an editable node
We do not want to blindly say we handled the key event. Otherwise, the
chrome is unable to handle shortcuts while an editable node is focused.
2024-03-17 09:32:37 +01:00
Timothy Flynn
4a476c3dd5 LibWeb: Ignore key presses when the OS super key is also pressed
Most shortcuts on macOS are activated with the super (command) key. For
now, we should ignore these like we ignore ctrl key modifiers.
2024-03-17 09:32:37 +01:00
MacDue
6c26ff567e LibGfx+LibWeb: Move HTML::CanvasPathClipper to Gfx::PathClipper
This does not depend on anything outside of LibGfx, and seems like it
may be useful elsewhere.

No behaviour change.
2024-03-17 09:30:53 +01:00
Andreas Kling
ead742886b LibWeb: Don't run HTMLImageElement timer when there is no animation
Before this change, we would wake up on every event loop iteration to
drive animations in single-frame images. This was a complete waste of
time and caused 100% CPU usage on our main GitHub repo page.

With this change, CPU usage is ~1% when idle on the same page. :^)
2024-03-16 16:35:54 +01:00
Andreas Kling
7121539576 LibWeb: Add fast_is<T> for UIEvents::MouseEvent 2024-03-16 16:35:54 +01:00
Andreas Kling
c0d7f748ed LibWeb: Avoid FlyString lookups when setting IDL interface prototypes
This commit introduces a WEB_SET_PROTOTYPE_FOR_INTERFACE macro that
caches the interface name in a local static FlyString. This means that
we only pay for FlyString-from-literal lookup once per browser lifetime
instead of every time the interface is instantiated.
2024-03-16 16:35:54 +01:00
Andreas Kling
98cf845d8a LibWeb: Use HTML::EventNames::animation* instead of string literals 2024-03-16 16:35:54 +01:00
Andreas Kling
43c720db81 LibWeb: Remove a bunch of redundant Document::navigable() lookups
Document::navigable() can be unpleasantly slow, since we don't have a
direct link between documents and navigables at the moment. So let's not
call it twice when once is enough.
2024-03-16 14:27:59 +01:00
Andreas Kling
77d98b5697 LibWeb: Add per-attribute-name CSS rule buckets
This allows us to skip evaluating selectors like "[foo=bar]" for any
element that doesn't have a "foo" attribute.

Note that the bucket is case-insensitively keyed on the attribute name
since case sensitivity is depending on evaluation context. This ensures
we may get some false positives but no false negatives.

Reduces the number of selectors evaluated by 36% when loading our GitHub
repo at https://github.com/SerenityOS/serenity
2024-03-16 14:27:59 +01:00
Andreas Kling
038e0ceee7 LibWeb: Avoid copying the CSS @namespace every time we run a selector 2024-03-16 14:27:59 +01:00
Andreas Kling
a378303629 LibWeb: Use unchecked_append in StyleComputer::collect_matching_rules()
We already grow the "rules to run" vector before appending to it, so we
can actually use unchecked_append() here and avoid the "needs to grow"
checks every time we append to it.

This takes appending from 3% to <1% when loading our GitHub repo.
2024-03-16 14:27:59 +01:00
Andreas Kling
b15316eba8 LibWeb: Avoid FlyString->String->FlyString roundtrips in CSS variables 2024-03-16 14:27:59 +01:00
Andreas Kling
7da3b0dd7b LibWeb: Avoid a FlyString->String->FlyString round-trip in StyleComputer 2024-03-16 14:27:59 +01:00
Andreas Kling
c0e0cb86e1 LibWeb: Make CSS::string_from_property_id() return FlyString const&
This avoids costly conversions from StringView to FlyString in CSS
parsing and variable expansion.
2024-03-16 14:27:59 +01:00
Andreas Kling
1cea4e6407 LibWeb: Use cached UsedValues pointer in IFC and its helper classes
This avoids expensive LayoutState lookups when we already have the
pointer sitting around anyway.
2024-03-16 14:27:59 +01:00
Andreas Kling
43ef3dc0ab LibWeb: Cache attribute names in lowercase to speed up selector matching
When matching a CSS attribute selector against an HTML element, the
attribute name is case-insensitive. Before this change, that meant we
had to call equals_ignoring_ascii_case() on all the attribute names.

We now cache the attribute name lowercased on each Attr node, which
allows us to do FlyString-to-FlyString comparison (simple pointer
comparison).

This brings attribute selector matching from 6% to <1% when loading our
GitHub repo at https://github.com/SerenityOS/serenity
2024-03-16 14:27:59 +01:00
Aliaksandr Kalenik
a3b4c2a30f LibJS+LibWeb: Change JobCallback to be GC-allocated
Fixes leak caused by mutual dependency when JS::Handle<JobCallback> is
owned by GC-allocated PromiseReaction.
2024-03-16 14:27:06 +01:00
Aliaksandr Kalenik
e0713376a0 LibWeb: Capture weak this ptr in HTMLTextAreaElement input callback
Fixes GC-leak caused by cycle dependency between input callback and
HTMLTextAreaElement that owns it.
2024-03-16 09:12:02 -04:00
Timothy Flynn
9eb38ce79c LibWeb: Update the <textarea> shadow DOM after reseting its form owner
This generally happens after a form is submitted. We need to update the
text node in the shadow DOM to actually display the reset value.
2024-03-16 13:11:57 +01:00
Timothy Flynn
c0d594568d LibWeb: Partially implement <textarea>'s selectionStart and selectionEnd
This implementation pretends we never have a selection. GitHub relies on
these values to know where to insert text corresponding to file uploads.
2024-03-16 13:11:57 +01:00
Timothy Flynn
abc1be5b9e LibWeb: Update the <textarea> shadow DOM when the value attribute is set
Otherwise, setting the value attribute after the element is added to the
DOM is not visibile. The logic here was stolen from the <input> element.
2024-03-16 13:11:57 +01:00
Timothy Flynn
2b6c00e8b9 LibWeb: Use the <textarea>'s API value, not its raw value, where needed
The API value of a <textarea> element is its raw value with normalized
newlines. This should be used in a couple of places where we currently
use the raw value.
2024-03-16 13:11:57 +01:00
Timothy Flynn
1c0541d706 LibWeb: Implement an AO to normalize newlines in a string 2024-03-16 13:11:57 +01:00
Timothy Flynn
324feb04e7 LibWeb: Fix spec link on <textarea>'s value setter 2024-03-16 13:11:57 +01:00
Aliaksandr Kalenik
a9b8840a82 LibWeb: Add fast path for animated style properties update
Patch up existing style properties instead of using the regular style
invalidation path, which requires rule matching for each element in the
invalidated subtree.

- !important properties: this change introduces a flag used to skip the
  update of animated properties overridden by !important.
- inherited animated properties: for now, these are invalidated by
  traversing animated element's subtree to propagate the update.
- StyleProperties has a separate array for animated properties that
  allows the removal animated properties after animation has ended,
  without requiring full style invalidation.
2024-03-16 09:49:40 +01:00
Aliaksandr Kalenik
dd07c7f729 LibWeb: Delete AnimationEffect::create() function
It should not be possible to create AnimationEffect because it is
an abstract interface according to the spec.
2024-03-16 09:49:40 +01:00
Timothy Flynn
6760d236e4 Ladybird+LibWeb+WebContent: Parse the <input type=file> accept attribute
This parses the accept attribute value for file input types and passes
it along to the browser chromes.
2024-03-16 08:42:33 +01:00
Andrew Kaster
1521a60a67 LibWeb: Support SubtleCrypto.exportKey for RSA-OAEP in JsonWebKey format 2024-03-14 17:57:37 -06:00
Andrew Kaster
2599142214 LibWeb: Export UnsignedBigInts into Uint8Arrays without losing bytes
The behavior of Crypto::UnsignedBigInt::export_data unexpectedly
does not actually remove leading zero bytes when the corresponding
parameter is passed. The caller must manually adjust for the location
of the zero bytes.
2024-03-14 17:57:37 -06:00
Andrew Kaster
0a3d27c41d LibWeb: Make SubtleCrypto AlgorithmParams classes virtual
This allows us to properly destroy the child classes through a pointer
to the base class, avoiding ASAN/UBSAN errors.
2024-03-14 17:57:37 -06:00
Andreas Kling
0c76c7ee36 LibWeb: Make Element::is_document_element() slightly nicer
By following the spec more closely, we can actually make this function
a bit more efficient (by comparing the parent against the document
instead of looking for the first element child of the document).
2024-03-14 12:42:08 +01:00
Andreas Kling
bbf67faa95 LibWeb: Add CSS rule buckets for pseudo elements, and for :root
If a selector must match a pseudo element, or must match the root
element, we now cache that information in the MatchingRule struct.
We also introduce separate buckets for these rules, so we can avoid
running them altogether if the current element can't possibly match.

This cuts the number of selectors evaluated by 32% when loading our
GitHub repo page https://github.com/SerenityOS/serenity
2024-03-14 12:42:08 +01:00
Andreas Kling
c6e37d0c44 LibWeb: Give Vector<MatchingRule> some inline capacity in StyleComputer
We frequently end up matching hundreds or even thousands of rules. By
giving this vector some inline capacity, we avoid a lot of the
repetitive churn from dynamically growing it all the way from 0
capacity.
2024-03-14 12:42:08 +01:00
Timothy Flynn
bc23c5b9fe LibWeb: Append the bytes of File objects in submitted form data
This is required to upload files to GitHub. Unfortunately, this is not
currently testable with our test infrastructure. This path is only hit
from HTTP/S uploads, whereas all of our tests are limited to file://.
2024-03-14 10:10:33 +01:00
Timothy Flynn
c0d18e976e LibWeb: Use string literals as format strings during form serialization
Passing a StringView bypasses compile-time format string validation.
2024-03-14 10:10:33 +01:00
Timothy Flynn
bb38cc1010 LibWeb: Do not blindly create File objects when adding FormData entries
We were unconditionally creating new File objects for all Blob-type
values passed to `FormData.append`. We should only do so if the value is
not already a File object (or if the `filename` attribute is present).

We must also carry MIME type information forward from the underlying
Blob object.
2024-03-14 10:10:33 +01:00
Timothy Flynn
f55471333b LibWeb: Set the MIME type when creating an <input> element's File list
We were passing the MIME type to the underlying Blob, but the factory
for creating a File only checks an explicit options structure.
2024-03-14 10:10:33 +01:00
Timothy Flynn
0cc8698a62 LibWeb: Reverse check for whether a FilesList index is supported
This fixes for..of iteration of a FilesList object.
2024-03-14 10:10:33 +01:00
Timothy Flynn
c2ef506b4a LibWeb: Add an empty DataTransfer IDL implementation
This does not implement any of the IDL methods, but GitHub requires the
interface exists to upload files via an <input type="file"> element.
Their JS handles uploads via this element and via drag-and-drop in one
function, and check if the uploaded file is `instanceof DataTransfer` to
decide how to handle it.
2024-03-14 10:10:33 +01:00
Timothy Flynn
7681772b9f LibWeb: Log failed Fetch responses when WEB_FETCH_DEBUG is enabled
We do the same for successful responses. Very useful for debugging
issues on live websites.
2024-03-14 10:10:33 +01:00
Andrew Kaster
a9d240c647 LibWeb: Implement SubtleCrypto.generateKey for RSA-OAEP
This patch implements and tests window.crypto.sublte.generateKey with
an RSA-OAEP algorithm. In order for the types to be happy, the
KeyAlgorithms objects are moved to their own .h/.cpp pair, and the new
KeyAlgorithms for RSA are added there.
2024-03-13 15:31:00 -06:00
Andrew Kaster
0b4858e589 LibWeb: Implement SubtleCrypto.generateKey skeleton
We don't have any algorithms defined that actually support generateKey,
but now all the scaffolding is there.
2024-03-13 15:31:00 -06:00
Andrew Kaster
810be6af07 LibWeb: Add CryptoKeyPair object for use in upcoming SubtleCrypto APIs 2024-03-13 15:31:00 -06:00
Andrew Kaster
0a6f195a71 LibWeb: Implement usages property for CryptoKey
And set it from the only place we currently create a CryptoKey, in
importKey.
2024-03-13 15:31:00 -06:00
Andrew Kaster
2d59d6c98c LibWeb: Refactor SubtleCrypto to allow adding more algorithms easier
This patch throws away some of the spec suggestions for how to implement
the normalize_algorithm AO and uses a new pattern that we can actually
extend in our C++.

Also update CryptoKey to store the key data.
2024-03-13 15:31:00 -06:00
Andreas Kling
72e6581585 LibWeb: Store copy of MutationObserver set in a MarkedVector
While iterating over MutationObservers in the microtask callback, we
need to keep them in a MarkedVector to ensure they don't get GC'd.
2024-03-13 09:41:55 +01:00
Tim Ledbetter
fc1f037cd1 LibWeb: Implement the window.opener attribute
This returns a reference to the window that opened the current window.
2024-03-13 08:06:00 +00:00
Aliaksandr Kalenik
bf11f4f73f LibWeb: Visit m_when_defined_promise_map in CustomElementRegistry 2024-03-12 18:18:10 +01:00
Aliaksandr Kalenik
90112468ac LibWeb: Visit custom element definitions in CustomElementRegistry 2024-03-12 18:18:10 +01:00
Aliaksandr Kalenik
bf8bbea209 LibWeb: Visit constructor callback in CustomElementDefinition 2024-03-12 18:18:10 +01:00
Aliaksandr Kalenik
3b4230e0b0 LibWeb: Visit custom element's lifecycle callbacks
...instead of using JS::Handle which causes leaks when object holding
the callback can be reached by visiting the callback's dependencies.
2024-03-12 18:18:10 +01:00
Andreas Kling
bbb96d65b1 LibWeb: Don't crash on live range offset update during node insertion
When inserting a node into a parent, any live DOM ranges that reference
the parent may need to be updated. The spec does this by increasing or
decreasing the start/end offsets of each live range *before* actually
performing the insertion.

This caused us to crash with a verification failure, since it was
possible to set the range offset to an invalid value (that would go on
to immediately become valid after the insertion was finished).

This patch fixes the issue by adding special badged helpers on Range for
Node to reach into it and increase/decrease the offsets during node
insertion. This skips the offset validity check and actually makes our
code read slightly more like the spec.

Found by Domato :^)
2024-03-12 16:30:39 +01:00
Andreas Kling
43d2c920e0 LibWeb: Ignore MessagePort.start() on already-closed port
This matches other browsers, and fixes an assertion found by Domato.
2024-03-12 16:30:39 +01:00
Andreas Kling
c11f710628 LibWeb: Fix bogus insertion logic in HTMLTableSectionElement.insertRow()
Found by Domato :^)
2024-03-12 16:30:39 +01:00
Tim Ledbetter
7625d8a155 LibWeb: Implement AbortSignal.any()
This method takes a list of AbortSignals and returns an AbortSignal
that is aborted when any of the input signals is aborted.
2024-03-12 09:31:41 +01:00
Tim Ledbetter
130f28cf50 LibWeb: Mark abort event as trusted before dispatching it
This matches the behavior of Firefox and Chrome.
2024-03-12 09:31:41 +01:00
MacDue
163b6bb401 LibWeb: Special case SVG masks during layout
Rather than try to lay out masks normally, this updates the TreeBuilder
to create layout nodes for masks as a child of their user (i.e. the
masked element). This allows each use of a mask to be laid out
differently, which makes supporting `maskContentUnits=objectBoundingBox`
fairly easy.

The `SVGFormattingContext` is then updated to lay out masks last (as
their sizing may depend on their parent), and treats them like
viewports.

This is pretty ad-hoc, but the SVG specification does not give any
guidance on how to actually implement this.
2024-03-12 08:51:50 +01:00
MacDue
15e3b0ebde LibWeb: Use SVGGraphicsBox for <symbol> and <use> elements
This allows various SVG properties (like masking) to be applied to these
elements.
2024-03-12 08:51:50 +01:00
MacDue
05f42efc06 LibWeb: Support preserveAspectRatio=none for SVGs
This is very easy now all transforms are computed during layout.
2024-03-12 08:51:50 +01:00
mobounya
190a8f948e LibWeb: Don't crash when visiting about:srcdoc
When navigating to about:srcdoc we try to populate the session history
by calling populate_session_history_entry_document, if the resource is
an about:srcdoc this method will rely on the document_resource in the
SessionHistoryEntry to have a String in order for it call the right
method to create navigation params.

However when navigating to about:srcdoc directly, document_resource
will have an Empty, this leads populate_session_history_entry_document
to call the wrong method to create navigation params.

This fixes the issue by populating document_resource with an empty
string if it has an Empty and we're dealing with an about:srcdoc.

Issue: #23216
2024-03-12 00:11:57 -06:00
Andreas Kling
9aefc5c927 LibWeb: Return a dummy value from various SVG getters
Instead of crashing with a TODO() on half of the test cases generated by
Domato, let's just return a zeroed-out SVGAnimatedLength or
SVGAnimatedNumber from getters that return them.

We'll eventually have to implement these correctly, but crashing is not
productive since it blocks us from finding other issues.
2024-03-11 18:29:10 +01:00
Andreas Kling
35f359c51c LibWeb: Fix infinite loop in ChildNode's before() and after()
The loop that was supposed to check the chain of previous or next
siblings had a logic mistake where it would never traverse the chain,
so we would get stuck looking at the immediate sibling forever.
2024-03-11 18:29:10 +01:00
Andreas Kling
ad843b6e4a LibWeb: Don't crash when accessing property in detached Window object
After removing an iframe from the DOM, its contentWindow will be
detached from its browsing context, per spec.

Because the contentWindow is still accessible, we cannot assume that
Window objects always have an associated browsing context.

This needs to be fixed in the spec, but let's add a sensible null check
in the meantime.
2024-03-11 18:29:10 +01:00
Andreas Kling
2e0297d703 LibWeb: Handle reference cycles in SVG gradient linking
Since SVG gradients can reference each other, we have to keep track of
visited gradients when traversing the link chain, or we will recurse
infinitely when there's a reference cycle.
2024-03-11 18:29:10 +01:00
Andreas Kling
1b8d8c7bbc LibWeb: Make a Layout::BlockContainer for MathML boxes
Instead of creating a generic Layout::Box, make a BlockContainer. This
allows them to be laid out by BFC, which is better than nothing(?),
even if it's not going to be correct at all.
2024-03-11 18:29:10 +01:00
Andreas Kling
3591a82e8d LibWeb: Look at paintable directly in Element::scroll* APIs
We don't need to go via the layout tree as the element has a link
directly to its paintable where the relevant metrics are stored.
2024-03-11 18:29:10 +01:00
Andreas Kling
b98a2be96b LibWeb: Ignore window-forwarded document.body.onfoo in detached DOM
Normally, assigning to e.g document.body.onload will forward to
window.onload. However, in a detached DOM tree, there is no associated
window, so we have nowhere to forward to, making this a no-op.

The bulk of this change is making Document::window() return a nullable
pointer, as documents created by DOMParser or DOMImplementation do not
have an associated window object, and so must be able to return null
from here.
2024-03-11 18:29:10 +01:00
Andreas Kling
7139d5945f LibWeb: Use NonnullGCPtr in EventTarget's event handler map
Null entries are not valid, so let's not allow them.
2024-03-11 18:29:10 +01:00
Andreas Kling
99ca2ccf08 LibWeb: Make DOMImplementation.createHTMLDocument() create HTMLDocument
Prior to this change, this API would actually create an XML Document(!)
2024-03-11 18:29:10 +01:00
Andreas Kling
b9bacb3ff4 LibWeb: Don't assume HTMLTableCellElement always has table ancestor
That's not actually a DOM invariant, just something the HTML parser
refuses to build. You can still construct table-less th and td elements
using the DOM API.
2024-03-11 18:29:10 +01:00
Aliaksandr Kalenik
ecce570cb7 LibWeb: Stop animation driver timer after document becomes inactive 2024-03-11 16:44:05 +01:00