Commit Graph

72303 Commits

Author SHA1 Message Date
Tim Ledbetter
7db73118e9 LibWeb+LibGfx: Draw shadows for stroke joins and caps 2025-10-21 18:55:08 +02:00
Tim Ledbetter
0f295e8989 LibWeb: Take transforms into account when drawing shadows 2025-10-21 18:55:08 +02:00
Tim Ledbetter
0516c414d4 LibWeb: Don't draw shadows for transparent gradient fills 2025-10-21 18:55:08 +02:00
Tim Ledbetter
13f551612c LibWeb: Don't draw shadows if shadow offset and blur are not set 2025-10-21 18:55:08 +02:00
Tim Ledbetter
eb44cca5bd LibWeb: Ignore non-finite shadow offset values 2025-10-21 18:55:08 +02:00
Tim Ledbetter
b99c0c6a7f LibWeb: Account for paint style and global alpha when drawing shadows 2025-10-21 18:55:08 +02:00
Ali Mohammad Pur
553a7a9278 AK: Remove unused and unintuitive Trait for char*
We don't use char* in containers, and the expectation would be a pointer
compare instead of a string compare; so remove this specialisation
entirely.
2025-10-21 18:20:48 +02:00
Tim Ledbetter
494fcc40ac LibWeb: Account for transforms in isPointInPath() 2025-10-21 17:42:28 +02:00
Andreas Kling
d17f666a8c LibWeb: Better CSS inheritance for nodes that represent a pseudo-element
When we compute style for elements inside a UA-internal shadow tree that
represent a pseudo-element (e.g ::placeholder), we actually run the
StyleComputer machinery for (host element :: pseudo-element).

While that lets us match the correct selectors, it was incorrectly
applying CSS inheritance, since we'd also then inherit from whatever was
above the host element in the tree.

This patch fixes the issue by introducing an inheritance override in
AbstractElement and then using that to force inheritance from whatever
is actually directly above in the DOM for these elements instead of
jumping all the way up past the host.

This fixes an issue where `text-align: center` on input type=text
elements would render the main text centered but placeholder text was
still left-aligned.
2025-10-21 16:42:00 +02:00
Andreas Kling
9e064bd3ff LibWeb: Make input type=text placeholder render as a block-level element
This will make the width: 100% we already apply actually do something
useful to the placeholders.
2025-10-21 16:42:00 +02:00
R-Goc
e8a9d23f92 CSS: Use i64 in StepsEasingFunction
Unbreaks Windows build. resolve_integer returns an i64 making creation
of a StepsEasingFunction with its result a narrowing conversion before
this change as a long is 32 bits on Windows.
2025-10-21 14:51:47 +02:00
Psychpsyo
80b629578e LibWeb: Fix partially selecting non-text nodes
Steps 4 and 5 were swapped since marking all the nodes between the start
and end of the selection now also marks the end node as full, even if it
should be marked as End.
There could be extra logic to avoid marking it if it is a text node, but
this seems easier.

As a whole, this fixes partially selected non-text nodes. In such cases,
where the selection starts or ends inside a node with descendants, it is
impossible to just select from the start node to the end node since that
would select all descendants of the start node and none of the end node.
Previously, this was only half considered and only if the start node was
a descendant of the end node.
2025-10-21 10:23:10 +01:00
Luke Wilde
66a36050bd LibWeb/WebGL: Use surfaceless contexts when making a context current
After we bind the surface to the context for the first time when
allocating the backing image, it internally has a permanent reference
count above 0.

If we switch to a different context and back, the switch back will fail
because the surface has a reference count, which makes ANGLE think
we're trying to use it on a different thread.

However, we can avoid this by using surfaceless contexts, since we
don't use the default framebuffer.

Fixes multiple WebGL contexts on the page freezing.
2025-10-21 09:59:59 +02:00
Tim Ledbetter
d3ca038b2c LibWeb: Ensure putImageData() is unaffected by drawing state 2025-10-21 09:52:16 +02:00
Tim Ledbetter
2ac4544a81 LibWeb: Align CanvasRenderingContext2D::putImageData() with the spec
This change implements `putImageData()` with `dirtyX`, `dirtyY`,
`dirtyWidth` and `dirtyHeight` arguments.
2025-10-21 09:52:16 +02:00
Aliaksandr Kalenik
509c86dca0 LibIPC: Simplify IPC read hook
- Return `PeerEOF` enum instead of `Error` containing string from
  `drain_messages_from_peer()`. There are no other error types to return
  from this function, so boolean-like enum is sufficient.
