Commit graph

27144 commits

Author SHA1 Message Date
Ali Mohammad Pur
221c52c696 LibRegex: Avoid slicing a RegexStringView in non-unicode Compare ops
Getting a single code point is much faster than slicing into the string.
2023-07-31 05:31:33 +02:00
Ali Mohammad Pur
11abca421a LibRegex: Always inline get_opcode()
This function's prologue was showing up as very hot in profiles, taking
almost 9% of runtime in our Regex test suite.
2023-07-31 05:31:33 +02:00
Ali Mohammad Pur
a539c261b1 Profiler: Correct the event names for 'malloc' and 'free'
These were renamed to 'kmalloc' and 'kfree' in the profile recording
infrastructure, but the Profiler application expected the old names
still.
2023-07-31 05:31:33 +02:00
Shannon Booth
3cb65645cf LibWeb: Make Web::URL::host_is_domain accept an AK::URL::Host
Which allows us to avoid serializing the host only to try and reparse it
again as either an IPv4 or IPv6 address.
2023-07-31 05:18:51 +02:00
Shannon Booth
8751be09f9 AK: Serialize URL hosts with 'concept-host-serializer'
In order to follow spec text to achieve this, we need to change the
underlying representation of a host in AK::URL to deserialized format.
Before this, we were parsing the host and then immediately serializing
it again.

Making that change resulted in a whole bunch of fallout.

After this change, callers can access the serialized data through
this concept-host-serializer. The functional end result of this
change is that IPv6 hosts are now correctly serialized to be
surrounded with '[' and ']'.
2023-07-31 05:18:51 +02:00
Sam Atkins
6038e36250 LibWeb: Add and use the "snap a length as a border width" algorithm
Previously, we always rounded border-widths up when converting them to
device pixels. However, the spec asks us to follow a specific algorithm
to "snap" these values, so that the computed value is snapped.

The difference from before, is that widths of between 0 and 1 device
pixels are rounded up to 1, and and values larger than 1 are rounded
down.
2023-07-30 22:18:26 +01:00
Sam Atkins
5ee1b7db7c LibWeb: Convert BorderData::width to CSSPixels
The `clip_shrink` optimization in `paint_background()` now also
correctly uses DevicePixels, instead of reducing a DevicePixel rect by
a CSSPixels amount.
2023-07-30 22:18:26 +01:00
Sam Atkins
072ab94889 LibWeb: Use double functions for pixel unit conversions
We're passing doubles to these, so using the _f versions is a bit silly.
2023-07-30 22:18:26 +01:00
Sam Atkins
7c8772ad86 FileManager: Add file properties tab for PDF documents 2023-07-30 22:16:40 +01:00
Sam Atkins
a333d9959c FileManager: Add file properties tab for ZIP archives 2023-07-30 22:16:40 +01:00
Sam Atkins
8d53442187 LibArchive: Extract logic for calculating ZIP statistics 2023-07-30 22:16:40 +01:00
Jonah
60e35f2a97 LibWeb: Rough implementation of CSS namespace rule
This provides a rough implementation of the CSS @namespace rule.
Currently we just support default namespaces, namespace prefixes
are still to come.
2023-07-30 20:27:19 +01:00
Sam Atkins
3f7d97f098 AK+Libraries: Remove FixedMemoryStream::[readonly_]bytes()
These methods are slightly more convenient than storing the Bytes
separately. However, it it feels unsanitary to reach in and access this
data directly. Both of the users of these already have the
[Readonly]Bytes available in their constructors, and can easily avoid
using these methods, so let's remove them entirely.
2023-07-30 19:32:52 +01:00
MacDue
109ea418ab LibWeb: Parse and ignore SVG paint fallback color 2023-07-30 16:06:03 +02:00
MacDue
439735fd35 LibWeb: Support legacy xlink:href attribute for linked gradients
...and rename the related functions to something more descriptive.
2023-07-30 16:06:03 +02:00
Sam Atkins
06eb4a7557 LibWeb: Match math function values to properties in correct order
If a math function resolves to `<length>` or `<percentage>`, then it
will by definition also resolve to `<length-percentage>`. (Same for any
other basic types.) Since we were checking `<length-percentage>` first
and then bailing if no given properties could accept that, math
functions would always fail to match a property that just accepts a non
`-percentage` type.
2023-07-30 14:18:13 +02:00
MacDue
3e6ca1085c LibGfx: Add apply_alpha option to Painter::blit_filtered() 2023-07-30 09:31:43 +02:00
MacDue
0ef0ad04e1 LibGfx: Take filter by reference in Painter::blit_filtered()
This allows reusing the filter rather than moving it into blit_filtered.
2023-07-30 09:31:43 +02:00
Shannon Booth
378595e8b1 LibJS: Add three more await thenable tests
The first test crashes in AST, and fails in bytecode, so the best thing
which we can do here without complicated test setup logic is to just
skip this test for now. Interestinglny, this crashing test is very
similar to the existing thenable test case, and only differs in the way
that the thenable is given to the async function.

