Commit Graph

2593 Commits

Author SHA1 Message Date
Aliaksandr Kalenik
768b8415f2 LibWeb: Follow the spec more precisely in Element::getClientRects()
Now, `Element::getBoundingClientRect()` implementation depends on
`Element::getClientRects()`, as defined in the specification.
2024-01-30 14:50:25 +01:00
Aliaksandr Kalenik
16f1962f10 LibWeb: Use clip rectangles assigned to paintables in hit-testing
This change makes hit-testing more consistent in the handling of hidden
overflow by reusing the same clip-rectangles.

Also, it fixes bugs where the box is visible for hit-testing even
though it is clipped by the hidden overflow of the containing block.
2024-01-30 11:22:22 +01:00
Nico Weber
6971ba35d5 LibGfx+Tests: Support grayscale jpegs with 2x2 sampling and MCU reset
Non-interleaved files always have an MCU of one data unit.

(A "data unit" is an 8x8 tile of pixels, and an "MCU" is a
"minium coded unit", e.g. 2x2 data units for luminance and
1 data unit each for Cr and Cb for a YCrCb image with
4:2:0 subsampling.)

For the test case, I converted an existing image to a ppm:

    Build/lagom/bin/image -o out.ppm \
        Tests/LibGfx/test-inputs/jpg/12-bit.jpg

Then I converted it to grayscale and saved it as a pgm in Photoshop.
Then I turned it into a weird jpeg like so:

    path/to/cjpeg \
        -outfile Tests/LibGfx/test-inputs/jpg/grayscale_mcu.jpg \
        -sample 2x2 -restart 3 out.pgm

Makes 3 of the 5 jpegs failing to decode at #22780 go.
2024-01-30 05:35:22 +01:00
Timothy Flynn
5a99a6afb4 LibWeb: Implement ReadableStreamBYOBRequest.respondWithNewView
The AO behind this prototype was added in commit ed1076d9ca,
so we can now trivially expose the prototype as well.
2024-01-29 17:10:56 -05:00
Nico Weber
fd316728a0 Everywhere: Remove references to UserspaceEmulator 2024-01-29 20:20:55 +00:00
Tim Ledbetter
4e383bdac1 LibWeb: Set select element text when an option is initially selected
Previously, a select element's text would initially be empty if the
`selected` property was set on one of its options.
2024-01-29 20:05:14 +00:00
MacDue
b10f58a1fe LibWeb: Support x and y attributes on nested SVGs
This allows positioning a child SVG relative to its parent SVG.

