Commit Graph

62994 Commits

Author SHA1 Message Date
Shannon Booth
8a469cf7e4 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.

(cherry picked from commit 28ed8e5d0f79fc9d961f746367127e137faaf46b)
2024-10-18 21:58:17 -04:00
Shannon Booth
f9c502ce6d BindingsGenerator: Support nullable integral attributes
Previously we were assuming that the attribute return value was never
nullable and going to be returned in an Optional<IntegralType>, causing
complile errors for something such as: `attribute unsigned long?`.

(cherry picked from commit ad32227c833e60c55b0f5460a4f9f9c1631ecd57)
2024-10-18 21:58:17 -04:00
Shannon Booth
77f953405f BindingsGenerator: Factor out code to generate JS::Value from an integer
Mirroring the pre-existing `generate_from_integral` function. This will
allow us to fix a bug that all of these if statements have in common -
no handling of nullable types.

This also adjusts the type casted for each integral to fully match that
stated by the spec.

(cherry picked from commit d6243abec3e0f10ddf75a32c8a291f43cbdae169)
2024-10-18 21:58:17 -04:00
Timothy Flynn
6e5a0fab09 LibWeb: Disable remaining Worker tests for now
These time out on macOS CI.

(cherry picked from commit b1718f56911e7352798715f18b7c6255fccc3ba7)
2024-10-18 21:57:08 -04:00
Aliaksandr Kalenik
7a50f2ea56 Tests/LibWeb: Disable cross-origin-window-properties.html test for now
After https://github.com/LadybirdBrowser/ladybird/pull/1616 got merged
this test started to occasionaly timeout on Linux CI:
https://github.com/LadybirdBrowser/ladybird/actions/runs/11174338933/job/31063881592
https://github.com/LadybirdBrowser/ladybird/actions/runs/11177347649/job/31072646967?pr=1623

Since it's only this test that is timing out, I'm concluding that the
event loop processing change is working fine and the issue lies with the
test itself, so let's disable it for now.

(cherry picked from commit e0cd2edccb0b81b44bd3bf25cc93419c06870f2d)
2024-10-18 21:57:08 -04:00
Timothy Flynn
275968fe33 LibWeb: Disable worker-crypto test for now
This times out on macOS CI.

(cherry picked from commit ee7b90b78955fc981fc1a271cce9437325d47c45)
2024-10-18 21:57:08 -04:00
Timothy Flynn
14cacb5611 LibWeb: Disable worker-blob and worker-location tests for now
These frequently time out on macOS CI.

(cherry picked from commit 5233f9c8e6e9dd62572ec9343dc1b1dda4d3be2e)
2024-10-18 21:57:08 -04:00
Tim Ledbetter
eae6aa6d1c Tests: Skip css-keyframe-fill-forwards.html ref test
This test is currently causing intermittent CI failures.

(cherry picked from commit 24c75922d8476b5096657acb5a1b4c71454ca616)
(cherry picked from commit 9585da37ada3be4d50df44e499a9c2884570f138)
2024-10-18 21:57:08 -04:00
Nico Weber
ed9b267c0a Tests: Install recently(ish) added PDF test files
These aren't needed for any automated tests, but it's still nice to have
them in the OS for manual testing.
2024-10-18 21:54:38 -04:00
Nico Weber
cfff04c9c7 Tests/LibPDF: Add a file where object 0 is not in xref table
This uses a non-stream xref table, and the spec says
"The cross-reference table (comprising the original cross-reference
section and all update sections) must contain one entry for each object
number from 0 to the maximum object number used in the file". So this
file isn't spec compliant. However, with xref streams this does
happen in practice (the spec isn't quite clear on if it's valid there),
and it's much easier to write a test file with a non-stream xref table
by hand. Also, this file shows up fine in other PDF viewers.

This is a regression test for #25079.
2024-10-18 21:54:38 -04:00
Nico Weber
c7b810437b Tests/LibPDF: Fix typo in test name 2024-10-18 21:54:38 -04:00
Nico Weber
536d27fbe6 LibPDF: Don't fail on files where object 0 is not in the xref table
History:

* 72f693e9ed from #6974 added the initial XRefTable. Here, -1
  was used for byte_offset of invalid entries. has_object() compared
  byte_offset to -1.

* e23bfd7252 from #7675 added invalid_byte_offset (equal to
  LONG_MAX) and initialized byte_offset with it, but forgot to update
  has_object(). has_object() still compared to -1, so has_object would
  now never return false.

