Commit graph

35145 commits

Author SHA1 Message Date
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
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 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
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
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
Andreas Kling 95bd0602ba LibWeb: Keep custom properties from all cascade layers
Before this change, we were cascading custom properties for each layer,
and then replacing any previously cascaded properties for the element
with only the set from this latest layer.

The patch fixes the issue by making each pass of the custom property
cascade add to the same set, and then finally assigning that set of
properties to the element.
2024-09-07 12:37:15 +02:00
Andrew Kaster 237bcbff36 LibWeb: Add ServiceWorker discarded flag to ESO
Looking at the spec it doesn't seem like there's a chance for a service
worker client to be an environment but not an environment settings
object. In the case that that changes in the implementation, we can
move it.
2024-09-07 11:37:49 +02:00
Andrew Kaster 0ece40c466 LibWeb: Add service worker client to ServiceWorkerContainer 2024-09-07 11:37:49 +02:00
Andrew Kaster ade4fc1779 LibWeb: Remove obsolete PlatformObject::global_object() API 2024-09-07 11:37:49 +02:00
Andrew Kaster 02a56f6480 LibWeb: Remove uses of obsolete PlatformObject::global_object()
This API is a relic from the time when it was important for objects to
have easy access to the Window, and to know it was the global object.

We now have more spec-related concepts like relevant_global_object and
current_global_object to pull the Window out of thin air.
2024-09-07 11:37:49 +02:00
Andrew Kaster 4df280689b LibWeb: Add oncontrollerchange to ServiceWorkerContainer 2024-09-07 11:37:49 +02:00
Andrew Kaster 2667726b74 LibWeb: Add WorkerNavigator.serviceWorker API
This simply adds a ServiceWorkerContainer object to the WorkerNavigator.
2024-09-07 11:37:49 +02:00
Tim Ledbetter 7c953552b7 UI: Add the --disable-scripting option to disable scripting by default 2024-09-07 11:37:41 +02:00
Gingeh 1b8c0cd368 LibWeb: Fix rendering of counter-clockwise arcs 2024-09-07 11:11:31 +02:00
Timothy Flynn fc809f9755 LibWebView: Add context menu support to the Inspector's cookie table
The menu can currently support deleting a specific cookie or all cookies
for the current page.
2024-09-07 11:10:27 +02:00
Timothy Flynn 3c5650f846 LibWebView: Add a storage tab to the Inspector to manage cookies
This adds a storage tab which contains just a cookie viewer for now. In
the future, storage like Local Storage and Indexed DB can be added here
as well.

In this patch, the cookie table is read-only.
2024-09-07 11:10:27 +02:00
Timothy Flynn 693af180dd LibWebView: Ensure manually expired cookies are purged from the database
Cookies are typically deleted by setting their expiry time to an ancient
time stamp (i.e. this is how WebDriver is required to delete cookies).

Previously, we would update the cookie in the cookie jar, which would
mark the cookie as dirty. We would then purge expired cookies from the
jar's transient storage, which removed the cookie from the dirty list.
If the cookie was also in the persisted storage, it would never become
expired there as it was no longer in the dirty list when the timer for
synchronization fired.

Now, we don't remove any cookies from the transient dirty list when we
purge expired cookies. We hold onto the dirty cookie until sync time,
where we now update the cookie in the persisted storage *before* we
delete expired cookies.
2024-09-07 11:10:27 +02:00
Timothy Flynn 2c35e272ba LibWebView: Migrate the Inspector's HTML to its own HTML file
It's getting a bit unwieldy to maintain as an inlined string. Move it to
its own file so it can be edited with syntax highlighting and other IDE
features.
2024-09-07 11:10:27 +02:00
Timothy Flynn 5eda629326 LibUnicode: Remove unused emoji support methods 2024-09-06 15:42:33 -04:00
Aliaksandr Kalenik 0244859ab7 LibGfx+Ladybird: Remove unused Emoji.h and Emoji.cpp 2024-09-06 16:56:20 +02:00