Commit graph

3222 commits

Author SHA1 Message Date
Aliaksandr Kalenik
036327332f LibWeb: Early return from replace_data() if data didn't change
Allows us to avoid invalidating layout when CharacterData didn't change.

Results in visible improvement on Discord that continuously invokes
this function with the same data, which previously resulted in relayout
on every frame.
2025-02-19 22:32:09 +01:00
Aliaksandr Kalenik
0f3665e64e LibWeb: Mark should_reject_with_ancestor_filter() as inline 2025-02-19 21:52:29 +01:00
Aliaksandr Kalenik
0f8050f0bd LibWeb: Break early from rule testing in hover style invalidation
Before this change, we did the following:
1. Created a bitmap with the matching state for each rule containing
   `:hover`.
2. Changed the actively hovered element in the document.
3. Created another bitmap with the matching state for each rule
   containing `:hover`.

With this change, we iterate rule by rule and compare the matching
state. This allows us to break early once we find the first rule whose
matching state changes after the hovered element update. Additionally,
this removes the need to allocate a bitmap.
2025-02-19 21:52:29 +01:00
Aliaksandr Kalenik
e1119023e9 LibWeb: Optimize pseudo elements presence check in hover style update
Instead of using `has_pseudo_elements()` that iterates over all pseudo
elements, only check if `::before` or `::after` are present.

Before this change, `has_pseudo_elements()` was 10% of profiles on
Discord while now it's 1-2%.
2025-02-19 19:56:52 +01:00
Timothy Flynn
82206d2abb LibWeb: Move DOM::NodeType to its own file
This is to allow using these values in libraries that otherwise do not
need to depend on LibWeb.
2025-02-19 08:45:51 -05:00
Shannon Booth
705001483a LibWeb: Make base URL of HTML::Script Optional
This is a null or a URL in the spec, which we were previously
representing through the invalid state of URL.
2025-02-19 08:01:35 -05:00
Shannon Booth
d62cf0a807 Everywhere: Remove some use of the URL constructors
These make it too easy to construct an invalid URL, which makes it
difficult to remove the valid state of URL - which this API relies
on.
2025-02-19 08:01:35 -05:00
Shannon Booth
0b8bcdcbd3 LibWeb: Remove some useless URL validity checks
It is not possible for a URL here to have a value and be invalid.
2025-02-19 08:01:35 -05:00
Shannon Booth
dc2b0e17bf LibWeb/ServiceWorker: Use has_value for checking for invalid URL
This is the correct API to call here.
2025-02-19 08:01:35 -05:00
Shannon Booth
2c8dab36f3 LibWeb: Port EnvironmentSettings URL Parsing to return Optional<URL> 2025-02-19 08:01:35 -05:00
Jelle Raaijmakers
5f5d18d719 LibWeb: Do not crash when inserting block elements into inline SVGBoxes
Fixes #3395.
2025-02-19 13:49:24 +01:00
Jelle Raaijmakers
0c58dad7a6 LibWeb: Factor out conditions for creation of inline continuation
Having one big `if` to determine whether or not we should restructure an
inline layout node became a bit unwieldy. This extracts the logic into a
separate method.
2025-02-19 13:49:24 +01:00
Jelle Raaijmakers
c0109039cb LibWeb: Do not consider <foreignObject> for inline continuation
We used to have an exception for this element that erroneously got
removed in 336684bc5c.

Fixes #3453.
2025-02-19 13:49:24 +01:00
Piotr
c9edb6ffc4 LibWeb: Support for Content-Language HTTP header 2025-02-19 10:53:31 +00:00
Jelle Raaijmakers
de7ca7b157 LibWeb: Retain display: contents in ancestor stack for continuations
When restructuring inline nodes because of a block element insertion
during the layout tree build, we might end up with a `display: contents`
element in the ancestor stack that is not part of the actual layout
tree, since it's never actually used as a parent for any node. Because
we were only rewinding the ancestor stack with actual new layout nodes,
it became corrupted and layout nodes were added to the wrong parent.

