Commit graph

52845 commits

Author SHA1 Message Date
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
Nico Weber
dcb2f3aa89 Meta/gn: Don't use "abspath" for IDL inputs
The idl file lists are used for two things:

1. As inputs for `generate_window_or_worker_interfaces`
2. In a loop in `generate_idl_bindings` and the loop variable
   is passed to `rebase_path`

Both these cases can handle a normal fully-qualified GN path,
so there's no need for the "abspath".

No behavior change.
2023-07-27 10:02:01 -06:00
Nico Weber
406b68a612 Meta: Port 77d7f715e3 to gn 2023-07-27 10:02:01 -06: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
Timothy Flynn
47595b9ef0 CI: Set TESTS_ONLY mode for unit tests on Lagom
This disables running benchmark test cases on Lagom in CI. When we run
unit tests on-board Serenity, run-tests sets this environment variable.
We do not use that utility to run unit tests on Lagom, so we've been
running benchmark tests unnecessarily.
2023-07-26 16:09:29 -06: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
Sam Atkins
bf1d680a75 FuzzPDF: Initialize document so page count is accurate
Without calling `initialize()`, the page count is 0, so the loop never
ran and we never actually tested any of the code in `get_page()`.
2023-07-26 06:22:34 -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
fa379b6e86 Tests/LibGfx: Use a JPEG XL image with a RCT transformation
This image is exactly the same as the previous one, excepted the RCT
transformation. It has been generated with:

Width 64
Height 64
RCT 29
Upsample 2
Bitdepth 10

if N > 300
  - NE -6
  - W 6
2023-07-26 08:44:17 +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
Tim Ledbetter
ea411774f0 truncate: Clamp file size to 0 when using the -s option
When using the `-s` option to reduce the size of a file, the file size
is now set to zero if the argument given would result in a file
size less than zero.

This matches the behavior of truncate on Linux and FreeBSD.
2023-07-26 08:42:05 +02:00
Tim Ledbetter
8e79afebb9 truncate: Allow size suffixes to be used with the -s option
The base 2 size suffixes: 'K', 'M' and 'G' may now be used when
specifying a file size with the `-s` option.
2023-07-26 08:42:05 +02:00
Tim Ledbetter
fb27702981 truncate: Remove unnecessary includes
These are no longer necessary, as we are now using LibCore syscall
wrappers.
2023-07-26 08:42:05 +02:00
Tim Ledbetter
0ae92cdaa0 truncate: Prefer StringView over DeprecatedString 2023-07-26 08:42:05 +02:00
zhiyuang
94491ead67 LibWeb: Fix border painting with border-radius and zero-width sides
When joined border width is zero width, then the midpoint
of the joined corner is no longer need to be computed
anymore. Just set the mid point to be the endpoint of the
corner.
2023-07-26 08:38:54 +02:00
Andi Gallo
8f7b269bf1 LibWeb: Convert divisor to double in TableFormattingContext
Improves precision of height and width distribution.
2023-07-26 08:38:03 +02:00
Andi Gallo
b12820c967 LibWeb: Handle float clearing specified on line break elements 2023-07-26 08:37:16 +02:00
Timothy Flynn
0652cc48c0 LibUnicode: Perform code point property lookups in constant time
We currently produce a single table for all categories of code point
properties (GeneralCategory, Script, etc.). Each row contains a field
indicating the range of code points to which that property applies. At
runtime, we then do a binary search through that table to decide if a
code point has a property.

This changes our approach to generate a 2-stage lookup table for each of
those categories. There is an in-depth explanation of these tables above
the new `create_code_point_tables` method. The end effect is that code
point property lookup is reduced from a binary search to constant-time
array lookups.

In total, this change:

    * Increases the size of libunicode.so from 2.7 MB to 2.9 MB.

    * Reduces the runtime of the new benchmark test case added here from
      3.576s to 1.020s (a 3.5x speedup).

    * In a profile of resizing a TextEditor window with a 3MB file open,
      the runtime of checking if a code point has a word break property
      reduces from ~81% to ~56%.
2023-07-26 08:36:20 +02:00
Timothy Flynn
8f1d73abde LibUnicode: Use the public CodePointRange in the code generator
The next commit will need a type from LibUnicode/CharacterTypes.h. To
avoid conflicts between that header's CodePointRange and the one that is
defined in the code generator, just use the public definition.
2023-07-26 08:36:20 +02:00
Timothy Flynn
cb128dcf75 LibUnicode: Move the CodePointRangeComparator struct to a public header
Move it out of the generated code so that it may be used by the code
generator itself.
2023-07-26 08:36:20 +02:00
Timothy Flynn
c950f88611 LibUnicode: Stop generating Block property data
We started generating this data in commit 0505e03, but it was unused.
It's still not used, so let's remove it, rather than bloating the size
of libunicode.so with unused data. If we need it in the future, it's
trivial to add back.

Note we *have* always used the block name data from that commit, and
that is still present here.
2023-07-26 08:36:20 +02:00
PaddiM8
6de701b5c3 LibWeb: Handle auto margins with flex and justify-content
Auto margins used together with justify-content would previously
result in children being positioned outside their parent. This was
solved by letting auto margins take precedence when they are used,
which was already implemented to some extent before, but not
fully.
2023-07-26 08:35:23 +02:00
PaddiM8
a26f2f0aab LibWeb: Handle flex reverse togther with justify-content
Containers with both flex reverse and justify content would
sometimes place children outside the container. This happened
because it assumed any reversed container would have items
aligned to the right, which isn't true when using eg. `flex-end`.

