Commit graph

54026 commits

Author SHA1 Message Date
Tim Ledbetter
fa0606ea36 find: Explicitly specify type when converting to uid_t
This reduces the risk of unintentional conversion errors.
2023-08-29 14:09:44 -04:00
Tim Ledbetter
bc50b629ee find: Don't allow negative GIDs to be passed to the -group option 2023-08-29 14:09:44 -04:00
Andreas Kling
6d7a2f5cc9 LibWeb: Prune old paintable pointers from layout tree after relayout
When text paintables shift around in the tree due to line wrapping,
we may end up in a situation where some text node does not generate
a paintable (due to being all whitespace, for example), even though
in the previous layout pass, it *did* generate a paintable.

To prevent holding on to old paintables in such cases, we now do a
pass in LayoutState::commit() where we explicitly detach all old
paintables from the layout tree.
2023-08-29 17:05:16 +02:00
Timothy Flynn
390da2985f Ladybird: Implement the View Source action for the AppKit chrome
This opens a new tab to display the current tab's source as HTML.
2023-08-29 08:11:11 -04:00
Timothy Flynn
a6bdf8c2a9 Ladybird: Use a web view for the Qt chrome's View Source action
Unlike the existing popup window, this will provide syntax highlighting.
2023-08-29 08:11:11 -04:00
Timothy Flynn
a718a1f3a6 Ladybird: Allow creating new tabs with plain HTML
This will allow us to internally create a new tab with HTML, to be used
by the View Source command.
2023-08-29 08:11:11 -04:00
Timothy Flynn
9c4ce1b80b Ladybird: Do not enable the reload button if history is empty
Not much of an issue currently, but will be once tabs are used to render
plain HTML.
2023-08-29 08:11:11 -04:00
Timothy Flynn
70830b711e Ladybird: Protect some application commands against non-Tab key windows
Currently, the only NSWindow type in the AppKit chrome is the Tab. Once
we have other window types (e.g. Inspector), commands which assume they
are used on a Tab will either crash or behave weirdly.

This changes the createNewTab: command to accept the tab from which the
new tab is created, rather than assuming that tab is the key window. So
if some JS on a page calls window.open() while a non-Tab window is key,
the new tab will be opened within the same tab group.

This also changes closeCurrentTab: to work on any key window. Regardless
of whether the key window is a Tab or some other window, pressing cmd+W
should just close that window.
2023-08-29 08:11:11 -04:00
Timothy Flynn
e981c13a4f Ladybird: Use the correct theme file for the current AppKit theme 2023-08-29 08:11:11 -04:00
Timothy Flynn
1e1c3e5a34 LibWebView: Create a method to syntax-highlight page source with HTML
This tokenizes a page's source to produce HTML with syntax highlighting.
The first implementation here is rather simple; we do not yet implement
code folding, line numbers, etc.

The goal is for this to be used as the View Source implementation for
all Ladybird chromes.
2023-08-29 08:11:11 -04:00
Timothy Flynn
fea440055a LibWeb: Track the byte offset of an HTMLToken's position
We currently track the [line, column] position of every HTMLToken, as
this is what is needed for LibGUI's syntax highlighting. Some non-LibGUI
purposes (e.g. highlighting HTML with HTML) require a byte offset. Track
both during tokenization.
2023-08-29 08:11:11 -04:00
Ali Mohammad Pur
ba4db899d4 LibSyntax+Userland: Make LibSyntax not depend on LibGUI
This moves some stuff around to make LibGUI depend on LibSyntax instead
of the other way around, as not every application that wishes to do
syntax highlighting is necessarily a LibGUI (or even a GUI) application.
2023-08-29 07:57:39 -04:00
Aliaksandr Kalenik
2495302991 LibWeb: Reset auto_placement_cursor_x after adding new column in GFC
We need to start looking from the beginning of current row if adding
new implicit column track made enough space to accomodate spanning item

This fixes placement for spanning grid items when `grid-auto-flow` is
specified to `column`.
2023-08-29 12:35:21 +02:00
Zaggy1024
ac6c06e235 LibAudio: Don't count buffered samples in Loader::loaded_samples()
The `Loader` uses a `Vector<Sample>` to store any samples that the
actual audio decoder returned that the loader client did not request
yet. However, it did not take that buffer into account when those
clients asked for the number of samples loaded. The buffer is an
internal implementation detail, and should not be reflected on the
external API.

This allows LibWeb to keep better track of audio position without any
desync caused by the buffer. When using the Serenity `PlaybackStream`
implementation as the back end for an `HTMLAudioElement`, this allows
us to perfectly stop on the exact last sample of the audio file, so it
will not stop before the media element can see that it has finished
playback.

