Commit graph

8810 commits

Author SHA1 Message Date
Sam Atkins
a28197669a LibWeb/CSS: Move property code from CSSStyleDeclaration to *Properties
CSSStyleDeclaration is a base class that's used by various collections
of style properties or descriptors. This commit moves all
style-property-related code into CSSStyleProperties, where it belongs.

As noted in the previous commit, we also apply the CSSStyleProperties
prototype now.
2025-03-19 13:53:00 +00:00
Sam Atkins
83bb92c4e0 LibWeb/CSS: Merge style declaration subclasses into CSSStyleProperties
We previously had PropertyOwningCSSStyleDeclaration and
ResolvedCSSStyleDeclaration, representing the current style properties
and resolved style respectively. Both of these were the
CSSStyleDeclaration type in the CSSOM. (We also had
ElementInlineCSSStyleDeclaration but I removed that in a previous
commit.)

In the meantime, the spec has changed so that these should now be a new
CSSStyleProperties type in the CSSOM. Also, we need to subclass
CSSStyleDeclaration for things like CSSFontFaceRule's list of
descriptors, which means it wouldn't hold style properties.

So, this commit does the fairly messy work of combining these two types
into a new CSSStyleProperties class. A lot of what previously was done
as separate methods in the two classes, now follows the spec steps of
"if the readonly flag is set, do X" instead, which is hopefully easier
to follow too.

There is still some functionality in CSSStyleDeclaration that belongs in
CSSStyleProperties, but I'll do that next. To avoid a huge diff for
"CSSStyleDeclaration-all-supported-properties-and-default-values.txt"
both here and in the following commit, we don't apply the (currently
empty) CSSStyleProperties prototype yet.
2025-03-19 13:53:00 +00:00
Sam Atkins
687d32b712 LibWeb: Remove ElementInlineCSSStyleDeclaration entirely
All of its behavior has now been moved up into its parent classes.
2025-03-19 13:53:00 +00:00
Sam Atkins
50455c2f5e LibWeb: Stop constructing temporary ElementInlineCSSStyleDeclarations
Previously, parse_css_style_attribute() would parse the string, extract
the properties, add them to a newly-created
ElementInlineCSSStyleDeclarations, and then user code would take the
properties back out of it again and throw it away. Instead, just return
the list of properties, and the caller can create an EICSD if it needs
one.
2025-03-19 13:53:00 +00:00
Sam Atkins
f0d198ca3f LibWeb/CSS: Move CSSStyleDeclaration subclasses' fields into it
The spec defines several properties on the declaration which we
previously made virtual or stored on subclasses. This commit moves these
into CSSStyleDeclaration itself, and updates some of the naming.
2025-03-19 13:53:00 +00:00
Sam Atkins
3425aa0737 LibWeb/DOM: Introduce an ElementReference type
We have the "Element, but also maybe a pseudo-element of it" concept in
a lot of places, so let's wrap it up in a single type to make it easier
to deal with.
2025-03-19 13:53:00 +00:00
Sam Atkins
dea5fde3f9 LibWeb/HTML: Fix source insertion/removal steps
Corresponds to be5f269ca8

We don't yet implement "moving steps" so that's left for when we do.
2025-03-19 13:52:20 +00:00
Jelle Raaijmakers
c2e21d33eb LibWeb: Do not calculate corner radii if no radius is set
The `as_corner()` and `floored_device_pixels()` functions popped up
frequently in profiles when selecting text on some Tweakers.net pages.
For every corner we're performing multiple device pixel calculations
regardless of whether any radius was actually set.

