Commit graph

1561 commits

Author SHA1 Message Date
Shannon Booth
2b46e6f664 Everywhere: Update copyrights with my new serenityos.org e-mail :^) 2023-07-15 16:21:29 +02:00
Andreas Kling
2887976ce9 LibWeb: Fully resolve max-width values on inline-block elements
This fixes an issue where `max-width: fit-content` (and other
layout-dependent values) were treated as 0 on inline-blocks.
2023-07-15 12:30:07 +02:00
Kenneth Myhra
1f4f750052 Tests/LibWeb: Verify setting {readable,writable}Type throws RangeError
This test proves that setting transformer.{readable,writable}Type to a
value throws a RangeError.
2023-07-15 11:59:39 +02:00
Kenneth Myhra
221f18f72e Tests/LibWeb: Add TransformStream flush callback test
This test proves the ability of TransformStream to execute
caller supplied code in the flush callback, and have access to
TransformStreamDefaultController.
2023-07-15 11:59:39 +02:00
Kenneth Myhra
5c6125c92b Tests/LibWeb: Add TransformStream start callback test
This test proves the ability of TransformStream to execute
caller supplied code in the start callback, and have access to
TransformStreamDefaultController.
2023-07-15 11:59:39 +02:00
Kenneth Myhra
74fdf59941 Tests/LibWeb: Add TransformStream transform callback test
This test proves the ability of TransformStream to execute to execute
caller supplied code in the transform callback that can transform
incoming chunks, and have access to TransformStreamDefaultController.
2023-07-15 11:59:39 +02:00
Kenneth Myhra
1faca5ed9f Tests/LibWeb: Add TransformStream Identity Transform test
This test proves the ability of TransformStream to convert between
writable and readable streams.
2023-07-15 11:59:39 +02:00
Andreas Kling
3ec9fd0aae LibWeb: Resolve calc() values in CSS transform
There are two parts to this fix:

- First, StyleProperties::transformations() would previously omit calc()
  values entirely when returning the list of transformations. This was
  very confusing to StackingContext which then tried to index into the
  list based on faulty assumptions. Fix this by emitting calc values.

- Second, StackingContext::get_transformation_matrix() now always calls
  resolve() on length-percentages. This takes care of actually resolving
  calc() values. If no reference value for percentages is provided, we
  default to 0px.

This stops LibWeb from asserting on websites with calc() in transform
values, such as https://qt.io/ :^)
2023-07-15 11:35:16 +02:00
Shannon Booth
5625ca5cb9 AK: Rename URLParser::parse to URLParser::basic_parse
To make it more clear that this function implements
'concept-basic-url-parser' instead of 'concept-url-parser'.
2023-07-15 09:45:16 +02:00
Aliaksandr Kalenik
2138c164c9 LibWeb: Respect justify-items property of grid container 2023-07-15 05:50:51 +02:00
Aliaksandr Kalenik
e4e1208050 LibWeb: Respect justify-self property of grid items 2023-07-14 15:48:58 +02:00
Andreas Kling
1470e60800 LibWeb: Add logical CSS properties for insets
This patch adds the following properties:

- inset-inline
- inset-inline-start
- inset-inline-end
- inset-block
- inset-block-start
- inset-block-end
2023-07-14 05:55:32 +02:00
Aliaksandr Kalenik
ca50da63e4 LibWeb: Do not crash if "fill: none" is specified for svg text 2023-07-13 18:43:21 +02:00
Aliaksandr Kalenik
e2c5e31292 LibWeb: Adjust grid columns size to fit spanning items
This change implements following paragraph from placement algorithm in
the spec:
"If the largest column span among all the items without a definite
column position is larger than the width of the implicit grid, add
columns to the end of the implicit grid to accommodate that column
span."

There were places in the grid implementation code with copies of this
text, but those were completely unrelated to the code where they were
being pasted so I removed them.
2023-07-13 16:54:53 +02:00
Andreas Kling
d620dd516c LibGfx: Add Rect::unite_{horizontally,vertically}()
These functions unite the rect with another rect, but only in one axis.
2023-07-13 05:09:08 +02:00
Andi Gallo
3476cf0fcb LibWeb: Add border conflict resolution with rowgroup 2023-07-12 20:42:51 +02:00
Andi Gallo
cf40b95be8 LibWeb: Resolve table border conflicts with rows 2023-07-12 20:42:51 +02:00
Andi Gallo
e30662a8a0 LibWeb: Resolve table border conflicts with cells
Build a mapping from coordinates to cells and use it to resolve
border conflicts between adjacent cells.
2023-07-12 20:42:51 +02:00
Nico Weber
323d76fbb9 LibPDF: Make encrypted object streams work
There were two problems:
1. parse_compressed_object_with_index() parses indirect objects
   without going through Parser::parse_indirect_value(), so
   push_reference() / pop_reference() weren't called.
   Manually call them, both for the indirect object containing
   the object stream and for the indirect object within the
   object stream.
