Commit graph

8827 commits

Author SHA1 Message Date
stasoid
1173b14c43 LibCore: Pass correct number of arguments to the Process on Windows
Incorrect behavior of CreateProcess:
CreateProcess("a.exe", "b c", ...) ->
    a.exe::main::argv == ["b", "c"] (wrong)
CreateProcess(0, "a.exe b c", ...) ->
    a.exe::main::argv == ["a.exe", "b", "c"] (right)

https://learn.microsoft.com/en-us/cpp/cpp/main-function-command-line-args
"If you use both the first and second arguments (lpApplicationName and
lpCommandLine), argv[0] may not be the executable name."

This means first argument of CreateProcess should never be used.
-----------------------------------------------------------------------

Searching for executable in path is suppressed now by prepending "./"

Additional bonus of the new code: .exe extension does not need to be
specified.
2025-02-06 15:15:16 -07:00
Aliaksandr Kalenik
a6bea99959 LibWeb: Use invalidation sets for :defined style invalidation 2025-02-06 20:07:11 +01:00
Aliaksandr Kalenik
51a5ebb91d LibWeb: Use bitfields for booleans in DOM::Element 2025-02-06 20:07:11 +01:00
Aliaksandr Kalenik
f7a3f785a8 LibWeb: Don't invalidate style of parent of inserted node
There is no need for this invalidation because taking care of siblings
is already done by invalidation with `NodeInsertBefore` reason. Parent
element itself (without subtree) is always invalidated by
`Node::children_changed()` hook, so `:empty` pseudo-class invalidation
is already covered.
2025-02-06 20:07:11 +01:00
Aliaksandr Kalenik
daf7c1ef60 LibWeb: Fix early return condition in Node::invalidate_style()
When checking whether an early return is possible because some ancestor
already has the whole subtree invalidation flag set, the check should
begin with the current node's parent rather than with the node itself.
Otherwise, if a node already has the whole subtree invalidation flag
set and is subsequently invalidated for the reason `NodeInsertBefore`
or `NodeRemove`, we will skip the sibling invalidation required for
these operations

This fix is required for optimizations in subsequent commits.
2025-02-06 20:07:11 +01:00
Aliaksandr Kalenik
61c952fb43 LibWeb: Optimize style invalidation caused by DOM structural changes
With this change, siblings of an inserted node are no longer invalidated
unless the insertion could potentially affect their style. By
"potentially affected," we mean elements that are evaluated against the
following selectors during matching:
- Sibling combinators (+ or ~)
- Pseudo-classes :first-child and :last-child
- Pseudo-classes :nth-child, :nth-last-child, :nth-of-type, and
  :nth-last-of-type
2025-02-06 20:07:11 +01:00
Psychpsyo
402d8220dd LibWeb: Make style containment influence quotes 2025-02-06 17:44:50 +00:00
Sam Atkins
6a4d80b9b6 LibWeb/CSS: Integrate ParsingContext into the Parser
This is not really a context, but more of a set of parameters for
creating a Parser. So, treat it as such: Rename it to ParsingParams,
and store its values and methods directly in the Parser instead of
keeping the ParsingContext around.

This has a nice side-effect of not including DOM/Document.h everywhere
that needs a Parser.
2025-02-06 16:47:25 +00:00
Sam Atkins
30ba7e334e LibWeb/CSS: Avoid creating a new Parser unnecessarily
This attr() code can instead just tokenize the input manually, and then
re-use the existing Parser.
2025-02-06 16:47:25 +00:00
Sam Atkins
36e3963263 LibWeb: Add CSSNamespaceRule to Forward.h 2025-02-06 16:47:25 +00:00
Sam Atkins
0cb7f2ab6d LibWeb: Add some missing includes
These were being transitively included before via ParsingContext.h, but
that will break in a subsequent commit.
2025-02-06 16:47:25 +00:00
Sam Atkins
4d0537ee80 LibWeb/CSS: Make CSS Parser non-copyable/movable
We never actually need to do this, and doing so was complicated because
of the token stream, so just disable it altogether.
2025-02-06 16:47:25 +00:00
Sam Atkins
ca5dee4c55 LibWeb/CSS: Remove an unnecessary ParsingContext constructor
Anywhere we have a Node, we have a Document. So just use that.
2025-02-06 16:47:25 +00:00
Sam Atkins
0ac133d73b LibWeb/CSS: Replace is_generic_font_family() with a CSS enum
Also add the missing "math" value to it.
2025-02-06 16:47:25 +00:00
Sam Atkins
6da7a6eab5 LibWeb/CSS: Un-template some CSS Parser methods
A few of these are only ever called with T=Token, so let's simplify them
a bit.

As a drive-by change: Also correct the "unnecessairy" typos and use
discard_a_token().
2025-02-06 16:47:25 +00:00
Sam Atkins
1413760047 LibWeb/CSS: Split up Parser.cpp
This file has been a pain to edit for a while, even with the previous
splits. So, I've divided it up into 3 parts:
- Parser.cpp has the "base" code. It's the algorithms and entry-points
  defined in the Syntax spec.
- ValueParsing.cpp contains code for parsing single values, such as a
  length, or a color, or a calculation.
- PropertyParsing.cpp contains code for parsing an entire property's
  value. A few of these sit in a grey area between being a property's
  value and a value in their own right, but the rule I've used is "is
  this useful outside of a single property and its shorthands?"