Note: These have been implemented as CSS properties as in SVG 2, these
are geometry properties that can be used in CSS (see
https://www.w3.org/TR/SVG/geometry.html), but there is not much browser
support for this. It is nicer to implement than the ad-hoc SVG
attribute parsing though, so I feel it may make sense to port the rest
of the attributes specified here (which should fix some issues with
viewport relative sizes).
2024-01-29 10:01:10 +00:00
Aliaksandr Kalenik
556679fedd LibWeb: Account for scroll offset in hit-testing
The hit-testing position is now shifted by the scroll offsets before
performing any checks for containment. This is implemented by assigning
each PaintableBox/InlinePaintable an offset corresponding to the scroll
frame in which it is contained. The non-scroll-adjusted position is
still passed down when recursing to children because the assigned
offset accumulated for nested scroll frames.

With this change, hit testing works in the Inspector.
Fixes https://github.com/SerenityOS/serenity/issues/22068
2024-01-29 09:57:40 +01:00
Timothy Flynn
6981ddfe13 LibWeb: Implement the ReadableByteStreamTee half of ReadableStreamTee 2024-01-29 07:21:59 +01:00
Timothy Flynn
debfe996d7 LibWeb: Implement the ReadableStreamDefaultTee half of ReadableStreamTee 2024-01-29 07:21:59 +01:00
Aliaksandr Kalenik
20de69693b LibWeb: Fix hidden overflow clipping with nested CSS transforms
This is a fix for regression introduced in
0bf82f748f

All CSS transforms need to be removed from the clip rectangle before
applying it. However, it is still necessary to calculate it with
applied transforms to find the correct intersection of all clip
rectangles in the containing block chain.
2024-01-29 07:21:38 +01:00
Tim Ledbetter
d1226f0b15 LibWeb: Don't crash when querying offsets of empty inline elements
Previously, querying `offsetTop` or `offsetLeft` of an inline element
with no text would cause a crash.
2024-01-28 23:32:40 +01:00
Tim Ledbetter
99fbd33d7d LibWeb: Make button flex wrapper inherit min-height property
This ensures that the vertical positioning of button text is correct
if a `min-height` property is present.
2024-01-28 14:48:33 +01:00
Aliaksandr Kalenik
0bf82f748f LibWeb: Move clip rect calculation to happen before painting
With this change, clip rectangles for boxes with hidden overflow or the
clip property are no longer calculated during the recording of painting
commands. Instead, it has moved to the "pre-paint" phase, along with
the assignment of scrolling offsets, and works in the following way:

1. The paintable tree is traversed to collect all paintable boxes that
   have hidden overflow or use the CSS clip property. For each of these
   boxes, the "final" clip rectangle is calculated by intersecting clip
   rectangles in the containing block chain for a box.
2. The paintable tree is traversed another time, and a clip rectangle
   is assigned for each paintable box contained by a node with hidden
   overflow or the clip property.

This way, clipping becomes much easier during the painting commands
recording phase, as it only concerns the use of already assigned clip
rectangles. The same approach is applied to handle scrolling offsets.

Also, clip rectangle calculation is now implemented more correctly, as
we no longer stop at the stacking context boundary while intersecting
clip rectangles in the containing block chain.

Fixes:
https://github.com/SerenityOS/serenity/issues/22932
https://github.com/SerenityOS/serenity/issues/22883
https://github.com/SerenityOS/serenity/issues/22679
https://github.com/SerenityOS/serenity/issues/22534
2024-01-28 08:25:28 +01:00
MacDue
5cf1570f40 LibWeb: Add initial support for nesting SVG viewports
Previously, we were handling viewBoxes/viewports in a slightly hacky
way, asking graphics elements to figure out what viewBox to use during
layout. This does not work in all cases, and can't allow for more
complex SVGs where it is possible to have nested viewports.

This commit makes the SVGFormattingContext keep track of the
viewport/boxes, and it now lays out each viewport recursively, where
each nested `<svg>` or `<symbol>` can establish a new viewport.

This fixes some previous edge cases, and starts to allow nested
viewports (there's still some issues to resolve there).

Fixes #22931
2024-01-27 18:12:13 +01:00
Andreas Kling
546143e9a6 LibWeb: Fix vector OOB access when comparing some calc() values
Before comparing the elements of two vectors, we have to check that
they have the same length. :^)

Fixes a crash seen on https://chat.openai.com/
2024-01-27 17:06:43 +01:00
Timothy Flynn
9272d185ad LibWeb: Implement a slightly better ad-hoc Body::clone method
Just creating a stream on the JS heap isn't enough, as we will later
crash when trying to read from that stream as it hasn't been properly
initialized. Instead, until we have teeing implemented (which is a
rather huge part of the Streams spec), create streams using proper AOs
that do initialize the stream.
2024-01-27 16:01:56 +01:00
Andrew Kaster
08a3c562f3 LibWeb: Resolve postMessage test promises if iframes already loaded
For some reason on macOS with ASAN enabled, the test promises in
HTML/Window-postMessage do not resolve. These promises wait for both
the in-document and the blob url iframes to load. It's not clear why
this works fine in Linux nor why the onload handler doesn't fire
when the iframe has already loaded.
2024-01-27 07:51:30 +01:00
Sam Atkins
e025bcc4f9 LibWeb: Make use of transform-box when calculating transforms
We don't currently calculate the fill- or stroke-boxes of SVG elements,
so for now we use the content- and border-boxes respectively, as those
are the closest equivalents. The test will need updating when we do
support them.

Also, the test is a screenshot because of rendering differences when
applying transforms: a 20px box does not get painted the same as a 10px
box scaled up 2x. Otherwise that would be the more ideal form of test.
2024-01-27 07:46:37 +01:00
Sam Atkins
391cfdc085 LibWeb: Parse the CSS transform-box property 2024-01-27 07:46:37 +01:00
Nico Weber
c694d4326b Tests: Add a pam cmyk test file
Hand-written in a text editor.

I verified that `convert` converts it to a png that looks like the
rgb test expectations.
2024-01-26 07:36:53 +01:00
Nico Weber
ba8f4e73bf Tests: Add a pam test file
Hand-written in a text editor.

I verified that `convert` converts it to a png that looks like the
test expectations.
2024-01-26 07:36:53 +01:00
Aliaksandr Kalenik
d5e3158cfe LibWeb: Use PaintableFragment::baseline() in paint_text_decoration()
No need to calculate baseline based on glyph height when we can get
this information from a fragment.
2024-01-26 07:36:40 +01:00
Timothy Flynn
09124fc3a5 LibWeb: Set up the Fetch response's body with the appropriate stream 2024-01-25 21:34:03 +01:00
Nico Weber
550937f5dd Tests: Add a test cmyk jpeg file with an embedded color profile
I opened Base/res/graphics/buggie.png in Photoshop, converted it
to U.S. Web Coated (SWOP) v2, flattened the image so we don't have
CMYK with alpha, and saved it as a jpeg (with color profile embedded).
2024-01-25 15:53:44 +01:00
Aliaksandr Kalenik
c02820759b LibWeb: Test nested elements in InlinePaintable::hit_test()
Before this change we were ignoring nested paintables inside inline
paintable during hit-testing, but now we recurse into subtree.

Fixes https://github.com/SerenityOS/serenity/issues/22927
2024-01-25 15:53:18 +01:00
Andreas Kling
1583e6ce07 LibWeb: Clamp justification space between flex items to 0
Before this change, it was possible for flex lines with negative
remaining space (due to overflowing items) to put a negative amount
of space between items for some values of `justify-content`.

This makes https://polar.sh/SerenityOS look much better :^)
2024-01-25 15:10:21 +01:00
Andreas Kling
e668cdcf22 Tests/LibWeb: Skip HTML/Window-postMessage.html since it's flakey 2024-01-25 13:50:40 +01:00
Andreas Kling
b12541b286 LibWeb: Add SVGSVGElement.viewBox attribute
This attribute has some compatbility issues...
- The spec says it should be an SVGAnimatedRect which contains
  a DOMRect and a DOMReadOnlyRect.
- Blink gives you an SVGAnimatedRect with 2x SVGRect
- Gecko gives you an SVGAnimatedRect with 2x SVGRect? (nullable)

I ended up with something similar to Gecko, an SVGAnimatedRect
with 2x DOMRect? (nullable)

With this fixed, we can now load https://polar.sh/ :^)
2024-01-25 08:23:41 +01:00
Lucas CHOLLET
a17041fe7f LibGfx/TIFF: Add support for CMYK
The test case has been generated with Krita.
2024-01-24 22:16:22 -07:00
Andrew Kaster
bf32a2027b LibWeb: Add happy path test for SubtleCrypto importKey and digest 2024-01-23 14:07:06 -07:00
Tim Ledbetter
7a3fc621bd LibWeb: Remove invalid assertion in table fixup
Previously, our code for the fixup of table rows assumed that missing
cells in a table row must be sequential. This may not be true if the
table contains cells have a rowspan greater than one.
2024-01-23 10:17:00 +01:00
Lucas CHOLLET
1faf9bb44f LibGfx/TIFF: Apply the HorizontalDifferencing on the alpha channel
When present, the alpha channel is also affected by the horizontal
differencing predictor.

The test case was generated with GIMP with the following steps:
 - Open an RGB image
 - Add a transparency layer
 - Export as TIFF with the LZW compression scheme
2024-01-22 20:10:48 -07:00
Aliaksandr Kalenik
1294cfb55c LibWeb: Find font that has whitespace glyph in first_available_font()
Fixes https://github.com/SerenityOS/serenity/issues/22853
2024-01-22 14:14:59 +01:00
MacDue
9f710b0fb6 Revert "LibGfx: Slightly simplify Color::blend()"
This was producing incorrect results.

This reverts commit a1bafafd78.
2024-01-22 07:12:25 +01:00
Dan Klishch
b5f1a48a7c AK+Everywhere: Remove JsonValue APIs with implicit default values 2024-01-21 15:47:53 -07:00
Dan Klishch
faef802229 AK+GMLCompiler: Remove JsonValue::as_double()
Replace its single (non-test) usage with newly created as_number(),
which does not leak information about internal integer storage type.
2024-01-21 15:47:53 -07:00
Dan Klishch
5230d2af91 AK+WebContent: Remove JsonValue::as_{i,u}{32,64}() 2024-01-21 15:47:53 -07:00
Dan Klishch
b74df136fe JSSpecCompiler: Always treat trailing MemberAccess as punctuation
Due to the way expression parser is written, we need to resolve the
ambiguity between member access operators and dots used for punctuation
during lexing. The lexer uses a (totally bulletproof) heuristic to do
that: whenever '.' is followed by ' ' or '\n', it is considered a dot
and member access otherwise. While it works fine for prettified test
cases, non-prettified files often lack enter after a trailing dot
character. Since MemberAccess will always be invalid at that position,
explicitly treat trailing dot as a part of punctuation.
2024-01-21 14:57:10 -07:00
Dan Klishch
b4a9fde756 JSSpecCompiler: Recurse into the correct subtrees in RecursiveASTVisitor
RecursiveASTVisitor was recursing into the subtrees of an old root if it
was changed in on_entry callback. Fix that by querying root pointer just
after on_entry callback returns. While on it, also use
`AK::TemporaryChange` instead of setting `m_current_subtree_pointer`
manually.

As it turns out, `FunctionCallCanonicalizationPass` was relying on being
able to replace tree on entry, and the bug in RecursiveASTVisitor made
the pass to not fully canonicalize nested function calls.

The changes to GenericASTPass.cpp alone are enough to fix the problem
but it is canonical (for some definition of canonicity) to only change
trees in on_leave. Therefore, the commit also switches
FunctionCallCanonicalizationPass to on_leave callback.

A test for this fix and one from the previous commit is also included.
2024-01-21 14:57:10 -07:00
Ali Mohammad Pur
4f6c9f410c AK+LibCore: Add BufferedSocket::can_read_up_to_delimiter()
This method (unlike can_read_line) ensures that the delimiter is present
in the buffer, and doesn't return true after eof when the delimiter is
absent.
2024-01-21 21:13:58 +01:00
Aliaksandr Kalenik
7e2308d290 LibWeb: Treat null as empty string in CSSStyleDeclaration::internal_set
Spec defines `[LegacyNullToEmptyString]` on `value` argument of
`setProperty` but since `internal_set` calls `setProperty` directly
instead of using IDL generated binding, we need to make sure that null
is treated as empty string.

Fixes items grid loading on https://d.rsms.me/stuff/
2024-01-21 21:03:39 +01:00
MacDue
e9e1ee11d4 LibGfx: Decrease flatness a little in Path::stroke_to_fill()
Noticed larger stroke widths were looking a little 'low poly', this
looks a little nicer.

(Minor LibWeb test changes)
2024-01-21 19:23:31 +01:00
Tim Ledbetter
58df9c45b9 LibWeb: Avoid division by zero when computing table width
Previously, a crash could occur when computing the width of a table
with cells that had a percentage width of 0.
2024-01-21 16:11:25 +01:00
Andreas Kling
1041dbb007 LibWeb: Don't lose track of inline margins when collapsing whitespace
When iterating inline level chunks for a piece of text like " hello ",
we will get three separate items from InlineLevelIterator:

- Text " "
- Text "hello"
- Text " "

If the first item also had some leading margin (e.g margin-left: 10px)
we would lose that information when deciding that the whitespace is
collapsible.

This patch fixes the issue by accumulating the amount of leading margin
present in any collapsed whitespace items, and then adding them to the
next non-whitespace item in IFC.

It's a wee bit hackish, but so is the rest of the leading/trailing
margin mechanism.

This makes the header menu on https://www.gimp.org/ look proper. :^)
2024-01-20 23:29:51 +01:00
Aliaksandr Kalenik
c1161111a7 LibWeb: Stop assuming navigable's existance in FrameBox
If the loading of iframe's navigable has not finished by the time
FrameBox layout occurs, we should not crash.

Fixes https://github.com/SerenityOS/serenity/issues/22874
2024-01-20 20:34:30 +00:00
Bastiaan van der Plaat
e2bc606eeb LibWeb: Add MouseEvent JavaScript constructor 2024-01-20 08:57:37 +01:00
Bastiaan van der Plaat
9aadc6c8c9 LibWeb: Add missing EventModifierInit fields and getModifierState 2024-01-20 08:57:37 +01:00
Sam Atkins
071f7fd818 LibCore+JSSpecCompiler: Add option for Process::spawn() to use spawnp()
Add a boolean to ProcessSpawnOptions, `search_for_executable_in_path`,
which when true, calls into posix_spawnp() instead of posix_spawn().
This defaults to false to maintain the existing behavior.

The `path` field is renamed to `executable` because having two fields
refer to "path" and mean different things seemed unnecessarily
confusing.
2024-01-19 12:16:21 -07:00
Lucas CHOLLET
c2c7365494 LibGfx/TIFF: Accept images with a single strip and no RowsPerStrip tag
This tag is required by the specification, but some encoders (at least
Krita) don't write it for images with a single strip.

The test file was generated by opening deflate.tiff in Krita and saving
it with the DEFLATE compression.
2024-01-19 14:13:44 +01:00
Andrew Kaster
682a6d5882 Tests: Add tests for navigation.navigate() 2024-01-19 11:47:59 +01:00
Andrew Kaster
6c1944ee61 LibWeb: Flesh out apply the history step to setup the navigation API
We now populate the navigation history entries in the navigation API and
fire more navigation events as appropriate.
2024-01-19 11:47:59 +01:00
Andreas Kling
9f6841a65c LibWeb: Update layout before looking at overflow in window.scroll()
Fixes a crash seen on https://www.ekioh.com/
2024-01-19 09:16:54 +01:00
Andrew Kaster
2505cecc0f LibWeb: Exclude [Global] interfaces from legacy platform object methods
Window and other global objects are not technically legacy platform
objects, and have other ways to override their setters and getters.

However, Window does need to share some code with the legacy platform
object paths, and simply adding another bool check to the mix seems
the shortest putt.
2024-01-19 09:02:00 +01:00
Timothy Flynn
2b22402c6a LibWeb: Correctly categorize Fetch responses as network errors
The condition here is flipped. From the spec:

     A network error is a response whose ... body is null ...
2024-01-18 23:10:56 +01:00
implicitfield
05ee5ffa36 LibCrypto: Add support for the POSIX cksum algorithm 2024-01-18 18:01:26 +03:30
Nico Weber
09a91e54c0 Tests: Add a pdf with text rotation
As usual, lovingly hand-written, with offsets fixed up with

    mutool clean Tests/LibPDF/rotate.pdf  Tests/LibPDF/rotate.pdf
2024-01-18 14:01:30 +01:00
Nico Weber
8507151850 Tests/LibPDF: Make text.pdf also use Tz, Tc, Tw, Ts operators
These set the horizontal scale factor, character spacing, word
spacing, and text rise respectively.

Also add a global scale transform, and set a text transform matrix
with a scale for some of the text.
2024-01-18 14:01:30 +01:00
Lucas CHOLLET
75d87ccf5f LibGfx/TIFF+CCITT: Start to decode CCITT Group 3 images
We currently only support 1D Group 3, but that's a start.

The test case was generated with GIMP (it happens to be 1D by chance).
2024-01-18 14:00:56 +01:00
Lucas CHOLLET
edffdc35a9 LibGfx/TIFF+CCITT: Clarify naming of compression type 2
Type 2 <=> One-dimensional Group3, customized for TIFF
Type 3 <=> Two-dimensional Group3, uses the original 1D internally
Type 4 <=> Two-dimensional Group4

So let's clarify that this is not Group3 1D but the TIFF variant, which
is called `CCITTRLE` in libtiff. So let's stick with this name to avoid
confusion.
2024-01-18 14:00:56 +01:00
Nicolas Ramz
534eeb6c4b LibGfx/ILBMLoader: Properly display images with a bitplane mask
Images with a display mask ("stencil" as it's called in DPaint) add
an extra bitplane which acts as a mask. For now, at least skip it
properly. Later we should render masked pixels as transparent, but
this requires some refactoring.
2024-01-18 13:59:17 +01:00
Aliaksandr Kalenik
a22ef086f5 LibWeb/CSS: Support calc() in grid placement values
Fixes reduction in https://github.com/SerenityOS/serenity/issues/22802
but does not result in visual improvement on https://kotlinlang.org/
2024-01-17 17:26:55 +01:00
Aliaksandr Kalenik
0a09ff698f LibWeb: Fix accounting for gaps in auto-fit count calculation in GFC
Fixes a bug where gaps between repeated tracks were accounted for only
once instead of multiple times, corresponding to the repeat count.

Fixes https://github.com/SerenityOS/serenity/issues/22823
2024-01-17 15:15:06 +01:00
Aliaksandr Kalenik
6a4dd8fa47 LibWeb: Account for gaps in grid container's intrinsic size calculation
Fixes https://github.com/SerenityOS/serenity/issues/22804
2024-01-16 21:54:23 +01:00
Aliaksandr Kalenik
f529188fb8 LibWeb: Resolve CSS transform lengths against padding rect
Fixes https://github.com/SerenityOS/serenity/issues/22797
2024-01-16 21:54:10 +01:00
Andreas Kling
2d50dee920 LibWeb: Use correct max-size in intrinsic sizing of column flex layout
Regressed in 72dd37438d
2024-01-16 13:14:00 +01:00
Aliaksandr Kalenik
9e23503c9c LibWeb: Align with spec "stretch auto tracks" step in GFC
Now, we will evenly distribute the remaining free space across tracks
using the auto max-tracks sizing function, exactly as the specification
states. Many tests are affected, but they are not visually broken.

Fixes https://github.com/SerenityOS/serenity/issues/22798
2024-01-16 13:13:47 +01:00
Sam Atkins
8d80841e9c LibFileSystem+Everywhere: Return ByteString from read_link() 2024-01-16 08:42:34 +00:00
Lucas CHOLLET
015c47da51 Tests/LibGfx: Use TRY_OR_FAIL more in TestImageDecoder 2024-01-15 23:16:57 -07:00
Andreas Kling
58b5181364 LibWeb: Skip select element internal shadow tree update unless it exists
This fixes a crash seen on https://www.gaslightanthem.com/
2024-01-15 23:45:02 +01:00
Nico Weber
3616d14c80 LibGfx/JPEG: Allow decoding more subsampling factors
We now allow all subsampling factors where the subsampling factors
of follow-on components evenly decode the ones of the first component.

In practice, this allows YCCK 2111, CMYK 2112, and CMYK 2111.
2024-01-15 11:20:11 -07:00
Aliaksandr Kalenik
64a48065b0 LibWeb: Check if corners have radius after converting to device pixels
Check needs to happen after conversion because non-zero radius in
CSSPixels could turn into zero in device pixels.

Fixes https://github.com/SerenityOS/serenity/issues/22765
2024-01-15 15:21:17 +01:00
Aliaksandr Kalenik
cc447c9c80 LibWeb+WebContent: Move paint recording init into Navigable
This refactoring makes WebContent less aware of LibWeb internals.
The code that initializes paint recording commands now resides in
`Navigable::paint()`. Additionally, we no longer need to reuse
PaintContext across iframes, allowing us to avoid saving and restoring
its state before recursing into an iframe.
2024-01-15 14:33:56 +01:00
Andreas Kling
72dd37438d LibWeb: Treat flex item cross axis max-size as "none" in more cases
There are a bunch of situations where we need to treat cross axis
max-size properties as "none", notably percentage values when the
reference containing block size is an intrinsic sizing constraint.

This fixes an issue where flex items with definite width would get
shrunk to 0px by "max-width: 100%" in case the item itself is an
SVG with no natural width or height.

For consistency, we now use the should_treat_max_width/height_as_none
helpers throughout FFC.

This makes the search/account/cart icons show up in the top right
on https://twinings.co.uk :^)
2024-01-15 12:55:47 +01:00
Nico Weber
9a93f677f4 LibPDF: Mark text rendering matrix as dirty after TJ numbers
Mostly because I audited all places that assigned to `m_text_matrix`
after #22760.

This one is very difficult to trigger in practice.

`show_text()` marks the text rendering matrix dirty already,
so this only has an effect if the `TJ` array starts with a
number, and the matrix isn't marked dirty going in.

`Tm` caches the text rendering matrix, so I changed text.pdf
to contain:

```
1 0 0 1 45 130 Tm
[ 200 (Hello) -2000 (World) ] TJ T*
```

This first sets an x offset of 5 (on top of the normal 40), and
then undoes it (`200` is multiplied by font size (25) / -1000,
and `200 * 25 / -1000` is -5). Before this change, the topmost
"Hello World" ended up slightly indented.

Likely no behavior change in practice, but makes the code easier
to understand, and maybe it helps in the wild somewhere.
2024-01-15 08:39:04 +00:00
Shannon Booth
3910efb80b LibWeb: Implement Element.removeAttributeNS 2024-01-14 16:10:18 -07:00
Shannon Booth
7a26a889cb LibWeb: Implement Element.getAttributeNodeNS 2024-01-14 16:10:18 -07:00
Nicolas Ramz
a1255cb6c9 LibGfx/ILBMLoader: Don't decode bits once full row has been decoded
We were potentially decoding more bits than needed: this could
trash the next lines if decoder didn't zero the extra bits.
2024-01-14 20:41:25 +01:00
Tim Ledbetter
d545fb2b60 LibCrypto: Parse negative input correctly in BigFraction::from_string()
Previously, when calling `BigFraction::from_string()`, the fractional
part of the number was always treated as positive. This led to an
incorrect result if the input string was negative.
2024-01-14 20:15:15 +01:00
Shannon Booth
4135c3885c LibWeb: Only wait for document to be ready for scripts if executing one
HTML fragments are parsed with a temporary HTML document that never has
its flag set to say that it is ready to have scripts executed. For these
fragments, in the HTMLParser, these scripts are prepared, but
execute_script is never called on them.

This results in the HTMLParser waiting forever on the document to be
ready to have scripts executed.

To fix this, only wait for the document to be ready if we are definitely
going to execute a script.

This fixes a hang processing the HTML in the attached test, as seen on:
https://github.com/SerenityOS/serenity

Fixes: #22735
2024-01-14 11:27:58 +00:00
Tim Ledbetter
48a3a02238 LibCrypto: Make constructing a BigInteger from string fallible
Previously, constructing a `UnsignedBigInteger::from_base()` could
produce an incorrect result if the input string contained a valid
Base36 digit that was out of range of the given base. The same method
would also crash if the input string contained an invalid Base36 digit.
An error is now returned in both these cases.

Constructing a BigFraction from string is now also fallible, so that we
can handle the case where we are given an input string with invalid
digits.
2024-01-13 19:01:35 -07:00
Tim Ledbetter
65827826fe AK: Add CharacterTypes::is_ascii_base36_digit()
This can be used to validate the string passed to
`parse_ascii_base36_digit()`.
2024-01-13 19:01:35 -07:00
Tim Ledbetter
bbdbd71439 Tests/AK: Add unit test for Base36 digit parsing 2024-01-13 19:01:35 -07:00
Liav A
90152dc859 Tests/Kernel: Add test cases for proper types in dirent for various FSes 2024-01-13 19:01:07 -07:00
Lucas CHOLLET
75bd1308c5 Tests/LibCompress: Add a reproducer of oss-fuzz issue 58046
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=58046
2024-01-13 15:17:08 -07:00
Bastiaan van der Plaat
63c6eae918 LibWebView: Fix sanitizing about scheme URLs 2024-01-13 13:41:09 -05:00
Aliaksandr Kalenik
2960bf4ec8 LibWeb: Make inline paintables own their fragments
The paintable tree structure more closely matches the painting order
when fragments are owned by corresponding inline paintables. This
change does not affect the layout tree, as it is more convenient for
layout purposes to have all fragments owned by a block container in
one place.

Additionally, this improves performance significantly on pages with
many fragments, as we no longer have to walk the ancestor chain up
to the closest block container to determine if a fragment belongs
to an inline paintable.
2024-01-13 18:46:41 +01:00
Aliaksandr Kalenik
de32b77ceb LibWeb: Use separate structure to represent fragments in paintable tree
This is a part of refactoring towards making the paintable tree
independent of the layout tree. Now, instead of transferring text
fragments from the layout tree to the paintable tree during the layout
commit phase, we allocate separate PaintableFragments that contain only
the information necessary for painting. Doing this also allows us to
get rid LineBoxes, as they are used only during layout.
2024-01-13 10:53:38 +01:00
Shannon Booth
785fa60cca LibWeb: Implement Element.getAttributeNS 2024-01-13 08:33:10 +01:00
Dan Klishch
ccd701809f Everywhere: Add deprecated_ prefix to JsonValue::to_byte_string
`JsonValue::to_byte_string` has peculiar type-erasure semantics which is
not usually intended. Unfortunately, it also has a very stereotypical
name which does not warn about unexpected behavior. So let's prefix it
with `deprecated_` to make new code use `as_string` if it just wants to
get string value or `serialized<StringBuilder>` if it needs to do proper
serialization.
2024-01-12 17:41:34 -07:00
Kemal Zebari
3aaa1c1df7 LibWeb/MimeSniff: Implement MP4 signature matching 2024-01-12 17:12:47 -07:00
kleines Filmröllchen
eada4f2ee8 AK: Remove ByteString from GenericLexer
A bunch of users used consume_specific with a constant ByteString
literal, which can be replaced by an allocation-free StringView literal.

The generic consume_while overload gains a requires clause so that
consume_specific("abc") causes a more understandable and actionable
error.
2024-01-12 17:03:53 -07:00
Martin Janiczek
5a8781393a AK: Cover TestComplex with more tests
Related:
- video detailing the process of writing these tests: https://www.youtube.com/watch?v=enxglLlALvI
- PR fixing bugs the above effort found: https://github.com/SerenityOS/serenity/pull/22025
2024-01-12 16:42:51 -07:00
Martin Janiczek
d52ffcd830 LibTest: Add more numeric generators
Rename unsigned_int generator to number_u32.
Add generators:
- number_u64
- number_f64
- percentage
2024-01-12 16:42:51 -07:00
Nico Weber
b47695c87e Tests: Add a pdf that embeds a wide-gamut 16-bits/channel image
I opened Tests/LibGfx/test-inputs/png/wide-gamut-only.png in
Preview.app and used File->Export as PDF... to convert it to a PDF.

I then ran

    mutool clean -d Tests/LibPDF/wide-gamut-only.pdf \
                    Tests/LibPDF/wide-gamut-only.pdf

to decompress it, edited by hand to remove padding around the image
and shrunk the page's MediaBox to be as big as the image, and ran the
command above again to fix up binary offsets in the xref table.
2024-01-12 16:20:46 -07:00
Nico Weber
1b4f9bdbdb Tests: Add a png in Display P3 that shows up as solid color in sRGB
I created a 16-bpp RGB file in Display P3 in photoshop, filled it
with (0, 255, 0), and then drew something on it with (100, 255, 0).

(Since it's a 16-bpp image, 255 ix stored as 0xffff and 100 is stored
as 65535 * 100 / 255 == 0x6464 in the file.)

I verified that Edit->Convert to Profile...->sRGB resulted in an
image filled with (0, 255, 0) in that color space (due to gamut
clipping).

Similar to these:
* https://webkit.org/blog-files/color-gamut/Webkit-logo-P3.png
* https://www.dropbox.com/s/tgarynpj65ouafd/insta-logo.png?dl=1

...but in green instead of in red, and hand-drawn by me so no license
concerns.
2024-01-12 16:20:46 -07:00
Andreas Kling
e7de5cb4d2 LibWeb: Bring CSS line-height closer to other engines
This patch makes a few changes to the way we calculate line-height:

- `line-height: normal` is now resolved using metrics from the used
  font (specifically, round(A + D + lineGap)).

- `line-height: calc(...)` is now resolved at style compute time.

- `line-height` values are now absolutized at style compute time.

As a consequence of the above, we no longer need to walk the DOM
ancestor chain looking for line-heights during style computation.
Instead, values are inherited, resolved and absolutized locally.

This is not only much faster, but also makes our line-height metrics
match those of other engines like Gecko and Blink.
2024-01-12 15:04:06 +01:00
Andrew Kaster
b5ec520f84 LibWeb: Implement named and indexed property access for HTMLFormElement 2024-01-12 09:11:18 +01:00
Ali Mohammad Pur
e265d81277 LibRegex: Correct And/Or and inversion interplay semantics
This commit also fixes an incorrect test case from very early on, our
behaviour now matches the ECMA262 spec in this case.

Fixes #21786.
2024-01-11 11:36:09 +01:00
Aliaksandr Kalenik
225ed58f7e LibWeb/CSS: Resolve NumericCalculationNode to percentage when requested
When the caller of NumericCalculationNode::resolve() does not provide
a percentage_basis, it expects the method to return a raw percentage
value.

Fixes crashing on https://discord.com/login
2024-01-11 08:01:47 +01:00
Shannon Booth
faccca7b32 LibWeb: Add ref-tests for 3-value background positions with center 2024-01-10 23:27:28 +01:00
Timothy Flynn
00510e40d9 LibWeb: Convert the cookie test page to a text test 2024-01-10 23:26:40 +01:00
Timothy Flynn
cd0e07f6a4 LibSQL: Add a helper to convert a SQL::Value to a UnixDateTime
Support for constructing a Value from a UnixDateTime was added in commit
effcd080ca.

That constructor just stores the value as the number of milliseconds
since epoch. There's no way for outside users to know this, so this adds
a helper to retrieve the value as a UnixDateTime and let SQL::Value be
the source of truth for how the value is encoded/decoded.
2024-01-10 23:26:40 +01:00
Andreas Kling
5af02a914c LibWeb: Let parent formatting context determine size of flex containers
Until now, we had implemented flex container sizing by awkwardly doing
exactly what the spec said (basically having FFC size the container)
despite that not really making sense in the big picture. (Parent
formatting contexts should be responsible for sizing and placing their
children)

This patch moves us away from the Flexbox spec text a little bit, by
removing the logic for sizing the flex container in FFC, and instead
making sure that all formatting contexts can set both width and height
of flex container children.

This required changes in BFC and IFC, but it's actually quite simple!
Width was already not a problem, and it turns out height isn't either,
since the automatic height of a flex container is max-content.
With this in mind, we can simply determine the height of flex containers
before transferring control to FFC, and everything flows nicely.

With this change, we can remove all the virtuals and FFC logic for
negotiating container size with the parent formatting context.
We also don't need the "available space for flex container" stuff
anymore either, so that's gone as well.

There are some minor diffs in layout test results from this, but the
new results actually match other browsers more closely, so that's fine.

This should make flex layout, and indeed layout in general, easier to
understand, since this was the main weird special case outside of
BFC/IFC where a formatting context delegates work to its parent instead
of the other way around. :^)
2024-01-10 16:28:12 +01:00
Bastiaan van der Plaat
675b242e84 LibWeb: Add missing CSS Transforms Module Level 2 functions 2024-01-10 09:48:25 +01:00
Bastiaan van der Plaat
c443f80137 LibWeb: Allow percentages on CSS transform scale functions 2024-01-10 09:48:25 +01:00
Nico Weber
7fb32b6682 LibGfx: Fix off-by-some in Painter::draw_scaled_bitmap_with_transform()
Before this, drawing a 1x1 bitmap scaled up to MxN would only fill
M/2 x N/2 pixel, due to source_point going outside (0, 0).
2024-01-10 09:38:13 +01:00
Shannon Booth
72d0257a19 LibWeb: Add ref-test cases for reordered keywords in CSS positions
Where if 'center' is present the horizontal or vertical values must be
used to infer whether center is X or Y.
2024-01-09 13:37:35 +00:00
implicitfield
c994326d5a LibWeb/CSS: Improve parsing of length percentage values for transforms 2024-01-09 14:15:05 +01:00
MacDue
00b24a55b1 LibWeb: Fix drawing axis-aligned lines
Previously, these were clipped by the RecordingPainter, which used the
path's bounding box (which in this case is zero width or height). The
fix is to expand the bounding box by the stroke width.

Fixes #22661

Note: This is unrelated to any recent LibGfx changes :^)
2024-01-09 00:03:09 +01:00
MacDue
fc41c282ec LibWeb: Fix utf16-be check in HTMLEncodingDetection
The utf-16be check mistakenly skipped index 3, so was not checking the
correct bytes. This meant UTF16-BE files could fail to decode.
2024-01-08 23:35:09 +01:00
MacDue
5e973fca0b LibWeb: Prevent OOB access in HTMLEncodingDetection for input of '</'
Previously, this never checked if `position + 2` was valid. This
slightly reorders the loop so all indices are checked.

