Commit graph

3229 commits

Author SHA1 Message Date
Sam Atkins
070c4a2045 LibWeb: Implement text-align: match-parent
At computed-value time, this is converted to whatever the parent's
computed value is. So it behaves a little like `inherit`, except that
an inherited start/end value uses the parent's start/end, which might
be different from the child's.
2025-02-05 17:45:44 +00:00
Andreas Kling
4f855286d7 LibWeb: Clamp layout content sizes to a max value instead of crashing
We've historically asserted that no "saturated" size values end up as
final metrics for boxes in layout. This always had a chance of producing
false positives, since you can trivially create extremely large boxes
with CSS.

The reason we had those assertions was to catch bugs in our own engine
code where we'd incorrectly end up with non-finite values in layout
algorithms. At this point, we've found and fixed all known bugs of that
nature, and what remains are a bunch of false positives on pages that
create very large scrollable areas, iframes etc.

So, let's change it! We now clamp content width and height of boxes to
17895700 pixels, apparently the same cap as Firefox uses.

There's also the issue of calc() being able to produce non-finite
values. Note that we don't clamp the result of calc() directly, but
instead just clamp values when assigning them to content sizes.

Fixes #645.
Fixes #1236.
Fixes #1249.
Fixes #1908.
Fixes #3057.
2025-02-05 18:28:55 +01:00
Aliaksandr Kalenik
da579e11b0 LibWeb: Start implementing render-blocking mechanism from HTML spec
This change implements enough spec steps to block rendering until
execution of sync scripts inserted from HTML parser is complete.
2025-02-05 18:28:46 +01:00
Sam Atkins
75168fa4d6 LibWeb/CSS: Remove redundant CSS:: namespaces from ComputedProperties
We're already in the CSS namespace, so let's remove the clutter.
2025-02-05 18:12:36 +01:00
Sam Atkins
4cb2063577 LibWeb/CSS: Stop returning Optional for enum properties
While keyword_to_foo() does return Optional<Foo>, in practice the
invalid keywords get rejected at parse-time, so we don't have to worry
about them here. This simplifies the user code quite a bit.
2025-02-05 18:12:36 +01:00
Luke Wilde
d3057a9c79 LibWeb: Preserve opening quotation in string token original source text
Used by chess.com, where it stores URLs to assets in CSS URL variables.
It then receives the value of them with getComputedStyle() and then
getPropertyValue(). With this, it trims off the url('') wrapper with a
simple slice(5, -2). Since we didn't preserve the opening quotation, it
would slice off the `h` in `https` instead of the quotation.
2025-02-05 16:02:09 +00:00
Aliaksandr Kalenik
a5e4a51b52 LibWeb: Change animation to schedule repaint only when necessary
Animation should trigger repaint only if it's required by animated style
update.
2025-02-05 14:34:41 +01:00
Jelle Raaijmakers
d94906fa1a LibWeb: Only apply style for continuation nodes once
This fixes the very, _very_ slow loading of https://yzy-sply.com. The
`apply_style()` method also calls into this method recursively, so we
just need to call it once instead of once per node in the continuation
chain.
2025-02-05 14:34:21 +01:00
Jelle Raaijmakers
cd4aca57c4 LibWeb: Use as_if<> in style propagation for continuation nodes
No functional changes.
2025-02-05 14:34:21 +01:00
Psychpsyo
bad7324307 LibWeb: Implement CSS validity pseudo-classes 2025-02-05 12:38:55 +00:00
Timothy Flynn
0a46b5cbb1 LibWeb: Check for closed browsing contexts before dispatching actions
See: https://github.com/w3c/webdriver/commit/0ac18fa
2025-02-05 11:33:33 +00:00
Timothy Flynn
28fb30b22f LibWeb: Move AO to check if a browsing context is open to a helper file
This will be needed outside of WebDriverConnection.cpp.
2025-02-05 11:33:33 +00:00
Glenn Skrzypczak
0fe30886f5 LibWeb/CSS: Implement mix-blend-mode
This adds support for the `mix-blend-mode` CSS property.
2025-02-05 11:26:58 +00:00
Glenn Skrzypczak
8575bddfe6 LibWeb/Canvas: Support globalCompositionOperation
Canvas now supports compositing and various blending modes via the
`globalCompositeOperation` attribute.
2025-02-05 11:26:58 +00:00
Andreas Kling
b8537f760d Revert "LibWeb: Make "assign slottables for a tree" fast when there are no slots"
This reverts commit adc25af8e2.