* d1bc89e30b from #16150 added validate_xref_table_and_fix_if_necessary,
  which used `byte_offset_for_object(index) == invalid_byte_offset` to
  detect if an object was in the xref table. `byte_offset_for_object`
  internally did `VERIFY(has_object(index))`, which due to the previous
  bullet was always true. It ran this for all object numbers from 0
  up to the first object with byte_offset != invalid_byte_offset.

* d458471e09 from #24099 updated has_object() to check against
  invalid_byte_offset instead of -1, making it work again -- but causing
  a VERIFY in validate_xref_table_and_fix_if_necessary(). This caused
  validate_xref_table_and_fix_if_necessary() to VERIFY if object 0
  was not in the xref table.

* The fix is to make validate_xref_table_and_fix_if_necessary() call
  has_object() to find out if an object exists in the xref table.
  (When validate_xref_table_and_fix_if_necessary(), that didn't work,
  because has_object() was broken then.)

This is hit 4 times in my 1000 file test set. For these three files,
the xref is valid:

* 0000200.pdf
* 0000567.pdf
* 0000651.pdf

For 0000900.pdf, validate_xref_table_and_fix_if_necessary() actually
fixes up the xref table.

Fixes #25079.
2024-10-18 21:54:38 -04:00
Nico Weber
f1a192da48 LibPDF: Flip two branches of a conditional
Rather than reading an int and then checking if we shouldn't have
read it and using a default value, start with the default value
and read the int if we should read it.

