Commit graph

63821 commits

Author SHA1 Message Date
Andrew Kaster e66ad7c452 Meta: Remove stale zsh shell completions for serenity.sh
If someone wants to add these back for ladybird.sh, they'll need largely
rewritten anyway.
2024-09-10 07:39:15 +02:00
Andrew Kaster 0427646883 Meta: Remove check-ak-test-files script
This script only checks Tests/AK, and verifies that all source files
that match Tests/AK/*.cpp are listed in the CMakeLists.txt.

This is a bit excessive. We don't have this check for any other test
files. This sort of error will definitely ™️ be caught in review.
2024-09-10 07:39:15 +02:00
Andrew Kaster 9356c967d7 Meta: Remove unused functions from shell_include.sh 2024-09-10 07:39:15 +02:00
Andrew Kaster b3a009f521 Meta: Check more file extensions for newlines at EOF 2024-09-09 22:34:52 -06:00
sideshowbarker 0601216ac4 LibWeb: Replace tabs with 4 spaces in ARIAMixin.idl
Also, remove blank lines. (https://w3c.github.io/aria/#ARIAMixin source
doesn’t have any blank lines, and it’s not clear that the blank lines in
ours follow any intended structure/logic.)
2024-09-09 21:19:53 -06:00
sideshowbarker 6bf3d34a67 LibWeb: Add CEReactions to all IDL for all ARIA attributes
This change adds the [CEReactions] attributes to all ARIA attributes in
the ARIAMixin WebIDL — as required by the WebIDL in the current spec at
https://w3c.github.io/aria/#ARIAMixin, and by the WPT test case at
http://wpt.live/custom-elements/reactions/AriaMixin-string-attributes.html,
and as implemented in other existing engines.

Otherwise, without this change, Ladybird doesn’t conform to the current
spec, fails all those tests, and isn’t interoperable with other engines.
2024-09-09 20:18:32 -06:00
Aliaksandr Kalenik ee41dbfec3 LibWeb: Fix wrong assumption that repeat() is always first track [GFC]
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Fixes crashing in
https://wpt.live/css/css-grid/grid-definition/grid-auto-fit-columns-001.html
2024-09-09 22:05:30 +02:00
Laura Braun 26415d39f7 Meta: Check for CMake version in ladybird.sh
CMake reads CMakePresets.json, which is before it reads CMakeLists.txt.
This causes CMake Error: Unrecognized "version" field if the version of
CMake is older than support for presets, or the version field of
presets.

The fix is to check CMake version in ladybird.sh before trying to create
the build directory.

Co-Authored-By: Andrew Kaster <andrew@ladybird.org>
2024-09-09 13:10:19 -06:00
Aliaksandr Kalenik 1d7c9cd1e1 LibWeb: Return computed grid-template-rows/columns if there's no used
If grid-template-rows or grid-template-columns queried for a box that is
not a grid container, the result should be computed value instead of
null.

Fixes crashing in inspector.
2024-09-09 20:12:20 +02:00
Andreas Kling b2aff403fc LibWeb: Make CSSStyleRule::qualified_layer_name() return a const-ref
And also make it inline. We were spending 8% of selector matching on
creating and destroying FlyString copies here. With this change, it's
now ~1%.
2024-09-09 20:12:07 +02:00
Andreas Kling ef4f5ac8fb LibWeb: Filter :hover selectors early for elements that aren't hovered
Some websites (like vercel.com...) have a *lot* of :hover selectors that
we can simply skip for any element that isn't currently hovered.
2024-09-09 20:12:07 +02:00
Andreas Kling 5bb0f43b90 LibWeb: Bucket :is/where() selectors by tag name and ID as well
Instead of only bucketing these by class name, let's also bucket by
tag name and ID.

Reduces the number of selectors evaluated on https://tailwindcss.com/
from 2.9% to 1.9%.
2024-09-09 20:12:07 +02:00
Andreas Kling 49d2b11085 LibWeb: Remove MatchingRule::contains_root_pseudo_class member
This can be a local variable while building a rule cache, no need to
take up space in MatchingRule.
2024-09-09 20:12:07 +02:00
Andreas Kling c8f22f65d9 LibWeb: Filter rules to run before allocating vector of matches
By filtering first, we end up allocating much less vector space
most of the time.

This is mostly helpful in pathological cases where there's a huge number
of rules present, but most of them get rejected early.
2024-09-09 20:12:07 +02:00
Noah Bright ee352e59db WebDriver: Add boilerplate for endpoint 15.7 Perform Actions
Some checks are pending
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Following the structure of the ReleaseActions endpoints, define
analogous classes and methods for PerformActions
2024-09-09 14:11:23 +01:00
Tim Ledbetter 3ae4ea7b10 LibWeb: Abort dependent signals before firing abort event
Previously, there was a bug in the specification that would cause an
assertion failure, due to the abort event being fired before all
dependent signals were aborted.
2024-09-09 12:48:30 +02:00
Aliaksandr Kalenik 68fcc37531 LibWeb: Return used values for grid tracks in getComputedStyle()
That's awkward, but getComputedStyle needs to return used track values
for gridTemplateColumns and gridTemplateRows properties. This change
implements it by saving style values with used values into layout state,
so it could be assigned to paintables during LayoutState::commit() and
later accessed by style_value_for_property().

I haven't seen it used in the wild, but WPT grid tests extensively use
it. For example this change helps to go from 0/10 to 8/10 on this test:
https://wpt.live/css/css-grid/layout-algorithm/grid-fit-content-percentage.html
2024-09-09 12:48:06 +02:00
Andreas Kling 34fdd0d44f LibWeb: Include immediate child (>) combinator in ancestor filter
Before this change, the ancestor filter would only reject rules that
required a certain set of descendant strings (class, ID or tag name)
to be present in the current element's ancestor chain.

An immediate child is also a descendant, so we can include this
relationship in the ancestor filter as well.

This substantially improves the efficiency of the ancestor filter on
websites using Tailwind CSS.

For example, https://tailwindcss.com/ itself goes from full style
updates taking ~1400ms to ~350ms. Still *way* too long, but a huge
improvement nonetheless.
2024-09-09 12:46:55 +02:00
Andreas Kling b365a5c42f LibWeb: Bucket div.foo and div#foo as class/ID rather than tag(div)
By bucketing these seletors by class or ID, we can avoid running them
in more cases.

Before, we were only avoiding them if the context element wasn't a div.
Now we avoid them for any element that doesn't have that specific class
or ID.

This reduces the number of selectors ran on https://vercel.com by a bit
more, from 1.90% to 1.65%.
2024-09-09 12:46:55 +02:00
Andreas Kling ad37c8cd26 LibWeb: Treat :is(.foo) & :where(.foo) as class selectors when bucketing
These are just roundabout ways of writing .foo, so we can still put them
in the rules-by-class bucket and skip running them when the element
doesn't have that class.

Note that :is(.foo .bar) is also bucketed as a class rule, since the
context element must have the `bar` class for the selector to match.

This is a massive speedup on https://vercel.com/ as it cuts the number
of selectors we actually evaluate from 7.0% to 1.9%.
2024-09-09 12:46:55 +02:00
Aliaksandr Kalenik 4ba38c55d6 LibWeb: Remove unnecessary copying of UsedValues in BFC 2024-09-09 11:41:36 +02:00
Aliaksandr Kalenik 07aa25ce50 LibWeb: Clamp growth limit after adding planned increase in GFC
Fixes implementation of the following line from the spec:
"However, limit the growth of any fit-content() tracks by their
fit-content() argument."

Now we correctly apply a limit to increased growth limit rather than to
the planned increase.

Change in "Tests/LibWeb/Layout/input/grid/fit-content-2.html" is a
progression and "Item as wide as the content." is actually as wide as a
content.
2024-09-09 11:41:10 +02:00
Tim Ledbetter 2c8fb49578 LibWeb: Don't attempt to set selection if control has no selectable text 2024-09-09 11:04:07 +02:00
Timothy Flynn 8d6f36f8d6 LibJS+LibWeb: Add a custom host hook to log unparsed date strings
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
This lets us log when our Date.parse implementation was unable to handle
a string found on the web.
2024-09-08 18:25:05 +02:00
Timothy Flynn 921a9cef62 LibJS: Add "month day, year" support to Date.parse
Used on https://rauchg.com.
2024-09-08 18:25:05 +02:00
Aliaksandr Kalenik 10064d0e1a LibJS: Reset in_formal_parameter_context after entering a new function
Fixes a bug when "'Await' expression is not allowed in formal parameters
of an async function" is thrown for "await" encountered in a function
definition assigned to a default function parameter.

Fixes loading of https://excalidraw.com/
2024-09-08 17:44:39 +02:00
Francesco Gazzetta 7af940dab3 LibGfx: Fix inconsistent skia includes
The "include/" #include prefix is not used anywhere else in the
codebase, and does not work with distro packages.
2024-09-08 16:25:19 +02:00
Timothy Flynn 0a482e1a53 WebContent+WebDriver: Properly define and invoke stubbed methods
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
2024-09-08 09:01:25 -04:00
Han d1ba317e22 WebDriver: Add Routes, IPC definitions, and boilerplates
Added the following Routes, IPC definitions, and boilerplates for the
missing endpoints:

- Switch To Frame
- Switch To Parent Frame
- Element Clear
- Element Send Keys
2024-09-08 12:59:06 +01:00
Kuba314 f3a6a589c8 LibWeb: Consider last resort font in font list
Getting the first font in a font cascade list with an empty font list
results in an OOTB index error. If the font list is empty, the last
resort font should be returned instead.
2024-09-08 13:43:15 +02:00
Andreas Kling b3f77e4769 LibJS: Don't copy current program counter into new execution contexts
This didn't make any sense, and was already handled by pushing a new
execution context anyway.

By simply removing these bogus lines of code, we fix a bug where
throwing inside a function whose bytecode was shorter than the calling
function would crash trying to generate an Error stack trace (because
the bytecode offset we were trying to symbolicate was actually from
the longer caller function, and not valid in the callee function.)

This makes --log-all-js-exceptions less crash prone and more helpful.
2024-09-08 11:33:50 +02:00
sideshowbarker 0c77b3bf59 Tests: Allow specifying a build preset for rebaseline-libweb-test
This change enables using the rebaseline-libweb-test script with Debug
and Sanitizer builds — and allows specifying which build to use when
using rebaseline-libweb-test to generate new test-expectations files.

The mechanism used is to check the BUILD_PRESET environment variable.

Otherwise, without this change, there’s no way to use the
rebaseline-libweb-test script with Debug and Sanitizer builds — except
by manually hacking the script locally to hardcode a directory name.
2024-09-08 09:46:56 +02:00
Timothy Flynn 16d003c563 LibWeb: Allow modifying non-editable text selections with the keyboard
This permits the user to use shift and the arrow/home/end keys to mutate
the document selection. Arrow key presses on non-editable text without
the shift key held has no effect.

This behavior differs browser-to-browser. The behavior here most closely
matches Firefox, though all browsers support this to some degree.
2024-09-08 09:46:18 +02:00
Timothy Flynn fc37c4ad40 LibWeb: Only set the editable text cursor position if necessary
When the user clicks on a text node, the event handler sets the cursor
position to the location that was clicked. But it would then be set back
to 0 in the DOM node's focus handler. Leave the cursor alone, unless the
the DOM node was never set as the cursor position node (which will occur
when the user clicks on the DOM node, but outside the shadow text node).
In that case, move the cursor to the end of the text node.

The end result here is that the cursor is placed where the user clicked,
or set to the end of node if the user clicked outside of the shadow text
node.
2024-09-08 09:46:18 +02:00
Tim Ledbetter 48e5d28ec9 LibWeb: Resolve HTMLFormElement.action relative to document base URL
Rather than returning a relative URL, an absolutized URL is now
returned relative to the document base URL
2024-09-08 09:45:57 +02:00
Tim Ledbetter 33c62be7f9 LibWeb: Implement HTMLInputElement.formAction 2024-09-08 09:45:57 +02:00
Tim Ledbetter c25dda767e LibWeb: Return document URL if formAction attribute is missing or empty
This change also ensures that relative URLs are resolved relative to
the document's base URL.
2024-09-08 09:45:57 +02:00
Timothy Flynn f83d082980 LibWebView: Alternate the color of inspector table rows
This makes large tables a bit easier to read.
2024-09-08 09:45:39 +02:00
Timothy Flynn f3bdee272b LibWeb: Assign native colors to input, text, and select elements
This allows rendering the elements with a dark color in dark mode. We
must also assign a `fill` color to the <select> element's chevron SVG
to match the text color.
2024-09-08 09:45:39 +02:00
Timothy Flynn 9cd34a7d80 UI/AppKit: Re-order field designators to be in declaration order
This is required by C++, but for some reason, only started causing a
compiler error today.
2024-09-08 09:45:39 +02:00
Andreas Kling 7df4365e40 LibWeb: Only invalidate style & DOM version if attribute really changes
When setting an element attribute to the value it already had, we don't
need to update style or invalidate anything that depends on the DOM
version counter.

This was a source of much pointless busywork.
2024-09-08 09:45:31 +02:00
Andreas Kling ddbfac38b0 LibWeb: Note what's causing a style invalidation to happen
You can now build with STYLE_INVALIDATION_DEBUG and get a debug stream
of reasons why style invalidations are happening and where.

I've rewritten this code many times, so instead of throwing it away once
again, I figured we should at least have it behind a flag.
2024-09-08 09:45:31 +02:00
Andreas Kling 1f5c49f40d LibWeb: Make CSS::is_inherited_property(PropertyID) go fast
Instead of switching on the PropertyID and doing a boatload of
comparisons, we reorder the PropertyID enum so that all inherited
properties are in two contiguous ranges (one for shorthands,
one for longhands).

This replaces the switch statement with two simple range checks.

Note that the property order change is observable via
window.getComputedStyle(), but the order of those properties is
implementation defined anyway.

Removes a 1.5% item from the profile when loading https://hemnet.se/
2024-09-08 09:45:31 +02:00
Jamie Mansfield 0fab3d3b62 LibWeb: MathMLElement includes ElementCSSInlineStyle
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
2024-09-07 19:44:56 +02:00
Jamie Mansfield 48366ddddf LibWeb/WebAssembly: Use a debug flag for dbgln calls
This prevents the horrendous console spam when functions are resolved,
e.g. on the Royal Albert Hall website.
2024-09-07 19:44:23 +02:00
Andreas Kling b10016d914 LibWeb+LibGfx: Optimize generation of alpha mask from bitmap
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
It would be nice if we could somehow move this work to the GPU, but even
with some basic local optimization (mostly coalescing bounds checks and
inlining pixel data access), this knocks a 13% item down to 9% in a
profile of loading https://vercel.com/
2024-09-07 14:35:29 +02:00
Andreas Kling f647d190a3 LibWeb: Avoid synchronous layout when getting scroll box of root element
When accessed on the root/document element, the following properties are
derived from the viewport, not layout-dependent metrics:

- scrollLeft
- scrollTop
- scrollWidth
- scrollHeight

We now avoid synchronous layout in such cases. This was causing some
unnecessary layout work when loading https://vercel.com/
2024-09-07 14:35:29 +02:00
Tim Ledbetter b140206a91 LibWeb: Don't crash when calling getBBox() on the outermost SVG element 2024-09-07 14:35:02 +02:00
Tim Ledbetter 7a26de7464 LibWeb: Allow SVGElement.ownerSVGElement to cross shadow boundary 2024-09-07 14:35:02 +02:00
Andreas Kling 44e4ea3d7a LibWeb: Cache the qualified layer name in CSSRule
This makes cascade layer filtering take <2% of CPU time when loading
https://vercel.com instead of 30%.
2024-09-07 13:23:55 +02:00