This only moves code, with as few modifications as possible to make that
work. I did add explicit instantiations for the template implementations
as part of this, which revealed a few that are actually only compatible
with a single type, so I'll clear those up in a subsequent commit.
2025-02-06 16:47:25 +00:00
Timothy Flynn
97f7cb805f LibJS: Remove errant invocation to FormatNumericUnits
This is an editorial change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/cdef892
2025-02-06 10:46:04 -05:00
Timothy Flynn
ee649fc13b LibWeb+WebContent+WebDriver: Bring session start and close up to spec
Lots of editorial spec bugs here, but these changes largely affect how
the unhandledPromptBehavior capability is handled. We also now set an
additional capability for the default User Agent string.
2025-02-06 09:01:16 -05:00
Timothy Flynn
2583996e18 LibWeb+WebContent+WebDriver: Allow specifying multiple prompt handlers
WebDriver script authors may now provide either:
* A user prompt handler configuration to be used for all prompt types.
* A set of per-prompt-type user prompt handlers.

This also paves the way for interaction with the beforeunload prompt,
though we do not yet support that feature in LibWeb.

See: https://github.com/w3c/webdriver/commit/43903d0
2025-02-06 09:01:16 -05:00
Timothy Flynn
eef9d07088 LibJS: Add an explicit check for a valid ISO date in ToTemporalYearMonth
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/a1c5d61
2025-02-06 07:59:09 -05:00
Timothy Flynn
97b384db74 LibJS: Move call to CreateISODateRecord lower in ToTemporalYearMonth
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/58fd7de
2025-02-06 07:59:09 -05:00
stasoid
b77016cc34 LibCore: Consistently treat file descriptors as handles on Windows
Also:
 * implement dup and is_socket
 * implement and call init_crt_and_wsa
2025-02-05 19:27:47 -07:00
stasoid
259cd70c1b LibCore: Simplify System::open
_O_OBTAIN_DIR flag makes _open use FILE_FLAG_BACKUP_SEMANTICS in
CreateFile call.

FILE_FLAG_BACKUP_SEMANTICS is required to open directory handles.

For ordinary files FILE_FLAG_BACKUP_SEMANTICS overrides file security
checks when the process has SE_BACKUP_NAME and SE_RESTORE_NAME
privileges, see https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea
2025-02-05 19:27:47 -07:00
stasoid
870cce9d11 AK: Add Error::from_windows_error(void)
Also slightly improve Error::from_windows_error(int)
2025-02-05 19:27:47 -07:00
Andrew Kaster
adfb371e4f LibWeb: Reference multipage spec for form element constraints 2025-02-05 17:35:10 -07:00
stasoid
e0576f4790 LibCore: Add definitions for socketpair in SocketAddressWindows.h 2025-02-05 16:07:39 -07:00
stasoid
a274a50bb3 LibCore: Add declarations for getaddrinfo in SocketAddressWindows.h 2025-02-05 16:07:39 -07:00
stasoid
170f056805 LibCore: Allow winsock2.h to be included after SocketAddressWindows.h 2025-02-05 16:07:39 -07:00
stasoid
eb650798d0 LibCore: Fix SocketAddress.h compilation errors on Windows 2025-02-05 16:07:39 -07:00
Psychpsyo
9b8120d8e8 Meta: Disallow links to single-page HTML spec 2025-02-05 16:04:50 -07:00
jg99
51434c2ed0 LibJS: Parse dates like "1 Jan 2001 00:00:00 GMT" 2025-02-05 15:06:54 -07:00
Felipe Muñoz Mazur
c2cc0d9cd0 LibWeb: Check if input is disabled before submit event to form 2025-02-05 14:45:57 -07:00
devgianlu
da9eaf8788 LibWeb: Stub for Credential Management API
Stub out basic Credential Management APIs and import IDL tests.

Spec: https://w3c.github.io/webappsec-credential-management/
2025-02-05 13:18:47 -07:00
devgianlu
348db1c445 LibIDL+IDLGenerators: Support generation of IDL partial dictionaries 2025-02-05 13:18:47 -07:00
Andreas Kling
8cf16da6c2 Fix build breakage caused by badly sequenced PR merges 2025-02-05 19:49:24 +01:00
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
Timothy Flynn
911b915763 LibJS: Handle call stack limit exceptions in NewPromiseReactionJob
The promise job's fulfillment / rejection handlers may push an execution
context onto the VM, which will throw an internal error if our ad-hoc
call stack size limit has been reached. Thus, we cannot blindly VERIFY
that the result of invoking these handlers is non-abrupt.

This patch will propagate any internal error forward, and retains the
condition that any other error type is not thrown.
2025-02-05 08:05:01 -05:00
Timothy Flynn
b91a0f5403 LibJS: Repurpose MUST_OR_THROW_OOM to propagate general internal errors
There are now no users of the MUST_OR_THROW_OOM macro. Let's rename this
macro to indicate it may be used to propagate any internal error (such
as the call stack limit error) in places that would otherwise crash due
to a MUST/VERIFY invocation.

Note there's no actual functional change here, as we weren't able to
ensure the internal error was an OOM error previously.
2025-02-05 08:05:01 -05:00
Timothy Flynn
4c51602437 LibJS: Remove OOM handling from TypedArrayGetElement 2025-02-05 08:05:01 -05:00
Timothy Flynn
49f1ef52ad LibJS: Remove OOM handling from JS intrinsics initialization 2025-02-05 08:05:01 -05:00
Timothy Flynn
0fe9bbad2e LibJS: Add missing include to Intrinsics.h
This was preventing clangd in my environment from processing the
Intrinsics class.
2025-02-05 08:05:01 -05:00
Psychpsyo
bad7324307 LibWeb: Implement CSS validity pseudo-classes 2025-02-05 12:38:55 +00:00