Commit Graph

53127 Commits

Author SHA1 Message Date
Lucas CHOLLET
fde26c53f0 AK: Remove the API to explicitly construct short strings
Now that ""_string is infallible, the only benefit of explicitly
constructing a short string is the ability to do it at compile-time. But
we never do that, so let's simplify the API and remove this
implementation detail from it.
2023-08-08 07:37:21 +02:00
Lucas CHOLLET
3f35ffb648 Userland: Prefer _string over _short_string
As `_string` can't fail anymore (since 3434412), there are no real
benefits to use the short variant in most cases.
2023-08-08 07:37:21 +02:00
Lucas CHOLLET
a5edc9cdfc Userland: Prefer _short_string over String::from_utf8_short_string
This user-defined literal is a strictly equivalent but shorter alias to
`String::from_utf8_short_string`.
2023-08-08 07:37:21 +02:00
Daniel Bertalan
66645cdc94 LibJS+LibWeb: Mark NonnullGCPtr::ptr() as returns_nonnull
This invariant is enforced by the fact that `NonnullGCPtr` can only be
constructed from references.

This commit fixes an instance where we compared a pointer to null after
we have already dereferenced it.
2023-08-07 22:20:03 -04:00
Daniel Bertalan
9feb1ce39f LibJS+LibWeb: Apply the Rule of Zero to {Nonnull,}GCPtr<T>
The compiler-generated copy constructor and copy assignment operator
already do the right thing (which is to simply copy the underlying
pointer).

The [Itanium C++ ABI][1] treats any class with non-trivial copy/move
constructors and destructors as non-trivial for the purposes of calls --
even if they are functionally identical to the compiler-generated ones.
If a class is non-trivial, it cannot be passed or returned in registers,
only via an invisible reference, which is worse for codegen. This commit
makes `{Nonnull,}GCPtr` trivial.

As the compiler can be sure that capturing a `GCPtr` by value has no
side effects, a few `-Wunused-lambda-capture` warnings had to be
addressed in LibWeb.

GCC seems to have a bug that prevents `ExceptionOr<Variant<GCPtr<T>>>`
from being implicitly constructed from `GCPtr<T>` after this change. A
non-invasive workaround is to explicitly construct the inner Variant
type.

[1]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#non-trivial
2023-08-07 22:20:03 -04:00
Andrew Kaster
82495083c3 Ladybird: Ensure selected new tab URL is a valid URL before saving 2023-08-07 22:17:40 -04:00
Andrew Kaster
391beef707 Ladybird: Move Qt-specific classes and functions to a Qt subdirectory
This will help a lot with developing chromes for different UI frameworks
where we can see which helper classes and processes are really using Qt
vs just using it to get at helper data.

As a bonus, remove Qt dependency from WebDriver.
2023-08-07 14:58:04 -06:00
Liav A
ccaa423372 Utilities: Add basic Package manager skeleton utility 2023-08-07 13:24:25 -06:00
Liav A
22737b70bc LibMarkdown: Add render_for_raw_print methods to Node derived classes
This method will be used by the package manager code to render an actual
Port's name to raw text as it is stored as relative URL currently in the
AvailablePorts.md file.
2023-08-07 13:24:25 -06:00
Liav A
8073c615af LibMarkdown: Add method to get access to Table columns
This will be used later when parsing the AvailablePorts.md file in the
upcoming package manager application.
2023-08-07 13:24:25 -06:00
Liav A
fcc3497803 Ports: Rename packages.db => installed.db
The /usr/Ports/packages.db will be used later for tracking available
ports by the upcoming package manager, which will use it to do search
queries, providing metadata on available ports, etc.

Ports that are installed will be registered from now on in the file of
/usr/Ports/installed.db, so that file will be used later on to allow
further management of what is actually installed on the system.
2023-08-07 13:24:25 -06:00
Liav A
c53b1360d7 Base: Add bind-mount for /usr/Ports/ to make it writable
This directory is only writable by root already by now. This will allow
the upcoming package manager to change files in this directory.
2023-08-07 13:24:25 -06:00
ronak69
44a46aabeb LibLine: Refresh the line after case-change operations
Previously, case-change operations did not produce visible results.
As of now, setting `m_chars_touched_in_the_middle` to a non-zero value
results in refreshing the whole line. So case-change operations now set
that variable (causing a line refresh) in order to produce visible
results as expected.
2023-08-07 22:51:49 +03:30
Sebastian Zaha
fc71403842 LibCore: Implement Process::is_being_debugged for macOS
The wait_for_debugger_and_break helper now works on macOS with this
change, tested on lldb 14.
2023-08-07 13:16:28 -06:00
Sebastian Zaha
35c45a94d3 LibCore: Implement a helper that waits for a debugger then breaks
This method can be used to force the current process to sleep, waiting
for a debugger to attach. On attach, the debugger breaks at the callsite
 directly.

