Commit graph

44064 commits

Author SHA1 Message Date
Linus Groh
011f6a6cb4 LibWeb/Fetch: Use tuple syntax for headers in spec comments
This is an editorial change in the Fetch spec.

See: https://github.com/whatwg/fetch/commit/b482186
2022-12-08 15:37:19 +00:00
Andreas Kling
b3b51a5001 LibGfx: Use a FixedArray for the dummy scanline in PNGWriter
PNGWriter sets up one dummy scanline with the same width as the other
scanlines in order to allow addressing the "previous scanline" without
complicating the code.

By using a FixedArray instead of a VLA, we sidestep the risk of stack
overflow and instead get something that can signal OOM.
2022-12-08 13:01:11 +00:00
Andreas Kling
e19c8897ee LibGfx: Propagate errors that occur internally in PNGWriter
This patch basically uses the TRY() macro throughout PNGWriter instead
of relying on the MUST()'ing wrappers in Vector and ByteBuffer.

One FIXME was killed in the making of this patch. :^)
2022-12-08 13:01:11 +00:00
Andreas Kling
d88c7fee32 LibGfx+Userland: Make PNGWriter::encode() return ErrorOr<ByteBuffer>
This is a first step towards handling PNG encoding failures instead of
just falling over and crashing the program.

This initial step will cause encode() to return an error if the final
ByteBuffer copy fails to allocate. There are more potential failures
that will be surfaced by subsequent commits.

Two FIXMEs were killed in the making of this patch. :^)
2022-12-08 13:01:11 +00:00
Andreas Kling
95b4ffad39 Mandelbrot: Make it possible for export_image to return an error
...and if we do get an error, present it to the user.
2022-12-08 13:01:11 +00:00
Tim Schumacher
2fc2025f49 LibCore: Move Core::Stream::File::exists() to Core::File
`Core::Stream::File` shouldn't hold any utility methods that are
unrelated to constructing a `Core::Stream`, so let's just replace the
existing `Core::File::exists` with the nicer looking implementation.
2022-12-08 12:52:14 +00:00
Sam Atkins
bd272e638c LibWeb: Introduce CSSPixels and DevicePixels classes
These are an attempt to separate the internal "pixel" used by CSS from
the actual "pixel" that exists on the display. Because of things like
2x display scaling, the ratio between these can vary, so having
distinct types will help prevent errors when converting from one unit
to the other.

`CSSPixels` refers to the `px` unit used on the web, which depending on
the device may or may not map to 1 pixel on the physical display. It's
a wrapper around `float`, and will be used by LibWeb for size and
position values up until we go to paint them to the screen.

`DevicePixels` on the other hand is a 1-to-1 pixel on the physical
display. It's a wrapper around `int`.
2022-12-08 12:46:03 +00:00
Sam Atkins
83f31cb4a7 LibGfx: Add int overloads for (AntiAliasing)Painter float methods
Without this change, the upcoming LibWeb pixel types will require a
silly doubled conversion in some places.

eg: `some_rect.to_type<int>().to_type<float>()`

With these overloads, we can get away with `some_rect.to_type<int>()`.
2022-12-08 12:46:03 +00:00
Poseydon42
d2334957ba Tests: Add tests for Checked<> decrement operator 2022-12-08 07:20:14 -05:00
Lucas CHOLLET
1ac0aaa555 CrashReporter: Disable save button until it is ready to use 2022-12-08 07:12:01 -05:00
Filiph Sandström
01cdd3f181 WindowServer+MouseSettings: Improve buttons_switched naming
Before this commit it was a bit ambiguous which buttons the function
name were referring to; this instead now makes it clear that it's
related to mouse input. Additionally, this also fixes incorrect getter
naming leftover from yesteryear.
2022-12-08 07:04:09 -05:00
Filiph Sandström
83380ebebc Kernel/aarch64: Initialize components that are already working
`SysFSComponentRegistry`, `ProcFSComponentRegistry` and
`attach_null_device` "just work" already; let's include them to match
x86_64 as closely as possible.
2022-12-08 09:20:27 +00:00
Andreas Kling
d6a3be1615 LibPDF: Add missing character quirk for WinAnsiEncoding fonts
Fonts with the encoding name "WinAnsiEncoding" should render missing
characters above character code 040 (octal) as a "bullet" character.

