Commit Graph

27121 Commits

Author SHA1 Message Date
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
Andi Gallo
6a17a30e2e LibWeb: Handle overlapping floating box and left margin
Allow the left margin of a box which creates a block formatting context
to overlap with left floating boxes which are siblings in the document
tree.

Fixes #20233 and the comment layout on https://lobste.rs.
2023-07-28 12:44:09 +02:00
Luke Wilde
34c702e6e8 LibWeb: Implement <meta http-equiv="Refresh">
Required by Atlassian to continue to their authorization process.
Also used by the SerenityOS FAQ redirect on the website, the Bootstrap
documentation for going to older versions from the dropdown and
likely several other sites.
2023-07-28 11:12:25 +02:00
Aliaksandr Kalenik
0e8a0a8191 LibWeb: Add support for "display: contents"
This change makes tree builder omit elements with "display: contents"
from the layout tree during construction. Their child elements are
instead directly appended to the parent element in layout tree.
2023-07-28 05:29:43 +02:00
Timothy Flynn
456211932f LibUnicode: Perform code point case conversion lookups in constant time
Similar to commit 0652cc4, we now generate 2-stage lookup tables for
case conversion information. Only about 1500 code points are actually
cased. This means that case information is rather highly compressible,
as the blocks we break the code points into will generally all have no
casing information at all.

In total, this change:

    * Does not change the size of libunicode.so (which is nice because,
      generally, the 2-stage lookup tables are expected to trade a bit
      of size for performance).

    * Reduces the runtime of the new benchmark test case added here from
      1.383s to 1.127s (about an 18.5% improvement).
2023-07-28 05:28:50 +02:00
Christophe Naud-Dulude
11b844ce20 LibWeb: Add support for align-items and align-self in CSS grid 2023-07-27 19:54:17 +02:00
Edwin Rijkee
dfbc2839b4 DisplaySettings: Handle case where there is no DPI value
DisplaySettings uses the optional `screen_dpi` value before checking
if it is set, causing an assertion failure. This change moves the
usage into the block where it is known to be set.

One situation where this is known to occur is on real hardware when
using the MULTIBOOT_VIDEO_MODE multiboot flag to enable graphical
display output.
2023-07-27 12:53:25 -04:00
Sam Atkins
bd7bd1d677 LibWeb: Remove IDL files from CMake SOURCES
The bindings generator already produces a depfile of IDL files for each
JS binding class, so we do not need to manually define these as sources.
2023-07-27 12:53:16 -04:00
Andreas Kling
a9aecbbd6f LibWeb: Batch processing of successfully downloaded images
Before this change, we would process each image as it finished
downloading. This often led to a situation where we'd decode 1 image,
schedule a layout, do the layout, then decode another image, schedule
a layout, do the layout, etc. Basically decoding and layouts would get
interleaved even though we had multiple images fetched and ready for
decoding.

This patch adds a simple BatchingDispatcher thingy that HTMLImageElement
uses to batch the handling of successful fetches.

With this, the number of layouts while loading https://shopify.com/ goes
from 48 to 6, and the page loads noticeably faster. :^)
2023-07-27 18:39:57 +02:00
Edwin Rijkee
fedd087546 NetworkSettings: Don't assert when there are no network adapters
NetworkSettings normally filters out `loop` when populating its list of
adapters. However, when checking if there aren't any adapters it did
not take this into account. This causes it to crash later when trying
to set the selected index of an empty combo box.

This moves the check for no adapters to after filtering the list, so
that shows the error message and exits.
2023-07-27 12:10:56 -04:00
Liav A
dc612231f5 LibGfx/TGA: Simplify the code by converting it to use AK::Stream
The conversion to AK::Stream makes everything much more straightforward
and understandable now, because we remove the custom reader we had.
Because AK::Stream is more tested, it means that the code should be now
more robust against bugs as well.
2023-07-27 14:40:00 +01:00
Lucas CHOLLET
18b7ddd0b5 AK: Rename the const overload of FixedMemoryStream::bytes()
Due to overload resolutions rules, this simple code provokes a crash:

ReadonlyBytes readonly_bytes{};
FixedMemoryStream stream{readonly_bytes};
ReadonlyBytes give_them_back{stream.bytes()};
    // -> Panics on VERIFY(m_writing_enabled);
    // but this is fine:
auto bytes = static_cast<FixedMemoryStream const&>(*stream).bytes()

