Commit graph

39497 commits

Author SHA1 Message Date
Andreas Kling
aee3d79ad1 LibWeb: Use the "scaled flex shrink factor" where noted by the spec 2022-07-11 18:57:45 +02:00
Andreas Kling
f7750985fa LibWeb: Treat "flex-basis: 0px" like any other definite basis value 2022-07-11 18:57:45 +02:00
Andreas Kling
61c27815e4 LibWeb: More specialization of intrinsic sizing layout
This patch adds a separate entry point for this kind of layout.
We override it in BFC to set up initial width/height values for the
BFC root block.

Resulting dimensions are assigned as content_width and content_height
at the end of intrinsic sizing, for each axis, if it's either "auto"
or there's a min-content or max-content constraint in effect.
2022-07-11 18:57:45 +02:00
Andreas Kling
28eec22c83 LibWeb: Don't iterate over text content inside replaced elements
This fixes an issue where whitespace inside embedded <svg> elements
would create unexpected whitespace text content on the page.

When combined with something like `white-space: pre-wrap`, it ended
up generating a lot of surprising vertical offsets.
2022-07-11 18:57:45 +02:00
Andreas Kling
7b4a86ab80 LibWeb: Use max-content main size for flex items w/ definite cross size
If the main size is indefinite, that is.
2022-07-11 18:57:45 +02:00
Andreas Kling
e78282aebb LibWeb: Make sure we always apply size constraints in IFC
Pre-compute the effective containing block width in the IFC constructor
and use that throughout.
2022-07-11 18:57:45 +02:00
Andreas Kling
7713198e9c LibWeb: Cache a pointer to the containing block state in IFC 2022-07-11 18:57:45 +02:00
Andreas Kling
9784a567d2 LibWeb: Factor out BFC "layout this block-level box" to a function 2022-07-11 18:57:45 +02:00
Andreas Kling
64959a8504 LibWeb: Express intrinsic size layout via size constraints
Previously, we had three layout modes:

- Normal:
    - Everything uses the computed values from CSS.

- MinContent:
    - Containing blocks act as if they have 0 width.
    - All line breaking opportunities are taken.

- MaxContent:
    - Containing blocks act as if they have infinite width.
    - Only forced line breaks are accepted.

The above was based on a set of misunderstandings of CSS sizing.
A major problem with the above was that *all* containing blocks
behaved differently during intrinsic size layout, not just the
relevant one.

With this patch there are only two layout modes:

- Normal:
    - Everything uses the computed values from CSS.

- IntrinsicSizeDetermination:
    - One or more boxes have size constraints applied.

There are two size constraints per layout box, set here:

- FormattingState::NodeState::width_constraint
- FormattingState::NodeState::height_constraint

They are of type SizeConstraint and can be one of None, MinContent,
or MaxContent. The default is None.

When performing an IntrinsicSizeDetermination layout, we now assign
a size constraint to the box we're trying to determine the intrinsic
size of, which is then honored by using two new helpers to query
the dimensions of containing blocks:

- FormattingContext::containing_block_width_for(Box)
- FormattingContext::containing_block_height_for(Box)

If there's a relevant constraint in effect on the Box, the size of
its containing block is adjusted accordingly.

This is essentially an implementation of the "available space"
constraints from CSS-SIZING-3. I'm sure some things will break from
this, and we'll have to deal with that separately.

Spec: https://drafts.csswg.org/css-sizing-3/#available
2022-07-11 18:57:45 +02:00
Andreas Kling
66d08d2417 LibWeb: Move IFC result measurement from IFC to BFC
Before this change, IFC would first generate all of its line boxes
and then measure them. It would then write some of the values into
the state of the IFC's containing block.

We now move that up to BFC::layout_inline_children() instead, which
is a much more natural place to decide metrics for the block.
2022-07-11 18:57:45 +02:00
Andreas Kling
fd68be29ab LibWeb: Make BFC always drive IFC
Instead of allowing FormattingContext to instantiate an IFC for anything
that has inline children, move this logic to BFC.

This is fine, since only BFC deals with blocks having inline children
anyway.
2022-07-11 18:57:45 +02:00
Andreas Kling
db2d62671f LibWeb: Add FFC helpers for getting intrinsic size of flex items 2022-07-11 18:57:45 +02:00
Andreas Kling
4f6fc3d3a6 LibWeb: Only perform the requested form of intrinsic size calculation
Before, querying any of the four intrinsic sizes would cause us to
calculate all of them (the four being min-content width/height, and
max-content width/height).

