Commit graph

53136 commits

Author SHA1 Message Date
Andreas Kling
a75b51de10 js: Remove ability to run with AST interpreter 2023-08-08 13:07:13 +02:00
Andreas Kling
9df7bf79cc LibJS: Add create_simple_execution_context<GlobalObjectType>() helper
This makes it easy to set up a realm, global object and root execution
context with a single call to LibJS. It will be useful to basically
everyone except LibWeb.
2023-08-08 13:07:13 +02:00
Andreas Kling
d1d24569f8 LibJS/Bytecode: Remove unused AST interpreter hacks from bytecode VM 2023-08-08 13:07:13 +02:00
Andreas Kling
196e04d1c7 CI: Stop running test-js with the AST interpreter 2023-08-08 13:07:13 +02:00
Andi Gallo
7bd00d6a42 LibWeb: Snap table grid to device pixels in separate borders mode
Build a grid snapped to device pixels and use it to construct the
rectangles for the cell edges, same as for collapsed borders. This is
especially important when border-spacing is set to 0 since it avoids
gaps between adjacent cells which have borders set.
2023-08-08 12:26:11 +02:00
Jelle Raaijmakers
14091f32c6 Browser: Synchronize database statements used for cookies
Since SQLServer is inherently asynchronous, database statements can run
in parallel. Our `CookieJar` did not require synchronous actions on the
database for its cookies, resulting in cookies not being set
immediately. This resulted in a bug that could be exposed by setting
`document.cookie` and immediately querying its value, revealing that the
cookie was not yet persisted.

Solve this by requiring all database statements to be executed
synchronously. Ideally SQLServer has a mechanism to determine interquery
dependencies and blocks until dependent queries are fully executed, but
until we have that, this works around that limitation.
2023-08-08 06:25:11 -04:00
Aliaksandr Kalenik
568c486610 LibWeb: Support positioning of abspos boxes inside grid container
- Out-of-flow items should not affect grid layout
- "The static position of an absolutely-positioned child of a grid
  container is determined as if it were the sole grid item in a grid
  area whose edges coincide with the content edges of the grid
  container."
2023-08-08 11:31:35 +02:00
Sam Kravitz
073eb46824 LibJS: Apply the correct precedence for unary + and - operators
When determining the precedence of the + and - operators, the parser
always returned the precedence using these operators in a binary
expression (lower than division!). The context of whether the operator
is used in a unary or binary expression must be taken into account.
2023-08-08 07:41:07 +02:00
Andreas Kling
18c54d8d40 LibJS: Make Cell::initialize() return void
Stop worrying about tiny OOMs.

Work towards #20405
2023-08-08 07:39:11 +02:00
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