Commit graph

977 commits

Author SHA1 Message Date
Tete17
bd4e3fd3e0 LibWeb: Hook TrustedTypes to the Range Dom api 2025-10-13 13:22:01 +01:00
Tim Ledbetter
1a640b1d95 LibWeb: Avoid crash when shadow root has null focused area 2025-10-12 22:50:12 +01:00
Aliaksandr Kalenik
eb4c616974 LibWeb: Dispatch "resize" event on VisualViewport size change 2025-10-10 15:37:45 +02:00
Aliaksandr Kalenik
9862d8b4a6 LibWeb: Implement pinch-to-zoom support
Adds pinch event handling that adjusts the VisualViewport scale and
offset. VisualViewport's (offset, scale) is then used to construct a
transformation matrix which is applied before display list execution.
2025-10-10 15:37:45 +02:00
Luke Wilde
adeedabf54 LibWeb: Don't class mousewheel as handled if scroll offset isn't updated
Before this change, you could only scroll the current hovered scroll
container, even if it was at the beginning or end and thus having no
effect.

Now, if it doesn't update, it will not be classed as handled and will
move onto the next scroll container.
2025-10-07 19:43:07 +02:00
Callum Law
05c336ea4e LibWeb: Use document's viewport when resolving lengths in media queries
Previously we would always use the window's viewport which was incorrect
if we were within an iframe.

This is likely applicable to all uses of
`Length::ResolutionContext::for_window`.
2025-10-07 10:32:59 +01:00
Johannes Gustafsson
d2030a5377 LibWeb: Implement Document.evaluate and related XPath methods 2025-10-03 13:16:11 +02:00
Tim Ledbetter
a00e7cb20b LibWeb: Implement <feComposite> SVG filter 2025-09-30 22:33:12 +01:00
Tomasz Strejczek
27dfaea32f LibWeb: Replace DateTime::parse with UnixDateTime::parse
Replace LibCore::DateTime::parse with UnixDateTime::parse. Add
conversion from UTC to local time zone.
2025-09-30 12:39:01 +02:00
Aliaksandr Kalenik
e07bb32455 LibJS+LibWeb: Add Object::fast_is<Element>() 2025-09-26 16:21:18 +02:00
Andreas Kling
989f6ddb42 LibWeb: Add fast_is<T> for hotly dynamic_cast'ed things on imdb.com 2025-09-25 21:42:52 +02:00
Andreas Kling
eff9989aeb LibWeb: Only update paint-only properties in affected subtrees
Before this change, we always updated paint-only properties for every
single paintable after layout or style changes.

This could get very expensive in large documents, so this patch makes
it something we can do partially based on "repaint" invalidations.

This cuts down time spent in paint-only property update when scrolling
https://imdb.com/ from 19% to 5%.
2025-09-24 23:59:41 +02:00
zac
191b026c9f LibWeb: Rename is_generated to is_generated_for_pseudo_element
While much longer, this better conveys the intent. Since this method
isn't used too often, I think the extra length is worth it.
2025-09-24 12:33:17 +01:00
Callum Law
39484e2027 LibWeb: Store font-weight in ComputedProperties in computed form
We now also more closely follow the spec when computing values for
font-weight and we now:
 - Support relative lengths in `calc()`s
 - Properly clamp `calc()`s
 - Support relative keywords (e.g. lighter, bolder)
 - Respect that font-weight can be a non-integer number.

This does expose a few false positives in the font-weight-computed.html
WPT test. This is because we don't recompute non-inherited font-weight
within `recompute_inherited_style` which means that relative keyword
values can fall out of sync with their parent's value. These previously
passed as we treated `bolder` and `lighter` as aliases for `bold` and
`normal` respectively.
2025-09-19 10:06:33 +01:00
Callum Law
b80e6a4d30 LibWeb: Rename get_inherit_value to get_non_animated_inherit_value
This more acurately represents what it does.
2025-09-19 10:06:33 +01:00
InvalidUsernameException
fbf47e57d0 LibWeb: Paint inspector overlays as a separate pass
The overlay shown for the node hovered in the inspector is painted as
part of the normal tree traversal of all paintables. This works well in
most cases, but falls short in specific scenarios:
* If the hovered node or one of its ancestors establishes a stacking
  context and there is another element that establishes a stacking
  context close by or overlapping it, the overlay and especially the
  tooltip can become partially hidden behind the second element. Ditto
  for elements that act as if they established a stacking context.
