Commit graph

35014 commits

Author SHA1 Message Date
Jamie Mansfield ea61e189eb LibWeb/SVG: Add missing SVGGElement IDL file 2024-08-17 07:41:04 +02:00
Jamie Mansfield e2f599ebee LibWeb/SVG: Implement <metadata> element 2024-08-17 07:40:45 +02:00
Jamie Mansfield b3fa8f0ce2 LibWeb/HTML: MathML's <ms> is a special tag
This is an omission I noticed while browsing some code :^)
2024-08-17 07:40:10 +02:00
Tim Ledbetter 1365289d98 LibWeb: Implement the setter for location.protocol 2024-08-17 07:39:58 +02:00
Shannon Booth 07940a89ca LibWeb: Handle cases with <template> on the HTML parsing stack
This appears to have been a bug in the spec which was later corrected -
so to fix the crash we can simply remove this assertion.

Fixes: #868
2024-08-16 22:38:18 +01:00
BenJilks 0d63269cb7 LibGfx+LibWeb: Use harfbuzz for text shaping
This replaces glyph positioning system with harfbuzz's shaping
algorithm. Adding support for bidirectional encoded text.
2024-08-16 22:28:34 +02:00
Ali Mohammad Pur 0d05ab2ad0 LibWasm: Allow all Value::to<Integral>() calls
This brings back the old behaviour of Value::to<short>() (and other
similar calls), which WASI depends on.
To make sure all similar issues are caught in the future, this commit
also introduces an static assertion in Value::to().
2024-08-16 21:03:10 +02:00
Jamie Mansfield e3b3041a0c LibWeb: Implement NavigatorStorage mixin interface
Co-authored-by: Tim Flynn <trflynn89@serenityos.org>
2024-08-16 11:22:09 -04:00
Jamie Mansfield 1b84062c74 LibWeb: Stub StorageManager idl interface 2024-08-16 11:22:09 -04:00
Colin Reeder 97d5cf4eef LibWeb: Add support for SVG display attribute 2024-08-16 12:12:09 +02:00
Timothy Flynn 73ca9516a9 LibJS: Remove the InitializeNumberFormat AO
The Initialize* AOs for Intl formatters were removed some time ago, and
the formatter construction steps are now inlined in the constructors
themselves. InitializeNumberFormat was the one remaining initializer we
still had laying around.
2024-08-15 17:21:00 -04:00
Timothy Flynn a1a368bb61 LibJS: Fix editorial rebasing errors in the ECMA-402 spec
This is the remainder of the editorial rebasing errors that were fixed
in:
https://github.com/tc39/ecma402/commit/3f029b0
2024-08-15 17:21:00 -04:00
Timothy Flynn c7dd4afd9c LibJS+LibUnicode: Update the Intl.DateTimeFormat constructor spec steps
This constructor has undergone a handful of editorial changes that we
fell behind on. But we weren't able to take the updates until now due to
a spec bug in those updates. See:
https://github.com/tc39/ecma402/commit/3f029b0

The result is that we can remove the inheritance of Intl::DateTimeFormat
from Unicode::DateTimeFormat; the former now contains the latter as an
internal slot.
2024-08-15 17:21:00 -04:00
Sam Atkins f518811f73 LibWeb: Use CSSKeywordValue for CSS-wide keywords
We previously had 4 single-instance StyleValues for these keywords.
CSS-Typed-OM expects them keywords to be exposed as CSSKeywordValue, so
it's simpler to treat them the same. The single-instance behaviour is
kept by having StyleValue::create() use a cached instance for each of
these.
2024-08-15 13:58:38 +01:00
Sam Atkins 6a74b01644 LibWeb: Rename "identifier" and "ValueID" to "Keyword" where correct
For a long time, we've used two terms, inconsistently:
- "Identifier" is a spec term, but refers to a sequence of alphanumeric
  characters, which may or may not be a keyword. (Keywords are a
  subset of all identifiers.)
- "ValueID" is entirely non-spec, and is directly called a "keyword" in
  the CSS specs.

So to avoid confusion as much as possible, let's align with the spec
terminology. I've attempted to change variable names as well, but
obviously we use Keywords in a lot of places in LibWeb and so I may
have missed some.

One exception is that I've not renamed "valid-identifiers" in
Properties.json... I'd like to combine that and the "valid-types" array
together eventually, so there's no benefit to doing an extra rename
now.
2024-08-15 13:58:38 +01:00
Sam Atkins 9559f0f123 LibWeb: Rename IdentifierStyleValue -> CSSKeywordValue
This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue
2024-08-15 13:58:38 +01:00
Sam Atkins 0e3487b9ab LibWeb: Rename StyleValue -> CSSStyleValue
This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue

No behaviour changes.
2024-08-15 13:58:38 +01:00
Sam Atkins 2e1f62681c LibWeb/CSS: Flatten ENUMERATE_STYLE_VALUE_TYPES macros
Being constrained by this macro is going to make it more difficult to
refactor our StyleValue types to match the Typed-OM spec, so let's
reintroduce the boilerplate for now.

No functional changes.
2024-08-15 13:58:38 +01:00
Timothy Flynn ca1257c6f9 LibJS+LibUnicode: Make the collation sensitivity default locale-aware
Note this happens to be 'variant' for every locale currently.
2024-08-15 13:44:32 +02:00
Timothy Flynn 78625c746d LibJS+LibUnicode: Make the collation punctation default locale-aware 2024-08-15 13:44:32 +02:00
Timothy Flynn eb8e516ed3 LibJS: Update Intl.Collator spec steps to the latest
The steps have been updated to indicate a few options that should be
defaulted based on locale preferences. Those steps have not yet been
implemented in this patch.
2024-08-15 13:44:32 +02:00
Timothy Flynn eb7e3583c9 LibJS+LibUnicode: Fully implement Intl.Collator with ICU
We were never able to implement anything other than a basic, locale-
unaware collator with the JSON export of the CLDR as it did not have
collation data. We can now use ICU to implement collation.
2024-08-15 13:44:32 +02:00
Aliaksandr Kalenik dc0d5da086 LibWeb: Remove ViewportPaintable::refresh_clip_frames()
After d0da377767 clip frame state is no
longer depends on scroll state, so it could be calculated only once for
each layout invalidation.
2024-08-15 09:45:07 +02:00
Aliaksandr Kalenik c4ce797366 LibWeb: Use scroll frame id in SVGSVGPaintable::before_children_paint()
A display list should not contain coordinates shifted by scroll offset.
Instead, "scroll frame id" needs to be used. In the future it's going to
allow us reuse a display list in cases when only scroll offsets need to
be updated.
2024-08-15 09:45:07 +02:00
Aliaksandr Kalenik 5b23190174 LibWeb: Remove scroll_offset() usage in PaintableWithLines
A display list should not contain coordinates shifted by scroll offset.
Instead, "scroll frame id" needs to be used. In the future it's going to
allow us reuse a display list in cases when only scroll offsets need to
be updated.
2024-08-15 09:45:07 +02:00
Tim Ledbetter c61262684b LibWeb: Return empty string if object element data URL is invalid 2024-08-15 09:44:35 +02:00
Tim Ledbetter 4f7a4d9c57 LibWeb: Return empty string if image element currentSrc URL is invalid 2024-08-15 09:44:35 +02:00
Jamie Mansfield bab086694a LibWeb: Support SRI for import maps
See:
- https://github.com/whatwg/html/commit/b2fdca1
2024-08-14 21:06:25 +01:00
Jelle Raaijmakers 124779a376 LibWeb: Implement the "fire a focus event" spec
We weren't setting the focus event's composed flag and view field
correctly.
2024-08-14 20:53:33 +01:00
Jamie Mansfield 9c4e80a3ec LibWeb/SVG: Implement default_tab_index_value for a element
Another FIXME bites the dust :^)
2024-08-14 20:39:35 +01:00
Aliaksandr Kalenik 9c13644cde LibWeb: Simplify ViewportPaintable::refresh_clip_state()
Removes code that accounts for clip frame's own overflow clip, because
it happens anyway on a first iteration of a loop through containing
blocks chain.
2024-08-14 21:04:46 +02:00
Aliaksandr Kalenik f9f39477a4 LibWeb: Fix clip for boxes nested into a stacking context with transform
Modifies a loop that collects clip rectangles to stop once a box with a
CSS transform is encountered, as its clip still needs to be considered.
2024-08-14 21:04:46 +02:00
sideshowbarker 23da1752b5 LibWeb/Fetch: Set HTTP status code on cached responses
This change causes HTTP status codes to be set on cached HTTP responses.