No behavior change.
2024-10-18 21:54:38 -04:00
Nico Weber
de66beee13 LibPDF: Use CommonNames for W in parse_xref_stream
No behavior change, just makes LibPDF more self-consistent.
2024-10-18 21:54:38 -04:00
Nico Weber
33b97f45a1 LibPDF: Add a spec comment to DocumentParser::parse_xref_stream() 2024-10-18 21:54:38 -04:00
Timothy Flynn
cb17194de8 LibWeb: Avoid allocating UTF-16 strings only the UTF-16 length is needed
(cherry picked from commit 4a166a45ec9db910542893133f08cc7de4ec974f,
minorly amended to resolve #include conflict due to our LibLocale
and LibUnicode being separate -- we don't want
https://github.com/LadybirdBrowser/ladybird/pull/257)
2024-10-18 18:21:18 -04:00
Timothy Flynn
59040d9bb8 AK: Add a method to compute UTF-16 length from a UTF-8 string
(cherry picked from commit 7a17c654d293c4afaf3086dc94e8cd4bceac48b1;
amended to resolve minor conflict in TestUtf16.cpp due to us not
(yet?) having `TEST_CASE(null_view)`. Also amended to make the new
method not call simdutf -- it's now also inefficient, but at least
the inefficient code is now only in one place instead of in several)
2024-10-18 18:21:18 -04:00
Nico Weber
14e2f8c065 LibWeb: Support stroke-linecap as attribute as well 2024-10-17 22:02:48 -04:00
Nico Weber
9713a56583 LibWeb: Plumb cap style from SVGPathPaintable to painting
We can now correctly paint svg paths that are styled with stroke-linecap
in a CSS rule.
2024-10-17 22:02:48 -04:00
Nico Weber
13ff4125fb Tests/LibWeb: Add a reftest for svg stroke-linecap 2024-10-17 22:02:48 -04:00
Tim Ledbetter
df8eec7786 LibWeb: Change attribute type to USVString where applicable
Also mark USVString attributes as containing a URL, where applicable.

(cherry picked from commit 1369fc5069598644842defabbfbf3d30d2f3e647)
2024-10-17 21:31:52 -04:00
Tim Ledbetter
ffa5a7747e IDLGenerators: Make USVString attribute reflection spec compliant
USVString attributes Now replace any surrogates with the replacement
character U+FFFD and resolve any relative URLs to an absolute URL. This
brings our implementation in line with the specification.

(cherry picked from commit 335d51d6782c66e7743d773f6f6b6a32a2cb2067)
2024-10-17 21:31:52 -04:00
Shannon Booth
fe2f85c5a0 LibWeb: Implement USVString scalar value handling
USVString is defined in the IDL spec as:

> The USVString type corresponds to scalar value strings. Depending on
> the context, these can be treated as sequences of either 16-bit
> unsigned integer code units or scalar values.

This means we need to account for surrogate code points by using the
replacement character.

This fixes the last test in https://wpt.live/url/url-constructor.any.html

(cherry picked from commit aa32bfa4481f6298c99846025394b7bc415ca621)
2024-10-17 20:28:06 -04:00
Shannon Booth
f02836e8b2 LibJS: Add Value::to_well_formed_string
(cherry picked from commit 2e884ff1404dca582985abfb372817e5276e9c1c)
2024-10-17 20:28:06 -04:00
Nico Weber
949c7df56c Utilities: Add a simple iconv utility
It's part of POSIX:

https://pubs.opengroup.org/onlinepubs/009604499/utilities/iconv.html

And it's an easy way to test LibTextCodec from lagom, now that
LibTextCodec also has some encoders.
2024-10-17 07:38:06 +01:00
Shannon Booth
f29482b038 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.

(cherry picked from commit 0b864bef6040fa66f6719bf06898e310d4c5c02f)
2024-10-16 23:56:40 -04:00
Shannon Booth
bcdb23ba3e AK: Add BOM handling to String::from_utf8_with_replacement_character
(cherry picked from commit b3bf5c4ea84bfbd0ba14fdbc3a86e5d54e053702)
2024-10-16 23:56:40 -04:00
Shannon Booth
6a9222ffd3 AK: Add fast-path in from_utf8_with_replacement_character for utf-8
This ports the same optimization which was made in
1a46d8df5fc81eb2c320d5c8a5597285d3d8fb3a to this function as well.

(cherry picked from commit 1e8cc97b731871409316c121e637c32806135122)
2024-10-16 23:56:40 -04:00
Alisson Lauffer
73bbe2b801 LibWeb: Replace "+" in value with a space while decoding search params
(cherry picked from commit d38b28b57b88e865b580f0d5e33310631f13e62c)
2024-10-16 23:56:40 -04:00
Shannon Booth
8f243cc632 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

(cherry picked from commit 9c72fc9642266ac92dedbccac7d8c0bd238450cd)
2024-10-16 23:56:40 -04:00
Shannon Booth
997ce4644f AK: Add String::from_utf8_with_replacement_character
This takes a byte sequence and converts it to a UTF-8 string with the
replacement character.

(cherry picked from commit 033ea0e7fb0f72338ae95aa0413da838206440bb)
2024-10-16 23:56:40 -04:00
Shannon Booth
fdc6730393 LibURL: Update spec comment for validation error in authority state
See: https://github.com/whatwg/url/commit/3e8cd02bb
(cherry picked from commit 84a09476ba9ed34379f82a4a42b361f046c2766a)
2024-10-16 23:56:40 -04:00
Shannon Booth
db4bab8041 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.

(cherry picked from commit 84a7fead0eefd967d4319f4d71c0a0ca3095d2d1)
2024-10-16 23:56:40 -04:00
Bastiaan van der Plaat
1a7a5e5172 LibWeb: Fix HTMLFrameElement noresize obsolete property typo
(cherry picked from commit e0c8a14fab937beb9e7c30740724bb0be6d3114e)
2024-10-16 19:46:21 -04:00
Bastiaan van der Plaat
67382ffa1f LibWeb: Add HTMLImageElement lowsrc obsolete property
(cherry picked from commit 4712f53dd7a9ea8c173c179869017738ed2ca1d1)
2024-10-16 19:46:21 -04:00
Bastiaan van der Plaat
f48fac2817 LibWeb: Add HTMLObjectElement codebase obsolete property
(cherry picked from commit d1fad9869bed8e0a8c8314968ffc8923ef239410)
2024-10-16 19:46:21 -04:00
Jamie Mansfield
21c4d1e088 LibWeb/HTML: Implement HTMLImageElement.longDesc
(cherry picked from commit 77a30bad9ffb52804b0cfd26f3589ab4c70fc2e3)
2024-10-16 19:40:02 -04:00
Jamie Mansfield
cadbe270f0 LibWeb/HTML: Implement HTMLIFrameElement.longDesc
(cherry picked from commit 45c2b1f62c5931a3dd9b573fc01095d95289d7e0)
2024-10-16 19:40:02 -04:00
Nico Weber
74f31d4988 Meta: Port recent changes to the GN build
4167d1214a LibTextCodec+LibURL: Implement `utf-8` and `euc-jp` encoders
2024-10-16 19:33:53 -04:00
Nico Weber
247e7bcb59 LibPDF: Make Document::text_string_to_utf8() fallible
TextCodec does not return Error for invalid UTF-8 or UTF-16, so
this only propagates allocation errors. No expected behavior change
in practice even for invalid PDFs. Removes three calls to
release_value_but_fixme_should_propagate_errors(), mostly for
aesthetic reasons.
2024-10-16 19:31:50 -04:00
Nico Weber
0d7de7681c LibPDF+Clients: Make Document::text_string_to_utf8() return String
It returns UTF-8 text, so make that clear in its return type,
and propagate this to clients.

No behavior change.
2024-10-16 19:31:50 -04:00
Nico Weber
66378471a0 LibGfx: When stroking zero-lengths paths, draw round and square end caps
PDF 1.7 spec, p231, 4.4.2 Path-Painting Operators, Stroking:

"If a subpath is degenerate (consists of a single-point closed path or
of two or more points at the same coordinates), the S operator paints it
only if round line caps have been specified, producing a filled circle
centered at the single point. If butt or projecting square line caps
have been specified, S produces no output, because the orientation of
the caps would be indeterminate. (This rule applies only to zero-length
subpaths of the path being stroked, and not to zero-length dashes in a
dash pattern. In the latter case, the line caps are always painted,
since their orientation is determined by the direction of the underlying
path.) A single-point open subpath (specified by a trailing m operator)
produces no output."

