Commit graph

52979 commits

Author SHA1 Message Date
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
Beckett Normington
8ee71a9920 Ports: Add perl5 2023-07-29 09:03:39 -06:00
Beckett Normington
c5b8903761 Ports: Add OBJDUMP to hosted_defs
This allows the `perl5` port to be built with the Clang toolchain.
2023-07-29 09:03:39 -06: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
Timothy Flynn
bbd80d2e4d LibLocale: Replace some slow CLDR vector lookups with a hash map
The LocaleData generator currently stores vectors of unique instances of
CLDR data (e.g. languages, currencies, etc.). For each CLDR file that we
parse, we linearly search through those vectors to decide if the current
field being parsed is unique. Given the size of the CLDR, this adds up
to quite a bit of time.

Augment these vectors with a hash map to store the index of each unique
instance in those vectors. This allows for quickly checking if a field
is unique, and to later look up those indices.

We do not apply this technique to every bit of CLDR data here. For
example, CLDR::character_orders contains only 2 entries. In that case,
it is quicker to search the vector than it is to hash a string key.

This reduces the runtime of GenerateLocaleData from to 2.03s to 1.09s.
2023-07-28 21:05:52 +02:00
Timothy Flynn
e86769c068 LibLocale: Preprocess unique CLDR date fields
Similar to languages and currencies, extract the loop to collect the
unique set of date fields to a preprocessing function. This alone does
not yield any performance improvement, but combined with an upcoming
patch will make the parse_locale_date_fields() a bit faster.
2023-07-28 21:05:52 +02:00
Timothy Flynn
c9b39c0c39 LibLocale: Decide to skip parsing CLDR calendars a little earlier
We currently parse each CLDR calendar, then decide based on its primary
key whether we want to skip it. Instead, we can decide to skip it based
on its file name.

This reduces the runtime of GenerateLocaleData from 2.03s to 1.97s.
2023-07-28 21:05:52 +02:00
Timothy Flynn
63035f029a LibLocale: Cache parsed CLDR files that must be read more than once
The LocaleData generator has to read a few of the CLDR files more than
once, to e.g. prepare some data up front (for reasons why, see commits
c86f7a6 and 0b69e9f). This takes non-neglible time, especially for large
JSON files such as currencies.json. So in these cases, cache the parsed
JSON in a map.

This reduces the runtime of GenerateLocaleData from 2.32s to 2.03s.
2023-07-28 21:05:52 +02:00
Shannon Booth
bf7af25a82 AK: Allow testing Empty instances for equality
This also makes it possible to compare `Variant<Empty, Ts...>`
objects if operator== exists for all Ts
2023-07-28 20:47:48 +03:30
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
kleines Filmröllchen
c8d7bcede6 Kernel/FileSystem: Rename block_size -> logical_block_size
Since this is the block size that file system drivers *should* set,
let's name it the logical block size, just like most file systems such
as ext2 already do anyways.
2023-07-28 14:51:07 +02:00
kleines Filmröllchen
d1e6e6110d Kernel/FileSystem: Rename logical_block_size -> device_block_size
This never was a logical block size, it always was a device specific
block size. Ideally the block size would change in accordance to
whatever the driver wants to use, but that is a change for the future.
For now, let's get rid of this confusing naming.
2023-07-28 14:51:07 +02:00
kleines Filmröllchen
bf1610d378 Kernel/Ext2: Don't rely on block size 512 for superblock offset 2023-07-28 14:51:07 +02:00
kleines Filmröllchen
10ba54a009 Kernel/Ext2: Write BGDT backups
Same as for the superblock, let's back up the block group descriptor
table.
2023-07-28 14:51:07 +02:00
kleines Filmröllchen
a0705202ea Kernel/Ext2: Write superblock backups
We don't ever read them out, but this should make fsck a lot less mad.
2023-07-28 14:51:07 +02:00
kleines Filmröllchen
cc1cb72fb5 Kernel/Ext2: Extract common calculations to functions
This also makes it easier to understand and reference where these
(sometimes rather arbitrary) calculations come from.

This also fixes a bug where group_index_from_block_index assumed 1KiB
blocks.
2023-07-28 14:51: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
b91af3c6a0 LibUnicode: Remove a few generator tracking fields that are now unused
These were used to generate specialized tables. Now that those tables
have been migrated to general 2-stage lookup tables, these fields are
all unused.
2023-07-28 05:28:50 +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
Timothy Flynn
0ee133af90 LibUnicode: Separate code point case information into its own structure
There is no functional change here. This information will compose the
upcoming multistage casing tables in an upcoming patch. Extract it to
its own struct to prepare for that.
2023-07-28 05:28:50 +02:00
Timothy Flynn
a332a8ad19 LibUnicode: Prepare Unicode data generator for multistage casing tables
There is no functional change here. This just adjusts the changes made
in commit 0652cc4 to be a bit more generic for code point casing tables.
We currently only generate property tables, which boil down to a vector
of booleans. Casing tables will be a struct of varying types, so this
generalizes some of the generator to prepare for that ahead of time, to
make the upcoming casing patch smaller / easier to grok.
2023-07-28 05:28:50 +02:00
Timothy Flynn
3fae92eea2 LibUnicode: Search code point properties sequentially at compile time
When generating code point property tables, we currently binary search
the code point range lists for each property to decide if a code point
has that property. However, we are both iterating over the code points
and through the sorted properties in order. This means we do not need
to search code point ranges that are below the current code point at
all. We can even remove the code point ranges that fall below the
current code point, as we will not see a code point in those ranges
again.

On my machine, this reduces the run time of GenerateUnicodeData from
3.4 seconds to 1.2 seconds.
2023-07-28 05:28:50 +02:00
gloof11
1f1d5ed119 Ports: Update Cave Story version
Updated the version of Cave Story that is pulled from my repo.
The original port of this was missing game files that would've been
extracted on first boot such as .pbm files, and some .pxt files.
2023-07-27 21:17:10 +01:00
Andrew Kaster
2e0e393889 Meta: Port recent build changes to gn build
This ports the following commits:

e8a63eeb0e
bec07d4af7
0e12503586
2023-07-27 12:08:22 -06: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
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