Add an early return if no radius is set. On my machine this reduces the
time taken in both `as_corner()` and `floored_device_pixels()` by 46%
(63% fewer calls).
2025-03-19 14:22:10 +01:00
devgianlu
cfeb916e61 LibWeb: Remove unused underlying_buffer_source function
This function is not used anywhere and will most likely end up causing
problems so just remove it.
2025-03-19 13:46:50 +01:00
devgianlu
033ba43faf LibWeb: Use get_buffer_source_copy for getting the actual byte buffer
`WebIDL::underlying_buffer_source` gets the underlying buffer source
which is not resized according to, for example, `subarray`.
2025-03-19 13:46:50 +01:00
devgianlu
e02521911a LibWeb: Refactor {Dec,C}ompressionStream to handle split chunks 2025-03-19 13:46:50 +01:00
devgianlu
2b3934e34e LibCrypto: Remove leftover checksum helpers 2025-03-19 13:46:50 +01:00
devgianlu
f3631d6517 LibCrypto: Remove unused cksum class 2025-03-19 13:46:50 +01:00
devgianlu
6b2515657c LibCrypto: Remove unused CRC32, CRC16 and CRC8 classes 2025-03-19 13:46:50 +01:00
devgianlu
0561d130f3 LibCrypto: Remove unused Adler32 class 2025-03-19 13:46:50 +01:00
devgianlu
1c2b373e9c LibCompress: Refactor deflate de/compressor using zlib
Also remove two crash tests that are not relevant anymore because the
implementation changed substantially.
2025-03-19 13:46:50 +01:00
devgianlu
2baa7977a4 LibCompress: Refactor gzip de/compressor using zlib 2025-03-19 13:46:50 +01:00
devgianlu
dafbe32626 LibCompress: Refactor zlib de/compressor using zlib 2025-03-19 13:46:50 +01:00
devgianlu
c4b76bea13 LibCompress: Introduce generic de/compressor using zlib
This compressor decompressor is capable of handling zlib, gzip and
deflate all in one.
2025-03-19 13:46:50 +01:00
devgianlu
3d3e77cd3e Meta: Add explicit vcpkg dependency for zlib
zlib is already included transitively for other dependencies, include it
explicitly and link it with `LibCompress`.
2025-03-19 13:46:50 +01:00
Sam Atkins
d5b9c39a98 LibWeb: Replace webkit meter-state pseudo-elements with pseudo-classes
This also implements the `:high-value` and `:low-value` that are in the
spec.

Same note as before about this being based on the very-drafty CSS Forms
spec. In fact, some of this isn't even in that spec yet. Specifically,
the `:suboptimal-value` and `:even-less-good-value` names are undecided
and subject to change. However, it's clear that this is a pseudo-class
situation, not a pseudo-element one, so I think this is still an
improvement, as it allows styling of the `::fill` pseudo-element
regardless of what state it is in.

Relevant spec issue: https://github.com/openui/open-ui/issues/1130
2025-03-19 10:10:03 +00:00
Sam Atkins
1978578a72 LibWeb: Expose HTMLMeterElement's optimum/suboptimum/etc state
No behaviour change, but this will allow us to switch over to
pseudo-classes for this state.
2025-03-19 10:10:03 +00:00
Sam Atkins
4c3c907041 LibWeb: Implement progress/range-input accent color in CSS
The `AccentColor` keyword does this in a simpler way, and allows authors
to override it.
2025-03-19 10:10:03 +00:00
Sam Atkins
3ebdb64fed LibWeb: Replace ::-webkit pseudo-elements with ones from CSS Forms spec
This spec is very early on, and likely to change. However, it still
feels preferable to use these rather than the prefixed -webkit ones.

Plus, as we have a `::fill` on range inputs, we can use that for styling
the bar instead of inserting CSS from C++.
2025-03-19 10:10:03 +00:00
Jess
f5a6704219 LibJS: Fix UAF in ECMAScriptFunctionObject::internal_construct
Currently, we create `this_argument` with
`ordinary_create_from_constructor`, then we use `arguments_list` to
build the callee_context.

The issue is we don't properly model the side-effects of
`ordinary_create_from_constructor`, if `new_target` is a proxy object
then when we `get` the prototype, arbitrary javascript can run.

This javascript could perform a function call with enough arguments to
reallocate the interpreters m_argument_values_buffer vector. This is
dangerous and leads to a use-after-free, as our stack frame maintains a
pointer to m_argument_values_buffer (`arguments_list`).
2025-03-19 10:31:00 +01:00
Aliaksandr Kalenik
b8fa355a21 LibWeb: Implement "transferred size suggestion" part of GFC spec 2025-03-19 10:21:54 +01:00
Tim Ledbetter
f0917ea150 LibWeb: Ensure shortest serialization is used for grid-column values 2025-03-19 02:08:05 +01:00
Tim Ledbetter
6811264b11 LibWeb: Ensure shortest serialization is used for grid-row values 2025-03-19 02:08:05 +01:00
Tim Ledbetter
83143e3018 LibWeb: Avoid repetition when serializing grid track placement values 2025-03-19 02:08:05 +01:00
Luke Wilde
7643a079c0 LibWeb: Enforce Content Security Policy of Fetch responses 2025-03-19 00:55:14 +01:00
Luke Wilde
51796e2d3a LibWeb: Report CSP violations for request 2025-03-19 00:55:14 +01:00
Luke Wilde
6f771f45e2 LibWeb: Enforce Content Security Policy on Fetch requests 2025-03-19 00:55:14 +01:00
Luke Wilde
86170f4bfd LibWeb/CSP: Introduce the ability to create and report a violation
A violation provides several details about an enforcement failing, such
as the URL of the document, the directive that returned "Blocked", etc.
2025-03-19 00:55:14 +01:00
Luke Wilde
02236be737 LibWeb/CSP: Implement SecurityPolicyViolationEvent
This is used to report violations of policies to the element/global
object that caused it.
2025-03-19 00:55:14 +01:00
Andrew Kaster
89ecc75ed8 LibCore+Meta: Un-break Swift build on Linux
LibCore's list of ignored header files for Swift was missing the Apple
only files on non-Apple platforms. Additionally, any generic glue code
cannot use -fobjc-arc, so we need to rely on -fblocks only.
2025-03-18 17:15:08 -06:00
Tim Ledbetter
f6a8e5aa68 LibWeb: Use correct canonical serialization for BorderRadiusStyleValue 2025-03-18 21:55:06 +01:00
Tim Ledbetter
85728b297f LibWeb: Ensure the shortest serialization is used for border-radius
This implementation also fixes an issue where the individual components
of the `border-radius` shorthand were always assumed to be of type
`BorderRadiusStyleValue`, which could lead to a crash when CSS-wide
keywords were used.
2025-03-18 21:55:06 +01:00
Sam Atkins
97e917bdf5 LibWeb/CSS: Allow bare zero for gradient angles
Corresponds to f952e97da9
2025-03-18 20:04:08 +00:00
Timothy Flynn
4dfc29356d LibWeb: Initialize the Storage byte count upon creation
A Storage object may be created with an existing storage bottle. For
example, if you navigate from site.com/page1 to site.com/page2, they
will have different localStorage objects, but will use the same bottle
for actual storage.