Otherwise, without this change, no status codes at all are set on cached
HTTP responses — which causes all cached responses to default to being
loaded/served with a 200 status code. And as a result of that, if the
cached response is from a 30x redirect, then without this change, when
that cached 30x response is loaded, we don’t follow the redirect —
because we see a 200 status, rather than the expected/original 30x.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/863

Note that this change also reverts the temporary workaround added in
https://github.com/LadybirdBrowser/ladybird/commit/f735c464d3f
(https://github.com/LadybirdBrowser/ladybird/pull/899).
2024-08-14 14:49:04 +02:00
Timothy Flynn 50dfaf8581 LibJS: Disallow grouping separators in formatted duration fields
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/68b00f3
2024-08-14 11:48:08 +02:00
Timothy Flynn 72f61396cd LibJS: Correctly display a negative sign on negative durations
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/adfc4a1
2024-08-14 11:48:08 +02:00
Timothy Flynn 300f8d3dbb LibJS: Impose limits on a valid duration
This is a normative change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/1104cad
https://github.com/tc39/proposal-temporal/commit/45462c4

Although our Temporal implementation is wildly out of date, this AO and
the changes to it are relied on in Intl.DurationFormat.
2024-08-14 11:48:08 +02:00
Timothy Flynn 78328ab83c LibJS: Disallow U+2212 MINUS SIGN in time zone offset strings
This is a normative change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/e7f1e5d
2024-08-14 11:48:08 +02:00
Bastiaan van der Plaat 517b1a2690 LibWeb: Add autocomplete property 2024-08-13 22:53:55 +01:00
Jelle Raaijmakers e7984a7711 LibWeb: Check presence of WWW-Authenticate header in fetch response
If a HTTP 401 response we get does not contain a `WWW-Authenticate`
header, we should not trigger the logic to ask the user for credentials
and retry the request.

This part is hinted at in a TODO / 'Needs testing' remark in the spec
but needs to be fleshed out. Raised an upstream issue to do so:

  https://github.com/whatwg/fetch/issues/1766

This fixes login forms triggering an infinite fetch loop when providing
incorrect credentials.

Co-Authored-By: Victor Tran <vicr12345@gmail.com>
2024-08-13 16:01:48 +01:00
BenJilks 1537d589ca LibWeb: Add start and end values to text-align
The `start` and `end` value set the text alignment based on the computed
value of `direction`. The default value of `text-align` is now `start`
instead of `left`.
2024-08-13 15:19:51 +01:00
BenJilks 82989554ab LibWeb: Use reverse direction on flex containers with rtl direction
If a flex container has `direction: rtl` set, reverse the row direction.
2024-08-13 15:19:51 +01:00
Colin Reeder c6975a1680 LibWeb: Use base URL for link loading 2024-08-13 14:34:15 +01:00
Shannon Booth ff71d8f2c9 LibURL+LibWeb: Pass a mutable reference URL to URL parser
If given, the spec expects the input URL to be manipulated on the fly
as it is being parsed, and may ignore any errors thrown by the URL
parser.

Previously, we were not exactly following the specs assumption here
which resulted in us needed to make awkward copies of the URL in these
situations.

For most cases this is not an issue. But it does cause problems for
situations where URL parsing would result in a failure (which is
ignored by the caller), and the URL is _partially_ updated
while parsing.

Such a situation can occur when setting the host of an href alongside a
port number which is not valid. It is expected that this situation will
result in the host being updates - but not the port number.

Adjust the URL parser API so that it mutates the URL given (if any), and
adjust the callers accordingly.

Fixes two tests on https://wpt.live/url/url-setters-a-area.window.html
2024-08-13 14:14:34 +02:00
Colin Reeder 00f75648e5 LibWeb: Update stylesheet media value when changing link media attribute 2024-08-13 14:12:55 +02:00
Colin Reeder b92abe5c26 LibWeb: Avoid calling matches before evaluate 2024-08-13 14:12:55 +02:00
Timothy Flynn f7fcde7f60 LibTest: Define test expectation macros without copying the input values
Currently, the following test case will actually copy both `a` and `b`
when the test macro is expanded:

    ByteBuffer a = { some large buffer };
    ByteBuffer b = { some other buffer };
    EXPECT_EQ(a, b);

This patch redefines the expectation macros to avoid copying.
2024-08-13 14:11:05 +02:00
Bastiaan van der Plaat e0c8a14fab LibWeb: Fix HTMLFrameElement noresize obsolete property typo 2024-08-13 14:08:34 +02:00
Bastiaan van der Plaat 4712f53dd7 LibWeb: Add HTMLImageElement lowsrc obsolete property 2024-08-13 14:08:34 +02:00
Bastiaan van der Plaat d1fad9869b LibWeb: Add HTMLObjectElement codebase obsolete property 2024-08-13 14:08:34 +02:00
Jelle Raaijmakers fe933b2057 LibWeb: Implement HTMLMediaElement.preload attribute
This implements the `preload` reflected attribute. No actual preloading
is going on yet.
2024-08-13 14:08:03 +02:00
Jamie Mansfield 77a30bad9f LibWeb/HTML: Implement HTMLImageElement.longDesc 2024-08-13 11:49:19 +01:00
Jamie Mansfield 45c2b1f62c LibWeb/HTML: Implement HTMLIFrameElement.longDesc 2024-08-13 11:49:19 +01:00
Shannon Booth d755a83c09 LibWeb: Actually set empty serialized query to OptionalNone
Because the type returned by to_string is a String, _not_ an
Optional<String>, the following code:

if (serialized_query.is_empty())
    serialized_query = {};

Was achieving nothing at all! Make sure that the type is an
Optional<String> so that we're not just setting an empty string to an
empty string.
2024-08-12 23:01:29 +01:00
Shannon Booth 1ba6dbd86c LibWeb: Use a stable sort for searching URLSearchParams
Quick sort is not a stable sort. This meant we had a subtle issue
implementing this portion of the spec comment:

 > The relative order between name-value pairs with equal names must
 > be preserved.

Switch to insertion sort which is a stable sort, and properly handles
keys which are the same.

Fixes 8 tests on  https://wpt.live/url/urlsearchparams-sort.any.html
2024-08-12 23:01:29 +01:00
Shannon Booth df4739d7ce LibWeb: Don't propogate small OOMs from URLSearchParams
Made easier now that URL percent encode after encoding is also not
throwing any errors. This simplfies a bunch of error handling.
2024-08-12 23:01:29 +01:00
Shannon Booth 4bb211ba88 LibURL: Make percent_encode_after_encoding infallible 2024-08-12 23:01:29 +01:00
Shannon Booth 264b5160c2 LibWeb: Implement value argument of URLSearchParams.has 2024-08-12 23:01:29 +01:00
Shannon Booth 5637dc43b2 LibWeb: Implement value argument of URLSearchParams.delete 2024-08-12 23:01:29 +01:00
Gasim Gasimzada 4a42c97f4d LibJS: Set empty prototype for console object 2024-08-12 17:21:01 +01:00
Aliaksandr Kalenik d0da377767 LibWeb: Make AddClipRect display list item account for scroll offset
Before this change AddClipRect was a "special" because it didn't respect
scroll frame offset and was meant to be recorded using viewport-relative
coordinates. The motivation behind this was to record a "final" clip
rectangle computed by intersecting all clip rectangles used by a clip
frame. The disadvantage of this approach is that it blocks us from
implementing an optimisation to reuse display list if the only change is
in the scroll offset, because any scroll offset change leads to
invalidating all AddClipRect items within a list.

This change aligns AddClipRect with the rest of display list items by
making it account for scroll frame offset. It required discontinuing
the recording of the intersection of all clip rectangles within a clip
frame and instead producing an AddClipRect for each of them.

A nice side effect is the removal of code that shifts clip rectangle by
`enclosing_scroll_offset()` in a bunch of places, because now it happens
automatically in `DisplayList::apply_scroll_offsets()`.
2024-08-12 18:20:13 +02:00
Shannon Booth 0b864bef60 LibTextCodec: Implement UTF8Decoder::to_utf8 using AK::String
String::from_utf8_with_replacement_character is equivalent to
https://encoding.spec.whatwg.org/#utf-8-decode from the encoding spec,
so we can simply call through to it.
2024-08-12 06:38:58 -04:00
Shannon Booth b3bf5c4ea8 AK: Add BOM handling to String::from_utf8_with_replacement_character 2024-08-12 06:38:58 -04:00
Maks Verver c68b8b5bda RequestServer: Fix compiling with -DREQUESTSERVER_DEBUG=ON 2024-08-12 02:27:48 +02:00
Jamie Mansfield 17c1e99ce4 LibWeb: Use keepalive maximum size in NavigatorBeacon
This is defined as 64 KiB in the fetch spec.

See:
 - https://wpt.live/beacon/beacon-basic.https.window.html
2024-08-11 20:07:10 +01:00
Jamie Mansfield 35047de1d8 LibWeb/Fetch: Add a constant for the keepalive maximum size 2024-08-11 20:07:10 +01:00
Gasim Gasimzada c5b8e75204 LibJS: Set configurable toStringTag property for console 2024-08-11 20:06:27 +01:00
Aliaksandr Kalenik dd8c693725 LibWeb: Unify scroll handling between viewport and scrollable boxes
This change causes the viewport to be treated as a "scroll frame,"
similar to how it already works for boxes with "overflow: scroll."
This means that, instead of encoding the viewport translation into a
display list, the items will be assigned the scroll frame id of the
viewport and then shifted by the scroll offset before execution. In the
future it will allow us to reuse a display list for repainting if only
scroll offset has changed.

As a side effect, it also removes the need for special handling of
"position: fixed" because compensating for the viewport offset while
painting or hit-testing is no longer necessary. Instead, anything
contained within a "position: fixed" element is simply not assigned
a scroll frame id, which means it is not shifted by the scroll offset.
2024-08-11 07:53:21 +02:00
Tim Ledbetter 5b09430c5e WebContent: Actually start WebDriver timeout timers
The timers added previously in #1021 had no effect, as they were never
started.
2024-08-10 23:18:08 +01:00
Alisson Lauffer d38b28b57b LibWeb: Replace "+" in value with a space while decoding search params 2024-08-10 10:39:43 +02:00
Shannon Booth 9c72fc9642 LibWeb: Actually run UTF-8 decode without BOM
This fixes a crash using URLSearchParams when provided a percent encoded
string which does not percent decode to valid UTF-8.

Fixes a crash running https://wpt.live/url/urlencoded-parser.any.html
2024-08-10 10:39:43 +02:00
Shannon Booth 84a09476ba LibURL: Update spec comment for validation error in authority state
See: https://github.com/whatwg/url/commit/3e8cd02bb
2024-08-10 10:39:43 +02:00
Shannon Booth 84a7fead0e LibURL: Make percent_encode return a String
This simplifies a bunch of places which were needing to error check and
convert from a ByteString to String.
2024-08-10 10:39:43 +02:00
Diego Frias c58665332e LibWasm: Ensure correct section ordering when parsing binary modules
There are (currently) no spec-tests ensuring that section ordering is
enforced, but it _is_ a part of the spec. A pull request to add this to
the specification testsuite has been opened at WebAssembly/spec#1775.
2024-08-10 10:39:10 +02:00
Aliaksandr Kalenik ea8d0304e9 LibWeb: Create clip and scroll frame trees separately for each navigable
While introducing clip and scroll frame trees, I made a mistake by
assuming that the paintable tree includes boxes from nested navigables.
Therefore, this comment in the code was incorrect, and clip/scroll
frames were simply not assigned for iframes:
// NOTE: We only need to refresh the scroll state for traversables
//       because they are responsible for tracking the state of all
//       nested navigables.

As a result, anything with "overflow: scroll" is currently not
scrollable inside an iframe

This change fixes that by ensuring clip and scroll frames are assigned
and refreshed for each navigable. To achieve this, I had to modify the
display list building process to record a separate display list for each
navigable. This is necessary because scroll frame ids are local to a
navigable, making it impossible to call
`DisplayList::apply_scroll_offsets()` on a display list that contains
ids from multiple navigables.
2024-08-10 10:38:12 +02:00
Tim Ledbetter 1b2f35c3af WebContent: Add timeouts to WebDriver window state modification methods 2024-08-10 10:37:43 +02:00
Tim Ledbetter fbff0ca6a8 WebContent: Abort WebDriver navigation if session timeout exceeded 2024-08-10 10:37:43 +02:00
Sam Atkins 80a20be176 LibWeb/CSS: Bring previous CSSRule parsing up to standard
GCPtrs instead of raw pointers, and logging when the media rule is
invalid.
2024-08-10 10:36:39 +02:00
Sam Atkins 9de73bf89b LibWeb/CSS: Parse gradient functions with TokenStream
They already used TokenStream for parsing the function parameters, but
this makes the `parse_foo_gradient()` functions themselves take a
TokenStream.
2024-08-10 10:36:39 +02:00
Sam Atkins 29d7aa9fc9 LibWeb/CSS: Parse url() functions with TokenStream 2024-08-10 10:36:39 +02:00
Sam Atkins d5f3a610ac LibWeb/CSS: Split out @keyframes parsing code
Changes are very minimal, this is just a code move.
2024-08-10 10:36:39 +02:00
Sam Atkins e5737232c0 LibWeb/CSS: Split out @supports parsing code 2024-08-10 10:36:39 +02:00
Sam Atkins 5b883929e0 LibWeb/CSS: Split out @namespace parsing code 2024-08-10 10:36:39 +02:00
Sam Atkins 16049db560 LibWeb/CSS: Split out @import parsing and convert it to TokenStream 2024-08-10 10:36:39 +02:00
Sam Atkins b9b2fd62b5 LibWeb/CSS: Parse builtin values using TokenStream 2024-08-10 10:36:39 +02:00
Sam Atkins 98963e0c9a LibWeb/CSS: Flatten parse_basic_shape_function() into only caller 2024-08-10 10:36:39 +02:00
Sam Atkins e5553d6d2f LibWeb/CSS: Make parse_color() take a TokenStream
This makes the parse_color_value() code a lot simpler.
2024-08-10 10:36:39 +02:00
Sebastian-Webster b0e3b28929 LibWebView: Add Ecosia search engine 2024-08-10 10:36:32 +02:00
Tobias Christiansen c3e69f2fc6 Inspector: Add "Fonts" tab
This adds another tab to the bottom tabs providing information
regarding the fonts computed for the currently selected DOM node.
2024-08-09 18:58:04 +01:00
Tobias Christiansen 5621f34062 LibWebView + WebContent: Add fonts to be transferable to inspector
This patch adds all the needed plumbing to transfer information
regarding fonts of the selected DOM node to the inspector.
2024-08-09 18:58:04 +01:00
Tobias Christiansen 049a261782 LibGfx: Add for_each_font_entry to FontCascadeList
This way there is a way to iterate over all the fonts in the object.
2024-08-09 18:58:04 +01:00
simonkrauter dd5550dde3 LibWebView: Remove early exit in InspectorClient::inspect()
This early exit prevents to show the current DOM in the inspector, when
the inspector was already opened.

Fixes #990
2024-08-09 17:19:56 +01:00
Jelle Raaijmakers 7a783d3a89 LibWeb: Account for intrinsic width or height in flex base size
In calculating the base size of a flex item, we have a piece of ad-hoc
code that deals with an item that does have an instrinsic aspect ratio,
but not a cross size to resolve that ratio against. In determining the
actual flex item size however, we also take into account the minimum
content width and height, which assumes the box' intrinsic width or
height when available. This would break having an image as a flex item,
which gets stretched to its maximum size within the flex container
instead of the flex item being shrunk to the instrinsic size of the
image.

Fix this by only stretching flex items that do not have an instrinsic
width nor height set.
2024-08-09 17:01:50 +01:00
Jelle Raaijmakers d82f8a4b16 LibWeb: Update two spec URIs
No functional changes.
2024-08-09 17:01:50 +01:00
Jelle Raaijmakers 89d21335a1 LibWeb: Remove unused includes
No functional changes.
2024-08-09 17:01:50 +01:00
Alec Murphy b3a67ee088 LibWeb: Skip trim trailing whitespace if user is typing
This PR stops the cursor from disappearing while typing trailing spaces
in a text input box.
2024-08-09 16:57:14 +01:00
Gasim Gasimzada 8545756d17 LibJS: Treat passing undefined as no argument for console labels
- Affects time, timeLog, timeEnd, count, and countReset functions
2024-08-09 11:02:22 +01:00
BenJilks 0ca5675d59 LibTextCodec: Implement iso-2022-jp encoder
Implements the `iso-2022-jp` encoder, as specified by
https://encoding.spec.whatwg.org/#iso-2022-jp-encoder
2024-08-08 17:49:58 +01:00
BenJilks 08a8d67a5b LibTextCodec: Implement shift_jis encoder
Implements the `shift_jis` encoder, as specified by
https://encoding.spec.whatwg.org/#shift_jis-encoder
2024-08-08 17:49:58 +01:00
BenJilks c1958437f9 LibWeb: Use text encoding from DOM when parsing URLs
This passes the DOM encoding down to the URL parser, so the correct
encoder can be used.
2024-08-08 17:49:58 +01:00
BenJilks d80575a410 LibTextCodec: Implement gb18030 and gbk encoders
Implements the `gb18030` and `gbk` encoders, as specified by
https://encoding.spec.whatwg.org/#gb18030-encoder
https://encoding.spec.whatwg.org/#gbk-encoder
2024-08-08 17:49:58 +01:00
BenJilks 34c8c559c1 LibTextCodec: Implement big5 encoder
Implements the `big5` encoder, as specified by
https://encoding.spec.whatwg.org/#big5-encoder
2024-08-08 17:49:58 +01:00
BenJilks 826292536c LibTextCodec: Implement euc-kr encoder
Implements the `euc-kr` encoder, as specified by
https://encoding.spec.whatwg.org/#euc-kr-encoder
2024-08-08 17:49:58 +01:00
BenJilks 72d0e3284b LibTextCodec+LibURL: Implement utf-8 and euc-jp encoders
Implements the corresponding encoders, selects the appropriate one when
encoding URL search params. If an encoder for the given encoding could
not be found, fallback to utf-8.
2024-08-08 17:49:58 +01:00
Tim Ledbetter 85863bb0ef LibWeb: Don't verify_cast where input and output types are the same 2024-08-08 17:50:59 +02:00
Shannon Booth deff8df2c7 LibWeb: Actually perform "update the href steps"
We completely missed this step, which made setters not actually do
anything!

Fixes 336 test failures on:

https://wpt.live/url/url-setters-a-area.window.html
2024-08-08 14:59:42 +01:00
Aliaksandr Kalenik 40742d95e6 LibWeb: Call set_needs_display() if navigable is scrolled or resized
`m_needs_repaint = true` is not enough because it doesn't schedule
repaint of a parent navigable.

Fixes the bug when an iframe is not repainted after scrolling.
2024-08-08 12:38:15 +02:00
Tim Ledbetter 087d400472 LibWeb: Avoid division by zero in SourceSet width descriptor calculation 2024-08-08 12:20:04 +02:00
Shannon Booth 2e884ff140 LibJS: Add Value::to_well_formed_string 2024-08-08 10:50:06 +01:00
Ali Mohammad Pur d2ff92077b LibWasm: Use braces to initialize Reference::Foo classes
These have no declared constructor, so apple clang and clang clang seem
to disagree on some versions.
2024-08-07 23:39:46 +02:00
Aliaksandr Kalenik 9def582fba LibWeb: Apply enclosing scroll frame offset to iframe's position
Fixes iframe painting when it's nested into a scrollable box.
2024-08-07 20:16:02 +02:00
Jelle Raaijmakers 5865cf5864 LibWeb: Use bitmap's alpha type instead of assuming unpremultiplied
When converting a `Gfx::Bitmap` to a Skia bitmap, we cannot assume the
color data is unpremultiplied. For example, everything canvas-related
uses premultiplied color data:

  https://html.spec.whatwg.org/multipage/canvas.html#premultiplied-alpha-and-the-2d-rendering-context

We were probably assuming unpremultiplied since that is what the PNG
decoder gives us. Since we now make `Gfx::Bitmap` identify what alpha
type is being used, we can instruct Skia a bit better :^)