The next two tests are effectively the same as the above two mentioned
tests, with the only different being that the thenable calls the fulfill
function. For the test case that crashes in AST mode, doing that appears
to fix the test case for AST mode (but both still fail in bytecode).
2023-07-30 09:31:16 +02:00
Lucas CHOLLET
fa43c70951 LibGfx/JPEGXL: Include the alpha channel in the output bitmap
Now that we are able to read extra channels, it's time to include them
in the final bitmap. They are usually at a smaller resolution than the
final bitmap and the first step to render them is upscaling. Luckily,
this is not necessary for rendering the `alpha_nonpremultiplied` case of
the conformance test suite, so, as usual, I implemented this rendering
function as a check + no-op.

Then, we simply test if an alpha channel is present and emit the
corresponding data when creating the bitmap.

Finally, it means that we are now capable of rendering images with a
full size alpha channel, like `alpha_nonpremultiplied`. In other words,
we now successfully decode one of the image of the official test suite!
2023-07-30 09:29:19 +02:00
Lucas CHOLLET
b2a559ddb0 LibGfx/JPEGXL: Create Image with the correct number of channel
As a quick and dirty implementation, we used to assume that the final
image was always composed of three channels of the same size. However,
JPEG XL has support for more than three channels and extra channels can
have a smaller size. With this patch, we now create the image with the
correct number of channel and with their respective sizes.
2023-07-30 09:29:19 +02:00
Shannon Booth
dd373eacbc LibDiff+patch: Support multiple patches in a single patch file
Multiple patches may be concatenated in the same patch file, such as git
commits which are changing multiple files at the same time. To handle
this, parse each patch in order in the patch file, and apply each patch
sequentially.

To determine whether we are at the end of a patch (and not just parsing
another hunk) the parser will look for a leading '@@ ' after every hunk.
If that is found, there is another hunk. Otherwise, we must be at the
end of this patch.
2023-07-30 07:47:22 +01:00
Shannon Booth
ddbd77cca1 run-tests: Correct logic for calculating number of skipped/xfail tests
Skipped tests were mistakenly being considered as expected failures.
2023-07-30 07:47:22 +01:00
Shannon Booth
f893e0820f patch: Support creation of a file
Previously patch would always expect the file that it was patching to
exist (even it were empty). If we know that the patch is creating a file
from nothing (i.e has a start line of '0'), then we treat a file that
doesn't exist as if it has no content lines.
2023-07-30 07:47:22 +01:00
Lucas CHOLLET
0612e8ec6a LibGfx/JPEGXL: Read data related to extra channels in FrameHeader
Thanks to previous patches, everything used in `read_frame_header`
supports extra channels. The last element to achieve the read of headers
of frame with extra channels is to add support in the function itself
and the `FrameHeader` struct, which that patch does.
2023-07-30 05:39:47 +02:00
Lucas CHOLLET
da0944f63d LibGfx/JPEGXL: Handle parsing BlendingInfo for extra channels
Extra channels have more parameters than basic one. This patch allows us
to read all these parameters.
2023-07-30 05:39:47 +02:00
Lucas CHOLLET
7cbf76586a LibGfx/JPEGXL: Start parsing the ExtraChannelInfo bundle
This implementation is not feature complete yet as it only supports
channels with a type different of `ExtraChannelType::kAlpha`.