Previously, if page1 set some key/value item, we would initialize the
byte count to 0 on page2 despite having a non-empty bottle. Thus, if
page2 set a smaller value with the same key, we would overflow the
computed byte count, and all subsequent writes would be rejected.

This was seen navigating from the chess.com home page to the daily
puzzle page.
2025-03-18 20:34:13 +01:00
Aliaksandr Kalenik
394073f611 LibWeb: Rename internals.signalTextTestIsDone() to signalTestIsDone()
In upcoming change this function will be used for ref-tests as well.
2025-03-18 20:09:46 +01:00
Alec Murphy
101a8aef26 LibWeb: Use Super on macOS for page scroll/nav
On macOS, we should use the Cmd (Super) modifier key along with the
arrow keys to scroll to the beginning/end of the document, or navigate
back and forth in the history, rather than the Ctrl or Alt keys.
2025-03-18 15:07:09 -04:00
Shannon Booth
894c51e8e7 LibWeb/HTML: Handle missing second component in datetime-local
We were previously not checking for EOF which meant we were not
handling seconds being missing in the time component.
2025-03-18 15:05:02 -04:00
Shannon Booth
a457ebeec5 LibWeb/HTML: Implement 'convert string to number' for datetime-local 2025-03-18 15:05:02 -04:00
Timothy Flynn
780de1395b LibJS: Merge Intl.DurationFormat style and display fields into a struct
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/d56d624
2025-03-18 11:47:23 -04:00
Timothy Flynn
00d00b84d3 LibJS: Ensure relevant extension keys are included in ICU locale data
This is a normative change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/7508197

In our implementation, we don't have the affected AOs directly, as we
delegate to ICU. So instead, we must ensure we provide ICU a locale with
the relevant extension keys present.
2025-03-18 11:47:23 -04:00
Timothy Flynn
37b8ba96f1 LibJS: Use currency digits for NumberFormat only for standard notation
This is a normative change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/9140da2
2025-03-18 11:47:23 -04:00
Timothy Flynn
96c059bf67 LibJS: Use correct enum casing in some Intl constructors 2025-03-18 11:47:23 -04:00
Timothy Flynn
ea10470071 LibJS: Correctly print labels for some Intl objects
For example, printing an Intl.Collator object would previously display:

    [Intl.Collator]  numeric:
    "en"  locale:
    "sort"  usage:
    "variant"  sensitivity:
    "upper"  caseFirst:
    "default"  collation:
    false  ignorePunctuation:
    false

We now print:

    [Intl.Collator]
      locale: "en"
      usage: "sort"
      sensitivity: "variant"
      caseFirst: "upper"
      collation: "default"
      ignorePunctuation: false
      numeric: false
2025-03-18 11:47:23 -04:00
Aliaksandr Kalenik
4a7b947c5d LibWeb: Clamp content-based minimum size by limited max track size [GFC]
Progress on https://wpt.live/css/css-grid/grid-items/grid-minimum-size-grid-items-022.html
2025-03-18 15:01:02 +01:00
Shannon Booth
ec3c545426 LibURL+LibWeb: Ensure opaque paths always roundtrip
Corresponds to: https://github.com/whatwg/url/commit/6c782003
2025-03-18 12:17:19 +00:00