1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 05:27:14 +09:00
Commit graph

3706 commits

Author SHA1 Message Date
Andreas Kling
3e1ee37c6a LibWeb: Don't claim that inline layout nodes can contain abspos elements
We assume elsewhere that any abspos element's containing block must be
some kind of Layout::Box, so let's enforce that when deciding if a box
can be such a container.

This fixes a bad downcast on https://serpapi.com/
2025-06-07 16:51:07 +02:00
Sam Atkins
ea33bdc975 LibWeb: Move non-DOM-related methods from DOM::Node to TreeNode
Motivated by wanting to do `is_before()` on a Layout::Node, and thought
I might as well move as many as possible while I was at it.
2025-06-07 16:51:00 +02:00
Gingeh
9ef9f8d38f LibWeb: Implement the request-close command
See: https://github.com/whatwg/html/pull/11045
2025-06-07 04:06:01 +01:00
Gingeh
fc35229dab LibWeb: Implement the ToggleEvent.source attribute
See: https://github.com/whatwg/html/pull/11186
2025-06-07 04:06:01 +01:00
Aliaksandr Kalenik
859991ca7b LibWeb: Skip painter allocation for a navigable created for SVG
Traversable navigable created for rendering svg element doesn't perform
any actual rendering, so there is no need to allocate a painter for it.
2025-06-06 03:56:57 +02:00
Aliaksandr Kalenik
ed1337add1 LibJS: Don't start rendering thread for a navigable created for SVG
Traversable navigable created for rendering svg element doesn't perform
any actual rendering, so there is no need to spawn a rendering thread.
2025-06-06 03:56:57 +02:00
Aliaksandr Kalenik
39fff3cf8a LibWeb: Don't early return when masking area of StackingContext is empty
An early return was occurring between the emission of
PushStackingContext and PopStackingContext, resulting in a
PushStackingContext without a corresponding PopStackingContext in the
display list, which caused broken painting.

Fixes black screen on Discord login page.
2025-06-06 00:52:19 +02:00
Aliaksandr Kalenik
7efdd1c1ec LibWeb: Stub CacheStorage interface
With this change we can again open login form https://discord.com/login
instead of failing in js because `caches.open()` is not defined.
2025-06-05 23:02:21 +02:00
InvalidUsernameException
1d0cfdc839 LibWeb: Consider margins during fit-content sizing in BFC
`BlockFormattingContext::compute_width()` stores the left and right
margins in the layout state at the very end of the function. However,
before doing so, it calls `FormattingContext::calculate_inner_width()`
which ends up calling `FormattingContext::calculate_stretch_fit_width()`
if the current box has `width: fit-content`.

Due to this, `calculate_stretch_fit_width()` would always see the
margins from the layout state as zero and therefore not take them into
account. Subsequently, the calculated width ended up being wrong.

Saving margins on the layout state earlier, before calling
`calculate_inner_width()`, makes sure that the width is calculated
correctly.
2025-06-05 17:56:19 +02:00
stelar7
7f2362643c LibWeb: Use a BFC for MathML
While this is not correct, it makes MathML text render atleast
2025-06-05 12:37:52 +01:00
Sam Atkins
5a1c73d7e2 LibGfx+LibWeb: Update definitions of supported font formats and features
Based very scientifically on what's listed here:
https://harfbuzz.github.io/what-does-harfbuzz-do.html

I've moved the code into LibGfx because including a HarfBuzz header
directly from LibWeb is a little unpleasant. But the Gfx::FontTech enum
follows the CSS definitions for font features for simplicity.

TrueType collections are supported. SVG and Embedded OpenType are not,
but they're not widely supported by other browsers so that's fine.

Most of the features are completely supported by HarfBuzz, so we can
just return true. Graphite support is optional (and it appears we use a
build of HarfBuzz without it) but there's a define we can check.
Incremental Font Transfer is a whole separate thing that we definitely
don't support yet.
2025-06-05 12:10:29 +01:00
Sam Atkins
ea101c6336 LibWeb/CSS: Limit string values for font format() to the spec's set
A couple of differences from before:
- Only the fixed set of strings are allowed. Some formats can only be an
  ident (eg, svg).
- We don't allow these foo-variations values in ident form.
- The comparison is done case-insensitively. It's unclear if this is
  more or less correct, but as most things in CSS are insensitive,
  including idents, it makes sense that these would be too.