Now, the helper functions only calculate the specific intrinsic size
requested. It's then cached at the root formatting context level,
so that it's never calculated twice within the same layout pass.
2022-07-11 18:57:44 +02:00
Andreas Kling
496cf39cf5 LibWeb: Make separate functions for calculating min/max content sizes
At first, these are just wrappers around calculate_intrinsic_sizes().
Eventually, we'll make them do only the work necessary for their
specific size.
2022-07-11 18:57:44 +02:00
Andreas Kling
1690d88887 LibWeb: Clamp intrinsic flex item main size contributions to min/max 2022-07-11 18:57:44 +02:00
Karol Kosek
0bba2a4415 Base: Improve visibility of PlaceholderText in themes 2022-07-11 18:11:11 +02:00
Karol Kosek
ff0b4bf360 HexEditor: Gray-out null bytes
This should improve an overall visibility of "meaningful" data. :^)
2022-07-11 18:11:11 +02:00
Idan Horowitz
8717e78918 Kernel: Stop committing pages for COW of uncommitted pages on sys$fork
Uncommitted pages (shared zero pages) can not contain any existing data
and can not be modified, so there's no point to committing a bunch of
extra pages to cover for them in the forked child.
2022-07-11 16:29:10 +02:00
Luke Wilde
38696dc626 LibWeb: Store MessageEvent::m_data in a JS::Handle
This protects it from GC.
2022-07-11 14:49:25 +01:00
kleines Filmröllchen
7b89c4e412 Base: Improve clipboard manpage style 2022-07-11 11:35:56 +02:00
kleines Filmröllchen
fb7cd7b340 Documentation: Merge UsingFontEditor into existing FontEditor manpage
The generate-manpages script needs to be updated again to handle the new
PNGs in section 1. (I'm intentionally not making this a multi-directory
glob.)
2022-07-11 11:35:56 +02:00
kleines Filmröllchen
8558a6b83b Meta: Also check CONTRIBUTING with check-markdown.sh 2022-07-11 11:35:56 +02:00
kleines Filmröllchen
1419732a73 Documentation: Move IPC endpoint documentation to manpage section 4 2022-07-11 11:35:56 +02:00
kleines Filmröllchen
9660f5d0e6 Documentation: Move all file format documentation into its own manpage
The documentation is largely unchanged except for adoption into the
standard manpage format.
2022-07-11 11:35:56 +02:00
Luke Wilde
da25ac0d48 AK: Treat empty string as invalid JSON
Previously we would treat the empty string as `null`. This caused
JavaScript like this to fail:
```js
var object = {};
try {
    object = JSON.parse("");
} catch {}
var array = object.array || [];
```
Since `JSON.parse("")` returned null instead of throwing, it would set
`object` to null and then try and use it instead of using the default
backup value.
2022-07-10 23:31:48 +02:00
Luke Wilde
36c3a0fac2 Meta: Make utmp start out as an empty object instead of empty string
The reason empty string was treated as JSON null was to paper over an
issue where UTMP would start out as the empty string and presumably
cause errors when trying to parse it as JSON. This was added in
commit a409b832.

This changes that by making UTMP start out as an empty JSON object
instead of the empty string.
2022-07-10 23:31:48 +02:00
Idan Horowitz
18d25124bf LibXML: Fail gracefully on integer overflow in character references
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47738
2022-07-10 22:29:11 +03:00
Idan Horowitz
1d96c30488 Kernel: Stop leaking leftover committed cow pages from forked processes
Since both the parent process and child process hold a reference to the
COW committed set, once the child process exits, the committed COW
pages are effectively leaked, only being slowly re-claimed each time
the parent process writes to one of them, realizing it's no longer
shared, and uncommitting it.
In order to mitigate this we now hold a weak reference the parent
VMObject from which the pages are cloned, and we use it on destruction
when available to drop the reference to the committed set from it as
well.
2022-07-10 22:17:21 +03:00
Idan Horowitz
c1fe844da4 Kernel: Stop leaking first thread on errors in sys$fork
Until the thread is first set as Runnable at the end of sys$fork, its
state is Invalid, and as a result, the Finalizer which is searching for
Dying threads will never find it if the syscall short-circuits due to
an error condition like OOM. This also meant the parent Process of the
thread would be leaked as well.
2022-07-10 22:17:21 +03:00
Karol Kosek
6901d3dcec LibGfx: Default-initialize dummy scanline
This should make the CI happier now.
2022-07-10 21:39:28 +03:00
gggggg-gggggg
d728017578 Kernel+LibC+LibCore: Pass fcntl extra argument as pointer-sized variable
The extra argument to fcntl is a pointer in the case of F_GETLK/F_SETLK
and we were pulling out a u32, leading to pointer truncation on x86_64.
Among other things, this fixes Assistant on x86_64 :^)
2022-07-10 20:09:11 +02:00
Tim Schumacher
656528f483 Meta: Prefix manually created directories with the staging prefix
In commit 02e8f29560 we started exporting
the `CMAKE_INSTALL_*DIR` variables without prefix in order to make
better use of the actual `PREFIX` settings.