Update our `EdgeFlagPathRasterizer` to use premultiplied alpha instead
of unpremultiplied so we can apply alpha correctly for path masks.

This fixes the dark borders sometimes visible when SVGs are blended
with a colored background.

This also exposed an issue with our `CanvasRenderingContext2D`, which is
supposed to hold a bitmap with premultiplied alpha internally but expose
a bitmap with unpremultiplied alpha in `CanvasImageData`. Expand our C2D
test to include the alpha channel as well.

Finally, this also exposed an off-by-one issue in
`EdgeFlagPathRasterizer` which caused the last scanlines for edges to
render incorrectly. We had some reference images which included these
corruptions (they were almost unnoticeable), so update them as well.
2024-08-07 18:51:12 +02:00
Jelle Raaijmakers a430ae6dcf LibGfx: Mark PNG bitmaps as having unpremultiplied alpha 2024-08-07 18:51:12 +02:00
Jelle Raaijmakers b193fe658d LibGfx: Store alpha type information in Gfx::Bitmap
We use instances of `Gfx::Bitmap` to move pixel data all the way from
raw image bytes up to the Skia renderer. A vital piece of information
for correct blending of bitmaps is the alpha type, i.e. are we dealing
with premultiplied or unpremultiplied color values?

Premultiplied means that the RGB colors have been multiplied with the
associated alpha value, i.e. RGB(255, 255, 255) with an alpha of 2% is
stored as RGBA(5, 5, 5, 2%).