In practice, Chrome, Firefox, and Preview all also draw a square
for square line endings (Preview a square rotated 45 degrees). Chrome
even draws something weird-looking for butt caps. (Acrobat only draws
the round cap, per spec.)

https://html.spec.whatwg.org/multipage/canvas.html#trace-a-path sounds
like zero-lengths paths should be ignored for canvas, but in practice
Chrome and Firefox do draw them. (Safari doesn't.)

We don't do linecaps in SVGs yet, but
https://www.w3.org/TR/SVG/paths.html#ZeroLengthSegments says:

"As mentioned in Stroke Properties, linecaps must be painted for
zero-length subpaths when stroke-linecap has a value of round or
square."

With this commit, we now draw round and square linecaps for
zero-lengths paths, which is what's apparently desired most of the
time. Maybe we can add a setting to pick different behavior for
PDF (only draw round caps), canvas (don't draw caps on zero-length
paths), and SVG (draw round and square caps) in the future.
2024-10-16 18:18:43 -04:00
Nico Weber
83facae137 LibWeb: Hook up square linecap support for canvas paths 2024-10-16 18:18:43 -04:00
Nico Weber
e0b2af654a LibPDF: Hook up square linecap support 2024-10-16 18:18:43 -04:00
Nico Weber
e90e4b4f25 LibGfx: Add support for square linecaps when stroking paths
This is now easy :^)
2024-10-16 18:18:43 -04:00
Nico Weber
03eda80d99 LibGfx: Make path stroke butt line caps look less janky
We now put butt line cap vertices in the correct position,
vertical to line direction. We still pretend we're walking on the
pen polygon though, so it's probably possible to make this produce
weird-looking output by making the line cap line segments very
short. In practice, for butt line caps of real-world paths,
it's a big improvement though.
2024-10-16 18:18:43 -04:00
Nico Weber
7d1d6012bf LibGfx: Make Path::stroke_to_fill longer
Instead of one dense loop, there are now one call for the outer
stroke, one for the first cap, one for the inner stroke, and one
for the second cap.

This will make it easier to do butt caps correctly, and to add
support for square caps.

It also makes it easier to not add any caps at all for closed
paths.

Maybe it also helps for adding non-round joins eventually.

In particular:

* `shape_idx` now starts at 1, since we now start with the
  stroke part, not the cap part, and explicitly call `close()`
  to connect the second cap with the first stroke
* Having explicit cap building code means that the convolution
  loop is kind-of duplicated for round caps
* We now need to remove duplicate points, else the explicit
  cap drawing gets confused. This is the only non-behavior-preserving
  part of this commit, and it's a progression for lines that have
  two identical points at the end of an open path (this would previously
  not correctly draw a round join)
* Similarly, there's no explicit rejection of empty paths
2024-10-16 18:18:43 -04:00
Nico Weber
5486c2d3c8 Tests: Add more paths to paths.pdf
* zero-lengths paths with different linecaps
* actual paths with duplicate points
* lines where cap size is smaller than line width
* vertical paths
* thin wide lines
* an open path with a orientation (CW vs CCW)

Also add comments to the file.
2024-10-16 18:18:43 -04:00
Jack Winch
88b569ba66 E1000NetworkAdapter: Fix incorrect cast of RX buffer descriptor pointer
Fix incorrect casts of (e1000_rx_desc*) to (e1000_tx_desc*) in functions
related to frame receive path.

Previous code appears to work because only fields common to both the TX
and RX descriptor types are used in the affected code and happen to be
at the same offset inside the packed structs.
2024-10-16 16:02:19 -04:00
0x4261756D
61f6c6c966 LibTextCodec: Add SingleByteEncoders
They are similar to their already existing decoder counterparts.

(cherry picked from commit 96de4ef7e00f44b3f7913db221625940da7f561a)
2024-10-16 10:25:48 -04:00