Both `justify-content: start` and `justify-content: end` are now
also independent of the reverseness.
2023-07-26 08:35:23 +02:00
Andrew Kaster
6266976e7a LibTLS: Move singleton for DefaultRootCACertificates out of line
This follows the pattern of every other singleton in the system.

Also, remove use of AK::Singleton in place of a function-scope static.
There are only three uses of that class outside of the Kernel, and all
the remaining uses are suspect. We need it in the Kernel because we
want to avoid global destructors to prevent nasty surprises about
expected lifetimes of objects. In Userland, we have normal thread-safe
statics available. 7d11edbe1 attempted to standardize the pattern, but
it seems like more uses of awkward singleton creation have crept in or
were missed back then.

As a bonus, this fixes a linker error on macOS with -g -O0 for Lagom
WebContent.
2023-07-26 05:34:38 +02:00
Sebastian Zaha
05dd46f9e3 LibWeb: Do not fire click event if mouseup/down elements do not match
Click event logic should start as false, and after checking if the
mousedown and subsequent mouseup have been on the same element, and if
the node dispatches events it can become true.

This fixes the issue that clicking anywhere on the page, then dragging
the mouse on top of a link or button, then releasing triggers the link.
This is also happening when selecting text, if the selection stops over
a link, the page navigates.
2023-07-26 05:22:43 +02:00
Sebastian Zaha
065c8cefb8 LibWeb: Remove unused code
The code that used these helpers has been moved a while ago to PageHost.
2023-07-26 05:22:43 +02:00
Aliaksandr Kalenik
152ce88984 LibWeb: Avoid leaking infinite remaining_free_space in FFC calculation
After switching to fixed-point arithmetic in CSSPixels, it no longer
supports representing infinite values, which was previously the case
for remaining_free_space in FFC. Using Optional that is not empty only
when value is finite to store remaining_free_space ensures that
infinity is avoided in layout calculations.
2023-07-26 05:17:56 +02:00
Aliaksandr Kalenik
de95a2fe33 LibWeb: Use empty Optional to represent infinte growth limit in GFC
In c66dbc99ee GFC was updated to use -1
as special value for the infinite growth limit. However, using Optional
instead reduces the risk of accidentally using -1 special value in
layout calculations.
2023-07-26 05:17:10 +02:00
Andreas Kling
96d5a1edb0 test-js: Run with the JavaScript bytecode VM by default
The AST interpreter is still available behind a new `--ast` flag.

We switch to testing with bytecode in the big run-tests battery on
SerenityOS. Lagom CI continues running both AST and BC.
2023-07-25 20:00:46 +02:00
Andreas Kling
72516ca101 js: Run with the JavaScript bytecode VM by default
The AST interpreter is still available behind a new `--ast` flag.
2023-07-25 20:00:46 +02:00
Andreas Kling
a3e97ea153 Browser+LibWebView: Run with the JavaScript bytecode VM by default
The AST interpreter is still available behind a new `--ast` flag.
2023-07-25 20:00:46 +02:00
Andreas Kling
c3e5487f00 headless-browser: Run with the JavaScript bytecode VM by default
The AST interpreter is still available behind a new `--ast` flag.
2023-07-25 20:00:46 +02:00
Andreas Kling
c93952f0fb Ladybird: Run with the JavaScript bytecode VM by default
The AST interpreter is still available behind a new `--ast` flag.
2023-07-25 20:00:46 +02:00
Aliaksandr Kalenik
875a8a3c2a LibWeb: Remove casting to double in normalized_border_radii_data
Fixes broken border-radius painting because of lost precision while
converting back and forth between double and CSSPixels.

Fixed example:
```html
<style>
  div {
    border-radius: 9999px;
    background: orange;
    padding: 10px;
  }
</style><div>huh</div>
```
2023-07-25 18:14:17 +02:00
Andreas Kling
a653b60e49 LibWeb: Implement basic support for window[number]
This fixes an assertion on https://amazon.com/ since WindowProxy
would advertise "0" as an own property key, but then act like it was
a bogus property when actually queried for it directly.
2023-07-25 15:45:44 +02:00
Aliaksandr Kalenik
c431167736 LibWeb: Implement subtraction using saturated_addition in CSSPixels
Fixes overflow bug found by UBSAN.
2023-07-25 15:21:40 +02:00
Andi Gallo
26c20e3da1 LibWeb: Split BorderConflictFinder::conflicting_edges method
Make it clearer which edges and elements are considered at each step.
2023-07-25 15:21:04 +02:00
Andi Gallo
a7166eb103 LibWeb: Complete table border conflict resolution
Add the element type and grid position to the algorithm and change the
table borders painting to apply the new criteria to corners as well.
2023-07-25 15:21:04 +02:00
Aliaksandr Kalenik
849cf894d8 LibWeb: Fix division by zero in distribute_any_remaining_free_space
This change fixes division by zero in case flex container has
"justify-content: space-between" and only single item.
2023-07-25 14:51:50 +02:00
MacDue
6088374ad2 LibPDF: Ensure all subpaths are closed before filling paths
This lets us correctly draw figure 3.4 in pdf_reference_1-7.pdf.
2023-07-25 13:42:40 +02:00