Unpremultiplied means that the original RGB colors are stored,
regardless of the alpha value. I.e. RGB(255, 255, 255) with an alpha of
2% is stored as RGBA(255, 255, 255, 2%).

It is important to know how the color data is stored in a
`Gfx::Bitmap`, because correct blending depends on knowing the alpha
type: premultiplied blending uses `S + (1 - A) * D`, while
unpremultiplied blending uses `A * S + (1 - A) * D`.

This adds the alpha type information to `Gfx::Bitmap` across the board.
It isn't used anywhere yet.
2024-08-07 18:51:12 +02:00
Jelle Raaijmakers 99dd063c58 LibGfx: Factor out alpha type from GradientPainting
Knowing whether pixel color data is premultiplied or unpremultiplied is
useful in more places; factor it out so we can use the enum elsewhere.

Implement support for premultiplied alpha in `Color::with_alpha()` and
`::set_alpha()`.
2024-08-07 18:51:12 +02:00
Jelle Raaijmakers 56ff36a0ee LibGfx: Prefix class members with m_ in EdgeTable
No functional changes.
2024-08-07 18:51:12 +02:00
Jelle Raaijmakers f5d838b64c LibGfx: Fix "coverage" typos in EdgeFlagPathRasterizer
No functional changes.
2024-08-07 18:51:12 +02:00
Jelle Raaijmakers 3eb4da514c LibGfx: Remove unused ColorRole forward from Color.h 2024-08-07 18:51:12 +02:00
Aliaksandr Kalenik ee4dd5a17c LibWeb: Remove unused image-rendering param for stacking context
Previously it was accounted for by LibGfx while applying scale
transformation, but is no longer needed for Skia.
2024-08-07 18:50:44 +02:00
Aliaksandr Kalenik 53ef0e2e88 LibWeb: Adjust stacking context position by scroll offset in hit-testing
Fixes a bug when stacking contexts nested inside scrollable box are
treated as fixed positioned during hit-testing.
2024-08-07 18:14:41 +02:00
Aliaksandr Kalenik 1163ff21d7 LibWeb: Don't wrap result in optional in enclosing_scroll_frame_offset()
Instead return (0, 0) if a box does not have an offset.
2024-08-07 18:14:41 +02:00
Sam Atkins 4ec3968178 WebContent+LibWeb: Display resolved pseudo-element style in inspector
This also now uses the cached computed style for them, instead of
computing it fresh each time.
2024-08-07 16:14:49 +02:00
Sam Atkins 173daec9db LibWeb: Show pseudo-elements in DOM whose parent has no other children
If a DOM node is an element with pseudo-elements, but it has no child
DOM nodes and is not a shadow host, then the code that serializes its
pseudo-elements would get skipped, making them not show up in the
inspector.
2024-08-07 16:14:49 +02:00
Sam Atkins 14611de362 LibWeb: Implement getComputedStyle() pseudoElement parameter
Right now, we deviate from the CSSOM spec regarding our
CSSStyleDeclaration classes, so this is not as close to the spec as I'd
like. But it works, which means we'll be able to test pseudo-element
styling a lot more easily. :^)
2024-08-07 16:14:49 +02:00
Sam Atkins dae9c9be40 LibWeb/CSS: Add quick-and-dirty parsing for pseudo-element selectors
As noted, this is hacky because the parser wasn't written to allow
parsing an individual component of a selector. (Fox example, the
convenient-sounding `parse_pseudo_simple_selector()` assumes the first
colon has already been consumed...) So until that changes, this parses
the input as an entire selector-list, and then throws it away if it's
not a single pseudo-element selector.

