Commit Graph

71731 Commits

Author SHA1 Message Date
Callum Law
1ac7b47764 LibWeb: Disallow spread distance value when parsing text-shadow
`text-shadow` does not support setting a value for spread distance
unlike `box-shadow`.
2025-09-18 15:21:22 +01:00
Callum Law
5d8a859457 Tests: Import text-shadow parsing test
Done in a distinct commit to show progress in following commits
2025-09-18 15:21:22 +01:00
Aliaksandr Kalenik
c3b0eabf18 LibJS: Capture PrototypeChainValidity before executing internal_get()
- Capture PrototypeChainValidity before invoking `internal_get()`. A
  getter may mutate the prototype chain (e.g., delete itself). Capturing
  earlier ensures such mutations invalidate the cached entry and prevent
  stale GetById hits.
- When caching, take PrototypeChainValidity from the base object
  (receiver), not from the prototype where the property was found.
  Otherwise, changes to an intermediate prototype between the base
  object and the cached prototype object go unnoticed, leading to
  incorrect cache hits.
2025-09-18 15:56:20 +02:00
Sam Atkins
1b8e81cd6f IDLGenerators: Support null as a default value for dictionary types
Specifically, NotificationOptions has this:

```webidl
dictionary NotificationOptions {
    // ...
    boolean? silent = null;
    // ...
};
```
https://notifications.spec.whatwg.org/#dictdef-notificationoptions

Without this patch, we generate this code, which isn't valid:

```c++
silent_value_11 = static_cast<bool>(null);
```

Treating `null` the same as no default value seems like the best option,
as they're equivalent in our C++ types.
2025-09-18 13:59:46 +01: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
Timothy Flynn
f529a4d98e LibWeb: Add a FIXME comment about multiple DOM nodes in arrow navigation 2025-09-18 07:39:10 -04:00
Timothy Flynn
80412d1ea5 LibWeb: Add a FIXME comment about handling wrapping in arrow navigation 2025-09-18 07:39:10 -04:00
Timothy Flynn
42a5f66e41 LibWeb: Move grapheme edge detection across lines to helper functions
EditingHostManager is going to have exactly the same implementation as
FormAssociatedElement.
2025-09-18 07:39:10 -04:00
Timothy Flynn
8b2187bf92 LibWebView+UI: Generate the entire Inspect menu
Now that all the actions in the Inspect menu are generated, we can
generate the menu itself.
2025-09-18 07:27:24 -04:00
Timothy Flynn
14d49d5a3a LibWebView+UI: Generate action to enable/disable DevTools 2025-09-18 07:27:24 -04:00
Timothy Flynn
6d30b0f4d4 LibWebView+UI: Generate actions to open about: pages 2025-09-18 07:27:24 -04:00
Timothy Flynn
ce331cbcd5 LibWebView+UI: Add an Application method to open a URL in a new tab
This lets us avoid each UI needing to handle link clicks directly, and
lets actions stored in LibWebView avoid awkwardly going through the link
click callbacks to open URLs.
2025-09-18 07:27:24 -04:00
Timothy Flynn
c2365653a5 LibURL: Add a few missing internal page factories 2025-09-18 07:27:24 -04:00
Timothy Flynn
60b71805bc UI/AppKit: Add menu icons for the zoom menu
Neglected to add these in ede6314cb6.
2025-09-18 07:27:24 -04:00
Timothy Flynn
255c4c2d9b UI/Qt: Simplify setting some action shortcuts
These were copied from their previous instantiations, but we don't need
to go through QKeySequence::keyBindings for standard shortcuts.
2025-09-18 07:27:24 -04:00
Timothy Flynn
dbce62bc0d UI/Qt: Move the View Source action back to the Inspect menu
Accidental copy/paste from e6b32bbbbf6c3b80649e355c2ad7f6ad87430fc3.
2025-09-18 07:27:24 -04:00
Rocco Corsi
3d1d055e27 LibRegex: Export OpCode/OpCode_Compare for REGEX_DEBUG builds
When building with REGEX_DEBUG or ENABLE_ALL_THE_DEBUG_MACROS there are
two issues with linking of bin/TestRegex

 - Libraries/LibRegex/RegexDebug.h:76 with undefined reference
       regex::OpCode_Compare::variable_arguments_to_byte_string(
           AK::Optional<regex::MatchInput const&>) const

 - Libraries/LibRegex/RegexByteCode.h:672 with undefined reference
       regex::OpCode::name(regex::OpCodeId)

Add REGEX_API on regex::OpCode and regex::OptCode_Compare to allow
access to the classes in bin/TestRegex
2025-09-18 11:02:13 +02:00
Rocco Corsi
73658c9785 LibDNS: Export DNS::Messages::Records::SIG for DNS_DEBUG builds
When building with DNS_DEBUG or ENABLE_ALL_THE_DEBUG_MACROS there is a
linking issue with Libraries/LibDNS/Resolver.h:1003 with
undefined reference DNS::Messages::Records::SIG::to_string() const