This is tested on Linux and macOS, in Clion and also terminal gdb and
lldb.
2023-08-07 13:16:28 -06:00
Sebastian Zaha
216667368d LibCore+Ladybird: Extract helper into generic Process::is_being_debugged 2023-08-07 13:16:28 -06:00
Sebastian Zaha
002e206af0 LibCore: Implement Process::get_name for linux and macos 2023-08-07 13:16:28 -06:00
Monroe Clinton
1b5b1e4153 Calendar: Implement saving, loading, and displaying of calendars
The user can now save, load, and view calendars. A calendar is made up
of an array of events which are saved in a JSON file. In the future we
should implement the iCalendar standard instead of using a custom
format.
2023-08-07 13:14:58 -06:00
Timothy Flynn
db3e1b128c SQLServer: Remove Core::EventReceiver parent from DatabaseConnection
This relationship was entirely unused.
2023-08-07 14:38:38 -04:00
Timothy Flynn
08d77ca6b1 SQLServer: Remove Core::EventReceiver parent from SQLStatement
This relationship was only used to provide factory methods and a parent-
child relationship between SQLStatement and DatabaseConnection.
2023-08-07 14:38:38 -04:00
Timothy Flynn
3ea4c56d04 LibSQL: Remove Core::EventReceiver parent from SQL::Relation
This relationship was only used to provide a name, factory methods, and
parent-child relationships for the relations.
2023-08-07 14:38:38 -04:00
Timothy Flynn
5ad78cab8d LibSQL: Remove Core::EventReceiver parent from SQL::Index
This relationship was only used to provide factory methods for the index
(and its BTree child).
2023-08-07 14:38:38 -04:00
Timothy Flynn
1b40bf9783 LibSQL: Remove unused HashIndex and related classes
The features provided by these classes should be used eventually, but so
far we've been maintaining these classes for over 2 years without any
actual use. We can restore them when it comes time to actually use them.
2023-08-07 14:38:38 -04:00
Timothy Flynn
1151ba333a LibSQL+SQLServer: Remove Core::EventReceiver parent from SQL::Database
This relationship was only used to provide factory methods for the
database.
2023-08-07 14:38:38 -04:00
Timothy Flynn
4a04438e43 LibSQL: Remove Core::EventReceiver parent from SQL::Heap
This relationship was only used to provide a name and factory methods
for the heap.
2023-08-07 14:38:38 -04:00
Dennis
2c17742811 Documentation: Add instructions to disable OpenSSL legacy renegotiation
In distributions with newer versions of OpenSSL, when you run
Meta/serenity.sh rebuild-toolchain you'll get curl: (35)
error:0A000152:SSL routines::unsafe legacy renegotiation
disabled. This is because OpenSSL was compiled with legacy
renegotiation disabled by default. I've added instructions
to Documentation/BuildInstructions.md to solve this issue.
2023-08-07 11:14:34 -06:00
Zaggy1024
50c73d02f0 LibAudio: Add a test for creating and destructing a PlaybackStream
This will ensure that we don't leak any memory while playing back
audio.

There is an expectation value in the test that is only set to true when
PulseAudio is present for the moment. When any new implementation is
added for other libraries/platforms, we should hopefully get a CI
failure due to unexpected success in creating the `PlaybackStream`.

To ensure that we clean up our PulseAudio connection whenever audio
output is not needed, add `PulseAudioContext::weak_instance()` to allow
us to check whether an instance exists without creating one.
2023-08-07 10:40:34 -06:00
Zaggy1024
515b255fa4 LibAudio: Clear callbacks and disconnect PulseAudioStream in destructor
If we don't clear the callbacks, they may be called after our functions
are deleted.

Disconnecting the stream also doesn't appear to be done automatically
when calling `pa_stream_unref()` for the last time, so let's do that.
2023-08-07 10:40:34 -06:00
Zaggy1024
2de3cee8ea LibAudio: Disconnect from and unref the PulseAudio context with lock
We don't want to pull the stream out from under our PulseAudio main
loop, so call these with the lock to ensure that nothing is touching
them.

The `pa_threaded_mainloop_stop()` call does not require lock as it sets
a flag to tell the main loop to exit.
2023-08-07 10:40:34 -06:00
Zaggy1024
37acdc9ba7 LibAudio: Unlock the mutex in PulseAudioContext::instance() before exit
The mutex used to protect from multiple threads creating PulseAudio
contexts simultaneously could remain locked when an application exited.
The static variables' destructors could be called on the main thread
while another thread is running `PulseAudioContext::instance()` and
synchronously connecting to a PulseAudio daemon. This would cause an
assertion in Mutex that it is unlocked upon its destructor being
called.

By creating a static `ScopeGuard` that locks and immediately unlocks
the mutex, we can ensure that the main thread waits for the connection
to succeed or fail. In most cases, this will not take long, but if the
connection is timing out, it could take a matter of seconds.
2023-08-07 10:40:34 -06:00
Zaggy1024
f22d7bbb90 LibAudio: Remove invalid FIXME from PulseAudioContext::create_stream()
The entire API is designed to run synchronously, the API callers must
implement the asynchronicity.
2023-08-07 10:40:34 -06:00
Zaggy1024
c3ded6d56c LibAudio: Improve PulseAudio stream connection error messages
We were missing a formatted error message printout when the connection
failed after the initial `pa_stream_connect_playback()` API call.
2023-08-07 10:40:34 -06:00
Zaggy1024
5ea5ae85d2 LibAudio: Remove the strong reference to the PulseAudio control thread
Now that `Thread` keeps itself alive when it is running detached, we do
not need to hold onto it in the PulseAudio playback stream's internal
state object. This was a hack that did not work correctly because the
`Thread` object and its action `Function` would be deleted before the
action had exited and cause a crash.
2023-08-07 10:40:34 -06:00
Zaggy1024
aff64b6a03 LibThreading: Make Thread keep itself alive while its action is running
Previously, a `Thread` could be deleted while its action was running,
even if it was running detached.