* If the hovered node or one of its ancestors involves clipping, the
  clip is applied to the overlay and espicially the tooltip. This can
  cause them to be partially invisible.
* Similarly, if the hovered node or one of its ancestors has a defined
  mask, the mask is applied to the overlay, often making it mostly
  invisible.
* No overlays are shown for SVG nodes because they are painted
  differently from HTML documents.

Some of these problems may be fixable with the current system. But some
seem like they fundamentally cannot work fully when the overlays are
painted as part of the regular tree traversal.

Instead we pull out painting the overlay as a separate pass executed
after the tree traversal. This way we ensure that the overlays are
always painted last and therefore on top of everything else. This also
makes sure that the overlays are unaffected by clips and masks. And
since overlay painting is independent from painting the actual elements,
it just works as well.

However we need to be careful, because we still need to apply some of
the steps of the tree traversal to get the correct result. Namely we
need to apply scroll offsets and transforms. To do so, we collect all
ancestors of the hovered node and apply those as if we were in the
normal tree traversal.
2025-09-19 10:17:56 +02:00
Sam Atkins
95aceb6ec9 LibWeb: Store custom properties in an OrderedHashMap
We are expected to preserve their order within a style declaration, so
let's do that. Passes 1 tracked WPT subtest.
2025-09-18 14:59:14 +02:00
Timothy Flynn
2674bd428e LibWeb: Implement up/down arrow navigation for EditingHostManager 2025-09-18 07:39:10 -04:00
Jelle Raaijmakers
c31eff6a47 Everywhere: Use Optional<T>::ensure() where useful
No functional changes.
2025-09-17 12:01:18 -04:00
Jelle Raaijmakers
e6474778c6 LibWeb: Some text-related cleanup
No functional changes.
2025-09-12 15:34:09 -04:00
Jelle Raaijmakers
12cec1bdb3 LibWeb: Clean up Range::to_string()
No functional changes.
2025-09-12 15:34:09 -04:00
Sam Atkins
fa790e5095 LibWeb/CSS: Take AbstractElement in for_each_matching_rules() 2025-09-11 18:45:35 +02:00
Sam Atkins
0293176429 LibWeb/CSS: Take AbstractElement in StyleComputer::get_*_inherit_value() 2025-09-11 18:45:35 +02:00
Sam Atkins
64c3319147 LibWeb/CSS: Take AbstractElement in font computation methods 2025-09-11 18:45:35 +02:00
Sam Atkins
263c51f6ac LibWeb/CSS: Take AbstractElement in compute_pe_style_if_needed() 2025-09-11 18:45:35 +02:00
Sam Atkins
d0b6fadb6d LibWeb/DOM: Add CascadedProperties accessors to AbstractElement 2025-09-11 18:45:35 +02:00
Sam Atkins
27aab90e66 LibWeb: Take AbstractElement in StyleComputer::compute_style() 2025-09-11 18:45:35 +02:00
Sam Atkins
40ab71e41e LibWeb/DOM: Expose AbstractElement outside of LibWeb
This ends up used by the WebContent service's ConnectionFromClient in a
later commit.
2025-09-11 18:45:35 +02:00
Sam Atkins
583d74e3a9 LibWeb/DOM: Reduce AbstractElement.h's includes
This doesn't need all of Selector.h and its various includes, it just
needs the PseudoElement enum.

StringStyleValue.h was transitively including ComponentValue.h through
this, so it now includes it directly.
2025-09-11 18:45:35 +02:00
Psychpsyo
c04f83f5f4 LibWeb: Add view transition related user relevancy 2025-09-10 17:37:41 +01:00
Feng Yu
66d18170c6 LibWeb: Add activeElement attribute in ShadowRoot 2025-09-10 16:52:39 +01:00
Psychpsyo
fa3c45d0b4 LibWeb: Implement optional function IDL arguments
This allows us to run some more view transitions WPT tests, one of
which has been imported.
2025-09-10 09:49:14 -04:00
Psychpsyo
17e5289524 LibWeb: Suppress rendering due to view transitions
This also fixes a bug in the view transitions code that was
required to get the imported test to pass. The code for setting
the initial containing block size just did not set the right thing,
since doing so would trigger an error later on.