Fixes #22163
2024-01-08 23:35:09 +01:00
Aliaksandr Kalenik
3f52d6045a LibWeb/CSS: Resolve percentages in NumericCalculationNode
Percentages should be resolved against the provided percentage basis
instead of just returning the underlying value.

Fixes https://github.com/SerenityOS/serenity/issues/22654
2024-01-08 15:57:42 +00:00
Nicolas Ramz
fc5b6e4dda LiGfx/ILBMLoader: Don't throw if malformed bitplane can be decoded
Some apps seem to generate malformed images that are accepted
by most readers. We now only throw if malformed data would lead to
a write outside the chunky buffer.
2024-01-08 07:21:27 -07:00
Lee Hanken
7e3249ad4c LibAudio: Test reading and writing of wav files
Includes a set of wav files of different frequencies, these are
each loaded and then written to a temporary file, checking that
the meta-data is correctly read and that the output matches the input.
2024-01-08 07:20:11 -07:00
Andreas Kling
aa245f9f18 LibWeb: Fix reverse flex layout with justify-content: normal
Before this change, we used the wrong insertion point for flex items
in reverse layouts with `justify-content: normal`. This caused flex
items to overflow the flex containers "backwards" from the start edge.
2024-01-08 14:42:19 +01:00
Aliaksandr Kalenik
6480ed20b8 LibWeb: Add support for implicit grid lines formed by grid areas in GFC
According to spec each grid area implicitly defines 4 additional named
lines that could be used to specify items position.
2024-01-08 09:28:37 +01:00
MacDue
13a4fb0325 LibGfx: Increase bezier splitting tolerance to 0.5
No noticeable difference a bit faster. This is still arbitrary and
should be somehow derived from the curve.
2024-01-08 09:26:43 +01:00
Aliaksandr Kalenik
5c02b960ab LibGfx: Take into account unicode ranges to find font for space glyph
Instead of assuming that the first font in the cascade font list will
have a glyph for space, we need to find it in the list taking into
account unicode ranges.
2024-01-08 01:00:24 +01:00
Lucas CHOLLET
335097e446 LibGfx/TIFF: Modify the image according to the Orientation tag
Let's use the already existing logic (ExifOrientedBitmap) to modify the
bitmap to honor the orientation tag.
2024-01-08 00:07:44 +01:00
Andreas Kling
ca57e40350 LibWeb: Take padding into account when resolving border radii
Before this change, we were resolving border radii values based on
content box + border widths only, ignoring padding.
2024-01-07 19:28:38 +01:00
Lucas CHOLLET
402de2985d LibGfx/ICO: Do not try to decode a mask if we already reached EOF
When using the BMP encoding, ICO images are expected to contain a 1-bit
mask for transparency. Regardless an alpha channel is already included
in the image, the mask is always required. As stated here[1], the
mask is used to provide shadow around the image.