If we need to be explicit about it, let's rename the overload instead of
adding that `static_cast`.
2023-07-27 14:40:00 +01:00
Zaggy1024
66c9696687 LibGfx: Add initial ISO BMFF parsing and a utility to print file info
Currently, the `isobmff` utility will only print the media file type
info from the FileTypeBox (major brand and compatible brands), as well
as the names and sizes of top-level boxes.
2023-07-27 12:02:37 +01:00
Andreas Kling
9caa0bda7d LibWeb: Don't relayout whenever a CSS transform changes
Transforms are a paint-level concept for us, so we should be okay to
only update the stacking context tree and repaint.

This makes a lot of CSS animations use way less CPU.
2023-07-27 12:39:44 +02:00
Aliaksandr Kalenik
9a90bf7d12 LibWeb: Fix calculation of bitmap size in paint_outer_box_shadow
Correctly compute the maximum possible width and height for
shadow_bitmap_rect by considering all pair combinations of corners.

Fixes https://github.com/SerenityOS/serenity/issues/20205
2023-07-27 08:02:44 +02:00
Aliaksandr Kalenik
72e959d753 LibWeb: Fix calculation of bitmap size in BorderRadiusCornerClipper
Correctly compute the maximum possible width and height for
corners_bitmap_size by considering all pair combinations of corners.

Partially fixes issue https://github.com/SerenityOS/serenity/issues/20205
2023-07-27 08:02:44 +02:00
Andi Gallo
3b75b9ef1c LibWeb: Avoid division by zero when computing table measures
For malformed tables which only have cells with span greater than 1, the
content sizes for row and column aren't initialized to non-zero values.
Avoid undefined behavior in such cases, which sometimes show up on
Wikipedia.
2023-07-27 08:01:36 +02:00
Sam Atkins
988130a935 LibGUI+GMLPlayground: Set correct undo text for ReplaceAllTextCommand
- Make the text a parameter instead of forcing it to be about GML.
- Change the wording to be imperative, and match the action text.
2023-07-26 14:18:20 -04:00
Sam Atkins
1d7d194062 LibGUI: Use set_text() for ReplaceAllTextCommand
Previously, this was reimplementing the same thing by removing all the
document text and then inserting the new text - which internally would
insert each code-point individually and fire change notifications for
each one. This made the "Reformat GML" button very slow, since it not
only had to recalculate the visual lines of the document each time, but
also rebuild the preview GUI.

The reason not to use `set_text()` is that it would throw away the undo
stack, since it always behaved as if the text is a new document. So,
let's add a parameter to disable that behaviour.

This takes the time for reformatting a ~200 line GML file from several
seconds, to basically instantaneous. :^)
2023-07-26 14:18:20 -04:00
Andrew Kaster
5028223c37 Meta+Utilities: Make pre-commit checks significantly less verbose
When markdown-check is built, it outputs hundreds of lines of "ignoring
this and that link because reasons". This is extremely not helpful when
trying to figure out exactly which check failed on your commit. Also
remove the timing numbers from lint-ci.sh These are just noise and also
don't help to figure out which pre-commit check failed. Ideally the
output on fail should be "[OK]: Check A" for all the passing checks and
"[FAIL] Check N" with the required context for the failed check.
2023-07-26 06:21:39 -04:00
Tim Ledbetter
b284e525f3 FileOperation: Replace LibC rename() call with LibCore equivalent 2023-07-26 08:44:49 +02:00
Tim Ledbetter
21fdefd297 FileOperation: Preserve mode bits and owner when copying files
Previously, all files and folders copied with FileManager would be
created with the default mode bits set and would have the same uid
and gid as the currently logged in user.
2023-07-26 08:44:49 +02:00
Lucas CHOLLET
697803efcc LibGfx/JPEGXL: Remove the BitmapDecoded state
There was a confusion between both `BitmapDecoded` and `FrameDecoded`
states. Removing one of them, solves the issue.
This patch removes the crash caused by requesting the same frame twice.
2023-07-26 08:44:17 +02:00
Lucas CHOLLET
33ca35f1c7 LibGfx/JPEGXL: Apply transformations after all PassGroups
The original image this decoder was written for has a single PassGroup,
so applying transformations after each PassGroup or after all of them
was equivalent. This patch fix the behavior for images with 0 or more
than one PassGroup.
2023-07-26 08:44:17 +02:00