Commit graph

26354 commits

Author SHA1 Message Date
Annya
bea7eec518 LibWeb/CSS: Implement revert-layer
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
With the introduction of the cascade layer, the 5th CSS-wide keyword,
`revert-layer`, has been added.
2024-09-11 22:30:20 +01:00
Asutosh Variar
229b64a4b7 Everywhere: Convert from_string_view -> from_string_literal where static 2024-09-11 10:59:04 +01:00
Aliaksandr Kalenik
4eb16b144e LibWeb: Skip abspos boxes layout in intrinsic sizing mode
Some checks are pending
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
CI / Lagom (false, 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
Absolutely positioned boxes do not affect the size of the formatting
context box they belong to, so it's safe to skip their layout entirely
when calculating intrinsic size.
2024-09-11 07:59:52 +02:00
Aliaksandr Kalenik
90b8bfc04c LibWeb: Save layout mode inside formatting context object
FormattingContext::run() does not allow reentrancy, so it's safe to
save and access layout mode from FC object. This avoids need to drill it
through methods of a formatting context and makes it clear that this
value could never be changed after FC construction.
2024-09-11 07:59:52 +02:00
Aliaksandr Kalenik
623e358d7a LibWeb: Remove box argument from FormattingContext::run()
Root formatting context box is passed into constructor and saved in FC,
so it's possible to access it from there instead of passing the same
box into run().
2024-09-11 07:59:52 +02:00
Tim Ledbetter
67981af276 LibWeb: Don't group radio buttons from different trees together
Previously, we were searching for other radio buttons from the document
root, rather than the element root.
2024-09-11 07:59:29 +02:00
sideshowbarker
51528ec677 LibWeb: Normalize all WebIDL definition lines to four leading spaces
This change takes all existing WebIDL files in the repo that had
definition lines without four leading spaces, and fixes them so they
have four leading spaces.
2024-09-10 21:16:53 +01:00
Tim Ledbetter
f9282f65d3 LibWeb: Treat dates and times with repeated separators as invalid
These would previously be treated as valid by the value sanitization
algorithm.
2024-09-10 15:59:30 -04:00
Tim Ledbetter
0de3145071 LibWeb: Don't crash when determining slot element auto directionality 2024-09-10 15:59:01 -04:00
Tim Ledbetter
1b74104c17 LibWeb: Make input type state change handling specification compliant
This change ensures that the value sanitization algorithm is run and
the text cursor is set to the correct position when the type attribute
of an input is changed.
2024-09-10 16:12:58 +01:00
Tim Ledbetter
2d7547921b LibWeb: Don't crash when normalizing a local datetime with a T separator 2024-09-10 16:12:58 +01:00
Tim Ledbetter
eb4e40bc49 LibWeb: Use correct value when parsing datetime-local input type 2024-09-10 16:12:58 +01:00
Tim Ledbetter
c4b82318f4 LibWeb: Ensure value sanitization algorithm trims whitespace if needed
Previously, the value sanitization algorithm would not trim whitespace
for inputs of type URL or email, if they didn't also contain any
newlines.
2024-09-10 16:12:58 +01:00
Andreas Kling
87056ee0d2 LibWeb: Bucket CSS rules by pseudo-element
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
Instead of throwing all pseudo-element rules in one bucket, let's have
one bucket per pseudo-element.

This means we only run ::before rules for ::before pseudo-elements,
only ::after rules for ::after, etc.

Average style update time on https://tailwindcss.com/ 250ms -> 215ms.
2024-09-10 16:54:40 +02:00
Andreas Kling
d22228ab93 LibWeb: Bail early from doomed pseudo-element style computation
Once we know the final value of the `content` property for a
pseudo-element, we can bail early if the value is `none` or `normal`
(note that `normal` only applies to ::before and ::after).

In those cases, no pseudo-element will be generated, so everything
that follows in StyleComputer would be wasted work.

This noticeably improves performance on many pages, such as
https://tailwindcss.com/ where style updates go from 360ms -> 250ms.
2024-09-10 15:19:55 +02:00
Andreas Kling
e399b472e9 LibWeb: Make CSS::StyleProperties copy-on-write internally
This makes the way we've implemented the CSS `revert` keyword a lot less
expensive.

Until now, we were making a deep copy of all property values at the
start of each cascade origin. (Those are the values that `revert` would
bring us back to if encountered.)

With this patch, the revert property set becomes a shallow copy, and we
only clone the property set if the cascade ends up writing something.

This knocks a 5% profile item down to 1.3% on https://tailwindcss.com
2024-09-10 13:51:28 +02:00
Andreas Kling
af68771dda AK+LibURL: Move CopyOnWrite<T> from LibURL to AK 2024-09-10 13:51:28 +02:00
Douwe Zumker
d6d94ba8cb LibWebView: Add GoogleScholar search engine to selection menu 2024-09-10 10:43:17 +01:00
Gingeh
4a3a9e6ec4 LibWeb: Implement justify-*: left/right 2024-09-10 10:40:07 +01:00
Andreas Kling
80e37db280 LibGfx: Cache the family name in TypefaceSkia
Instead of asking Skia for the family name every time we're called,
just cache the string once and make subsequent calls fast.

This knocks a 3.2% item off the profile entirely on
https://tailwindcss.com (at least on macOS with the CoreText backend)
2024-09-10 11:03:46 +02:00
Andreas Kling
84ec690d90 LibGfx: Cache code point -> glyph ID lookups in TypefaceSkia
This brings back the optimization we had in the old OpenType
implementation where we cache lookup tables for code point / glyph ID
mappings.

This noticeably improves performance on https://tailwindcss.com/ by
knocking an 8% profile item down to 0.2%. :^)
2024-09-10 11:03:46 +02:00
Aliaksandr Kalenik
2aa07e0e65 LibWeb: Do not try to load a font if format detection has failed
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
Skia is more permissive when it comes to font loading, compared to our
own OpenType implementation, which it has superseded, parsing an invalid
TTF does not result in an error but rather produces a font that is
incorrectly displayed. This change updates the FontLoader to address
this behavior and to stop attempting to parse a font as a last resort
when format detection has failed.

Fixes regression on x.com when text is not displayed introduced in
a9d5a99568
2024-09-10 07:40:25 +02: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
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
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
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