Commit graph

34645 commits

Author SHA1 Message Date
Shannon Booth
ffe070d7f9 LibWeb+LibURL: Use URL paths directly for comparison
This matches the text of the spec a little more closely in many cases
and is also more efficient than serializing the URL path.
2024-08-05 09:58:13 +02:00
Tim Ledbetter
ea68bdef26 LibWeb: Return error on modification of a computed CSS style declaration
Previously, calling `setProperty` or `removeProperty` from JS on a
CSSStyleDeclaration returned from `getComputedStyle()` would return
null. We now return a NoModificationAllowedError instead, which aligns
our implementation with the specification.
2024-08-05 09:55:50 +02:00
Andreas Kling
08d60d7521 LibWeb: Make HTML::Task IDs a sequential, distinct numeric type
This also fixes a bug where task IDs were being deallocated from the
wrong IDAllocator. I don't know if it was actually possible to cause any
real trouble with that mistake, nor do I know how to write a test for
it, but this makes the bug go away.
2024-08-05 09:12:07 +02:00
Andreas Kling
0e1256e5a4 LibWeb: Make requestAnimationFrame() callback IDs sequential
This is required by the spec, so let's stop returning random IDs in
favor of a simple sequential integer sequence.
2024-08-05 09:12:07 +02:00
Jamie Mansfield
a034d1e675 LibWeb/HighResolutionTime: Add missing visit to Performance
This should fix the CI :^)
2024-08-04 20:33:22 +02:00
Jamie Mansfield
bedb626c29 LibWeb: Set script force async to false when async changes 2024-08-04 19:25:29 +01:00
Jamie Mansfield
77c41a82be LibWeb: Script force async flag should default to true
See:
 - http://wpt.live/html/semantics/scripting-1/the-script-element/async_001.htm
2024-08-04 19:25:29 +01:00
Shannon Booth
fdf4f1e887 LibURL: Validate for invalid _domain_ code points for non-opaque domains
We were previously not checking for C0 control, U+0025 (%), or U+007F
DELETE.

This makes another good set of URL tests in WPT pass :^)
2024-08-04 18:29:06 +01:00
Shannon Booth
f511c0b441 LibURL+LibWeb: Do not percent decode in password/username getters
Doing it is not part of the spec. Whenever needed, the spec will
explicitly percent decode the username and password.

This fixes some URL WPT tests.
2024-08-04 12:59:02 +01:00
Andreas Kling
a10610a1ca LibWeb: Don't crash on CSS all: revert
Not every value in a StyleProperties will be non-null by the time we
perform `revert`, so let's make a specialized function for reverting a
property instead of using the path that requires the value to be
non-null.
2024-08-04 11:49:44 +02:00
Tim Ledbetter
96c0cbf584 LibWeb: Ensure ParentNode.getElementsByClassName() matches all classes 2024-08-04 10:39:17 +02:00
Colin Reeder
14267b5d63 LibWeb: Add stub implementation of performance.navigation 2024-08-04 10:38:42 +02:00
Colin Reeder
cca03e484b LibWeb: Also invalidate placeholder style on focus change 2024-08-04 10:38:09 +02:00
Shannon Booth
a661daea71 LibURL: Don't consider file:// URL hosts as always opaque
Which was resulting in file URL hosts not being correctly percent
decoded.
2024-08-04 10:37:33 +02:00
Shannon Booth
dd7c720657 LibURL: Remove note about bare-boned URL host parsing
It's not so bare-boned any longer :^)
2024-08-04 10:37:33 +02:00
Timothy Flynn
e75ba44f37 LibProtocol+RequestServer: Add IPC to dump RequestServer connection info
This was available on Serenity by sending SIGINFO to RequestServer. Add
an IPC so we may see this info while running the browser.
2024-08-03 15:53:07 -04:00
Aliaksandr Kalenik
fa605ef225 LibWeb: Fix OOB access in "text-overflow: ellipsis" clip
Fixes out of bound access to glyph run when `last_glyph_index` is 0.

Fixes crashing on https://github.com/LadybirdBrowser/ladybird/pulls
2024-08-03 19:45:41 +02:00
Tim Ledbetter
c0f30f31d1 LibXML: Include line and column numbers in parse error messages 2024-08-03 18:23:36 +02:00
Tim Ledbetter
82ed253477 LibWeb: Match class selectors case insensitively in quirks mode
This align our implementation with the CSSWG Selectors Level 4
specification.
2024-08-03 16:45:23 +02:00
Tobias Christiansen
da7f0897d1 LibWeb: Implement "text-overflow" property
The "text-overflow" property affects text that may get clipped if it is
larger than its container and does not do any line breaks.
The ellipsis character gets added to the end and the rest of the text
gets trunctated if the property is set to "ellipsis".
This patch implements this behavior in the InlineFormattingContext. :^)