Add DNS_API on DNS:Messages::Records::SIG definition to allow access
to the class in bin/dns, bin/TestDNSResolver, libexec/RequestServer
2025-09-18 11:02:13 +02:00
luizgfc
b8787cb021 LibWeb: Import CSSOM variable names fixed WPT test 2025-09-18 09:25:23 +01:00
luizgfc
bcbbecff9f LibWeb: Correctly handle properties on CSS declaration serialization 2025-09-18 09:25:23 +01:00
luizgfc
3b5df12b38 LibWeb: Handle custom properties on CSSStyleProperties list 2025-09-18 09:25:23 +01:00
Zaggy1024
261cd5846f LibWeb: Use Duration::to_seconds_f64 to set HTMLMediaElement duration 2025-09-17 16:45:45 -05:00
Zaggy1024
5207de9a2d AK: Add a function to Duration to convert it to double seconds 2025-09-17 16:45:45 -05:00
Jelle Raaijmakers
c31eff6a47 Everywhere: Use Optional<T>::ensure() where useful
No functional changes.
2025-09-17 12:01:18 -04:00
Jelle Raaijmakers
0fe9255991 AK: Add Optional<T>::ensure()
We often use Optional<T> in a cache pattern such as:

  if (!m_cache.has_value())
      m_cache = slow_thing();
  return m_cache.value();

The new ::ensure() makes it a bit simpler:

  return m_cache.ensure([&] { return slow_thing(); });
2025-09-17 12:01:18 -04:00
Aliaksandr Kalenik
d45f8a3081 LibJS: Add inline caching for adding new own properties to objects
We already had IC support in PutById for the following cases:
- Changing an existing own property
- Calling a setter located in the prototype chain

This was enough to speed up code where structurally identical objects
(same shape) are processed in a loop:
```js
const arr = [{ a: 1 }, { a: 2 }, { a: 3 }];
for (let obj of arr) {
    obj.a += 1;
}
```

However, creating structurally identical objects in a loop was still
slow:
```js
for (let i = 0; i < 10_000_000; i++) {
    const o = {};
    o.a = 1;
    o.b = 2;
    o.c = 3;
}
```

This change addresses that by adding a new IC type that caches both the
source and target shapes, allowing property additions to be fast-pathed
by directly jumping to the shape that already includes the new property.
2025-09-17 12:44:44 +02:00
Aliaksandr Kalenik
a54215c07d LibJS: Make internal_define_own_property() save added property offset
...in `PropertyDescriptor`. This is required for the upcoming change
that needs to know offset of newly added properties to set up inline
caching.
2025-09-17 12:44:44 +02:00
Timothy Flynn
ede6314cb6 LibWebView+UI/AppKit: Display icons in the macOS UI on Tahoe
On macOS Tahoe, it is now recommended to show menu item icons. We use
system symbols for this now. Symbols do not have constant variable names
and must be found via the SF Symbols app.

The symbols chosen here were to match Safari as close as possible.
2025-09-17 11:29:01 +01:00
Timothy Flynn
8ebc20a4f0 UI/AppKit: Make the location field bordered on Tahoe
Otherwise, it sticks out on macOS Tahoe when it is unbordered. This
matches Safari's look.
2025-09-17 11:29:01 +01:00
Timothy Flynn
e0a7217c4b UI/AppKit: Hide button borders when the button should be invisible
On macOS Tahoe, the zoom button's border is visible when the button
itself is hidden. This feels like a macOS bug, but for now let's hide
the borders as well.
2025-09-17 11:29:01 +01:00
Rocco Corsi
55d4adc614 LibWasm: Missing argument formatter (Wasm::Value) for WASI_DEBUG
Formatting code was removed in PR #960 for performance improvements.
Adding Wasi::Value back as u128 to allow WASI_DEBUG MACRO compilation
2025-09-16 22:13:23 +02:00
Jelle Raaijmakers
49817a1c6a CI+Meta: Add option to enable baseline CPU target for CI
We currently have the issue that our macOS builds are being hosted by
both Apple M1 and M4 runners. By default, these target `-mcpu=apple-m1`
and `-mcpu=apple-m3` respectively, causing their ccache artifacts to be
incompatible and effectively thrashing each other's ccache cache on each
run.

Add a new CMake option `ENABLE_CI_BASELINE_CPU` that toggles a baseline
`-mcpu/-march` compile option for each of the supported build platforms.
When disabled (the default), we now default to `-march=native` which on
Linux could theoretically lead to better performance.