This new logic leaves the ancestor stack intact, only replacing layout
nodes whenever a new one is created.

Fixes the sidebar on https://reddit.com.
Fixes #3590.
2025-02-18 23:31:49 +01:00
Tim Ledbetter
dd8cca180f LibWeb: Remove unintentional recursion in ValidityState::valid 2025-02-18 21:58:35 +01:00
Andrew Kaster
8e3798b25e LibWeb: Convert ConnectionTimingInfo to a standard layout struct
There's nothing about this type that requires it to be GC allocated
2025-02-18 11:26:34 -07:00
Andrew Kaster
47716a4e11 LibWeb: Explicitly capture resource in closures in load_resource
A hygine patch to not use a generic = capture, and remove some
unnecessary const-casts
2025-02-18 11:26:34 -07:00
Andrew Kaster
8760825bb4 LibWeb: Don't store Page on ResourceLoader
We only need a Page for file:// urls. At some point we probably
needed it for other kinds of requests, but the current functionality
doesn't need to store the Page pointer on the ResourceLoader.
2025-02-18 11:26:34 -07:00
Andrew Kaster
a869a1c056 LibWeb: Establish WebSocket connections in parallel 2025-02-18 11:26:34 -07:00
Psychpsyo
aa243000f3 LibWeb: Implement TimeRanges and HTMLMediaElement.seekable() 2025-02-18 10:45:32 -07:00
Psychpsyo
3952ff4786 LibWeb: Add a stub for HTMLMediaElement.played() 2025-02-18 10:45:32 -07:00
Psychpsyo
0206697d36 LibWeb: Implement MediaCapabilities.decodingInfo() 2025-02-18 10:18:40 -07:00
Psychpsyo
a8004a77bb LibWeb: Implement setCustomValidity IDL attribute 2025-02-18 10:17:06 -07:00
Tim Ledbetter
0e470d5cdf LibWeb: Apply presentational hints for the HTMLHRElement align attribute 2025-02-18 12:06:44 +01:00
Tim Ledbetter
c217057cfd LibWeb: Apply presentational hints for the HTMLHRElement color attribute 2025-02-18 12:06:44 +01:00
Psychpsyo
83c4e22247 LibWeb: Implement validity IDL attribute 2025-02-18 06:37:11 +00:00
Aliaksandr Kalenik
184ae687c5 LibWeb+WebContent: Remove unused code in BrowsingContext 2025-02-17 19:11:14 -05:00
Shannon Booth
cf7b775709 LibWeb/URLPattern: Implement the URLPattern IDL getters
These simply return the compiled URLPattern pattern strings for
each component, and whether any of the components contained any
regexp groups.
2025-02-17 19:10:39 -05:00
Aliaksandr Kalenik
93253e993b LibWeb: Fix invalidations calculation for values with relative units
...in inherited style update. Instead of comparing old absolutized value
with new non-absolutized value, we should wait until
`absolutize_values()` and then compare old and new values, when both are
absolutized.

