Commit graph

63003 commits

Author SHA1 Message Date
Jamie Mansfield
5151f94d39 LibWeb/Fetch: Correct check for X-Method-Override
Previously the code was checking for X-Method.

See:
 - http://wpt.live/fetch/api/basic/request-forbidden-headers.any.html
2024-08-05 10:01:34 +02:00
Jamie Mansfield
f88e7bc5ee LibWeb/Fetch: Add Set-Cookie as a forbidden header name
See:
 - https://github.com/whatwg/fetch/commit/50d77e6
 - http://wpt.live/fetch/api/request/request-headers.any.html
2024-08-05 10:01:34 +02:00
Shannon Booth
cc55732332 LibURL+Everywhere: Only percent decode URL paths when actually needed
Web specs do not return through javascript percent decoded URL path
components - but we were doing this in a number of places due to the
default behaviour of URL::serialize_path.

Since percent encoded URL paths may not contain valid UTF-8 - this was
resulting in us crashing in these places.

For example - on an HTMLAnchorElement when retrieving the pathname for
the URL of:

http://ladybird.org/foo%C2%91%91

To fix this make the URL class only return the percent encoded
serialized path, matching the URL spec. When the decoded path is
required instead explicitly call URL::percent_decode.

This fixes a crash running WPT URL tests for the anchor element on:

https://wpt.live/url/a-element.html
2024-08-05 09:58:13 +02:00
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
96bb8fe944 UI/Qt: Add a debug menu item to dump RequestServer connection info 2024-08-03 15:53:07 -04:00
Timothy Flynn
b1433a8097 UI/AppKit: Add a debug menu item to dump RequestServer connection info 2024-08-03 15:53:07 -04: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
Timothy Flynn
62fa84865d UI/Qt: Unregister WebContentView instances just once
We already unregister the view in the ViewImplementation destructor. We
do not need to do so again in the WebContentView destructor.
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
e2c9e34050 Tests: Add ref-test for "text-overflow" 2024-08-03 10:04:38 +01: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
Timothy Flynn
5c73a31b4f LibWebView: Use an overflow-x value of 'auto' for Inspector containers
The Inspector looks a bit nicer if we don't paint the horizontal scroll
bars unless we need to.
2024-08-02 12:21:22 -04:00
Timothy Flynn
d2c775b0ca LibWebView: Improve scrolling of Inspector content containers
Currently, the feel of scrolling containers in the Inspector is a bit
awkward. We make the entire split-view container scrollable, then we
absolutely position the tab control buttons to force them to not scroll.
The result is that the scroll bar is painted over the tab controls, and
the tab content that we actually want to scroll has to scroll under the
tab controls. This never looked quite right.

It was basically:

    <div tab-container> <!-- Scrollable -->
        <div tab-controls /> <!-- Pinned to not be scrollable -->
        <div tab-content /> <!-- The part we actually want to scroll -->
    </div>

This patch moves the "scrollability" to just the tab content. We then
don't need to go out of our way to ensure only the content is actually
scrollable.

So we now have:

    <div tab-container> <!-- Not scrollable -->
        <div tab-controls /> <!-- Not pinned, uses normal layout -->
        <div tab-content /> <!-- Scrollable -->
    </div>
2024-08-02 12:21:22 -04:00
Sam Atkins
113b4da1df LibWebView: Sort vendor-prefixed properties last in the inspector
Previously, the legacy `-webkit-foo` properties would all be top of the
list, when they are generally not useful to inspect. Instead, put them
at the bottom, so that users can still see them if they want to, but
they're not in the way.
2024-08-02 08:51:52 -04: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
6a19cffdde WebDriver: Add a --force-cpu-painting option
This launches the browser withb the `--force-cpu-backend` option, which
forces Skia to use the CPU backend rather than the GPU.
2024-08-01 23:26:45 +01: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