It's only temporary though, I promise. 😅
2024-08-07 16:14:49 +02:00
Sam Atkins 521cd161a8 LibWeb: Store pseudo-element layout nodes as NodeWithStyle
We were already guaranteed to return a NodeWithStyle from
`create_layout_node_for_display_type()`, so make use of that knowledge.
2024-08-07 16:14:49 +02:00
Andrew Kaster 7758875cfd AK+LibGfx: Only generate clang module map if ENABLE_SWIFT
The script pulls in a dependency on the `yaml` python package. Instead
of updating all the docs and CI jobs to account for this, let's guard
calling the script behind our experimental flag instead.
2024-08-07 09:04:09 +02:00
Andrew Kaster 5a31fed1da LibGfx: Generate clang module map 2024-08-06 18:28:10 -06:00
Andrew Kaster 54c7bb1e9d LibGfx: Include implicit header files from EdgeFlagPathRasterizer
This ensures that we aren't relying on transitive dependencies for
AK::log2(integral_value) and WindingRule
2024-08-06 18:28:10 -06:00
Jamie Mansfield fa5800ebc5 LibWeb: Implement HTMLTableCellElement.cellIndex
See:
 - http://wpt.live/html/semantics/tabular-data/attributes-common-to-td-and-th-elements/cellIndex.html