Improves performance on pages with GitHub action logs where previously
we had to invalidate layout after hover style recalculation, because
there was `margin-left: 1rem`.
2025-02-18 00:24:45 +01:00
Aliaksandr Kalenik
9dd59e0673 LibWeb: Early return when invalidations=none in animation style update
This allows to skip a bunch of unnecessary work performed by
`apply_style()`.
2025-02-18 00:24:45 +01:00
Aliaksandr Kalenik
1e07227e98 LibWeb: Early return when invalidations=none in inherited style update
This allows to skip a bunch of unnecessary work performed by
`apply_style()`.
2025-02-18 00:24:45 +01:00
Aliaksandr Kalenik
e5b4fe2c65 LibWeb: Fix wrong invalidations calculation in inherited style update
We were incorrectly comparing new value against itself instead of the
old value to determine required set of invalidations.
2025-02-18 00:24:45 +01:00
devgianlu
f630ca7cd0 LibCrypto: Rename and remove unused methods from SECPxxxr1 class 2025-02-18 00:02:26 +01:00
devgianlu
048d6b8012 LibCrypto: Remove unused constructors from RSA class 2025-02-18 00:02:26 +01:00
devgianlu
8ae01f81c9 LibCrypto: Remove unused MGF class 2025-02-18 00:02:26 +01:00
Andreas Kling
fb020a3c8f LibWeb: Store final box model metrics in paint tree, not layout tree
This was a weird case of layout results being stored in the layout tree
instead of in the paint tree like everything else.
2025-02-17 18:28:29 +01:00
Gingeh
4966fa4aed LibWeb: Prevent crash with custom cursor
We don't support custom cursors, use the default instead of crashing.
Also clean up a bit of dead code from when Cursor was optional.
2025-02-17 12:24:49 +00:00
InvalidUsernameException
29d74632c7 LibWeb: Move z-index to table wrapper box
When drawing a table, some of the CSS properties must be moved from the
table grid box to an anonamyous table wrapper box. One of these
properties is `position`. `z-index` however is not. This leads to the
following behavior if a table has both `position` and `z-index`:
* The wrapper box has the `position`, but a `z-index` of `auto`.
* The grid box has the `z-index`, but `position: static`.

This effectively means that the `z-index property is ignored since it
has no effect on non-positioned elements. This behavior contradicts what
other browsers do and causes layout issues on websites.

To align Ladybird behavior with other browser this commit also moves the
`z-index` property to the wrapper box.
2025-02-16 21:05:59 +01:00
Gingeh
91e4fb248b LibWeb: Hide unrelated popovers when showing popovers
Also hides decendant popovers when hiding.
Also hides unrelated popovers when showing dialogs.
2025-02-16 19:40:07 +00:00
Gingeh
bc0729f5d2 LibWeb: Create a BlockContainer for 'block ruby' elements
Prevents the layout engine from crashing.
(and unlocks ~200 new subtests)
2025-02-16 19:40:07 +00:00
David Hewitt
be3e221b3f LibWeb/XHR: Ensure type set on blob responses 2025-02-16 19:08:45 +00:00
Andreas Kling
31a69ce887 LibWeb+LibGfx: Make IntersectionObserver checks edge-inclusive
This fixes an issue where 0x0 rectangles were not considered to be
intersecting, even when they fell inside (or were adjacent to) the
viewport.
2025-02-16 18:09:08 +01:00
Psychpsyo
f839f1b44b LibWeb: Make a elements honor base element's target 2025-02-16 09:21:52 +01:00
Luke Wilde
751b93959f LibWeb/CSS: Use fallback var() value if custom property is empty
If the expansion of a custom property in variable expansion returns
tokens, then the custom property is not the initial guaranteed-invalid
value.

If it didn't return any tokens, then it is the initial
guaranteed-invalid value, and thus we should move on to the fallback
value.

Makes Shopify checkout show the background colours, borders, skeletons,
etc.
2025-02-16 09:19:19 +01:00
Psychpsyo
8f79f2137e LibWeb: Fix steps for finding a navigable by target name 2025-02-16 09:03:51 +01:00
Aliaksandr Kalenik
d3c481f71a LibWeb: Schedule input event processing on HTML event loop
Our existing coalescing mechanism for input events didn't prevent
multiple mousemove/mousewheel events from being processed between paint
cycles. Since handling these events can trigger style & layout updates
solely for hit-testing purposes, we might end up doing work that won't
be observable by a user and could be avoided by shceduling input events
processing to happen right before painting the next frame.
2025-02-15 21:09:18 +01:00
Shannon Booth
9072a7caef Everywhere: Use URL::about_XXX factory functions 2025-02-15 17:05:55 +00:00
Shannon Booth
53826995f6 LibURL+LibWeb: Port URL::complete_url to Optional
Removing one more source of the URL::is_valid API.
2025-02-15 17:05:55 +00:00
Tim Ledbetter
4bb22c52d1 LibWeb: Initialize AnalyserNode previous block at construction time 2025-02-13 20:31:37 +00:00