This patch also introduces the `read_enum` function.
2023-07-30 05:39:47 +02:00
Lucas CHOLLET
9b9244150e LibGfx/JPEGXL: Move code to read a string in a utility function
This was only used for the name of the `Frame`, but this code will soon
be used to read `ExtraChannelInfo`'s name. So let's factorize it!
2023-07-30 05:39:47 +02:00
Lucas CHOLLET
c6731b0970 LibGfx/JPEGXL: Consider the HfGlobal section of the TOC
There is always a section for HfGlobal, even if it's empty like with
Modular images.

I also removed the outdated (and misinterpreted) spec comment and
replace it with the name of the section.
2023-07-30 05:39:47 +02:00
Lucas CHOLLET
ea8384219f LibGfx/JPEGXL: Perform size computation in a floating point type
The computation was copied from the spec, but I forgot that they mention
that every "/" should be performed without truncation or rounding. Let's
use `double`s instead of integers.
2023-07-30 05:39:47 +02:00
Lucas CHOLLET
b5b17269c4 LibGfx/JPEGXL: Support reading LfGroups with an empty ModularLfGroup
I recently discovered a bug when we count the number of LfGroups, and it
turns out that this number can't be null. So that means that we need to
support reading them. The trick is that we only have support for images
that contains an empty LfGroup, so this patch implement a dummy reader
that just check that we are indeed facing an empty one and `TODO()`
otherwise.
2023-07-30 05:39:47 +02:00
Lucas CHOLLET
fee3eff947 LibGfx/JPEGXL: Use the correct condition to read save_before_ct
During the original implementation, I mixed the condition for
`save_before_ct` and the one for `save_before_ct`, resulting in a bogus
code. That's fixed now!
2023-07-30 05:39:47 +02:00
Lucas CHOLLET
338d64abd9 LibGfx/JPEG: Don't fail to decode images with non-compliant ICC profile
Some images (like https://www.w3.org/Press/Stock/Berners-Lee/2001-europaeum-eighth.jpg)
embed a non-compliant ICC profile. Instead of rejecting the image, we
can simply discard the color profile and resume the decoding of the
bitmap.
2023-07-30 05:10:08 +02:00
Shannon Booth
81df0278b1 patch+LibDiff: Implement 'strip' of filenames when parsing patch
Implement the patch '-p' / '--strip' option, which strips the given
number of leading components from filenames parsed in the patch header.
If not given this option defaults to the basename of that path.
2023-07-29 17:09:09 -06:00
Shannon Booth
4d8a59f34b patch: Implement d, --directory option
When given, patch will chdir into the given directory before processing
the patch file.
2023-07-29 17:09:09 -06:00
Abhishek Raturi
7bc3fd8c15 HackStudio: Add option to open file in single click
This feature is similar to Clion's "Open files with Single Click" which
allows user to open file without double clicking it

HackStudio: Update action name to remove "toggle"

Action name does need to include "Toggle" word since its already implie
d with checkable action
2023-07-29 17:07:38 -06:00
Sergey Bugaev
b604640950 LibC: Fix struct declaration visibility
Isn't

"expected struct timeval *, but argument is of type struct timeval *"

a fun error message? C considers a 'struct foo' mentioned inside a
function argument to be a distinct type from 'struct foo' declared on
the global level, but only if the in-function definition comes first. So
we need to ensure that struct timeval is declared (either fully, or
forward-declared) before we declare select() and pselect(). This was
taken care of by including <sys/time.h>, but
https://github.com/SerenityOS/serenity/pull/20044 made it so that
<sys/time.h> itself includes <sys/select.h>. So if the user's program
includes <sys/time.h> (before possibly including <sys/select.h>), then
<sys/select.h>'s include of <sys/time.h> will turn into a no-op (since
<sys/time.h> is already being included), yet there will not have been a
struct timeval definition yet, and we'd get the fun error message.