This patch adds Encoding::should_map_to_bullet(char_code) which is then
called by char_code_to_code_point() to check if the given char code
should be displayed as a bullet instead.

I didn't have a good way to test this, so I've only verified that it
works by manually overriding inputs to the function during the rendering
stage.

This takes care of a FIXME in the Annex D part of the PDF specification.
2022-12-08 09:54:20 +01:00
Xexxa
f4f5b045ca Base: Add more emoji
🫷 - U+1FAF7 LEFTWARDS PUSHING HAND
🫸 - U+1FAF8 RIGHTWARDS PUSHING HAND
⛷️ - U+26F7 SKIER
🫏 - U+1FACF DONKEY
🐔 - U+1F414 CHICKEN
🌹 - U+1F339 ROSE
🪻 - U+1FABB HYACINTH
🗺️ - U+1F5FA WORLD MAP
🚏 - U+1F68F BUS STOP
🛥️ - U+1F6E5 MOTOR BOAT
🎗️ - U+1F397 REMINDER RIBBON
🥅 - U+1F945 GOAL NET
🪇 - U+1FA87 MARACAS
✏️ - U+270F PENCIL
✒️ - U+2712 BLACK NIB
🗂️ - U+1F5C2 CARD INDEX DIVIDERS
⚒️ - U+2692 HAMMER AND PICK
🔩 - U+1F529 NUT AND BOLT
⚖️ - U+2696 BALANCE SCALE
🔗 - U+1F517 LINK
🛋️ - U+1F6CB COUCH AND LAMP
2022-12-07 23:47:27 +00:00
Xexxa
b63ce06604 Base: Adjust emoji
🖕 - U+1F595 MIDDLE FINGER
🖋️ - U+1F58B FOUNTAIN PEN
Remove left padding
✈️ - U+2708 AIRPLANE
Make plane motors symmetrical
2022-12-07 23:47:27 +00:00
Sam Atkins
81fe2ef178 FileManager: Silence the "not found" error when setting no wallpaper
If we're setting the path to "" then we can just set the wallpaper to
nullptr and carry on with our day. :^)
2022-12-07 17:12:45 +00:00
Aliaksandr Kalenik
f0ab127a41 LibWeb: Consider strut while calculating baseline for a line
Strut should be taken in account while computing baseline of
a line. Otherwise it results in wrong alignment in boxes that
has inline elements without any text.

This also fixes red box in Acid 2.
2022-12-07 17:50:13 +01:00
Timothy Flynn
d37d6b3479 LibJS: Protect CanonicalIndex against double-to-integer overflow
Explicitly disallow constructing a CanonicalIndex from a floating point
type without going through a factory method that will throw when the
provided index cannot fit in a u32.
2022-12-07 16:43:19 +00:00
Timothy Flynn
8f46cb83c7 LibJS: Put CanonicalIndex in the JS namespace 2022-12-07 16:43:19 +00:00
Timothy Flynn
8f1f794bbd LibJS: Change an error message used by %TypedArray%.prototype.with
ErrorType::InvalidIndex does not encapsulate the reasons why an index
may be invalid. For example:

    let array = new Uint8Array([1, 2, 3, 4, 5]);
    array.with(10, 0);

Will currently yield:

    [RangeError] Index must be a positive integer

Which is misleading because 10 *is* a positive integer.
2022-12-07 16:43:19 +00:00
Linus Groh
1dd8655514 LibJS: Replace standalone js_symbol() with Symbol::create() 2022-12-07 16:43:06 +00:00
Linus Groh
525f22d018 LibJS: Replace standalone js_string() with PrimitiveString::create()
Note that js_rope_string() has been folded into this, the old name was
misleading - it would not always create a rope string, only if both
sides are not empty strings. Use a three-argument create() overload
instead.
2022-12-07 16:43:06 +00:00
Linus Groh
5db38d7ba1 LibJS: Replace standalone js_bigint() with BigInt::create()
Three standalone Cell creation functions remain in the JS namespace:

- js_bigint()
- js_string()
- js_symbol()

All of them are leftovers from early iterations when LibJS still took
inspiration from JSC, which itself has jsString(). Nowadays, we pretty
much exclusively use static create() functions to construct types
allocated on the JS heap, and there's no reason to not do the same for
these.
Also change the return type from BigInt* to NonnullGCPtr<BigInt> while
we're here.

This is patch 1/3, replacement of js_string() and js_symbol() follow.
2022-12-07 16:43:06 +00:00
Thomas Queiroz
07f1aad3dd Kernel: Add missing VERIFY in MM::allocate_committed_physical_page 2022-12-07 16:31:16 +00:00
Thomas Queiroz
c681330450 Kernel: Don't panic if MemoryManager::find_free_physical_page fails 2022-12-07 16:31:16 +00:00
Thomas Queiroz
8e8ea99bf3 Kernel: Return nullptr instead of PANICking in KmallocSlabHeap
I dared to return nullptr :^)
2022-12-07 16:31:16 +00:00
Andreas Kling
4828f0b636 UserspaceEmulator: Implement MOV_RM16_seg 2022-12-07 13:18:48 +01:00
Andreas Kling
661a940ddd UserspaceEmulator: Implement MOV_seg_RM32 and MOV_seg_RM16
This allows hosted programs to write to segment registers. :^)
2022-12-07 13:18:48 +01:00
Andreas Kling
bd1f39ebaa UserspaceEmulator: Implement PUSH_{CS,DS,ES,FS,GS,SS}
You can now push the segment registers on the stack! :^)
2022-12-07 13:18:48 +01:00
Andreas Kling
b6472c250c UserspaceEmulator: Add SoftCPU getters for FS and GS 2022-12-07 13:18:48 +01:00
Andreas Kling
fba91a4307 UserspaceEmulator: Initialize the FS segment on startup
Set it to 0x23, matching the initial value in a native process.
2022-12-07 13:18:48 +01:00
Timothy Flynn
b159bdd4fd LibSQL+SQLServer+sql: Send and parse the correct number of changed rows
The sql REPL had the created/updated rows swapped by mistake. Also make
sure SQLServer fills in the correct value depending on the executed
command, and that the DELETE command indicates the rows it deleted.
2022-12-07 13:09:00 +01:00
Timothy Flynn
b9d8c25b0b LibSQL+SQLServer+SQLStudio+sql: Send result rows over IPC as SQL::Value
We've been sending the values converted to a string, but now that the
Value type is transferrable over IPC, send the values themselves. Any
client that wants the value as a string may do so easily, whereas this
will allow less trivial clients to avoid string parsing.
2022-12-07 13:09:00 +01:00
Timothy Flynn
27ce88864f SQLServer: Do not store statement execution results at the class level
If a statement is executed multiple times in quick succession, we may
overwrite the results of a previous execution. Instead of storing the
result, pass it around as it is sent to the client.
2022-12-07 13:09:00 +01:00
Timothy Flynn
f9d23e1d2f LibSQL+SQLServer+SQLStudio+sql: Propagate connection errors immediately
Currently, when clients connect to SQL server, we inform them of any
errors opening the database via an asynchronous IPC. But we already know
about these errors before returning from the connect() IPC, so this
roundabout propagation is a bit unnecessary. Now if we fail to open the
database, we will simply not send back a valid connection ID.