The "text-overflow" property is also added  to the
getComputedStyle-print-all test.
2024-08-03 10:04:38 +01:00
Tobias Christiansen
794069b3cf LibWeb: Add plumbing for new "text-overflow" CSS property
This patch adds the new "text-overflow" CSS property to all the
relevant places.
2024-08-03 10:04:38 +01:00
Tobias Christiansen
a8d3c077ea LibWeb: Add "text-overflow" property to code generation
The CSS property "text-overflow" as well as its valid identifiers are
added to the relevant json files for code generation
2024-08-03 10:04:38 +01:00
Andreas Kling
e746b2b133 LibWeb: Cache the Document's node navigable when possible
To avoid expensive lookups, we now cache a weak pointer from document to
the last known node navigable. Before using the cache, we validate that
the document is still the navigable's active document.
2024-08-02 21:59:41 +02:00
Andreas Kling
936b76f36e LibURL: Make URL a copy-on-write type
This patch moves the data members of URL to an internal URL::Data struct
that is also reference-counted. URL then uses a CopyOnWrite<T> template
to give itself copy-on-write behavior.

This means that URL itself is now 8 bytes per instance, and copying is
cheap as long as you don't mutate.

This shrinks many data structures over in LibWeb land. As an example,
CSS::ComputedValues goes from 3024 bytes to 2288 bytes per instance.
2024-08-02 20:37:40 +02:00
Andreas Kling
c282138fd0 LibWeb: Make CSS::PercentageOr<T> non-virtual
This shrinks each instance of PercentageOr by 8 bytes and avoids virtual
dispatch when resolving calc() values. It's a win-win!

Many data structures shrink as a result. An example is ComputedValues
which goes from 3376 bytes to 3024 bytes per instance.
2024-08-02 20:37:40 +02:00
Andreas Kling
b42b7c8dd0 LibWeb: Use bitmaps for important/inherited bits in StyleProperties
This avoids padding the style value array, shrinking StyleProperties
from 4368 bytes to 2288 bytes per instance.
2024-08-02 20:37:40 +02:00
Andreas Kling
c288bfb404 LibWeb: Only remember source CSSStyleDeclaration for animation-name
We were saving to source declarations for *every* property, even though
we only ever looked it up for animation-name.

This patch gets rid of the per-property source pointer and we now keep
a single pointer to the animation-name source only.

This shrinks StyleProperties from 6512 bytes to 4368 bytes per instance.
2024-08-02 20:37:40 +02:00
Timothy Flynn
faebbbc281 LibWeb: Move the navigable's cursor position to be owned by the document
Navigables are re-used for navigations within the same tab. Its current
ownership of the cursor position is a bit ad-hoc, so nothing in the spec
indicates when to reset the cursor, nor do we manually do so. So when a
cursor update happens on one page, that cursor is retained on the next
page.

Instead, let's have the document own the cursor. Each navigation results
in a new document, thus we don't need to worry about resetting cursors.

This also makes many of the callsites feel nicer. We were previously
often going from the node, to the document, to the navigable, to the
cursor. This patch removes the navigable hop.
2024-08-02 18:40:39 +02:00
Timothy Flynn
f8d83b2922 LibWeb: Remove needless virtual qualifiers from EditEventHandler
This class does not inherit from any class, nor does any other class
inherit from EditEventHandler.
2024-08-02 18:40:39 +02:00
BenJilks
963cf1c2c4 LibWeb: Add additional padding to the end of the scrollable overflow
Adds additional padding to the end-side of the scrollable overflow
rectangle as necessary to enable a scroll position that satisfies
the requirements of `place-content: end` alignment.
2024-08-02 08:07:56 +02:00
Timothy Flynn
40b2d24d55 LibWeb: Support ctrl/cmd-clicking a link to open it in a new tab
The spec does not define activation behavior of ctrl/cmd clicks, so we
have to go a bit ad-hoc here. When an anchor element is clicked with the
cmd (on macOS) or ctrl (on other platforms) modifier pressed, we will
skip activation of that element and pass the event on to the chrome. We
still dispatch the event to allow scripts to cancel the event.
2024-08-02 08:07:00 +02:00
Timothy Flynn
c2d5e30a35 LibWeb: Remove debug spam when clicking a link 2024-08-02 08:07:00 +02:00
Timothy Flynn
facaf953eb LibWeb+WebContent: Add a page hook to invoke the did-click-link IPC 2024-08-02 08:07:00 +02:00
Timothy Flynn
3ff965d672 WebContent: Remove unnecessary [[maybe_unused]] attributes
Noticed while copy-pasting this method to a did-click-link method.
2024-08-02 08:07:00 +02:00
Timothy Flynn
71b25e3e5a LibWeb: Define a helper constant for the platform ctrl-ish key
For all intents and purposes, the cmd (super) key on macOS should be
treated as the ctrl key.
2024-08-02 08:07:00 +02:00
Timothy Flynn
ee00730225 LibUnicode+LibJS: Normalize spaces in formatted date-time strings
ICU 72 began using non-ASCII spaces in some formatted date-time strings.
Every major browser has found that this introduced major breakage in web
compatibility, as many sites and tools expect ASCII spaces. This patch
removes these non-ASCII spaces in the same manner as the major engines.
Such behavior is also tested by WPT.
2024-08-02 08:05:52 +02:00
Aliaksandr Kalenik
9e22233be9 LibWeb: Enable fast path of animation invalidation for pseudo-elements
3abd3ef5e2 made possible using fast
invalidation path for pseudo-element by saving previously computed style
in DOM::Element.
2024-08-02 08:05:31 +02:00
Aliaksandr Kalenik
4049cce40c LibWeb: Add slots for pseudo-elements animation cache in Animatable
Fixes the bug when animation does not run at all if an element has a
pseudo-element, because both of them use the same cache.
2024-08-02 08:05:31 +02:00
Tim Ledbetter
2854113ee6 LibWebView+WebContent: Add a --force-cpu-painting option
This option forces Skia to use the CPU backend rather than using the
GPU.
2024-08-01 23:26:45 +01:00
Tim Ledbetter
ae51fbd5de WebDriver: Use correct WebDriver IPC path argument name
Previously, the incorrect name for this argument  was being used when
attempting to launch `headless-browser`.
2024-08-01 16:40:19 -04:00
Timothy Flynn
ce5f2861d8 LibWebView+UI: Allow profiling any helper process
This removes the --enable-callgrind-profiling flag, and replaces it with
a --profile-process=<process-name> flag. For example:

    ladybird --profile-process=WebContent
    ladybird --profile-process=RequestServer