2024-08-07 00:53:38 +01:00
Diego Frias a58704296c LibWasm: Remove type information from Value
Gets fib(30) from 380ms to 340ms.
2024-08-07 01:10:20 +02:00
Diego Frias a2448308fd LibWasm: Directly remove from the stack when clearing a label
Theoretically, the previous "pop, then push" method should be faster,
but it's actually faster to just remove from the stack directly.
2024-08-07 01:10:20 +02:00
Diego Frias b73b17aab4 LibWasm: Inline bytecode interpreter instruction interpretation
Gets fib(30) from 480ms to 380ms.
2024-08-07 01:10:20 +02:00
Diego Frias a3b077c641 LibWasm: Split main interpreter stack into three
Instead of one stack to hold frames, labels, and values, there is now
three separate stacks. This speeds up fib(30) from 580ms to 480ms.
2024-08-07 01:10:20 +02:00
Diego Frias 15510fb42e LibWasm: Simplify downcasting in bytecode interpreter 2024-08-07 01:10:20 +02:00
Shannon Booth 6cac2981fb LibURL: Fail parsing IPV4 URLs starting with 0x that overflow
Parsing last as an IPV4 number was not returning true in "ends with a
number" as the parsing of that part was overflowing. This means that the
URL is not considered to be an IPv4 address, and is treated as a valid
domain.

Helpfully, the spec also points out in a note that this step is
equivalent to simply checking that the last part ends with 0x followed
by only hex digits - which doesn't suffer from any overflow problem!

Arguably this is an editorial issue in the spec where this should be
clarified a little bit. But for now, fixing this fixes 3 sub tests in
WPT for:

https://wpt.live/url/url-constructor.any.html
2024-08-06 23:08:12 +01:00
Shannon Booth db3f118046 LibURL: Fix heuristic for URL domain parsing IDNA fast path
Our heuristic was a bit too simplistic and would not run through the
ToASCII unicode algorithm which performs some extra validation. This
would cause invalid URLs that should fail to be parsed be mistakenly
accepted.

This fixes 8 tests in: https://wpt.live/url/url-constructor.any.html
2024-08-06 23:08:12 +01:00
Shannon Booth fd4e943e12 LibWeb: Don't strip leading '?' in query initializing a URL
In our implementation of url-initialize, we were invoking the
constructor of URLSearchParams:

https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams

Instead of the 'initialize' AO:

https://url.spec.whatwg.org/#urlsearchparams-initialize

This has the small difference of stripping any leading '?' from the
query (which we are not meant to be doing!).
2024-08-06 23:08:12 +01:00
Shannon Booth 1dc4959e91 LibURL: Don't return early parsing a URL with an empty input
We can't simply use the base URL as it may need to be modified in some
form. For example - for the included test, the fragment was previously
being included in the resulting URL.

This fixes 1 test on https://wpt.live/url/url-constructor.any.html
2024-08-06 23:08:12 +01:00
Shannon Booth d161602b6d LibURL: Fix method name in debug logging 2024-08-06 23:08:12 +01:00
Shannon Booth d9927d128c LibURL: Remove unused URL::create_with_help_scheme
This is unused since the SerenityOS split.
2024-08-06 23:08:12 +01:00
Aliaksandr Kalenik 672ff7e45e LibWeb: Define bounding rect for AddMask display list item
This allows display list player to skip masks that would not be visible.
2024-08-06 22:16:17 +02:00
Aliaksandr Kalenik 9f4deb57c8 LibWeb: Skip AddMask in display list player if destination rect is empty
...because otherwise Skia will fail to allocate empty surface.

Fixes crashing on https://null.com/games/chainstaff
2024-08-06 22:16:17 +02:00
Aliaksandr Kalenik a8f4ea5226 LibWeb: Fix "background-clip: text" for elements nested in scrollable
Instead of carrying the display list for a mask in each command that
might potentially be affected by "background-clip: text", this change
introduces a new AddMask command that is applied once for all
background layers within one box.

The new AddMask command includes a rectangle for the mask destination
that is translated by the corresponding scroll offset.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/857
2024-08-06 21:14:47 +02:00
Andreas Kling 861d46be3e LibWeb: Use a HashTable when querying SessionHistoryTraversalQueue
Instead of asking "do you have an entry not in this Vector", let's ask
"do you have an entry not in this HashTable".
2024-08-06 16:33:23 +02:00
Andreas Kling a1519e67fb LibWeb: Fire navigation event as required in History.pushState() 2024-08-06 16:33:23 +02:00
Andreas Kling e3408c4a7f LibWeb: Allow changing the query of file:// URL via history.pushState()
The spec didn't match how other browsers behave, and we dutifully did
what the spec said. A spec bug has been filed, so let's fix this locally
for now with a FIXME.
2024-08-06 16:33:23 +02:00
Andreas Kling faf097bb41 LibWeb: Sync with spec in "destroy a document and its descendants"
The only real change here is that we make the document unsalvageable.
Everything else is fixing up spec comments.
2024-08-06 16:33:23 +02:00
Aliaksandr Kalenik 0fe84e89b2 LibWeb: Use padding box to get background rect for inline paintable
Fixes regression introduced by f574e2b03a
2024-08-06 16:25:45 +02:00
Jamie Mansfield c891b83fc0 LibWeb: Don't crash with invalid import maps
See:
 - http://wpt.live/import-maps/multiple-import-maps/with-errors.html
2024-08-06 09:40:44 +02:00
Aliaksandr Kalenik 040653311e LibWeb: Fix background clip for elements nested into scrollable boxes
add_clip_rect() accepts a rectangle in viewport-relative coordinates,
so it must be translated by the enclosing scroll offset to be displayed
correctly inside a scrollable box.
2024-08-06 09:40:34 +02:00
Aliaksandr Kalenik f574e2b03a LibWeb: Resolve background size and offset only after style invalidation
This change fixes layering violation by moving to_px() calls to happen
before display list recording. Also it should make display list
recording a bit faster by resolving background properties beforehand.
2024-08-06 09:40:34 +02:00
Shannon Booth 2995a57f63 LibHTTP: Don't double percent encode path in HTTPRequst::to_raw_request
This was a goof in cc55732332 which
resulted in the URL path getting double percent encoded. Since the path
already comes out percent encoded following the rules in the URL spec -
we don't need to percent encode again.