- Don't override read hook in `ConnectionFromClient` constructor. It was
  previously redefined only to suppress EOF error returned by
  `drain_messages_from_peer()`.
2025-10-21 09:31:22 +02:00
Rocco Corsi
edb60e38bd LibWeb: Update painting backing stores in all cases
To consistently update the backing stores in reallocate_backing_stores()
the variables storing the backing stores need to be set to nullptr at
the start so that they are properly update later on near the end of the
function.
2025-10-21 09:17:53 +02:00
Callum Law
2404f95e03 LibWeb: Invalidate style for tree counting functions when required
We mark any element that relies on tree counting functions as needing a
style update when a sibling is inserted/removed.
2025-10-20 16:12:08 +01:00
Callum Law
e9036c7c75 LibWeb: Support tree counting functions within calc() 2025-10-20 16:12:08 +01:00
Callum Law
55bcdcf824 LibWeb: Set up initial infrastructure for non-math functions in calc
There are some non-math functions (such as tree counting functions)
which we should allow within `calc()`s . This commit implements the
initial infrastructure for this.

We don't yet parse any of these non-math functions in
`parse_a_calculation` so there is no functional change.
2025-10-20 16:12:08 +01:00
Callum Law
831e471444 LibWeb: Support top-level tree counting functions
Adds support for `sibling-index()` and `sibling-count()` when parsing
`<number>` and `<integer>`. This is achieved by a new
`TreeCountingFunctionStyleValue` class which is converted within
`absolutized` to `NumberStyleValue` and `IntegerStyleValue` respectively

There are still a few kinks to work out in order to support these
everywhere, namely:
 - There are some `StyleValue`s which aren't absolutized (i.e. those
   which are stored within another `StyleValue` without an
   `absolutize()` method.
 - We don't have a way to represent this new `StyleValue` within
   `{Number,Integer}OrCalculated`. This would be fixed if we were to
   instead just use the `StyleValue` classes until style computation at
   which time they would be absolutized into their respective
   primitives (double, i64, etc) bypassing the need for *OrCalculated
   entirely.
2025-10-20 16:12:08 +01:00
Callum Law
9cd23e3ae5 LibWeb: Compute and propagate tree-counting function resolution context
Tree counting functions should be resolved at style computation time -
to do this we will need to know the element's sibling count and index.

This commit computes that information and propagates it to the various
`StyleValue::to_computed_value` methods.
2025-10-20 16:12:08 +01:00
Callum Law
fd31fbd84b LibWeb: Add method for whether tree-counting function is allowed
Some contexts (e.g. descriptors, media conditions) don't allow tree
counting functions, this commit adds an easy way to check if the current
value context is one of those.
2025-10-20 16:12:08 +01:00
Callum Law
fbc6a4c96f LibWeb: Allow setting initial value context when creating CSS parser 2025-10-20 16:12:08 +01:00
Callum Law
85239fb1da Tests: Import tree-counting function WPT tests 2025-10-20 16:12:08 +01:00
Callum Law
8284a99f0a LibWeb: Add absolutized method for FontStyleStyleValue 2025-10-20 16:12:08 +01:00
Callum Law
28451b16c9 LibWeb: Absolutize StyleValues before computing font properties
We also avoid prematurely constructing CSSPixels when computing
font-size which gains us a couple of test passes
2025-10-20 16:12:08 +01:00
Callum Law
ca9d107a1a LibWeb: Remove unused variable in white-space property serialization 2025-10-20 16:12:08 +01:00
Luke Wilde
ab3eb9adab LibWeb/WebGL: Replace manual pointer math with Span
This deduplicates a lot of sensitive pointer math by using Span, which
performs this math for us with more safety checks and with type
information.

This also allows us to use the correctly typed Span for typed arrays,
which automatically fixes srcOffset to now offset by the number of
elements instead of bytes. This goes for srcLengthOverride too.

Fixes the Rive animations on Shopify's homepage not appearing.
Fixes some Unity applications such as ArcViewer having missing
graphics.
2025-10-20 16:26:12 +02:00
Luke Wilde
afd170d16c AK: Add the ability to reinterpret a Span to a given type
This allows you to reinterpret a Span to any given type, maintaining
the original data and working out the new size for you.