However, commands like `file(MAKE_DIRECTORY ...)` don't understand the
GNUInstallDirs way of building paths, so we ended up creating
directories in our main project directory by accident.

Fix that by manually adding the correct prefix onto the path.
2022-07-10 16:55:29 +02:00
networkException
6697ab33dc LibGUI: Disallow selection identation in readonly text editors 2022-07-10 16:23:40 +02:00
Karol Kosek
b5420b8a9a LibGfx: Implement PNG filtering on write
Is it another great upgrade to our PNG encoder like in 9aafaec259?
Well, not really - it's not a 2x or 55x improvement like you saw there,
but still it saves something:

- a screenshot of a blank Serenity desktop dropped from about 45 KiB
  to 40 KiB.
- re-encoding NASA photo of the Earth to PNG again saves about 25%
  (16.5 MiB -> 12.3 MiB), compared to not using filters.

[1]: https://commons.wikimedia.org/wiki/File:The_Blue_Marble_(remastered).jpg
2022-07-10 15:01:07 +02:00
Karol Kosek
98a90d79de LibGfx: Move PNG header and paeth_predictor function to a shared header 2022-07-10 15:01:07 +02:00
Karol Kosek
ebc20f7ac3 LibGfx: Use enum instead of magic numbers for PNG Color and Filter types 2022-07-10 15:01:07 +02:00
Liav A
9dbec601b0 Kernel+SystemServer: Make KCOVDevice a character device
This device should not be a block device, as in Serenity, block devices
represent an interface to either disk partitions or storage devices.
2022-07-10 14:57:55 +02:00
Xexxa
b1ed151c9c Browser: Add Brave and Mojeek to search engines 2022-07-10 14:30:51 +02:00
Ali Mohammad Pur
d348eaf305 LibRegex: Treat inverted Compare entries as disjunctions
[^XYZ] is not(X | Y | Z), we used to translate this to
not(X) | not(Y) | not(Z), this commit makes LibRegex interpret this
pattern as not(X) & not(Y) & not(Z).
2022-07-10 14:26:03 +02:00
Ali Mohammad Pur
fe46b2c141 LibRegex: Correctly track current inversion state in the optimizer
This is currently not important as we do not nest TemporaryInverse.
2022-07-10 14:26:03 +02:00
Ali Mohammad Pur
9c5febe800 LibRegex: Flush compare tables before entering a permanent inverse state 2022-07-10 14:26:03 +02:00
Idan Horowitz
fbeef409c6 DynamicLoader: Stop performing relative relocations on non-pie objects
Co-authored-by: Daniel Bertalan <dani@danielbertalan.dev>
2022-07-10 14:24:34 +02:00
Idan Horowitz
b700d1a474 Kernel: Support sys$connect to LocalSockets with short sockaddr_uns
This is not explicitly specified by POSIX, but is supported by other
*nixes, already supported by our sys$bind, and expected by various
programs. While were here, also clean up the user memory copies a bit.
2022-07-10 14:24:34 +02:00
Idan Horowitz
68980bf711 Kernel: Stop reporting POLLHUP exclusively when available in sys$poll
As per Dr. Posix, unlike POLLERR and POLLNVAL, POLLHUP is only mutually
exclusive with POLLOUT, all other events may be reported together with
it.
2022-07-10 14:24:34 +02:00
Idan Horowitz
08e88bfcad Kernel: Remove unused WriteNotOpen File BlockFlag 2022-07-10 14:24:34 +02:00
Idan Horowitz
275e5cdb64 Kernel: Report POLLNVAL events in sys$poll instead of returning EBADF
As required by Dr. Posix.
2022-07-10 14:24:34 +02:00
Idan Horowitz
e32f6903f6 Kernel: Stop providing POLLRDHUP events in sys$poll by default
Dr. Posix specifies that only POLLERR, POLLHUP & POLLNVAL are provided
by default.
2022-07-10 14:24:34 +02:00
Idan Horowitz
5ca46abb51 Kernel: Set POLLHUP on WriteHangUp in sys$poll instead of POLLNVAL
POLLNVAL signifies an invalid fd, not a write hang up.
2022-07-10 14:24:34 +02:00
Idan Horowitz
020c898290 Kernel: Handle SHUT_RDWR in Socket::shutdown
We were previously assuming that the how value was a bitfield, but that
is not the case, so we must explicitly check for SHUT_RDWR when
deciding on the read and write shutdowns.
2022-07-10 14:24:34 +02:00
Idan Horowitz
a6f237a247 Kernel: Accept SHUT_RD and SHUT_WR as shutdown() how values
The previous check for valid how values assumed this field was a bitmap
and that SHUT_RDWR was simply a bitwise or of SHUT_RD and SHUT_WR,
which is not the case.
2022-07-10 14:24:34 +02:00