This caused images to stop loading on https://reddit.com/ and needs
more investigation.
2025-02-04 22:19:25 +01:00
Tim Ledbetter
67c950b002 LibWeb: Update create_element() to follow the latest specification 2025-02-04 20:07:32 +00:00
Tim Ledbetter
08c68cf699 LibWeb: Set is value when creating a customized built-in element 2025-02-04 20:07:32 +00:00
Tim Ledbetter
70097a7141 LibWeb: Add missing elements to valid local name map
Previously, attempting to create a custom element that extended any of
these elements would fail.
2025-02-04 20:07:32 +00:00
Sam Atkins
6d0fcb8f9a LibWeb/SVG: Rename text-space-collapse to white-space-collapse
This is the current name for this property in CSS-Text-4. We don't
implement it, but at least our "missing property" message can be about
one we haven't implemented instead of one that's redundant. :^)
2025-02-04 12:25:08 +01:00
Sam Atkins
26b7946123 LibWeb: Add NavigateEvent.sourceElement
Corresponds to:
- https://github.com/whatwg/html/pull/10898
- https://github.com/whatwg/html/pull/10971

I've also updated the imported WPT test as it's been recently changed to
account for 10898 being merged.
2025-02-04 12:24:50 +01:00
Luke Warlow
62f4cebbee LibWeb: Fix dialog.requestClose() crash
The spec previously asserted that close watcher was not null.

This could lead to a crash in some situations,
so instead we skip to close the dialog.
2025-02-04 12:22:25 +01:00
Felipe Muñoz Mazur
f6c4304e89 LibWeb: Check if event is not "beforeunload" before cancelling 2025-02-03 19:17:58 +00:00
Aliaksandr Kalenik
f5ba22d3e8 LibWeb/DOM: Don't use recursion for subtree traversal in Node.h
This change is mainly motivated by the fact that iterating in a loop
makes profiles easier to read and understand where time was spent in
traversal callback. Additionally, using a loop reduces function call
overhead and ensures constant stack usage.
2025-02-03 18:36:57 +01:00
Aliaksandr Kalenik
dfcee2bbdf LibWeb/DOM: Inherit Node from TreeNode
This allows to delete lots of tree helper functions duplicated between
Node and TreeNode.
2025-02-03 18:36:57 +01:00
Aliaksandr Kalenik
ec6201806f LibWeb: Delete tree treversal methods defined in Paintable.h
Those are duplicates of ones inherited from TreeNode.
2025-02-03 18:36:57 +01:00
Jelle Raaijmakers
314f4ff0da LibWeb: Prevent double page title update in DOM::Document
This ad-hoc code informs the client of a potentially changed page title.
But because we always update the title element (either the SVG or HTML
title) the client was already informed, causing the code to run twice.
2025-02-03 18:34:22 +01:00
Mehran Kamal
cfe6702767 LibWeb/CSS: Fix linear-gradient single color-stop usage
The Web::CSS::Parser's GradientParsing ignores color-stops if
it is only a single one. This change allows to have color-stops
with double positions against a single color.

Further, also allows for `linear-gradient(black)` and similar
other gradient functions
2025-02-03 17:24:10 +00:00
Andreas Kling
4fa372564d LibWeb: Support both ::before/::after pseudo elements on button elements
This was mainly a matter of deferring the wrapping of the button's
children until after its internal layout tree has been constructed.
That way we don't lose any pseudo elements spawned along the way.

Fixes #2397.
Fixes #2399.
2025-02-03 15:59:38 +01:00
Aliaksandr Kalenik
0f17ad9ebc LibWeb: Use fast CSS selector matching in default matches() code path
Before this change, checking if fast selector matching could be used was
only enabled in style recalculation and hover invalidation. With this
change it's enabled for all callers of SelectorEngine::matches() by
default. This way APIs like `Element.matches()` and `querySelector()`
could take advantage of this optimization.
2025-02-03 10:28:08 +01:00
Tim Ledbetter
6d7b7e7822 LibWeb: Use as to cast global object to WindowOrWorkerGlobalScopeMixin
No functional changes.
2025-02-02 17:18:56 +01:00
Sam Atkins
3794665b0b LibWeb/DOM: Add spec steps for WebDriver BiDi to document history algo
This is "update document for history step application" but that's too
long for the commit title. :^)