Fix this by including <Kernel/API/POSIX/sys/time.h> instead of
<sys/time.h>
2023-07-29 16:51:58 -06:00
Sergey Bugaev
cd4298ae04 Userland: Teach strace(1) to format pledge(2) 2023-07-29 16:51:58 -06:00
Sergey Bugaev
8c8ba4cfe4 LibC: Fix duplicated function symbols
Commit cccb6c7287 has moved some function
definitions into complex.h. The functions were marked inline, but not
static, so a symbol definition was emited for them in any compilation
unit that included complex.h. If multiple such compilation units get
linked into the same binary, we get a duplicate symbol error.

Fix this by declaring the functions static inline.
2023-07-29 16:51:58 -06:00
Andreas Kling
8f29bdb62c LibWeb: Implement the CSS revert keyword
This is a universal value like `initial` and `inherit` and works by
reverting the current value to whatever we had at the start of the
current cascade origin.

The implementation is somewhat inefficient as we make a copy of all
current values at the start of each origin. I'm sure we can come up with
a way to make this faster eventually.
2023-07-29 19:16:08 +02:00
Andreas Kling
13d5d47b56 LibWeb: Implement the CSS all property
This sets all longhand values to one of initial, inherit, unset or
revert. Note that revert is not supported yet, but will be soon.
2023-07-29 19:16:08 +02:00
Aliaksandr Kalenik
921aee8c66 LibWeb: Optimize stacking context rebuilds on opacity change
Stacking context tree rebuild can be avoided if opacity value changes
within the range below 1.
2023-07-29 18:23:10 +02:00
Kenneth Myhra
77e339022b LibWeb: Serialize and deserialize standard built-in objects
This adds support for serializing and deserializing standard built-in
objects:
- Boolean object
- Number object
- String object
- Date object
2023-07-29 17:24:39 +02:00
Aliaksandr Kalenik
e5dcfe3905 LibWeb: Verify that value is not saturated in set_content_width/height
Checking if CSSPixels contains a finite value is no longer makes sense
after converting to fixed-point arithmetics. Instead there should
assertion that used value is not saturated.
2023-07-29 17:23:27 +02:00
Andreas Kling
df249f269b LibWeb: Make responsive images react to changes in size viewport
This patch implements "react to changes in the environment" from the
HTML spec and hooks HTMLImageElement up with viewport rect change
notifications (from the browsing context).

This fixes the issue where we'd load a low-resolution image and not
switch to a high-resolution image after resizing the window.
2023-07-29 11:58:51 +02:00
Andreas Kling
95097e47a7 LibWeb: Allow calc() values in image sizes attribute
Note that we currently can't resolve calc() values without a layout
node, so when normalizing an image's source set, we'll flush any pending
layout updates and hope that gives us an up-to-date layout node.

I've left a FIXME about implementing this in a more elegant and less
layout-thrashy way, as that will require more architectural work.
2023-07-29 11:58:51 +02:00
MacDue
9997f46593 LibWeb: Resolve currentColor when used for SVG gradient <stop>s
A small workaround is needed here as <stop> elements don't create a
layout node, so we can't get the current color from value->to_color().

This fixes the gradients in the Atlassian logo and icons.
2023-07-29 08:26:04 +01:00
Aliaksandr Kalenik
2bdc69c42c LibJS: Add caching of this value in ResolveThisBinding instruction
Because "this" value cannot be changed during function execution it is
safe to compute it once and then use for future access.

This optimization makes ai-astar.js run 8% faster.
2023-07-29 04:23:49 +02:00
Christophe Naud-Dulude
4f9f21e8fe LibWeb: Only derive baseline from children with a non-empty line box
If none of the box children have a baseline set, the bottom margin
edge of the box is used as the baseline.
2023-07-28 17:02:33 +02:00
Aliaksandr Kalenik
38edab09a0 LibWeb: Allow <svg> to act as a containing block
This change makes overflow clipping work correctly for children of svg
element.

Fixes following example:
```html
<!doctype html><style>
    body {
        width: 300px;
        height: 300px;
        position: relative;
        overflow: hidden;
        border: 1px solid black;
    }
    svg {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 100%;
        height: 100%;
        transform: translate(-50%, -50%);
    }
</style>
<body>
<svg viewBox="0 0 100 100">
   <g>
     <rect x="0" y="0" width="100" height="100" fill="green"></rect>
   </g>
</svg>
```
2023-07-28 15:15:07 +02:00