The target type must evenly fit into the Span's original type, ensuring
bytes are not dropped.
2025-10-20 16:26:12 +02:00
Luke Wilde
b15f4424f9 LibWeb/WebGL: Implement the EXT_texture_filter_anisotropic extension 2025-10-20 15:33:33 +02:00
Luke Wilde
d08915a0cd LibWeb/WebGL: Implement the WEBGL_compressed_texture_s3tc_srgb extension 2025-10-20 15:33:33 +02:00
Luke Wilde
ddf60ebe9e LibWeb/WebGL2: Implement the EXT_texture_norm16 extension 2025-10-20 15:33:33 +02:00
Luke Wilde
93d3ebfd59 LibWeb/WebGL2: Implement the EXT_render_snorm extension 2025-10-20 15:33:33 +02:00
Sam Atkins
7ba496b798 LibWeb/CSS: Add ValueTypes for <foo-percentage> 2025-10-20 13:55:23 +01:00
Sam Atkins
c619c90e23 Tests: Import some @property tests 2025-10-20 13:55:23 +01:00
Tim Ledbetter
dab994c4f3 LibWeb: Remove redundant SVG presentation attribute handling 2025-10-20 12:38:19 +01:00
Amish K. Naidu
884b7fcbf5 LibWeb: Peek after extracting next chunk in InlineLevelIterator
Peek is used to determine if the current chunk is
the last and if so, add trailing box metrics.
For this to work correctly, it must be done only
after calling next(), otherwise peek gives us the
current chunk.
2025-10-20 12:37:25 +01:00
Lorenz A
eeef370902 LibWeb: Check that elements are HTML elements in StackOfOpenElements 2025-10-20 12:14:14 +01:00
Tim Ledbetter
08641c9e15 LibWeb: Ensure CanvasPath::arc() nonfinite radius argument is ignored 2025-10-20 12:12:16 +01:00
Tim Ledbetter
303ebc0a67 LibWeb: Ignore non-finite arguments to canvas text drawing methods 2025-10-20 12:12:16 +01:00
Callum Law
26b82986c4 LibWeb: Clean up parse_css_value_for_properties
We no longer rely on parsing easing functions before keywords so this
can be moved down with the other parse_for_type calls.

`parse_for_type` is used for more than just parsing easing functions so
the variable name `maybe_easing_function` was misleading
2025-10-20 11:27:44 +01:00
Callum Law
03be70087d LibWeb: Maintain easing keywords as KeywordStyleValue until use-time
This excludes `step-end` and `step-start` which are expected to be
converted to the equivalent function at parse time.

We are expected to serialize these as the explicit keywords - previously
we would parse as `EasingStyleValue` and serialize equivalent functions
as the keywords. This caused issues as we would incorrectly serialize
even explicit functions as the keyword.

This also allows us to move the magic easing functions to
`EasingFunction` rather than `EasingStyleValue` which is a bit tidier
2025-10-20 11:27:44 +01:00
Callum Law
755a576013 LibWeb: Support relative lengths within easing function calc()s 2025-10-20 11:27:44 +01:00
Callum Law
ad41f053b8 LibWeb: Clamp calculated steps() interval count using normal system
Previously we were doing this ad-hoc later in the process but we now
have the `calc` clamping system which can simplify things.

This reveals some false-positives in that we don't handle relative
lengths within these `calc`s but these are fixed in the next commit
2025-10-20 11:27:44 +01:00
Callum Law
06a57a280d LibWeb: Clamp calculated cubic-bezier() X coords using normal system
Previously we were doing this ad-hoc later in the process but we now
have the `calc` clamping system which can simplify things
2025-10-20 11:27:44 +01:00
Callum Law
ef4f01ea44 LibWeb: Discard Number type when converting to CalculationNode
Before this change we would maintain explicit signs when serializing
e.g. `animation-iteration-count: calc(+1)` would serialize as `calc(+1)`
rather than `calc(1)` as intended
2025-10-20 11:27:44 +01:00
Callum Law
2f83356c0f LibWeb: Support calc within linear() easing function 2025-10-20 11:27:44 +01:00
Callum Law
91925db9ca LibWeb: Don't canonicalize linear easing function points until use time
Canonicalization can require information that is only known after
compute time (i.e. resolved relative lengths within calcs).

This also allows us to get rid of the `had_explicit_input` flag and just
rely on whether Optional has a value
2025-10-20 11:27:44 +01:00
Callum Law
95e26819d9 LibWeb: Separate use time easing functions from EasingStyleValue
In the future there will be different methods of creating these use-time
easing functions (e.g. from `KeywordStyleValue`s)
2025-10-20 11:27:44 +01:00