2. The indirect object within the object stream got decrypted
   twice: Once when the object stream data itself got decrypted,
   and then incorrectly a second time when the object data within
   the stream was read. To fix, disable encryption while parsing
   object stream data (since it's already decrypted).

The test is from http://opf-labs.org/format-corpus/pdfCabinetOfHorrors/
which according to readme.md at the same location is CC0.
2023-07-12 17:16:25 +02:00
Nico Weber
6200097bcc Tests/LibPDF: Make encrypted_with_aes test some metadata too 2023-07-12 17:16:25 +02:00
Emil Militzer
bf3144fcff LibWeb: Prevent max-width expanding the width 2023-07-12 11:44:57 +02:00
Nico Weber
2061ee2632 Tests/LibPDF: Add test for AES-encrypted PDF
I created this by typing "sup" into TextEdit.app on macOS 13.4,
hitting Cmd-P to bring up the print dialog, clicked the PDF button
at the bottom, changed Title and Author to "sup", clicked
"Security Options…", and checked "Require password to open document"
(with password "sup").

This file tests several things:
- It has a compressed stream as first object. This used to make the
  linearization dict detection logic assert.
- It uses AES as encryption key using version 4 of the encryption
  dict. This used to not be implemented.
2023-07-12 06:28:15 +02:00
Nico Weber
e0887dd045 Tests/LibPDF: Use MUST() more
No behavior change.
2023-07-12 06:28:15 +02:00
Andreas Kling
9174ffd7e6 LibWeb: Create Layout::Box for display: inline-grid
This makes us actually run a GridFormattingContext instead of rendering
inline-grid elements as nothing. :^)
2023-07-11 19:15:17 +02:00
Andi Gallo
a27c9d8b05 LibWeb: Use max width from content for cells unless length is specified
Max width shouldn't be tied to min width, commit d33b99d went too far
and made them the same when the table-root had a specified percentage
width.

Fixes #19940.
2023-07-11 14:37:30 +02:00
Andreas Kling
06d9451551 LibWeb: Don't cache property accesses on WindowProxy
Since the underlying HTML::Window can change, caching property accesses
on WindowProxy is not as simple as remembering the shape. Let's disable
caching here for now. We can come back to it in the future when we have
no low-hanging fruit left. :^)

Fixes an assertion failure on https://twinings.co.uk/
2023-07-11 00:14:50 +02:00
Sebastian Zaha
17d23e76e5 LibWeb: Fix flex & abspos alignment issues
Fixes a couple of weirder interactions between justify-content and
flex-direction related to reverse direction packing and how margins
are set.
2023-07-10 20:57:49 +02:00
Andi Gallo
4c81d39483 LibWeb: Adjust border widths for tables using collapsing borders
When using the collapsing border model, cells on either side of the edge
get half the specified width of the border for their box model.
2023-07-09 06:29:43 +02:00
Ali Mohammad Pur
0c5c75e8a4 LibCore: Slightly rework the Core::Promise API
The previous iteration of this API was somewhat odd and rough in random
places, which degraded usability and made less than perfect sense.
This commit reworks the API to be a little closer to more
conventional promise APIs (a la javascript promises).

Also adds a test to ensure the class even works.
2023-07-08 23:13:00 +01:00
Timothy Flynn
c911781c21 Everywhere: Remove needless trailing semi-colons after functions
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
Andreas Kling
db5bde01dc LibWeb: Resolve % top and bottom insets against containing block height
This makes cookie banner buttons show up on Linktree again. :^)

Regressed in fd37ad3a84
2023-07-08 10:51:12 +02:00
Sebastian Zaha
fd37ad3a84 LibWeb: Fix absolute positioning issues
Make sure the insets and margins calculated according to the spec are
not later ignored and ad-hoc recomputed in
layout_absolutely_positioned_element.

Use the static position calculation in a couple of places where the
spec (and comment) was indicating it should be used.