Unfortunately, it seems that some encoder do not include that second
transparency mask. So let's read that mask only if some data is still
remaining after decoding the image.

The test case has been generated by truncating the 64 last bytes
(originally dedicated to the mask) from the `serenity.ico` file and
changing the declared size of the image in the ICO header. The size
value is stored at the offset 0x0E in the file and I changed the value
from 0x0468 to 0x0428.

[1]: https://devblogs.microsoft.com/oldnewthing/20101021-00/?p=12483
2024-01-07 12:32:02 -05:00
Lucas CHOLLET
9c54c13744 Tests/LibGfx: Move the ICO test file to the ico directory
And add more tests on the image than just "we are able to decode it".
2024-01-07 12:32:02 -05:00
Andreas Kling
4a35693dd7 LibWeb: Improve style propagation to anonymous wrappers
- We now propagate changes in font and line-height to anonymous wrappers
  when doing a partial style update after invalidation.

- We no longer (incorrectly) propagate style from table wrapper boxes
  to the table root, since inheritance works in the other direction.

Fixes #22395
2024-01-07 14:24:38 +01:00
Bastiaan van der Plaat
be7538961b LibWeb: Add DOMMatrix string constructor and set matrix value 2024-01-07 13:15:53 +01:00
Aliaksandr Kalenik
903d3c92c8 LibWeb: Support auto-fill for rows in GFC
This change fixes the function that calculates the number of auto-fill
tracks, ensuring it uses height when applied to rows, instead of
assuming that it always operates on columns.
2024-01-07 11:12:35 +01:00
Lucas CHOLLET
75fc51bb67 Tests/LibGfx: Fix a typo 2024-01-07 10:22:59 +01:00
Bastiaan van der Plaat
52397d01bd LibWeb: Add textarea placeholder 2024-01-07 10:22:32 +01:00
Bastiaan van der Plaat
091faf1aae LibWeb: Add textarea value properties 2024-01-07 10:22:32 +01:00
Aliaksandr Kalenik
a32046ea50 LibWeb: Fix auto-fill track counting to correctly handle gaps in GFC
Fixes the mistake that gaps are counted as if they exist after each
track, when actually gaps are present only between tracks.