No code changes, just adding more FIXME comments for the new steps.
(And indented step 7's substeps for clarity.)

Corresponds to https://github.com/whatwg/html/pull/10910
2025-02-01 23:32:39 +01:00
Aliaksandr Kalenik
0c5b61b7e1 LibWeb: Fix infinite repaint loop when cached display list is used
Before this change, `m_needs_repaint` was reset in
`Document::record_display_list()` only when the cached display list was
absent. This meant that if the last triggered repaint used the cached
display list, we would keep repainting indefinitely until the display
list was invalidated (We schedule a task that checks if repainting is
required 60/s).

This change also moves `m_needs_repaint` from Document to
TraversableNavigable as we only ever need to repaint a document that
belongs to traversable.
2025-02-01 23:31:16 +01:00
Aliaksandr Kalenik
0cfe90b59e LibWeb: Don't allow "display: none" start CSS animations
This is both a correctness fix and a performance optimization.
2025-02-01 13:42:00 +01:00
Gingeh
93f9ed72d2 LibWeb/SVG: Skip unwanted transformations on clip-path 2025-02-01 13:38:56 +01:00
Gingeh
3f8d4c2c92 LibWeb/SVG: Make SVGClipPathElement inherit from SVGGraphicsElement 2025-02-01 13:38:56 +01:00
Gingeh
59ba2fb2ee LibWeb: Clear stylesheet pointer when disabling link element
This fixes a crash when enabling an already disabled link element.
Fixes a crash when changing mdbook themes.
2025-02-01 08:11:37 +00:00
Sam Atkins
1bd73184da LibWeb/HTML: Update get_an_elements_noopener() to current spec
Note that this preemptively includes this fix to step 3:
https://github.com/whatwg/html/pull/10962
2025-01-31 17:27:03 +00:00
Sam Atkins
6bc38832af LibWeb/HTML: Update follow_the_hyperlink() to current spec 2025-01-31 17:27:03 +00:00
Sam Atkins
7fcd8df49b LibWeb/HTML: Update submit_form() to current spec 2025-01-31 17:27:03 +00:00
Sam Atkins
9254994687 LibWeb/HTML: Update get_an_elements_target() to current spec 2025-01-31 17:27:03 +00:00
Tim Ledbetter
8dfd382e12 LibWeb: Use as_if instead of dynamic_cast in a few places 2025-01-31 14:29:48 +01:00
Sam Atkins
6ebe19d13b LibWeb/CSS: Correct "percentages-resolve-to" data for properties
These were missing for properties that take a `<position>`, and were
incorrectly present for opacity-related properties.
2025-01-31 14:24:39 +01:00
Sam Atkins
d15e1eb9f6 LibWeb/CSS: Don't multiply non-canonical dimensions in calc()
This fixes the layout of tweakers.net, which regressed when calc
simplification was added in ee712bd98f.
2025-01-31 14:24:39 +01:00
Luke Wilde
6701aaf1cd LibWeb/CSS: Make inline-size a logical alias for the height property 2025-01-31 14:18:21 +01:00
Luke Wilde
010cdd8f90 LibWeb/CSS: Implement the ({min,max}-)block-size properties
These are heavily used by morrisons.com, using them in place of the
usual properties these map to.
2025-01-31 14:18:21 +01:00
Jelle Raaijmakers
f204970052 LibWeb: Ignore fragments with pointer-events: none in hit-testing 2025-01-31 13:37:15 +01:00
Jelle Raaijmakers
e7add9abc6 LibWeb: Remove unnecessary const_casts from TextPaintable 2025-01-31 13:37:15 +01:00
Jelle Raaijmakers
cbe78454fc LibWeb: Remove unused includes from PaintableFragment 2025-01-31 13:37:15 +01:00
Jelle Raaijmakers
342cb7addf LibGfx+LibWeb: Reuse DisplayListPlayer and PaintingSurface when possible
Previously, we were reinstantiating the DisplayListPlayer and
PaintingSurface on every paint.
2025-01-31 13:28:09 +01:00
Jelle Raaijmakers
7b3d4a9edb LibWeb: Cache Skia backend context in TraversableNavigable
We just need to create the backend context once and let Skia handle the
context's state.

On my machine, this reduces the load time for https://tweakers.net from
7.5s to 3.5s.
2025-01-31 13:28:09 +01:00