2025-06-05 12:10:29 +01:00
Sam Atkins
d611806f18 LibWeb/CSS: Parse and use tech() in @font-face { src } 2025-06-05 12:10:29 +01:00
Sam Atkins
5b42f8d707 LibWeb/HTML: Compare paragraph align="" values insensitively
This is the one place we weren't comparing align keywords insensitively.
2025-06-05 12:10:17 +01:00
Sam Atkins
6f4df83917 LibWeb: Always compare attribute names directly
Attributes are already stored with their names in lowercase, so we can
do a direct comparison instead of a case-insensitive one.
2025-06-05 12:10:17 +01:00
Sam Atkins
bc8a97589f LibWeb/SVG: Add stop-color and stop-opacity to AttributeNames 2025-06-05 12:10:17 +01:00
Callum Law
670c247937 LibWeb: Resolve FIXME around shorthand properties in remove_property()
This exposes some false-positive sub-tests in the font-computed.html
test which are now correctly marked as failed.
2025-06-04 16:34:31 +01:00
Ruben
88da6250f9 LibWeb: Use the correct definition of separated-borders mode
We previously checked the cell's computed values for the border-collapse
property, but a cell is only in separated-borders mode if the table has
border-collapse set to separate. Curiously in some other placed where
this mode is checked we already did the correct thing.
2025-06-04 15:02:42 +01:00
Callum Law
50cce72ab9 LibWeb: Implement text-wrap CSS property
This resolves an issue introduced in 94f5a51 with the
tab-size-text-wrap test
2025-06-04 12:48:36 +01:00
Callum Law
9ba74316d2 LibWeb: Implement text-wrap-style CSS property 2025-06-04 12:48:36 +01:00
Timothy Flynn
7d99a92135 LibWeb: Absolutize CSS image URLs for computed style resolution
For getComputedStyle(), we must return an absolute URL for image style
values. We currently return the raw parsed URL.

This fixes loading the marker icons on https://usermap.serenityos.org.
2025-06-03 19:30:43 -04:00
Timothy Flynn
3ae2220534 LibWeb: Add missing FlyString include to CSS/URL.h
clangd is complaining about this.
2025-06-03 19:30:43 -04:00
Andreas Kling
6dba720370 LibWeb: Invalidate layout tree at nearest non-anonymous ancestor
When marking a part of the layout tree for rebuild, if the subtree root
that we're marking has an anonymous parent, we now mark from the nearest
non-anonymous ancestor instead.

This ensures that subtrees inside anonymous wrappers don't just get
duplicated (i.e recreated but inserted instead of replaced).
2025-06-04 00:43:23 +02:00
aplefull
3781c132aa LibWeb: Fix grid item placement when only grid-column-end is specified 2025-06-03 22:22:24 +02:00
Rocco Corsi
4b3dccd0f2 LibWeb: Remove Unicode Cyrillic e char (04+35) in variable name
Static analysis tool cppcheck reports that
LibWeb/Internals/Internals.cpp:65 has a variable named
hit_tеsting_result with a Cyrillic e in the 'testing' portion of the
name, instead of the more common ASCII e. No other use of Unicode
characters for identifiers in the Ladybird code base noted by cppcheck,
so assuming that this is unintended use.
2025-06-03 21:22:27 +02:00
Manuel Zahariev
99c6eb0c35 LibWeb/CSS: Invalidate layout tree for changes to counter definitions
A change to a counter "definition" propagates to all subsequent
instances of this counter: descendents, siblings and their descendents
(the "next tree slice"). Rebuilding the layout tree (from the parent
node) covers at least the "next_tree_slice".
2025-06-03 03:51:42 +02:00
Saksham Mittal
c52c05555b LibWeb: Don't place cursor on certain <input> elements
For example, button inputs shouldn't have a cursor
displayed in their text since they're not editable,
and are not meant to be editable.

Fixes #4140

Co-authored-by: Sam Atkins <sam@ladybird.org>
2025-06-02 11:38:38 +01:00
Tim Ledbetter
17f14a277b LibWeb: Don't crash when interpolating single-value repeatable lists
Previously, when interpolating a repeatable list from a list with
multiple values to a single value, we would crash.
2025-06-02 11:33:01 +01:00
Tim Ledbetter
e2d0d8e2b9 LibWeb/CSS: Implement the scrollbar-color property
This allows the user to set the scrollbar thumb and track colors.
2025-06-02 00:17:51 +02:00
Lucien Fiorini
0fcb574041 LibGfx+LibWeb: Turn Gfx::Filter into a SkImageFilter wrapper 2025-06-01 23:22:10 +02:00
Aliaksandr Kalenik
4b4d960cba LibWeb: Cancel previous animation if new animation-name is "none"
"none" value should be interpreted as "no animation" to trigger the path
that cancels previous animation if it exists.
2025-06-01 05:02:12 +02:00
Shannon Booth
bc4317be20 LibWeb/HTML: Handle failure determining mime type fetching module script
Fixes crash in WPT test:

https://wpt.live/html/semantics/scripting-1/the-script-element/css-module/content-type-checking.html
2025-05-31 09:15:52 -04:00
Shannon Booth
caf959f06c LibWeb/FileAPI: Handle an aborted stream in Blob::get_stream() close
The streams AO that we were calling to close the stream would assert
if it was not in a readable state. This version of close is exported
publicly in the streams specification, and properly handles this
situation.