Disconnect has a similar story. Rather than disconnecting and invoking
an asynchronous IPC to inform the client of the disconnect, make the
disconnect() IPC synchronous (because all it does is remove the database
from the map of open databases). Further, the only user of this command
is the SQL REPL when it wants to connect to a different database, so it
makes sense to block it. This did require moving a bit of logic around
in the REPL to accommodate this change.
2022-12-07 13:09:00 +01:00
Timothy Flynn
aec75d749a LibSQL+SQLServer+SQLStudio+sql: Allocate per-statement-execution IDs
In order to execute a prepared statement multiple times, and track each
execution's results, clients will need to be provided an execution ID.
This will create a monotonically increasing ID each time a prepared
statement is executed for this purpose.
2022-12-07 13:09:00 +01:00
Timothy Flynn
e2f71d2808 LibSQL+SQLServer+SQLStudio+sql: Use proper types for SQL IPC and IDs
When storing IDs and sending values over IPC, this changes SQLServer to:

1. Stop using -1 as a nominal "bad" ID. Store the IDs as unsigned, and
   use Optional in the one place that the IPC needs to indicate an ID
   was not allocated.

2. Let LibIPC encode/decode enumerations (SQLErrorCode) on our behalf.

3. Use size_t for array sizes.
2022-12-07 13:09:00 +01:00
Timothy Flynn
3a915483b0 IPCCompiler: Mark size_t as a primitive type
This allows size_t to be used within an IPC message without being passed
by const-reference.
2022-12-07 13:09:00 +01:00
Timothy Flynn
8fcb8c30c6 SQLServer+SQLStudio+sql: Allow sending placeholder values to SQLServer 2022-12-07 13:09:00 +01:00
Timothy Flynn
b13527b8b2 SQLServer: Parse SQL a single time to actually "prepare" the statement
One of the benefits of prepared statements is that the SQL string is
parsed just once and re-used. This updates SQLStatement to do just that
and store the parsed result.
2022-12-07 13:09:00 +01:00
Timothy Flynn
83bb25611e LibSQL: Add an IPC encoder/decoder for SQL::Value
This will allow clients to send placeholder values for prepared
statements over IPC.
2022-12-07 13:09:00 +01:00
Timothy Flynn
b2b9ae27fd LibSQL: Parse and execute sequential placeholder values
This partially implements SQLite's bind-parameter expression to support
indicating placeholder values in a SQL statement. For example:

    INSERT INTO table VALUES (42, ?);

In the above statement, the '?' identifier is a placeholder. This will
allow clients to compile statements a single time while running those
statements any number of times with different placeholder values.

Further, this will help mitigate SQL injection attacks.
2022-12-07 13:09:00 +01:00
Timothy Flynn
53f8d62ea4 LibSQL: Partially implement the UPDATE command
This implements enough to update rows filtered by a WHERE clause.
2022-12-07 13:09:00 +01:00
MacDue
1574f2c3f6 Meta+Userland: Pass Gfx::FloatSize by value
Just two floats like Gfx::FloatPoint.
2022-12-07 11:48:27 +01:00
MacDue
27fae78335 Meta+Userland: Pass Gfx::IntSize by value
Just two ints like Gfx::IntPoint.
2022-12-07 11:48:27 +01:00
MacDue
e011eafd37 Meta+Userland: Pass Gfx::FloatPoint by value
Just a small 8-byte value like Gfx::IntPoint.
2022-12-07 11:48:27 +01:00
MacDue
7be0b27dd3 Meta+Userland: Pass Gfx::IntPoint by value
This is just two ints or 8 bytes or the size of the reference on
x86_64 or AArch64.
2022-12-07 11:48:27 +01:00
MacDue
bbc149ebb9 Meta+Userland: Pass Gfx::Color by value
Gfx::Color is always 4 bytes (it's just a wrapper over u32) it's less
work just to pass the color directly.

This also updates IPCCompiler to prevent from generating
Gfx::Color const &, which makes replacement easier.
2022-12-07 11:48:27 +01:00
Marcus Nilsson
f76c7f3788 LibGL: Generate GL_OUT_OF_MEMORY error in glBufferData when OOM 2022-12-07 11:46:37 +01:00
Linus Groh
54abfcf835 LibJS: Remove redundant AK_MAKE_NON{COPYABLE,MOVABLE} from Symbol class
These are already applied to the Cell base class.
2022-12-07 09:58:59 +00:00