Visual progression on https://kde.org/products/
2024-01-07 09:57:13 +01:00
Aliaksandr Kalenik
4bc38300ad LibWeb: Forbid using CSS::Length as reference value in resolved()
CSSPixels should not be wrapped into CSS::Length before being passed
to resolved() to end up resolving percentages without losing
precision.

Fixes thrashing layout when 33.3333% width is used together with
"box-sizing: border-box".
2024-01-07 09:03:57 +01:00
Aliaksandr Kalenik
e7eaf3b566 LibWeb: Remove rounding division for CSSPixels
Reverts 98926b487c
that regressed: block-and-inline/small-percentage-margin.html
(thrashing layout while window resizing)

Fixes https://github.com/SerenityOS/serenity/issues/22610
2024-01-06 21:40:27 +01:00
Andreas Kling
cc88a2657d LibWeb: Resolve grid item vertical margin/padding against CB width
Percentage vertical margin and padding values are relative to the
containing block *width*, not *height*. This has to be one of the most
commonly recurring mistakes we make :^)
2024-01-06 21:06:21 +01:00
Bastiaan van der Plaat
cf69fd0a09 LibWeb: Add input element valueAsDate property 2024-01-06 09:59:30 -07:00
hanaa12G
3c52c25515 LibC: Implement getgrgid_r() and getgrnam_r()
We currently don't have those 2 functions so let's add them
2024-01-06 04:59:50 -07:00
Aliaksandr Kalenik
9c72807976 LibWeb: Account for auto-fill/fit when expanding grid lines in GFC
Named line placement now works when auto-fill or auto-fit is used to
define grid columns.
2024-01-05 22:52:25 +01:00
Aliaksandr Kalenik
90142ad307 LibWeb: Account for gap in auto-fill columns count calculation in GFC
Fixes https://github.com/SerenityOS/serenity/issues/22603
2024-01-05 22:52:25 +01:00
Aliaksandr Kalenik
3cf5ad002a LibWeb: Allow inline nodes to establish a stacking context
With this change, a stacking context can be established by any
paintable, including inline paintables. The stacking context traversal
is updated to remove the assumption that the stacking context root is
paintable box.
2024-01-05 19:36:55 +01:00
Bastiaan van der Plaat
c1ba3e5fa9 LibWeb: Add support for LegacyWindowAlias IDL extended attribute 2024-01-05 18:28:48 +01:00
Aliaksandr Kalenik
cfcc459140 LibWeb: Fix grid line name placement when repeat() is used
Before this change, parsed grid-template-columns/grid-template-rows
were represented as two lists: line names and track sizes. The problem
with this approach is that it erases the relationship between tracks
and their names, which results in unnecessarily complicated code that
restores this data (incorrectly if repeat() is involved) during layout.
This change solves that by representing line definitions as a list of
sizes and names in the order they were defined.

Visual progression https://genius.com/
2024-01-05 13:21:09 +01:00
Andreas Kling
182a2b0c3a LibGfx/GIF: Only parse global color table if header flag is set
This fixes an issue where GIF images without a global color table would
have the first segment incorrectly interpreted as color table data.

Makes many more screenshots appear on https://virtuallyfun.com/ :^)
2024-01-05 13:20:00 +01:00
Kemal Zebari
5d14691149 LibWeb: Add rules for distinguishing if a resource is text or binary
Resolves a FIXME in MimeSniff::Resource allowing us to determine
the computed MIME type given supplied types that are used in older
versions of Apache that need special handling.
2024-01-04 12:25:38 -07:00
Kemal Zebari
0b7148e2a6 LibWeb/MimeSniff: Add sniffing in a font context 2024-01-04 12:25:38 -07:00
Timothy Flynn
8064c9fc4d AK: Add unit tests for StringUtils::find_last
This method was added without tests. Add some now to ensure future
changes do not break it.
2024-01-04 11:28:03 -05:00
Lucas CHOLLET
b8cbc282f3 LibGfx/TIFF: Don't stop decoding when failing to decode a tag
TIFF files are made in a way that make them easily extendable and over
the years people have made sure to exploit that. In other words, it's
easy to find images with non-standard tags. Instead of returning an
error for that, let's skip them.

Note that we need to make sure to realign the reading head in the file.

The test case was originally a 10x10 checkerboard image with required
tags, and also the `DocumentName` tag. Then, I modified this tag in a
hexadecimal editor and replaced its id with 30 000 (0x3075 as a LE u16)
and the type with the same value as well. This is AFAIK, never used as
a custom TIFF tag, so this should remain an invalid tag id and type.
2024-01-04 14:27:16 +01:00
Timothy Flynn
1b4a23095c AK: Add a Utf16View::starts_with method
Based heavily on Utf8View::starts_with.
2024-01-04 12:43:10 +01:00
Timothy Flynn
c46ba7e68d AK: Allow constructing a UTF-16 view from a UTF-16 string literal
UTF-16 string literals are a language-level feature. It is convenient to
be able to construct a Utf16View from these strings.
2024-01-04 12:43:10 +01:00
Shannon Booth
a545935997 LibWeb: Create XML Documents in DOMParser.parseFromString 2024-01-04 11:23:20 +01:00
Shannon Booth
cd156bad6b LibWeb: Create XMLDocuments in DOMImplementation.createDocument 2024-01-04 11:23:20 +01:00
Shannon Booth
e9dfa61588 LibWeb: Use UTF-16 code unit offsets in Range::to_string
Similar to another problem we had in CharacterData, we were assuming
that the offsets were raw utf8 byte offsets into the data, instead of
utf16 code units. Fix this by using the substring helpers in
CharacterData to get the text data from the Range.

There are more instances of this issue around the place that we will
need to track down and add tests for, but this fixes one of them :^)

For the test included in this commit, we were previously returning:

llo💨😮

Instead of the expected:

llo💨😮 Wo
2024-01-04 10:10:44 +01:00
Aliaksandr Kalenik
b6123df492 LibWeb: Add support for start, center and end justify-content in GFC
Fixes https://github.com/SerenityOS/serenity/issues/22555
2024-01-04 09:47:20 +01:00
Aliaksandr Kalenik
56ff9bffae LibWeb: Support "normal" and "stretch" justify-content in CSS parser 2024-01-04 09:47:20 +01:00
Aliaksandr Kalenik
b395cfccb0 LibWeb: Add support for "align-content: normal" in CSS parser 2024-01-04 09:47:20 +01:00
Tim Schumacher
707a36dd79 LibCompress/Brotli: Update the lookback buffer with uncompressed data
We previously skipped updating the lookback buffer when copying
uncompressed data, which resulted in a wrong total byte count.
With a wrong total byte count, our decompressor implementation
ended up choosing a wrong offset into the dictionary.
2024-01-03 17:54:36 +01:00
Nico Weber
4380be9d01 Tests/LibPDF: Add a PDF using the standard 14 fonts
Hand-written (with offsets fixed up by `mutool clean`).
Uses the default encoding for each font.  Manual test for now.

Byte strings generated with:

    python3 -c "for i in range(4):
        print('<' +
              ''.join('%02x' % r for r in range(i * 64, (i + 1) * 64)) +
              '>')"
2024-01-03 10:19:24 +01:00
Nico Weber
9495f64f91 LibPDF: Improve hex string parsing
A local (non-public) PDF I have lying around contains this in
a page's operator stream:

```
[<00b4003e> 3 <002600480051> 3 <005700550044004f0003> -29
<00330044> 3 <0055> -3 <004e0040> 4 <0003> -29 <004c00560003> -31
<0057004b> 4 <00480003> -37 <0050
>] TJ
```

That is, there's a newline in a hexstring after a character.

This led to `Parser error at offset 5184: Unexpected character`.

The spec says in 3.2.3 String Objects, Hexadecimal Strings:
"""Each pair of hexadecimal digits defines one byte of the string.
White-space characters (such as space, tab, carriage return, line feed,
and form feed) are ignored."""

But we didn't ignore whitespace before or after a character, only
in between the bytes.

The spec also says:
"""If the final digit of a hexadecimal string is missing—that is, if
there is an odd number of digits—the final digit is assumed to be 0."""

In that case, we were skipping the closing `>` twice -- or, more
accurately, we ignored the character after it too. This has been
wrong all the way back in #6974.

Add a test that fails if either of the two changes isn't present.
2024-01-02 22:13:21 +01:00
Aliaksandr Kalenik
49fcc5dcd8 LibWeb: Do not require box to be positioned to create stacking context
Instead of implementing stacking context painting order exactly as it
is defined in CSS2.2 "Appendix E. Elaborate description of Stacking
Contexts" we need to account for changes in the latest standards where
a box can establish a stacking context without being positioned, for
example, by having an opacity different from 1.

Fixes https://github.com/SerenityOS/serenity/issues/21137
2024-01-02 21:45:05 +01:00
Shannon Booth
6b88fc2e05 LibWeb: Properly convert UnderlyingSource's autoAllocateChunkSize to u64
The JS::Value being passed through is not a bigint, and needs to be
converted using ConvertToInt, as per:

https://webidl.spec.whatwg.org/#es-unsigned-long-long

Furthermore, the IDL definition also specifies that this is associated
with the [EnforceRange] extended attribute.

This makes it actually possible to pass through an autoAllocateChunkSize
to the ReadableStream constructor without it throwing a TypeError.
2024-01-02 10:01:26 +01:00
Luke Wilde
5af058d2b6 LibWeb: Only reload iframe on src/srcdoc attribute changes, not all
Fixes Cloudflare Turnstile suddenly going blank and stopping when it
changes the style attribute after doing some setup on the iframe.
2024-01-01 18:41:14 +01:00
Aliaksandr Kalenik
e8f04be3ae LibWeb/CSS: Fix crashing when calc() is used for border-radius
`BorderRadiusStyleValue::absolutized` should not try to extract length
from LengthPercentage that represents calculated.
2024-01-01 10:12:20 +01:00
Timothy Flynn
c190294a76 LibCore: Fix compilation of infallible Promise::when_resolved handlers
This overload is currently unused. When used, it doesn't compile due to
mismatched return types in the handler provided to the function and the
type of `on_resolution`.
2024-01-01 10:11:45 +01:00
Ali Mohammad Pur
267040dde7 LibRegex: Error out on Eof when parsing nonempty class range elements
Fixes #22507.
2023-12-31 15:36:42 +01:00
MacDue
7c162747ef Tests/LibWeb: Add ref test for SVG background without natural size 2023-12-30 23:23:19 +01:00
Aliaksandr Kalenik
e394971209 AK+LibWeb: Use segmented vector to store commands in RecordingPainter
Using a vector to represent a list of painting commands results in many
reallocations, especially on pages with a lot of content.

This change addresses it by introducing a SegmentedVector, which allows
fast appending by representing a list as a sequence of fixed-size
vectors. Currently, this new data structure supports only the
operations used in RecordingPainter, which are appending and iterating.
2023-12-30 23:02:46 +01:00
Luke Wilde
7e8d3e370f LibWeb: Treat BufferSource as a DataView/ArrayBuffer/TA in IDL overloads
Required by WebAssembly.instantiate.
2023-12-30 18:50:29 +01:00
Luke Wilde
54972e3ceb LibWeb: Implement SVGUseElement#href
Required by Ruffle.
b196c8d1bc/web/packages/core/src/shadow-template.ts (L601-L602)
2023-12-30 18:50:29 +01:00
Luke Wilde
d503fd51ec LibWeb: Add test for valueAsNumber 2023-12-30 18:50:29 +01:00
Andreas Kling
9ce267944c LibWeb: Fix crash in HTML encoding detection when handling non-ASCII
The fix here was to stop using StringBuilder::append(char) when told to
append a code point, and switch to StringBuilder::append_code_point(u32)

There's probably a bunch more issues like this, and we should stop using
append(char) in general since it allows building of garbage strings.
2023-12-30 13:49:50 +01:00
Aliaksandr Kalenik
ac6b3c989d LibWeb: Apply scroll boxes offsets after painting commands recording
With this change, instead of applying scroll offsets during the
recording of the painting command list, we do the following:
1. Collect all boxes with scrollable overflow into a PaintContext,
   each with an id and the total amount of scrolling offset accumulated
   from ancestor scrollable boxes.
2. During the recording phase assign a corresponding scroll_frame_id to
   each command that paints content within a scrollable box.
3. Before executing the recorded commands, translate each command that
   has a scroll_frame_id by the accumulated scroll offset.

This approach has following advantages:
- Implementing nested scrollables becomes much simpler, as the
  recording phase only requires the correct assignment of the nearest
  scrollable's scroll_frame_id, while the accumulated offset from
  ancestors is applied subsequently.
- The recording of painting commands is not tied to a specific offset
  within scrollable boxes, which means in the future, it will be
  possible to update the scrolling offset and repaint without the need
  to re-record painting commands.
2023-12-30 11:10:24 +01:00
Lucas CHOLLET
73c8b4865e LibGfx/TIFF: Add AdobeDeflate compression support
This new compression is quite popular and uses a basic Zlib compression
to compress strips. Note that this is not part of the original TIFF
specification but in the Technical Notes from 2002:
https://web.archive.org/web/20160305055905/http://partners.adobe.com/public/developer/en/tiff/TIFFphotoshop.pdf

The test case was generated with GIMP.
2023-12-29 20:12:07 +01:00
Andrew Kaster
3c7abe22ca LibWeb: Skip window-scrollTo test that keeps timing out on macOS 2023-12-29 17:03:51 +01:00
Nico Weber
a2bd19fdac LibGfx/JPEG: Make ycck jpegs with just cc subsampled decode correctly
We currently assume that the K (black) channel uses the same sampling
as the Y channel already, so this already works as long as we don't
error out on it.
2023-12-29 09:45:31 -05:00
Nico Weber
4236798244 Tests/LibGfx: Add automated tests for ycck jpegs
Only one of the three test cases pass at the moment.
2023-12-29 09:45:31 -05:00
Nico Weber
e735ee5251 Tests/LibGfx: Add YCCK jpeg test files
Obtained by running:

    convert rgb_components.jpg -colorspace cmyk \
        -sampling-factor 1 ycck-1111.jpg
    convert rgb_components.jpg -colorspace cmyk \
        -sampling-factor 2 ycck-2111.jpg
    convert rgb_components.jpg -colorspace cmyk ycck-2112.jpg

where rgb_components.jpg is the file in Tests/LibGfx/test-inputs/jpg.