Fixes a crash in the imported test, and happens to fix some others!
2025-05-31 09:12:57 -04:00
Andrew Kaster
0f81f021ce LibWeb: Clean up main thread promise when exiting RenderingThreads
Not cleaning these up by rejecting or resolving the promise causes
the main thread to try to reject them at EventLoop::exit() time.

If the RenderThread has already been destroyed by then, we get into
use-after-free territory and segfault.
2025-05-30 16:18:23 +02:00
Aliaksandr Kalenik
3178679f0b LibWeb: Implement CSS transitions support for pseudo elements
We already had all necessary things for pseudo elements support in place
except ability to save transition properties in Animatable. This commit
adds the missing part.
2025-05-30 15:48:16 +02:00
Andreas Kling
61285ffbee LibWeb: Add document null check in ...navigable_target_name_property_set 2025-05-30 10:13:25 +02:00
Andreas Kling
2eea8894a1 LibWeb: Don't crash on named property access on detached window
In WindowProxy.[[Get]] it's not guaranteed that the current principal
global object has an associated document at the moment. This may happen
if a script is continuing to execute while a navigation has been
initiated.

Because of that, we can't blindly dereference the active document
pointer, so this patch adds a null check.
2025-05-30 10:13:25 +02:00
InvalidUsernameException
164afdcc59 LibWeb: Ensure scroll offset is applied to mask-images
When recording the display list for a stacking context, the following
operations (relevant to this bug) happened:
* push a stacking context
  * as part of that push a None-value to the scroll frame id stack
* apply filters
* apply masking
* paint recursively

This meant that mask-images were always recorded without scroll frame
id, causing them to be painted without any scroll offset. As a result
mask-images would break as soon as the website using them was scrolled.

Instead, push to the scroll frame id stack later to solve the problem:
* push a stacking context
* apply filters
* apply masking
* push a None-value to the scroll frame id stack
* paint recursively
2025-05-29 22:02:07 +02:00
Callum Law
ed65d5b342 LibWeb: Serialize CSS declarations as shorthands where applicable
When serializing CSS declarations we now support combining multiple
properties into a single shorthand property in some cases.

This comes with a healthy dose of FIXMEs, including work to be done
around supporting:
 - Nested shorthands (e.g. background, border, etc)
 - Shorthands which aren't represented by the ShorthandStyleValue type
 - Subproperties pending substitution

This gains us a bunch of new test passes, both for WPT and in-tree
2025-05-29 12:04:28 +02:00
Callum Law
94f5a51820 LibWeb: Convert white-space CSS property to shorthand
This exposed a few bugs which caused the following tests to behave
incorrectly:
- `tab-size-text-wrap.html`: This previously relied on a bug where we
  incorrectly treated `white-space: pre` as allowing text wrapping. The
  fix here is to implement the text-wrap CSS shorthand property.

- `execCommand-preserveWhitespace.html`: We don't correctly serialize
  shorthand properties. This is covered by an existing FIXME in
  `CSSStyleProperties::serialized()`

- `white-space-shorthand.html`: The last 5 subtests here fail as we
  don't correctly handle shorthand properties in
  `CSSStyleProperties::remove_property()`. This is covered by an
  existing FIXME in said function.
2025-05-29 12:04:28 +02:00
Callum Law
9d06c86fe4 LibWeb: Support shorthands as relevant_css_property for editing commands 2025-05-29 12:04:28 +02:00
Callum Law
45689936f2 LibWeb: Support shorthand properties as presentational hints 2025-05-29 12:04:28 +02:00
Callum Law
9480b1fc5c LibWeb: Parse and propagate white-space-trim CSS property 2025-05-29 12:04:28 +02:00
Callum Law
50bdd2cb85 LibWeb: Parse and propagate text-wrap-mode CSS property 2025-05-29 12:04:28 +02:00
Callum Law
ea30356fba LibWeb: Parse and propagate white-space-collapse CSS property 2025-05-29 12:04:28 +02:00
Andreas Kling
00ad2bd758 LibWeb: Use the GC::RootVector deduction guides where helpful 2025-05-29 03:46:49 +02:00
Andreas Kling
5c5283492b LibWeb: Iterate safely in HTMLSelectElement::set_value()
We can't iterate over m_cached_list_of_options and call set_selected()
in the loop, since that may end up rebuilding m_cached_list_of_options,
disrupting iteration.
2025-05-29 03:46:49 +02:00
Andreas Kling
18d17385fb LibWeb: Remove leftover debugging hack in process_top_layer_removals() 2025-05-29 03:46:49 +02:00
Andreas Kling
2afe208328 LibWeb: Iterate safely in process_top_layer_removals()
We should not remove from a container while iterating over it, since
that may disrupt iteration.
2025-05-29 03:46:49 +02:00
Andreas Kling
59d46af946 LibWeb: Iterate safely in update_animations_and_send_events()
Make copies of the animation timeline list and animations to dispatch
events at before iterating over them. This ensures that they can't be
modified during iteration.
2025-05-29 03:46:49 +02:00