Note that `Loader::get_more_samples()` also calls `loaded_samples()` to
determine how many samples are remaining to load into the output
buffer. However, this change appears to be correct even there, given
that the samples copied from the internal sample buffer are included in
that count.
2023-08-29 11:31:10 +02:00
Zaggy1024
9d65965060 WebContent: Replace the Serenity audio plugin with the agnostic one
The behavior of the Serenity `PlaybackStream` implementation should
match the `AudioCodecPluginSerenity` class removed by this commit. Any
inconsistencies should be fixable without needing feature additions to
the underlying implementation.
2023-08-29 11:31:10 +02:00
Zaggy1024
88190202cc LibWeb: Update the audio timestamp every 50 ms instead of every 10 ms
The previous update time of 10 ms was set completely arbitrarily, but
puts an unnecessary load on the CPU. This reduces the rate, and it can
be adjusted in future depending on what web pages expect.
2023-08-29 11:31:10 +02:00
Zaggy1024
bb156f8133 LibAudio: Add a Serenity implementation of PlaybackStream
This implementation is very naive compared to the PulseAudio one.

Instead of using a callback implemented by the audio server connection
to push audio to the buffer, we have to poll on a timer to check when
we need to push the audio buffers. Implementing cross-process condition
variables into the audio queue class could allow us to avoid polling,
which may prove beneficial to CPU usage.

Audio timestamps will be accurate to the number of samples available,
but will count in increments of about 100ms and run ahead of the actual
audio being pushed to the device by the server.

Buffer underruns are completely ignored for now as well, since the
`AudioServer` has no way to know how many samples are actually written
in a single audio buffer.
2023-08-29 11:31:10 +02:00
ronak69
2caf68fd03 AK: Add binary and octal mode formatting for FixedPoint 2023-08-29 11:10:45 +02:00
ronak69
352480338e AK: Refactor FixedPoint's formatter
The main change is the simplification of the expression
`(10^precision * fraction) / 2^precision` to `5^precision * fraction`.

Those expressions overflow or not depends on the value of `precision`
and `fraction`. For the maximum value of `fraction`, the following table
shows for which value of `precision` overflow will occur.

            Old   New
    u32      08    10
    u64      15    20
    u128     30    39

As of now `u64` type is used to calculate the result of the expression.
Meaning that before, only FixedPoints with `precision` less than 15
could be accurately rendered (for every value of fraction) in decimal.
Now, this limit gets increased to 20.