That later error resulted from walking up the tree, without
considering that the document element has a parent that is not
itself an element. (and then doing element things to it)
2025-09-09 10:25:17 +02:00
Psychpsyo
56739b4b16 LibWeb: Implement plumbing for view transitions
This implements large parts of the CSS view-transitions-1 spec.
2025-09-07 13:58:05 +01:00
euro20179
e442aa6e10 LibWeb: Ensure parser cannot change the mode is handled
This fixes at least 1 wpt bug where text/plain documents are rendered in
quirks mode. The test in question: https://wpt.live/html/browsers/browsing-the-web/read-text/load-text-plain.html
2025-09-07 11:11:43 +01:00
Aliaksandr Kalenik
e095bf3a5f LibWeb: Rewrite "destroy a document and descendants" without spin until
Replaces spin until with GC-allocated counting object that invokes
destruction callback once all child navigable documents are destroyed.

The change doesn't have a test but not using spin until is strictly
better than using it. Also improves https://www.rottentomatoes.com/
where previously we would hang or crash after loading.
2025-09-04 15:53:46 +02:00
Jelle Raaijmakers
8986e1f1ec LibWeb: Merge nested editing hosts
If a node with `contenteditable=true/plaintextonly` is the child of an
editable node or an editing host, we should make it editable instead of
an editing host. This effectively merges nested editing hosts together,
which is how other browsers deal with this as well.

Gains us 5 WPT subtest passes in `editing`.
2025-09-04 00:24:55 +02:00
Jelle Raaijmakers
3931c0336b LibWeb: Clean up some editing-related code
No functional changes.
2025-09-04 00:24:55 +02:00
Luke Wilde
74e0483ea5 LibWeb: Implement the Gamepad API with SDL3 2025-09-01 21:10:47 +02:00
Tete17
2083708897 LibWeb: Enumerate all injection sinks relevant to the TrustedTypes spec
This enables us to more strictly control the available sinks we support.
2025-09-01 16:19:24 +01:00
Idan Horowitz
849ade88ce LibWeb: Fire change events on deletion in FormAssociated Text Elements
Previously we would only trigger change events on insertion, which
resulted in javascript code missing changes due to deletion.

This makes the calculator on the MDN simple web worker demo update on
deletion as well.
2025-08-31 01:47:52 +02:00
Luke Wilde
b17783bb10 Everywhere: Change west consts caught by clang-format-21 to east consts 2025-08-29 18:18:55 +01:00
Tim Ledbetter
d4f05bc4ef LibWeb: Implement <feImage> SVG filter 2025-08-29 10:15:24 +01:00
Tim Ledbetter
b23fd1f440 LibWeb: Update layout when view box properties are changed 2025-08-28 15:42:56 +02:00
Callum Law
f9e5332d16 LibWeb: Initial work to store ComputedProperties in computed form
`StyleValue`s stored within `ComputedProperties` should be in their
computed forms, this is for various reasons including:
 - Inheritance should be of computed values
 - Animations should work on computed values
 - Triggering transitions should work on computed values

Currently we store `StyleValue`s in an absolutized version of the
specified value - this is equivalent to the computed form in many cases
which is why this hasn't been causing significant issues but there are
some cases - such as `border-*-width` keywords where this is not the
case.

No functionality change as we are yet to implement any properties
2025-08-28 09:29:46 +01:00
stelar7
d65f599f92 LibWeb/EME: Add EncryptedMedia allowed allowed feature flag 2025-08-27 09:58:00 +02:00
Jelle Raaijmakers
84c4eb7aa9 LibWeb: Always update computed properties for finished animations
If an animation got to its finished state before its target's computed
properties could be updated, we would end up with invalid styles. Do not
skip finished animations, but prevent effect invalidation on timeline
updates if the animation is already finished.

This fixes the CI flake on WPT test
`css/css-transitions/inherit-height-transition.html`.
2025-08-26 18:47:57 +02:00
Callum Law
912ffc3f84 LibWeb: Remove unnecessary ComputedProperties::maybe_null_property
We know that all (longhand) properties have a value so this is
unnecessary.
2025-08-26 12:17:55 +02:00
Callum Law
1a3da3d825 LibWeb: Don't store separate computed value for font_size
The StyleValue stored in m_property_values is already in it's computed
form and it's trivial to pull the underlying value out so there is no
need to store this separately.

Also removes unnecessary handling of percentage values in
`absolutize_values` - this is already handled within `compute_font`.
2025-08-26 12:17:55 +02:00
Callum Law
487d0abd7c LibWeb: Only consider longhands when recomputing inherited style
Only longhands have computed values so checking shorthand values is
unnecessary
2025-08-26 12:17:55 +02:00