Fixes: #978
2024-08-06 08:18:20 +01:00
Shannon Booth 8723f72f0f LibURL: Remove unspecified steps in URL file slash parsing state
There were some extra steps in there which produced wrong results for
relative file URLs.

Fixes 7 test cases in: https://wpt.live/url/url-constructor.any.html

We also need to adjust the test results in TestURL. The behaviour tested
does not match how URL is specified to work as an absolute relative is
given.
2024-08-06 07:58:07 +01:00
Jamie Mansfield 1d12cb69d4 LibWeb: Implement HTMLTrackElement.readyState 2024-08-06 07:57:33 +01:00
Shannon Booth d6af5bf5eb LibURL: Allow inputs containing only whitespace
The check for:

```
    if (start_index >= end_index)
        return {};
```

To prevent an out of bounds when trimming the start and end of the input
of whitespace was preventing valid URLs (only having whitespace in the
input) from being parsed.

Instead, prevent start_index from ever getting above end_index in the
first place, and don't treat empty inputs as an error.

Fixes one WPT test on:

https://wpt.live/url/url-constructor.any.html
2024-08-05 17:21:26 +01:00
Shannon Booth 4f5af3e90e LibURL: Remove FIXME for stripping c0 control or space
The FIXME was not correct - this was done correctly. But let's use a
helper to make the implementation slightly more readable.
2024-08-05 17:21:26 +01:00
Shannon Booth 670ce3ebb1 LibURL: Remove not particuarly useful NOTE
This doesn't seem like something we will neccessarily do in the URL
class anyway due to performance reasons - unless strictly needed (like
for the DOMURL implementation).
2024-08-05 17:21:26 +01:00
Andreas Kling 1e7b17f150 LibWeb: Don't crash on getClientRects() in document without navigable
I previously believed there was no way a detached document should have
layout information, but it turns out there is a way: getComputedStyle().

So we need to account for cases where we have a layout node, but no
navigable, since that is a state we can get into at this moment.

Fixes #354
2024-08-05 14:56:04 +02:00
Shannon Booth 41cf9f6fe3 LibURL: Also remove carriage returns from URL input
The definition of an "ASCII tab or newline" also includes U+000D CR.

This fixes 3 subtests in:

https://wpt.live/url/url-constructor.any.html
2024-08-05 11:27:05 +02:00
Shannon Booth a342370dfb LibWeb: Rename SharedImageRequest to SharedResourceRequest
For the SVG <use> element, we want to support loading HTML documents
that have a SVG element inside of it pointed to by the URL fragment.

In this situation we would need to fetch and parse the entire document
in SharedImageRequest (so that we can still cache the SVGs). Rename
SharedImageRequest to SharedResourceRequest to make the class a little
more generic for future usecases.
2024-08-05 11:26:41 +02:00
Shannon Booth 2fb5054603 LbiWeb: Add and use SharedImageRequest::handle_successful_resource_load
This closer mirrors handle_failed_fetch, making the handling slightly
more clear to understand. It also means that we don't need to take a
strong reference to this on a successful SVG resource load.
2024-08-05 11:26:41 +02:00
Shannon Booth e0f2e42687 LibWeb: Use handle_failed_fetch to implement handle_failed_decode
...When loading images through SharedImageRequest.

There is a small behavioural difference here - handle_failed_fetch
clears the pending callbacks whereas handled_failed_decode was
previously not. This does not seem intentional, and appears like a bug.

Implementing it this way is _slightly_ simpler - and also means we
don't need to take a strong handle to this in the case of loading an
SVG image.
2024-08-05 11:26:41 +02:00
Shannon Booth 85e8e7ec23 LibWeb: Add support for fetching SVG use elements from external docs
This allows SVG elements to refer to elements which are in other
documents, such as https://www.neogaf.com/forums/gaming-discussion.2/
or on lemmy.ml

Fixes: #141
Progress towards: #350
2024-08-05 11:26:41 +02:00
Shannon Booth e11a7b668f LibWeb: Do not const qualify clone_element_tree_as_our_shadow_tree
We are mutating the shadow root of the element.
2024-08-05 11:26:41 +02:00
Shannon Booth cf7f07b822 LibWeb: Pass Element const& to is_valid_reference_element
The element can't be null - and we don't need to mutate it either.
2024-08-05 11:26:41 +02:00
Shannon Booth ab70932681 LibWeb: Factor out "process the URL" AO for SVGUseElement 2024-08-05 11:26:41 +02:00
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 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
Ali Mohammad Pur 1fa528b19f LibWeb: Keep Wasm-imported functions alive
The user is not required to keep the object alive, this commit makes it
so the lifetime of these functions is extended to match the Wasm module
it is imported into.
Fixes the crash in #907.
2024-08-01 11:41:19 +02:00
Timothy Flynn 1eced20521 LibJS: Change Intl.Locale.prototype.firstDayOfWeek to be a string
This is a normative change in the Intl Locale Info proposal. See:

https://github.com/tc39/proposal-intl-locale-info/commit/5cb45fd
https://github.com/tc39/proposal-intl-locale-info/commit/6d80e69
https://github.com/tc39/proposal-intl-locale-info/commit/04039b8
2024-08-01 11:40:37 +02:00
Tim Ledbetter 34e465a67e LibWeb: Account for header size when reading MessagePort message payload
Previously, the fact that this wasn't accounted for could lead to a
crash when large messages were received.
2024-08-01 11:39:43 +02:00
sideshowbarker f735c464d3 LibWeb/Fetch: Don’t cache redirects
This change disables caching for 301, 302, 303, 307, and 308 responses.
This is just for now, ad-hoc — not adhering to any particular spec.
Fixes https://github.com/LadybirdBrowser/ladybird/issues/863
2024-08-01 11:39:27 +02:00
Timothy Flynn 5f8d852dae LibWebView+UI: Migrate Ladybird's command line flags to LibWebView
Currently, if we want to add a new e.g. WebContent command line option,
we have to add it to all of Qt, AppKit, and headless-browser. (Or worse,
we only add it to one of these, and we have feature disparity).

To prevent this, this moves command line flags to WebView::Application.
The flags are assigned to ChromeOptions and WebContentOptions structs.
Each chrome can still add its platform-specific options; for example,
the Qt chrome has a flag to enable Qt networking.

There should be no behavior change here, other than that AppKit will now
support command line flags that were previously only supported by Qt.
2024-08-01 11:38:42 +02:00
Timothy Flynn 0e640f6f70 WebContent: Limit the Console client to the top-level navigable client
We don't want to set the intrinsic Console object's client to non-top-
level clients, created for e.g. subframes. We also want to make sure the
Console client is updated if the top-level document has changed.
2024-08-01 11:35:49 +02:00
Timothy Flynn 0a819e628e LibWeb+WebContent: Store console clients on the DOM document
We explicitly stopped visting the map of documents to console clients in
commit 44659f2f2a to avoid keeping the
document alive. However, if nothing else visits the console clients, we
may set the top-level console client to a client that has been garbage
collected.