This refactor also fixes, broken decimal render for explicitly specified
precision width in format string, and broken hexadecimal render.
2023-08-29 11:10:45 +02:00
ronak69
d40807681d AK: Cast lhs of left shifts to FixedPoint's underlying integer type
By default, `1` is of the type `int` which is 32-bits wide at max.
Because of that, if `precision` of a `FixedPoint` is greater than 32,
the expression `1 << precision` will get clamped at 32-bits and the
result will always be zero. Casting `1` to the wider underlying type
will make the expression not overflow.
2023-08-29 11:10:45 +02:00
ronak69
4c6ea4a963 AK: Fix off-by-one error in round-to-even logic of FixedPoint
Because of the off-by-one error, the second bit of the fraction was
getting ignored in differentiating between fractions equal to 0.5 or
greater than 0.5. This resulted in numbers like 2.75 being considered
as having fraction equal to 0.5 and getting rounded incorrectly (to 2).
2023-08-29 11:10:45 +02:00
Sönke Holz
6ef2c34eb4 Kernel: Add riscv64 assembly startup code
This adds a simple boot.S for RISC-V (64-bit), which clears the BSS and
sets up the processor to be ready for pre_init.cpp (which is not added
yet).
2023-08-29 11:07:06 +02:00
Sönke Holz
132d25e5bf Kernel: Add linker script for riscv64 2023-08-29 11:07:06 +02:00
Marcus Nilsson
a2f0804f22 LibC: Move parsing of service file line to static helper function
This patch adds `parse_service_file_line()` which both `getservent()`
and `getaddrinfo()` makes use of.
2023-08-29 11:04:48 +02:00
Marcus Nilsson
e2ca144cf9 Tests: Add tests for getaddrinfo() 2023-08-29 11:04:48 +02:00
Marcus Nilsson
2b430e1f56 LibC: Remove dependency of getservbyname() in getaddrinfo() 2023-08-29 11:04:48 +02:00
Marcus Nilsson
37cea81837 LibC: Use gethostbyname_r() in getaddrinfo()
getaddrinfo() used to use gethostbyname() which isn't MT-Safe.
2023-08-29 11:04:48 +02:00
Marcus Nilsson
db2f96e4ed Tests: Add tests for gethostbyname() 2023-08-29 11:04:48 +02:00
Marcus Nilsson
fd792f93c4 LibC: Use gethostbyname_r() in gethostbyname()
Since `gethostbyname()` can't fail because of memory-related issues, it
has no way of representing a memory-related failure. We therefor use
`NO_RECOVERY` to represent a memory-related failure as well
as its normal name server related failures.
2023-08-29 11:04:48 +02:00
Marcus Nilsson
5c4b71ac67 Tests: Add tests for gethostbyname_r() 2023-08-29 11:04:48 +02:00
Marcus Nilsson
1a7e262752 LibC: Implement gethostbyname_r()
gethostbyname_r() will be used to make getaddrinfo() MT-Safe.
2023-08-29 11:04:48 +02:00
kleines Filmröllchen
bf3fa19314 LibAudio: Write FLAC metadata
This includes a generalization of the metadata block infrastructure, so
adding and writing blocks is handled in a generalized fashion.
2023-08-29 10:43:34 +02:00
kleines Filmröllchen
fc2301c23c LibAudio: Allow writing Vorbis comments
The vorbis comment parsing code is slightly generalized to reuse
field-role associations for artists.
2023-08-29 10:43:34 +02:00
kleines Filmröllchen
c853a73ae2 aconv: Override encoder in output metadata
After all, we encoded this file :^)
2023-08-29 10:43:34 +02:00
kleines Filmröllchen
34978b364b LibAudio: Understand album (IPRD) metadata in WAV
This is in common usage, just not present in the reference I looked at.
2023-08-29 10:43:34 +02:00
kleines Filmröllchen
4c9c2104f3 aconv: Copy metadata to output
This requires postponing FLAC header finalization, since FLAC cannot
write metadata after a finalized header.
2023-08-29 10:43:34 +02:00
kleines Filmröllchen
1e291753b0 LibAudio: Allow adding metadata to encoders 2023-08-29 10:43:34 +02:00
kleines Filmröllchen
b4b411b8a3 LibAudio: Add a sample count hinting mechanism to audio encoding 2023-08-29 10:43:34 +02:00
kleines Filmröllchen
0960a92670 LibAudio: Add more common classes to the forward declare header 2023-08-29 10:43:34 +02:00
Andreas Kling
9d6f00d918 LibJS: Behave like major engines when substituting missing capture group
When a substitution refers to a 2-digit capture group that doesn't exist
we need to check if the first digit refers to an existing capture group.
In other words, '$10' should be treated as capture group #1, followed by
the literal '0' if 1 is a valid capture group but 10 is not.

This makes the Dromaeo "dom-query" subtest run to completion.
2023-08-29 10:33:48 +02:00
Cubic Love
b5ed86ab68 Base: Improve the King piece in Classic chess set
Make the King's crown more rounded.
2023-08-29 10:28:24 +02:00
Cubic Love
91269a8064 Chess: Capitalize chess set names + Rename 'stelar7' to 'Classic'
Now when selecting a chess set in Games Settings, the names of the sets
are capitalized which looks much neater.

The default set 'stelar7' has been renamed to 'Classic' to reflect its
default vanilla design, as opposed to more stylized sets.
This commit also updates any code references to this set.
2023-08-29 10:28:24 +02:00
Shannon Booth
f3e5335096 LibWeb: Port CSSKeyframeRules interface from DeprecatedString to String 2023-08-29 10:05:02 +02:00
Shannon Booth
15334a68df LibWeb: Port CSSKeyframesRules interface from DeprecatedString to String 2023-08-29 10:05:02 +02:00
Shannon Booth
826374d04b LibWeb: Port Path2D interface from DeprecatedString to String 2023-08-29 10:05:02 +02:00
Shannon Booth
e8d592ded2 LibWeb: Port WebGLRenderingContext IDL from DeprecatedString to String 2023-08-29 10:05:02 +02:00
Shannon Booth
cf733d309e LibWeb: Port CSSConditionRule interface from DeprecatedString to String 2023-08-29 10:05:02 +02:00
Shannon Booth
ff45874d4e LibWeb: Port MediaList interface from DeprecatedString to String 2023-08-29 10:05:02 +02:00
Shannon Booth
72f54eca26 LibWeb: Port History interface from DeprecatedString to String 2023-08-29 10:05:02 +02:00
Shannon Booth
7b79324548 LibWeb: Port Range interface from DeprecatedString to String 2023-08-29 10:05:02 +02:00