Commit Graph

52824 Commits

Author SHA1 Message Date
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
Andreas Kling
ccf35a973f LibWeb: Derive box baseline from last child *with line boxes*
Before this change, we always derived a box's baseline from its last
child, even if the last child didn't have any line boxes inside.

This caused baselines to slip further down vertically than expected.

There are more baseline alignment issues to fix, but this one was
responsible for a fair chunk of trouble. :^)
2023-07-25 13:42:32 +02:00
Shannon Booth
7b3902e3d5 AK: Remove unused URL::scheme_requires_port
THis function does not seem to be used anywhere, and I cannot find any
spec equivalent for this function.
2023-07-25 06:43:50 -04:00
Shannon Booth
c8da880806 AK: Add spec comments to URL::serialize 2023-07-25 06:43:50 -04:00
Shannon Booth
177b04dcfc AK: Fix url host parsing check for 'ends in a number'
I misunderstood the spec step for checking whether the host 'ends with a
number'. We can't simply check for it if ends with a number, this check
is actually an algorithm which is required to avoid detecting hosts that
end with a number from an IPv4 host.

Implement this missing step, and add a test to cover this.
2023-07-25 06:43:50 -04:00
Nico Weber
715b6f868f LibPDF: Sketch out Type0 font support some more
Type0 fonts can be either CFF-based or TrueType-based.
Create a subclass for each, put in some spec text, and
give each case a dedicated error code, so that `--debugging-stats`
can tell me which branch is more common.
2023-07-25 12:10:36 +02:00
Aliaksandr Kalenik
0f21b35d1c Tests/LibWeb: Add tests for CSSPixels class
After the CSSPixels implementation evolved from a wrapper of double
to a fixed-point saturated math arithmetic implementation, it makes
sense to have separate tests for it.
2023-07-25 11:52:02 +02:00
Aliaksandr Kalenik
bec07d4af7 LibWeb: Use fixed-point saturated arithmetics for CSSPixels
Using fixed-point saturated arithmetics for CSSPixels allows to avoid
accumulating floating-point errors.

This implementation is not complete yet: currently saturated
arithmetics implemented only for addition. But it is enough to not
regress any of layout tests we have :)

See https://github.com/SerenityOS/serenity/issues/18566
2023-07-25 11:52:02 +02:00
Aliaksandr Kalenik
5cdd03fc53 LibWeb: Fix divisions by zero in FFC and GFC
This is the preparation to use fixed-point to represent CSSPixels.
Previously, it was acceptable to divide CSSPixels by zero, resulting
in inf, but after migrating to fixed-point stored as an integer, it
would lead to undefined behavior.
2023-07-25 11:52:02 +02:00
Aliaksandr Kalenik
d216621d2a AK: Add clamp_to_int(value) in Math.h
clamp_to_int clamps value to valid range of int values so resulting
value does not overflow.

It is going to be used to clamp float or double values to int that
represents fixed-point value of CSSPixels.
2023-07-25 11:52:02 +02:00
Aliaksandr Kalenik
c66dbc99ee LibWeb: Use a special value to represent an infinite growth limit in GFC
This is preparation for introducing fixed-point CSSPixels in upcoming
commits.

Infinity is a valid state for the growth limit value of a grid track.
It was possible to use INFINITY when CSSPixels were represented using
floating point, but it won't work after the transition to fixed point,
which is represented using integers. This change addresses this by
using -1 as a special value to represent the infinite state of the
growth limit.
2023-07-25 11:52:02 +02:00
Andi Gallo
66c92ebe3d LibWeb: Fix vertical position of top table caption
Setting the top of the table coordinate should not consider the top
padding and margin of the caption, just the bottom and content height.
2023-07-25 11:21:07 +02:00
Andreas Kling
902e76baff LibWeb: Ignore whitespace around easing function argument values
This makes our css-animations.html test file actually parse :^)
2023-07-25 07:20:29 +02:00
Shannon Booth
8d2ccf0f4f AK: Implement IPV4 host URL parsing to specification
This implements both the parsing and serialization IPV4 parts from
the URL spec.
2023-07-24 17:07:16 -04:00
Shannon Booth
50359567e0 AK: Add spec comments for URL spec defined member variables 2023-07-24 17:07:16 -04:00
Sam Atkins
9d2027de6b LibGUI: Make folded lines take up 0 vertical space in no-wrap mode
If a line is hidden by a folding region, then it needs to not take up
any vertical space, or else we just get a glitchy blank line instead of
a folded one. This change corrects the logic when wrapping is not
enabled.
2023-07-24 16:39:02 +01:00
Sam Atkins
d832f3a887 HackStudio+LibGUI: Remove TextDocument::is_code_document()
The same thing can be accomplished with `is` and `verify_cast`, without
making LibGUI care about HackStudio internals.
2023-07-24 16:39:02 +01:00
Sam Atkins
63d14a7e6e HackStudio: Remove Editor::gutter_icon_rect()
This was only used for a redundant call to update().
remove_gutter_indicator() already updates the correct area.
2023-07-24 16:39:02 +01:00
Sam Atkins
489f20d997 HackStudio: Remove unused Editor::m_autocomplete_in_focus field 2023-07-24 16:39:02 +01:00
Sam Atkins
4c551bfad9 HackStudio: Make use of existing TextEditor::on_focusin callback 2023-07-24 16:39:02 +01:00
Nico Weber
5aab31dc40 LibPDF: Dedicated messages for Indexed and Pattern spaces
Makes them easier to interpret in `pdf --debugging-stats` output.
2023-07-24 11:01:25 -04:00
Nico Weber
4bb29e6ac4 pdf: Add a --debugging-stats flag
Tries to render all pages of a PDF and then produces a report on which
unimplemented things were encountered.

Example, for pdf_reference_1-7.pdf:

    113 times: Rendering of feature not supported: Type0 font not imp...
        on pages: 170 (3x) 217 (2x) 250 (9x) 252 (2x) 329 (6x)...
    21 times: Rendering of feature not supported: unknown color space
        on pages: 489 (4x) 490 (5x) 491 (3x) 492 (5x) 493 (4x)
    4 times: Rendering of feature not supported: CCITTFaxDecode Filte...
        on pages: 494 (4x)

(Actually, rendering crashes for some page in that file at the moment.
This was with a local change to only render the first 800 pages to work
around that. So this is also good for finding crashes.)
2023-07-24 11:00:01 -04:00