(I used the web version of `convert` at
https://cancerberosgx.github.io/magic/playground/index.html)

While this does indeed produce a cmyk jpg (using the YCCK encoding
internally), it uses the mathematical rgb->cmyk conversion and does
not embed an cmyk color space in the output jpg.

Normally, cmyk images are for printing and hence converting them
from cmyk to rgb using a color profile like SWOP leads to better
results. So if a cmyk image does not contain color space information,
applications might use something like SWOP instead of the simple
math transform to convert to RGB. Programs doing that will show
these images as fairly muted (and would arguably be correct doing
so).

Hence, tests using these images shouldn't check their RGB values.
Ideally, we'd add a way to get the raw cmyk data from a cmyk jpeg,
and then tests could test color values against that.

The -1111 image uses no subsampling, meaning each channel's sampling
factor is 1.

The -2111 image uses subsampling for the non-Y channels, meaning the
sampling factors are 2 for Y and 1 each for YYK.

The -2112 image uses subsampling for the two C channels, meaning the
sampling factors are 2 for Y and K and 1 each for YY.

We correctly render the -1111 variant (using e.g.
`Build/lagom/bin/image -o out.png .../ycck-1111.jpg).

We render the -2111 variant, but it looks pretty broken.

We refuse to decode the -2112 variant. This is #21259.

Manual tests for now, but having these in tree will make it easier
to write unit tests later, once things work better.
2023-12-29 08:17:10 +00:00
Timothy Flynn
507a5d8a07 AK: Add an option to zero-fill ByteBuffer data upon growth
This is to avoid UB in cases where we need to be able to read from the
buffer immediately after resizing it.
2023-12-27 19:30:39 +01:00
Lucas CHOLLET
d748edd994 LibCompress: Add a PackBits decoder
This compression scheme was quite popular during the 80's, and we can
still find it in use inside file formats such as TIFF or PDF.
2023-12-27 17:40:11 +01:00
MacDue
daecf741d4 LibWeb: Ensure DocumentObserver document_completely_loaded() is called
This stopped being called for anything without a navigable container
after 76a97d8, due to the early return. This broke SVG <use> elements
that reference elements defined later in the document.
2023-12-26 21:37:04 +01:00
Aliaksandr Kalenik
cd56ec6e5c LibWeb: Redo "tracks maximize" if initial run is over max-size in GFC
Implements missing "redo" step defined in the spec.
2023-12-26 19:19:50 +01:00
Idan Horowitz
863e8c30ad Kernel: Ensure sockets_by_tuple table entry is up to date on connect
Previously we would incorrectly handle the (somewhat uncommon) case of
binding and then separately connecting a tcp socket to a server, as we
would register the socket during the manual bind(2) in the sockets by
tuple table, but our effective tuple would then change as the result of
the connect updating our target peer address. This would result in the
the entry not being removed from the table on destruction, which could
lead to a UAF.

We now make sure to update the table entry if needed during connects.
2023-12-26 18:36:43 +01:00
Idan Horowitz
da2f33df82 Kernel: Stop modifying peer address/port in sendto on a TCP socket
POSIX (rightfully so) specifies that the sendto address argument is
ignored in connection-oriented protocols.

The TCPSocket also assumed the peer address may not change post-connect
and would trigger a UAF in sockets_by_tuple() when it did.
2023-12-26 18:36:43 +01:00
Aliaksandr Kalenik
b172c29d9a LibWeb: Apply min/max-widths to block container during intrinsic layout
Fixes https://github.com/SerenityOS/serenity/issues/22430
2023-12-26 16:24:51 +01:00
Aliaksandr Kalenik
ed42b12123 LibWeb: Respect box-sizing in min-height calculation of grid container 2023-12-26 11:13:38 +01:00
Andrew Kaster
fd70e1a9ce LibWeb: Skip Worker-echo test again
Turns out it's still flaky in CI :(
2023-12-25 15:05:07 -05:00
Andrew Kaster
b10fee00eb LibWeb+WebWorker: Convert Workers to use MessagePorts for postMessage
This aligns Workers and Window and MessagePorts to all use the same
mechanism for transferring serialized messages across realms.

It also allows transferring more message ports into a worker.

Re-enable the Worker-echo test, as none of the MessagePort tests have
themselves been flaky, and those are now using the same underlying
implementation.
2023-12-25 12:09:11 +01:00
Aliaksandr Kalenik
4969ad9d6b LibWeb: Limit scroll position by overflow area in Window::scroll()
This change fixes "vertical shift" in inspector.
2023-12-24 23:22:35 +01:00
MacDue
64411127cb LibGfx: Clip edges above or below the visible area in the rasterizer
This avoids doing pointless plotting for scanlines that will never be
seen.

Note: This currently can only clip edges vertically. Horizontal clipping
is more tricky, since edges that are not visible can still change how
things accumulate across the scanline.

Fixes #22382

Sadly, this causes a bunch of LibWeb test churn as this change
imperceptibly changes the final rasterized output.
2023-12-24 13:25:40 +01:00
Andreas Kling
fe04d83ef5 LibWeb: Process all pending lazy loading intersection observations
This fixes an issue where images outside the viewport could prevent
loading of images inside the viewport, depending on DOM order.
2023-12-24 13:23:40 +01:00
Shannon Booth
ec2b4c271f LibWeb: Support RadioNodeList named items in HTMLFormControlsCollection
We would previously not return a RadioNodeList in the curious case where
a named item resolves to two different elements within the form.

This was not a problem when calling namedItem directly in the IDL as
named_item_or_radio_node_list shadows named_item but is exposed when
calling the property through array bracket notation (as an example).

Fix this, and add a bunch more tests to cover
HTMLFormControlsCollection.
2023-12-23 20:53:11 +01:00
Aliaksandr Kalenik
0a7e4a0d22 LibWeb: Ignore "display: contents" boxes while inserting inline nodes
With this change "display: contents" ancestors are not considered as
insertion point for inline nodes similar to how we already ignore them
for non-inline nodes.

Fixes https://github.com/SerenityOS/serenity/issues/22396
2023-12-23 20:52:42 +01:00
Lucas CHOLLET
67522fab2e LibGfx/TIFF: Add support for RGBPalette images
TIFF images with the PhotometricInterpretation tag set to RGBPalette are
based on indexed colors instead of explicitly describing the color for
each pixel. Let's add support for them.

The test case was generated with GIMP using the Indexed image mode after
adding an alpha layer. Not all decoders are able to open this image, but
GIMP can.
2023-12-23 20:41:48 +01:00
Shannon Booth
d8759d9656 LibWeb: Use UTF-16 code unit offsets and lengths in CharacterData
We were previously assuming that the input offsets and lengths were all
in raw byte offsets into a UTF-8 string. While internally our String
representation may be in UTF-8 from the external world it is seen as
UTF-16, with code unit offsets passed through, and used as the returned
length.

Beforehand, the included test included in this commit would crash
ladybird (and otherwise return wrong values).

The implementation here is very inefficient, I am sure there is a
much smarter way to write it so that we would not need a conversion
from UTF-8 to a UTF-16 string (and then back again).

Fixes: #20971
2023-12-23 20:41:41 +01:00
Shannon Booth
e2e7c4d574 Everywhere: Use to_number<T> instead of to_{int,uint,float,double}
In a bunch of cases, this actually ends up simplifying the code as
to_number will handle something such as:

```
Optional<I> opt;
if constexpr (IsSigned<I>)
    opt = view.to_int<I>();
else
    opt = view.to_uint<I>();
```

For us.

The main goal here however is to have a single generic number conversion
API between all of the String classes.
2023-12-23 20:41:07 +01:00
Bastiaan van der Plaat
44ff957784 LibWeb: Make -webkit-appearance an alias for the appearance css property 2023-12-23 10:12:36 +01:00
Sam Atkins
1e6cd19b28 LibWeb: Prevent calling test() twice
Calling test() multiple times in the same test file is not actually
valid, and can cause the following test to hang forever. So let's stop
doing that in the one test that did so, and also prevent the same
mistake happening again. :^)

Throwing an exception on subsequent test() calls means that we don't
hang, the test will fail with missing output, and we get a log message
explaining why.
2023-12-22 16:49:06 +01:00
Shannon Booth
1f88046bb2 LibWeb: Add a test for setting and getting Text data
This is a pretty straightforward test, but I managed to make this crash
on real sites while trying to fix #20971 without any other test in the
existing suite failing.
2023-12-22 08:19:51 +00:00
Lucas CHOLLET
2cfca633ca LibGfx/TIFF: Add support for images with UnassociatedAlpha
UnassociatedAlpha is the one used by GIMP when generating TIFF images
with transparency. Support is added for Grayscale and RGB images as it's
the two that we support right now but managing transparency should be
really straightforward for other types as well.
2023-12-22 08:08:47 +00:00
Aliaksandr Kalenik
25e9d2ccf0 Tests/LibWeb: Add ref-tests for "overflow: hidden"
Adds ref-tests from pages used in the following PRs:
https://github.com/SerenityOS/serenity/pull/16035
https://github.com/SerenityOS/serenity/pull/17591
2023-12-21 19:25:31 +01:00
Nicolas Ramz
6ccdb1dc72 LibGfx/ILBMLoader: Add support for 24bit files 2023-12-21 09:19:30 +00:00
Andrew Kaster
c0f50b12a4 LibWeb: Post all MessagePort messages over their LocalSockets
This is to allow future changes to do cross-process MessagePorts in an
implementation-agnostic way. Add some tests for this behavior.

Delivering messages that were posted to a MessagePort just before it was
transferred is not yet implemented still.
2023-12-20 12:25:40 -07:00
Nico Weber
4107c2985e Tests: Add a PDF rendering test
Having some rendering test coverage is motivated by #22362, but this
test wouldn't have found the crashes over there (since colorspaces.pdf
does not contain pattern color spaces). Still, good to have some
in-repo test coverage of PDF rendering.
2023-12-20 12:45:07 +01:00
Nico Weber
13641693cb LibPDF: Use make_object<>() to make objects
No behavior change.
2023-12-20 12:19:08 +01:00
MacDue
8b5d90734d Tests/LibWeb: Add ref test for SVG <textPath>s 2023-12-19 21:29:03 +01:00
Lucas CHOLLET
64912d4d02 LibGfx/TIFF: Add support for images with CCITT3 1D compression
This compression (tag Compression=2) is not very popular on its own, but
a base to implement CCITT3 2D and CCITT4 compressions.

As the format has no real benefits, it is quite hard to find an app that
accepts tho encode that for you. So I used the following program that
calls `libtiff` directly:
```cpp
#include <vector>
#include <cstdlib>
#include <iostream>

#include <tiffio.h>

// An array containing 0 and 1 of length width * height.
extern std::vector<uint8_t> array;
int main() {
    // From: https://stackoverflow.com/a/34257789

    TIFF *image = TIFFOpen("input.tif", "w");
    int const width = 400;
    int const height = 300;
    TIFFSetField(image, TIFFTAG_IMAGEWIDTH, width);
    TIFFSetField(image, TIFFTAG_IMAGELENGTH, height);
    TIFFSetField(image, TIFFTAG_PHOTOMETRIC, 0);
    TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_CCITTRLE);

    TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, 1);
    TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, 1);
    TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, 1);

    std::vector<uint8_t> scan_line(width / 8 + 8, 0);
    int count = 0;
    for (int i = 0; i < height; i++) {
        std::fill(scan_line.begin(), scan_line.end(), 0);
        for (int x = 0; x < width; ++x) {
            uint8_t eight_pixels = scan_line.at(x / 8);
            eight_pixels = eight_pixels << 1;
            eight_pixels |= !array.at(i * width + x);
            scan_line.at(x / 8) = eight_pixels;
        }
        int bytes = int(width / 8.0 + 0.5);
        if (TIFFWriteScanline(image, scan_line.data(), i, bytes) != 1)
            std::cerr << "Something went wrong\n";
    }

    TIFFClose(image);
}
```
2023-12-19 21:01:24 +01:00
Aliaksandr Kalenik
c5d91dce8b LibWeb: Scroll to the "start" in Document::scroll_to_fragment()
Implements spec comment.
2023-12-19 20:59:52 +01:00
Aliaksandr Kalenik
cda1d886df LibWeb: Fix not working Element::scroll_an_element_into_view()
Fixes following mistakes:
- "scrolling box" for a document is not `scrollable_overflow_rect()`
   but size of viewport (initial containing block, like spec says).
- comparing edges of "scrolling box" with edges of target element
  does not make any sense because "scrolling box" edges are relative
  to page while result of `get_bounding_client_rect()` is relative
  to viewport.
2023-12-19 10:45:07 +01:00
Bastiaan van der Plaat
a05fd28b7b LibWeb: Move use pseudo element styles from TreeBuilder to StyleComputer
The styling of elements using the `use_pseudo_element()` was only
applied on layout. When an element style was recomputed later that
styling was not overruled with the pseudo element selector styles.
This moves the styling override from `TreeBuilder.cpp` to
`StyleComputer.cpp`. Now the styles are always correctly applied.
I also removed the method `property_id_by_index()` because it was
not needed anymore.

Als some calls to `invalidate_layout()` in the Meter, Progress and
Select elements where not needed anymore because the style values
are update on the changing of the style attribute.

This fixes issue #22278.
2023-12-17 23:12:34 +01:00
Jesús "gsus" Lapastora
7578620f25 AK/StringUtils: Ensure needle positions don't overlap in replace
Previously, `replace` used `find_all` to find all of the positions to
replace. But `find_all` finds all the *overlapping* instances of the
needle, while `replace` assumed that the next position was always at
least `needle.length()` away from the last one. This led to crashes like
https://github.com/SerenityOS/jakt/issues/1159.
2023-12-17 12:00:48 -07:00
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Aliaksandr Kalenik
2753075830 LibWeb: Do not crash when svg mask calculation failed
Currently `calculate_mask()` fails to create bitmap when
`maskContentUnits="objectBoundingBox"` is present.

Fixes https://github.com/SerenityOS/serenity/issues/22316
2023-12-16 19:48:36 +01:00
Aliaksandr Kalenik
4c81414b14 LibWeb: Fix division by zero in auto-fit/fill track calculation in GFC
Fixes https://github.com/SerenityOS/serenity/issues/22319
2023-12-16 19:39:44 +01:00
Aliaksandr Kalenik
8f8ec37d58 LibWeb: Add missing paintable null check in get_bounding_client_rect()
Fixes crashing on https://github.com/
2023-12-16 16:11:15 +01:00
Vladimir Shakhov
e2391105a1 LibWeb: Call process_session_history_traversal_queue on history update
Spec declares that the updates to history should be synchronous on
initial page load and on history pushState/replaceState.
2023-12-15 22:11:49 +01:00
Andreas Kling
70193c0009 LibWeb: Let Document have a direct GCPtr to its containing Web::Page
With this change, Document now always has a Web::Page. This means we no
longer rely on the breakable link between Document and BrowsingContext
to find a relevant Web::Page.

Fixes #22290
2023-12-15 22:04:46 +01:00
Dan Klishch
8afbeb1892 JSSpecCompiler: Print stderr in test runner if compiler invocation fails 2023-12-14 09:06:05 -07:00
Dan Klishch
8126e76e59 JSSpecCompiler: Compare CFG when running regression tests 2023-12-14 09:06:05 -07:00
Tim Schumacher
a1cf2708ee LibCompress: Implement the XZ BCJ filter for ARM64 2023-12-14 08:59:23 -07:00
Andrew Kaster
ec11743fae LibWeb: Use StructuredSerializeWithTransfer in window.postMessage()
And update tests to transfer message a message port between iframes.
2023-12-14 08:36:11 -07:00
Aliaksandr Kalenik
e464d484c4 LibWeb: Implement getBoundingClientRect() for inline paintables
This fixes the issue that occurred when, after clicking an inline
paintable page would always scroll to the top. The problem was that
`scroll_an_element_into_view()` relies on `get_bounding_client_rect()`
to produce the correct scroll position and for inline paintables we
were always returning zero rect before this change.
2023-12-14 16:25:27 +01:00
Nicolas Ramz
cd6c7f3fc4 LibGfx/ILBMLoader: Add support for PC DeluxePaint files 2023-12-13 10:39:13 +00:00
stelar7
dd391d5e8c LibWeb: Add test for week_number_of_the_last_day microsyntax 2023-12-11 14:04:27 -07:00
Aliaksandr Kalenik
6b79508c08 LibWeb: Use offset of nearest scrollable ancestor for positioned boxes
Because positioned descendants are painted out-of-order we need to
separately apply offset of nearest scrollable box for them.

Fixes https://github.com/SerenityOS/serenity/issues/20554
2023-12-11 20:37:05 +01:00
Shannon Booth
ed97946975 LibWeb: Support obsolete but required -webkit- CSS parsing quirk
As outlined in: https://www.w3.org/TR/selectors-4/#compat

We now do not treat unknown webkit pseudo-elements as invalid at parse
time, and also support serializing these elements.

Fixes: #21959
2023-12-11 16:54:59 +01:00
Shannon Booth
74284abcba LibWeb/Tests: Rename css-attr-ref.html reference to text-div.html
This is currently only used by CSS attr ref tests, but is useful outside
of attr ref tests as well. Give a more generic name to this ref file for
this usage.
2023-12-11 16:54:59 +01:00
Andreas Kling
6994ea5885 LibWeb: Skip out-of-flow boxes when wrapping inlines in anonymous block
Out-of-flow boxes (floating and absolutely-positioned elements) were
previously collected and put in the anonymous block wrapper as well, but
this actually made hit testing not able to find them, since they were
breaking expectations about tree structure that hit testing relies on.

After this change, we simply let out-of-flow boxes stay in their
original parent, preserving the author's intended box tree structure.
2023-12-11 13:19:12 +01:00
Bastiaan van der Plaat
d025d207d9 LibWeb: Hide input placeholder when input already has a value 2023-12-10 20:56:19 +01:00
Aliaksandr Kalenik
df57d7ca68 LibGfx+LibWeb: Update for_each_glyph_position to use font cascade list
This change updates function that builds list of glyphs to use font
cascade list to find font for each code point.
2023-12-10 17:32:04 +01:00
Kyle Pereira
60c7ff9db1 Tests: Add a test for LibPDF pattern rendering
This is based largely on Adobe's EXAMPLE 2 on p176 of the specification,
manually edited slightly and then cleaned up with mutool.

https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf
2023-12-10 16:44:24 +01:00
Bastiaan van der Plaat
f621dc464b LibWeb: Add internal use_pseudo_element to DOM Element 2023-12-10 16:44:12 +01:00
Andreas Kling
cfe9577b48 LibWeb: Bring HTMLElement.offset{Left,Top,Parent} closer to spec
(Or rather, bring offsetLeft and offsetTop closer to spec, and implement
the previously-missing offsetParent)

This makes mouse inputs on https://nerget.com/fluidSim/ work properly.
2023-12-10 16:30:21 +01:00
Bastiaan van der Plaat
ea04a86715 LibWeb: Add fieldset elements property 2023-12-10 08:07:41 -05:00
Simon Wanner
5bcb019106 LibUnicode: Add IDNA::to_ascii
This implements the ToASCII operation of Unicode Technical Standard 46
2023-12-10 08:04:58 -05:00
Simon Wanner
cfd0a60863 LibUnicode: Add Punycode::encode 2023-12-10 08:04:58 -05:00
Simon Wanner
299d35aadc LibUnicode: Add Punycode::decode 2023-12-10 08:04:58 -05:00
Andreas Kling
7abb182fa3 LibWeb: Honor negative margins on atomic inlines
Sizing already worked correctly, but before this change, we were too
aggressive with inserting line breaks when negative margins would
still an atomic inline to fit on the line.
2023-12-10 11:09:22 +01:00
Bastiaan van der Plaat
466153e680 Ladybird+LibWeb: Add basic select element support 2023-12-09 22:06:20 +01:00
Andrew Kaster
512624f31a LibWeb: Add a basic MessageChannel test 2023-12-09 21:52:28 +01:00
Bastiaan van der Plaat
fef7571931 LibWeb: Add output element value 2023-12-09 21:50:17 +01:00
Bastiaan van der Plaat
f8509e2183 LibWeb: Add input number up down UI buttons 2023-12-09 21:49:38 +01:00
Lucas CHOLLET
234d084876 LibGfx/TIFF: Add support for bit-depth up to 32 bits per sample
This makes us support every "minisblack" and "rgb-contig" images from
the depth folder of libtiff's test suite:
https://libtiff.gitlab.io/libtiff/images.html
2023-12-09 21:47:33 +01:00
Lucas CHOLLET
25993cd93b Tests: Use TRY_OR_FAIL instead of MUST in TestImageDecoder.cpp
No need to panic the executable on a test failure.
2023-12-09 19:05:45 +01:00
Bastiaan van der Plaat
1b9a961fb0 LibWeb: Add input stepUp and stepDown functions 2023-12-07 16:46:28 -05:00
Andrew Kaster
39c4a5e948 LibWeb: Add config file for LibWeb tests that skips Worker-echo.html 2023-12-07 16:46:20 -05:00
Kemal Zebari
3a820ddbdf LibWeb/MimeSniff: Add sniffing in an audio or video context 2023-12-07 10:31:54 -07:00
Kemal Zebari
02ea85da2c LibWeb/MimeSniff: Add sniffing in an image context 2023-12-07 10:31:54 -07:00
Kemal Zebari
ea15501f37 LibWeb/MimeSniff: Add sniffing in a browsing context 2023-12-07 10:31:54 -07:00
Kemal Zebari
f6d3ea33fa LibWeb/MimeSniff: Add match an archive type pattern algorithm 2023-12-07 10:31:54 -07:00
Kemal Zebari
d5e5a1138f LibWeb/MimeSniff: Add match an audio or video type pattern algorithm 2023-12-07 10:31:54 -07:00
Kemal Zebari
62ca3b518b LibWeb/MimeSniff: Add the image type pattern matching algorithm 2023-12-07 10:31:54 -07:00
Kemal Zebari
2babc08c17 LibWeb/MimeSniff: Add rules for identifying an unknown mime type
This also implements the pattern matching algorithm since it's
needed.
2023-12-07 10:31:54 -07:00
Kemal Zebari
04e19df06a LibWeb/MimeSniff: Implement Resource
See https://mimesniff.spec.whatwg.org/#resource
2023-12-07 10:31:54 -07:00