Fixes #19362
2023-07-08 06:13:56 +02:00
Sebastian Zaha
6a66a05809 LibWeb: Adjust 4 abspos tests to highlight errors
The tests still pass, but opening the files in Ladybird and Safari or
Firefox shows clearly where the layouting in Ladybird is incorrect
for some absolute positioned elements. The previous 1px border was
subtly hiding some issues.
2023-07-08 06:13:56 +02:00
kleines Filmröllchen
10edd38543 LibCore: Keep track of file offset to avoid system call for tell()
This optimization makes the new test run 2x faster.
2023-07-06 21:05:57 +02:00
Tim Schumacher
60ac254df6 AK: Use hashing to accelerate searching a CircularBuffer 2023-07-06 15:06:20 +01:00
Tim Schumacher
42d01b21d8 AK: Rewrite the hint-based CircularBuffer::find_copy_in_seekback
This now searches the memory in blocks, which should be slightly more
efficient. However, it doesn't make much difference (e.g. ~1% in LZMA
compression) in most real-world applications, as the non-hint function
is more expensive by orders of magnitude.
2023-07-06 15:06:20 +01:00
Tim Schumacher
046a9faeb3 AK: Split up CircularBuffer::find_copy_in_seekback
The "operation modes" of this function have very different focuses, and
trying to combine both in a way where we share the most amount of code
probably results in the worst performance.

Instead, split up the function into "existing distances" and "no
existing distances" so that we can optimize either case separately.
2023-07-06 15:06:20 +01:00
Tim Schumacher
9e82ad758e AK: Move parts for searching CircularBuffer into a new class
We will be adding extra logic to the CircularBuffer to optimize
searching, but this would negatively impact the performance of
CircularBuffer users that don't need that functionality.
2023-07-06 15:06:20 +01:00
Andreas Kling
42675971e2 LibWeb: Resolve inline-block percentage padding against 0, not infinity
When the containing block has an indefinite width, any descendants with
a percentage size should resolve that against 0, not infinity.

Fixes an assertion failure when loading https://www.gnu.org/
2023-07-06 14:25:40 +01:00
Andreas Kling
5955a504e0 LibWeb: Allow font-family names to start with -
We achieve this by making properties that accept a custom-ident value
skip the "someone else's vendor prefix" check for values that start with
a `-` character.

This fixes an issue where e.g `font-family: Arial, -apple-system` would
be rejected by the parser completely. We now treat `-apple-system` like
an identifier in such cases.

Also add `valid-types` metadata for the `font-family` property so this
actually works. :^)
2023-07-06 14:30:06 +02:00
Andreas Kling
3372a691da LibWeb: Don't let items flex to infinite size in column layout
When sizing under a max-content constraint, we allow flex lines to have
an infinite amount of "remaining space", but we shouldn't let infinity
leak into the geometry of items. So treat it as zero in arithmetic.

This fixes an issue where inline SVGs with natural aspect ratio (from
viewBox) but no natural width or height could get an infinite size as
flex items.
2023-07-06 09:25:48 +02:00
Lucas CHOLLET
aff38ae80f Tests: Add a test for grayscale JPEGs with an App14 segment
See af14ed6b2e for more details.

This test has been created by artificially adding an App14 segment to an
existing grayscale image.
2023-07-05 20:58:25 +01:00
Andreas Kling
1177308afb LibWeb: Support justify-content: space-evenly in flex layouts
Aligns the cookie banner correctly on https://twitter.com/ :^)
2023-07-05 19:03:20 +02:00
Andreas Kling
4474aa0ae5 LibWeb: Resolve flex item auto cross sizes through aspect ratio
Makes the bird logo show up on https://twitter.com/ :^)
2023-07-05 19:03:20 +02:00
Lucas CHOLLET
3d2e4ba482 Tests: Add a test for JPEGs with an empty ICC profile
No encoder should declare an ICC profile with a size of zero, but some
does. This image has one of these dummy declaration.
2023-07-05 17:41:17 +01:00
Andreas Kling
6b3b056476 LibWeb: Support CSS font shorthand with up to 4 consecutive normal
All of the following properties in the font shorthand can be `normal`:

- font-style
- font-variant
- font-weight
- font-stretch

This means that we must allow up to four consecutive `normal` at the
start of a font shorthand value.
2023-07-04 16:25:23 +02:00
Andreas Kling
793c2ff65a LibWeb: Improve align-items in abspos static position of flex child
Basically, just support more values. And add a test. :^)
2023-07-04 16:25:23 +02:00
Andreas Kling
80a734d42e LibWeb: Improve justify-content in abspos static position of flex child
Also, add a test so we know these actually work correctly now. :^)
2023-07-04 16:25:23 +02:00
Andreas Kling
477a96820d LibWeb: Support valign attribute on td elements
This presentational hint maps to the CSS `vertical-align` property.

Fixes #19786.
2023-07-04 13:26:49 +02:00
Andreas Kling
fb727332f9 LibWeb: Decode linked style sheets before parsing them
This fixes an issue where a BOM at the head of a style sheet would be
passed verbatim to the parser, who would then interpret it as an ident
token and (after some confusion) fail to parse the first rule, but then
carry on with the rest of the sheet.
2023-07-04 10:45:20 +02:00