By changing it to be atomically reference counted, and incrementing the
count when starting the action, we can keep the Thread and its running
action `Function` alive until it exits. Thus, detached `Thread` objects
can be deleted by the thread creating them and allowed to die
naturally.
2023-08-07 10:40:34 -06:00
Zaggy1024
71df0ee994 LibThreading: Remove Thread's inheritance from Core::EventReceiver
Inheritance from `EventReceiver` on the `Thread` class was only used in
the `BackgroundAction` class, where the children vector was keeping the
action alive until the work was completed. However, this can be
accomplished by instead capturing a `NonnullRefPtr` of `this`. The work
function can then avoid having to remove the `BackgroundAction` from
its parent `Thread` when the work completes.
2023-08-07 10:40:34 -06:00
Zaggy1024
925afcd4b0 Meta: Install libpulse on Azure to build PlaybackStreamPulseAudio on CI 2023-08-07 10:40:34 -06:00
Andrew Kaster
167eb501d9 Ladybird: Copy cacert.pem into the expected build-time path on macOS
With the CMake build, the ladybird binary ends up in
$build/bin/ladybird.app/Contents/MacOS. Which is a bit unfortunate for
a few reasons, but the main one is that --enable-lagom-networking
doesn't work with ./Meta/serenity.sh run lagom ladybird.

Let's copy the file to the expected location. There's very likely better
solutions we can use in the future.
2023-08-07 10:34:26 -06:00
Andreas Kling
25eee91811 AK: Make "foo"_fly_string infallible
Stop worrying about tiny OOMs.

Work towards #20405.
2023-08-07 16:03:27 +02:00
Andreas Kling
34344120f2 AK: Make "foo"_string infallible
Stop worrying about tiny OOMs.

Work towards #20405.
2023-08-07 16:03:27 +02:00
Zaggy1024
db2a8725c6 LibCore: Only use coarse time in the Unix event loop wait_for_events()
A typo in the changes to our userland timekeeping classes caused us to
make a syscall every time we want to check whether a timer is ready to
fire in `EventLoopManagerUnix::wait_for_events()`. Instead, only use
coarse time, and get it immediately before it is used in both cases.

This reduces CPU usage by an (eyeballed) 20-30% while playing back
video with VideoPlayer.
2023-08-07 13:38:20 +02:00
Andreas Kling
742eff26a9 Meta: Add Tim Ledbetter to the contributors list :^) 2023-08-07 12:38:03 +02:00
Andi Gallo
ea6e079e07 LibWeb: Snap table grid to device pixels in collapsed borders mode
Before painting the borders, build a grid snapped to device pixels and
use it to construct the rectangles for the cell edges. Also adjust
their starting coordinate and size such that they join correctly
without overhangs. This approach works at all zoom levels.
2023-08-07 05:51:19 +02:00
Jelle Raaijmakers
9466512847 LibGUI: Traverse into directory upon filename entry in FilePicker
Previously, typing e.g. `/home/anon` in the filename field of the
FilePicker resulted in an error for applications expecting an existing
file to open. Intuitively I expected the file picker to navigate to the
directory I typed there, similar to what we have with the location text
box at the top, so I changed it to do exactly that :^)
2023-08-07 05:25:12 +02:00
Aliaksandr Kalenik
c985a1b2af LibWeb: Add non-const version of paintable_box() in DOM::Node 2023-08-07 05:23:31 +02:00
Aliaksandr Kalenik
6868ace8f4 LibWeb: Add non-const version of paintable_box() in Layout::Node
Allows to remove a bunch of const_cast's
2023-08-07 05:23:31 +02:00
Aliaksandr Kalenik
dc08e9138c LibWeb/Tests: Add basic test for Element::scroll(x, y) 2023-08-07 05:23:31 +02:00
Aliaksandr Kalenik
433d3f988d LibWeb: Add ad-hoc implementation for Element::scroll(x, y)
Adds very naive implementation for js function to trigger scroll but
that is enough to start using it in tests :)
2023-08-07 05:23:31 +02:00
Aliaksandr Kalenik
4160f13174 LibWeb: Include scroll offset in paint tree dump 2023-08-07 05:23:31 +02:00
Aliaksandr Kalenik
b89481564b LibWeb: Null check dom_node() in PaintableBox::scroll_offset() 2023-08-07 05:23:31 +02:00
Aliaksandr Kalenik
fee5b4deb6 LibWeb: Move set_scroll_offset() from Layout::Box to PaintableBox
Nodes in layout tree should not be aware of scroll state.
2023-08-07 05:23:31 +02:00