The new CPU baseline is used by the `lagom-template.yml` and
`js-and-wasm-artifacts.yml` workflows, since they both produce artifacts
or caches that might be picked up by other runners. We also enable it
for Flatpak builds, so they target a fixed architecture instead of
whatever architecture the action runner that picked up the job has.
2025-09-16 10:53:15 -04:00
Callum Law
7a9b1a8033 LibWebView: Show a better error for invalid download dir in headless
Previously if the directory returned by `downloads_directory()` didn't
exist (or wasn't a directory) when taking a screnshot in headless mode
we try to ask the user for the download directory and fail with the
unhelpful error: QWidget: Must construct a QApplication before a QWidget
2025-09-16 10:39:20 -04:00
Jelle Raaijmakers
b9da7baac4 LibWeb: Extend logic for extraneous line breaks in block elements
While editing, we need to consider whether removing a <br> has any
effect on layout to determine whether its extraneous. This new condition
finds most cases for extraneous <br>s inside block elements.
2025-09-16 06:57:30 -04:00
Jelle Raaijmakers
f77f169824 LibWeb: Reformat code and comments in Editing::split_the_parents()
Mainly rewrapping the spec text to 120 characters. No functional
changes.
2025-09-16 06:57:30 -04:00
Jelle Raaijmakers
c557db8315 LibWeb: Pass existing DOM::BoundaryPoints in delete_the_selection() 2025-09-16 06:57:30 -04:00
Jelle Raaijmakers
9b614eebb3 LibWeb: Make TreeNode::child_at_index() accept a size_t
This gets rid of IDE warnings when the call site already uses a size_t.
2025-09-16 06:57:30 -04:00
Jelle Raaijmakers
b51cc00478 LibWeb: Resolve Unicode FIXME in forwardDelete 2025-09-16 06:57:30 -04:00
Tete17
82f56e30ed LibWeb: Adapt the parsing of script elements to accommodate TrustedTypes 2025-09-16 10:57:34 +02:00
Tete17
f7c05013c7 LibWeb: Add innerText attribute of HTMLScriptElement for TrustedTypes 2025-09-16 10:57:34 +02:00
Tete17
6b9c44390f LibWeb: Add textContent attribute of HTMLScriptElement for TrustedTypes 2025-09-16 10:57:34 +02:00
Tete17
f65dca1b53 LibWeb: Extend src attribute of HTMLScriptElement with TrustedTypes
The field does no longer have the Reflect and URL attributes so we
remove it from our internal unit test.
2025-09-16 10:57:34 +02:00
Tete17
664a3b536a LibWeb: Extend set_text of HTMLScriptElement to accommodate TrustedTypes 2025-09-16 10:57:34 +02:00
Timothy Flynn
b4df857a57 LibWeb+LibWebView+WebContent: Replace DNT with GPC
Global Privacy Control aims to be a replacement for Do Not Track. DNT
ended up not being a great solution, as it wasn't enforced by law. This
actually resulted in the DNT header serving as an extra fingerprinting
data point.

GPC is becoming enforced by law in USA states such as California and
Colorado. CA is further working on a bill which requires that browsers
implement such an opt-out preference signal (OOPS):

https://cppa.ca.gov/announcements/2025/20250911.html

This patch replaces DNT with GPC and hooks up the associated settings.
2025-09-16 10:38:20 +02:00
Timothy Flynn
d9ebd44924 UI/Qt: Remove unused/undefined declaration from Qt settings 2025-09-16 10:38:20 +02:00
Zaggy1024
850aea7e17 LibWeb: Remove a FIXME and simplify the painting of video frames
The extra representations of a video element are unnecessary to specify
in VideoPaintable, as the playback system itself should take care of
all the details of the representation as specified.
2025-09-16 10:26:03 +02:00
Zaggy1024
861c10f37f LibWeb: Use an IIFE to determine a VideoPaintable's representation 2025-09-16 10:26:03 +02:00
Timothy Flynn
7b3465ab55 LibWeb: Do not require multipart form data to end with CRLF
According to RFC 2046, the BNF of the form data body is:

    multipart-body := [preamble CRLF]
                      dash-boundary transport-padding CRLF
                      body-part *encapsulation
                      close-delimiter transport-padding
                      [CRLF epilogue]

Where "epilogue" is any text that "may be ignored or discarded". So we
should stop parsing the body once we encounter the terminating delimiter
("--").

Note that our parsing function is from an attempt to standardize the
grammar in the spec: https://andreubotella.github.io/multipart-form-data
This proposal hasn't been updated in ~4 years, and the fetch spec still
does not have a formal definition of the body string.
2025-09-15 18:28:48 +02:00
Callum Law
34b8947ca0 LibWeb: Support text-underline-position: under 2025-09-15 15:24:20 +01:00