So instead of storing this map, just store the console client on the
document itself. This will allow the document to visit its client.
2024-08-01 11:35:49 +02:00
Timothy Flynn a1c57ed79a WebContent: Do not create JS consoles for fragment-parsing documents
There's no need to go through this setup.
2024-08-01 11:35:49 +02:00
Timothy Flynn c838ca78c8 LibWeb: Indicate documents are for fragment parsing during construction
This will allow testing if they are for fragment parsing during methods
invoked from Document::initialize.
2024-08-01 11:35:49 +02:00
Aliaksandr Kalenik 2cc2646f55 LibWeb: Apply scroll offset and clip rectangle to table borders
Moves paint_table_borders() call into PaintableBox::paint() to make
scroll offset and clip rectangle of enclosing scrollable be applied
in ::before_paint().
2024-07-31 21:43:17 +02:00
Timothy Flynn cf25a06d67 LibWebView: Make open file limit modifications non-fatal
If setrlimit fails, let's just report the error rather than failing to
start the browser at all.
2024-07-31 10:12:37 -06:00
Timothy Flynn 9e7e22dc74 LibCore: Use Error::from_syscall to report get/setrlimit errors 2024-07-31 10:12:37 -06:00
Sam Atkins 3abd3ef5e2 LibWeb: Compute pseudo-element style when computing element style
Previously, pseudo-elements had their style computed while the layout
tree was being built. Instead, do so inside Element::recompute_style(),
using the same invalidation mechanism that the element itself uses.

This also has the effect of invalidating the layout much less often.
2024-07-31 12:15:39 +02:00
Sam Atkins d58c1c1176 LibWeb/CSS: Make content property change require full invalidation
`content` determines the element or pseudo-element's layout, including
its children.
2024-07-31 12:15:39 +02:00
Timothy Flynn 4a166a45ec LibWeb: Avoid allocating UTF-16 strings only the UTF-16 length is needed 2024-07-31 05:55:34 -04:00
Andrew Kaster 2fa6c445cb CMake: Work around two upstream CMake issues for Swift files
https://gitlab.kitware.com/cmake/cmake/-/issues/26174
https://gitlab.kitware.com/cmake/cmake/-/issues/26175
2024-07-30 18:38:02 -06:00
Andrew Kaster d1969851ce LibGfx: Add an implementation of #rrggbb color parsing in Swift 2024-07-30 18:38:02 -06:00
Andrew Kaster 45301e8169 Everywhere: Remove AK_DONT_REPLACE_STD macro
Let's just always include `<utility>`. Placing our own incompatible with
the STL declaration of these functions in AK was always fishy to begin
with.
2024-07-30 18:38:02 -06:00
Andrew Kaster cf42bf2bca LibGfx: Factor out #rrggbb Color parsing into its own helper function 2024-07-30 18:38:02 -06:00
Diego Frias 3c5e3eef10 LibWeb: No longer return undefined on null table entry in Wasm API
Return `null` instead, as per the specification.
2024-07-30 23:43:44 +02:00
Ali Mohammad Pur 93216a875e RequestServer: Actually hold on to the preload job until it's done
This was some nonsense code left in by mistake, ref commit:
4211639e45

Fixes #904.
2024-07-30 12:03:30 -04:00
Sam Atkins 7daf5cdaff LibWeb: Invalidate layout if pseudo-element style changes
Pseudo-elements' style is only computed while building the layout tree.
This meant that previously, they would not have their style recomputed
in some cases. (Such as when :hover is applied to an ancestor.)

Now, when recomputing an element's style, we also return a full
invalidation if one or more pseudo-elements would exist either before or
after style recomputation.

This heuristic produces some false positives, but no false negatives.
Because pseudo-elements' style is computed during layout building, any
computation done here is then thrown away. So this approach minimises
the amount of wasted style computation. Plus it's simple, until we have
data on what approach would be faster.

This fixes the Acid2 nose becoming blue when the .nose div is hovered.
2024-07-30 09:45:45 +02:00
Sam Atkins f23f0721bd LibWeb: Combine Element's pseudo-element data together
Rather than maintain two dynamically-allocated arrays of data for
pseudo-elements, put them in a single array, which is easier to manage.
2024-07-30 09:45:45 +02:00
Aliaksandr Kalenik 2c0f03f5b6 LibWeb: Delete BlitCornerClipping display list command
Contrary to LibGfx, where corner clipping was implemented by sampling
and blitting pixels under corners into a temporary bitmap, Skia allows
us to simply apply a mask. As a result, we no longer need the
BlitCornerClipping command, which has become a no-op.

- SampleUnderCorners is renamed to AddRoundedRectClip
- The optimization that skipped unnecessary blit and sample commands has
  been removed. However, this should not result in a performance
  regression because Skia seems to perform mask rasterization lazily.
2024-07-30 09:43:43 +02:00
Aliaksandr Kalenik 333c9270b1 LibWeb: Simplify outer box shadow's bounding box calculation
There is no need in the overly complicated OuterBoxShadowMetrics after
switching to use Skia for painting.
2024-07-30 09:43:20 +02:00
Timothy Flynn 4f5604c7db WebContent: Ignore invalid attributes set via the Inspector
Rather than crash, just ignore these values for now. We should invent a
mechanism to send feedback to the user (perhaps via the JS console).
2024-07-30 09:41:35 +02:00
Timothy Flynn 93f2af38b1 LibWebView: Escape HTML entities in attribute names
Otherwise, we can embed invalid HTML in the Inspector web view.
2024-07-30 09:41:35 +02:00
Timothy Flynn 657bbd1542 LibWeb: Append attributes to the correct element
The spec indicates we should append attributes to the top element of the
stack of open elements. We were appending the attribute to the bottom.
2024-07-30 09:41:35 +02:00
Timothy Flynn 9fe35ddddf LibWeb: Use an infallible method to add attributes to nodes
In the HTML parser spec, there are 2 instances of the following text:

    add the attribute and its corresponding value to that element

The "add the attribute" text does not have a corresponding spec link to
actually specify what to do. We currently use `set_attribute`, which can
throw an exception if the attribute name contains an invalid character
(such as '<'). Instead, switch to `append_attribute`, which allows such
attribute names. This behavior matches Firefox.

Note we cannot yet make the unclosed-html-element.html test match the
expectations of the unclosed-body-element.html due to another bug that
would prevent checking if the expected element has the right attribute.
That will be fixed in an upcoming commit.
2024-07-30 09:41:35 +02:00
Timothy Flynn c1b0e180ba LibWebView: Insert line numbers before each line in about:srcdoc
The behavior chosen here (fixed-width counters, alignment, etc.) matches
Firefox.
2024-07-29 18:27:16 +01:00
Sam Atkins 5abe246385 LibWeb/CSS: Treat counters() function with 1 argument as invalid
Fixes #887.
2024-07-29 12:57:43 -04:00