This allows profiling any helper process with callgrind.
2024-08-01 15:40:49 +02:00
Timothy Flynn
7106a7bd58 LibWebView+UI: Allow debugging any helper process
This removes the --debug-web-content flag, and replaces it with a
--debug-process=<process-name> flag. For example:

    ladybird --debug-process=WebContent
    ladybird --debug-process=RequestServer

This allows attaching gdb to any helper process.
2024-08-01 15:40:49 +02:00
Aliaksandr Kalenik
bbc89a383d LibWeb: Fix overflow clip when "complicated" CSS transform is used
Overflow clipping is currently implemented as:
1. Create clip frame for each box with hidden overflow
2. Calculate clip rect for each clip frame by intersecting padding boxes
   of all boxes with hidden overflow in containing block chain
3. Assign enclosing clip frame (closest clip frame in containing block
   chain) to each PaintableBox
4. Apply clip rect of enclosing clip frame in Paintable::before_paint()

It breaks when any CSS transform other than simple translation is lying
between box with hidden overflow and a clipped box, because clip
rectangle will be applied when transform has already changed.

The fix is implemented by relying on the following rule:
"For elements whose layout is governed by the CSS box model, any value
other than none for the transform also causes the element to establish
a containing block for all descendants."

It means everything nested into a stacking context with CSS transform
can't escape its clip, so it's safe to apply its clip for all children.
2024-08-01 12:03:13 +02:00
Aliaksandr Kalenik
e75791d9e1 LibWeb: Add missing border-radius clip in refresh_clip_state()
Adds missing clip of border-radius for clip frame. While we have already
accounted for the border-radius of containing blocks, the box itself was
not being clipped.
2024-08-01 12:03:13 +02:00
Aliaksandr Kalenik
1829ec56e2 LibWeb: Apply scroll offset to transform origin in PushStackingContext 2024-08-01 12:03:13 +02:00
Aliaksandr Kalenik
c47ec26bcd LibWeb: Delete m_clipping_overflow in PaintableBox 2024-08-01 12:03:13 +02:00
Diego Frias
23cfee2205 LibWasm: Clean up module sections API
Remove `for_each_section_of_type` in favor of making the module's
sections defined as distinct fields. This means it is no longer possible
to have two of the same section (which is invalid in WebAssembly, for
anything other than custom sections).
2024-08-01 11:44:07 +02:00
Shannon Booth
9f24176cac HTML: Partially implement HTMLInputElement's selection{Start,End}
Now that the implementation is in FormAssociatedElement, the
implementation in HTMLInputElement is effectively just a passthrough,
with some minor differences to handle small behavioural quirks between
the two (such as the difference in nullability of types).
2024-08-01 11:42:39 +02:00
Shannon Booth
62bf428a7f HTML: Put HTMLTextAreaElement selection helpers in FormAssociatedElement
This will allow us to more closely follow the spec and share these
functions with HTMLInputElement.
2024-08-01 11:42:39 +02:00
Shannon Booth
28ed8e5d0f HTML: Add const qualified form_associated_element_to_html_element
Put the const cast in a common location to make the helper more
convenient to use.
2024-08-01 11:42:39 +02:00