Commit graph

56493 commits

Author SHA1 Message Date
Nico Weber
54c98a46d8 LibPDF: Correctly parse the d0 and d1 operators
They are the first operator in a type 3 charproc.
Operator.h already knew about them, but we didn't manage to parse
them, since they're the only two operators that contain a digit.
2023-11-17 19:47:53 +00:00
Nico Weber
5513f8bbe3 LibPDF: Move ScopedState from a function on Renderer into Renderer
No behavior change.
2023-11-17 19:47:53 +00:00
Nico Weber
126a0be595 LibPDF: Pass Renderer to SimpleFont::draw_glyph()
This makes it available in Type3Font::draw_glyph().

No behavior change.
2023-11-17 19:47:53 +00:00
Nico Weber
bcc6439b5f LibPDF: Pass Renderer to PDFFont::draw_string()
It's a bit unfortunate that fonts need to know about the renderer,
but type 3 fonts contain PDF drawing operators, so it's necessary.

On the bright side, it makes it possible to pass fewer parameters
around and compute things locally as needed.

(As we implement more fonts, we'll probably want to create some
functions to do these computations in a central place, eventually.)

No behavior change.
2023-11-17 19:47:53 +00:00
Nico Weber
e0c0864ddf LibPDF: Load a few values off a type 3 font dictionary 2023-11-17 19:47:53 +00:00
Nico Weber
9632d8ee49 LibPDF: Make SimpleFont font matrix configurable
Type 3 fonts can set it to a custom value.
2023-11-17 19:47:53 +00:00
Nico Weber
4cd1a2d319 LibPDF: Add some scaffolding for type 3 fonts 2023-11-17 19:47:53 +00:00
Nico Weber
7f999b1ff5 LibPDF: Sink m_base_font_name from PDFFont into subclasses
/BaseFont is a required key for type 0, type 1, and truetype
font dictionaries, but not for type 3 font dictionaries.

This is mechanical; type 0 fonts don't even use this yet
(but probably should).

PDFFont::initialize() is now empty and could be removed,
but maybe we'll put stuff there again later, so I'm leaving
it around for a bit longer.
2023-11-17 19:47:53 +00:00
Nico Weber
6c1da5db54 LibPDF: Make SimpleFont::draw_glyph() fallible 2023-11-17 19:47:53 +00:00
Nico Weber
843e9daa8c LibPDF: Remove unused PDFFont::type()
This got added in #15270, but its one use then got removed again
in #16150.

No behavior change.
2023-11-17 19:47:53 +00:00
Nico Weber
26fd29baf8 LibPDF: Give Type3 fonts a dedicated error message
They're described in "5.5.4 Type 3 Fonts" in the PDF 1.7 spec, so we
shouldn't `internal_error()` on them. They're just not implemented yet.
2023-11-17 19:47:53 +00:00
Aliaksandr Kalenik
6bed27cca9 LibWeb: Use border box rect in getBoundingClientRect()
With this change we scroll to correct position on Acid2 :)
2023-11-17 20:46:56 +01:00
Aliaksandr Kalenik
ef71f46da6 LibWeb: Flesh out "scroll a target into view" spec implementation
This change fixes regressed Acid2 test and now we at least can see
the face after clicking "Take The Acid2 Test" link.
2023-11-17 20:46:56 +01:00
Timothy Flynn
08572d45b8 Documentation: Change macOS Ladybird command to launch in the foreground
Also add flags to direct stdout/stderr to the terminal, and show how to
pass arguments to the browser.
2023-11-17 19:14:53 +01:00
Timothy Flynn
72e5b10b30 Ladybird/AppKit: Remove explicit application activation
We call [NSApp activateIgnoringOtherApps:YES] to ensure the application
is brought into view and focused when launched from a terminal. But in
a macOS environment, we're better off using the `open` command to launch
the application (in which case, it does take foreground focus).
2023-11-17 19:14:53 +01:00
Nico Weber
5eaa403ddf LibPDF: Use font dictionary object as cache key, not resource name
In the main page contents, /T0 might refer to a different font than
it might refer to in an XObject. So don't use the `Tf` argument as
font cache key. Instead, use the address of the font dictionary object.

Fixes false cache sharing, and also allows us to share cache entries
if the same font dict is referred to by two different names.

Fixes a regression from 2340e834cd (but keeps the speed-up intact).
2023-11-17 19:14:39 +01:00
Nico Weber
443b3eac77 LibPDF: Let decode_png_prediction() call LibGfx's unfilter_scanline()
It's less code, but it also fixes a bug: The implementation in
Filter.cpp used to use the previous byte as reference value, while
we're supposed to use the value of the previous channel as reference
(at least when a pixel is larger than one byte).
2023-11-17 19:09:50 +01:00
Nico Weber
145ade3a86 LibPDF: Remove a needless AK:: qualification
No behavior change.
2023-11-17 19:09:50 +01:00
Nico Weber
000d9da73c LibGfx: Allow passing FilterType::None to unfilter_scanline()
Makes calling this in LibPDF less awkward, and there's no reason
not to allow this.
2023-11-17 19:09:50 +01:00
Nico Weber
574357ef00 LibGfx: Use ceil_div() in png decoder
No behavior change, arguably easier to read.
2023-11-17 19:09:50 +01:00
Nico Weber
5a70813d11 LibGfx: Make unfilter_scanline() a static PNGImageDecoderPlugin method
That way, LibPDF will be able to call it.

No behavior change.
2023-11-17 19:09:50 +01:00
Nico Weber
0416a07d56 LibPDF: Make filter byte not part of row in decode_png_prediction()
No behavior change.
2023-11-17 19:09:50 +01:00
Nico Weber
b763960fc2 LibPDF: Convert decode_png_prediction to use spans
No behavior change.
2023-11-17 19:09:50 +01:00
Nico Weber
588d6fab22 LibGfx+LibPDF: Create filter_type() for converting u8 to FilterType
...and use it in LibPDF.

No behavior change.
2023-11-17 19:09:50 +01:00
Nico Weber
7e4fe8e610 LibPDF: Use PNG::paeth_predictor() in png decoding path
No behavior change.

Ideally, the PDF code would just call a function PNGLoader to do the
PNG unfiltering, but let's first try to make the implementations look
more similar.
2023-11-17 19:09:50 +01:00
Nico Weber
6b2c60404d LibGfx: Use PNG::paeth_predictor() in png decoding path
Increases code reuse between encoder and decoder a tiny bit.
No behavior change.

(We should use the vectorized version in the future! But first,
we should learn to do the prediction in-place.)
2023-11-17 19:09:50 +01:00
Timothy Flynn
2763fb45f7 LibTimeZone: Handle systems with varying zoneinfo file locations
On my mac, the zoneinfo location is /usr/share/zoneinfo.default. This
breaks our implementation for finding the system time zone, which was
assuming the zoneinfo location contains "/zoneinfo/". This patch makes
the implementation a bit more lenient.

This didn't break tests on CI because we fallback to UTC, which is the
time zone CI machines are in anyways.
2023-11-17 19:07:53 +01:00
Simon Wanner
6c8ab1ca0d LibJS/JIT: Add a builtin for Math.abs 2023-11-17 19:06:25 +01:00
Simon Wanner
86b85aa68b LibJS: Introduce Builtins
Builtins are functions that can be detected during bytecode generation
and enable fast-paths in the JIT.
2023-11-17 19:06:25 +01:00
Liav A
b9141d85d8 WindowServer: Introduce the window roll-up feature
The roll-up feature allows the user to set the window content to be
hidden, while retaining the window title bar visibility.
While in roll-up mode, the window height size is not changeable.
However, tiling the window or maximizing (as well as unmaximize) it will
instruct exiting the roll-up mode.
2023-11-17 17:31:51 +00:00
sSt3lla
6b72fc0924 Calculator: Convert DeprecatedString to String 2023-11-17 17:17:00 +00:00
Idan Horowitz
9677d8eeac LibWeb: Reject improperly encoded XML documents as not well-formed 2023-11-17 16:02:36 +01:00
Idan Horowitz
278e8afb42 LibWeb: Consider content-type charset when determining XML encoding 2023-11-17 16:02:36 +01:00
Idan Horowitz
07ea3ab306 LibWeb: Display error page when document parsing fails 2023-11-17 16:02:36 +01:00
Idan Horowitz
079c96376c LibTextCodec: Support validating encoded inputs 2023-11-17 16:02:36 +01:00
Ali Mohammad Pur
ad4470bc39 Shell: Escape program-provided completions unless they're marked as code
This makes it so program-provided completions don't have to worry about
escaping, making the Shell the only authority on escaping.
2023-11-17 11:02:02 +03:30
Dan Klishch
2dba79bc6b Meta: Globally disable floating point contraction
FP contraction is a standard-conforming behavior which allows the
compiler to calculate intermediate results of expressions containing
floating point numbers with a greater precision than the expression type
allows. And in theory, it enables additional optimizations, such as
replacing `a * b + c` with fma(a, b, c).

Unfortunately, it is extremely hard to predict when the contraction will
happen. For example, Clang 17 on x86_64 with the default options will
use FMA only for constant-folded non-constexpr expressions. So, in
practice, FP contraction leads to hard-to-find bugs and inconsistencies
between executables compiled with different toolchains or for different
OSes. And we had two instances of this happening last week.

Since we did not ever used -mfma on x86_64, this patch can only possibly
regress performance on Apple ARM devices, where FMA is enabled by
default. However, this regression will likely be negligible since the
difference would be one additional add instruction, which would be then
likely executed in parallel with something else.
2023-11-16 19:05:13 -05:00
Adam Harald Jørgensen
67bc7cecbb Base: Fix indentation in completion function for kill 2023-11-16 23:07:31 +03:30
Adam Harald Jørgensen
66955b82a7 Base: Add completion for cd that suggests only directories 2023-11-16 23:07:31 +03:30
Thomas Voss
785f95d0af head(1): Fix typo in flag name
The shorthand for the ‘--bytes’ flag is ‘-c’, not ‘-b’.
2023-11-16 19:54:04 +01:00
Aliaksandr Kalenik
f6a9f613c7 LibAccelGfx+LibWeb: Add basic support for linear gradients painting
Linear gradient painting is implemented in the following way:
1. The rectangle is divided into segments where each segment represents
   a simple linear gradient between an adjacent pair of stops.
2. Each quad is filled separately using a fragment shader that
   interpolates between two colors.

For now `angle` and `repeat_length` parameters are ignored.
2023-11-16 18:02:51 +01:00
Aliaksandr Kalenik
61a2e59d87 LibAccelGfx+WebContent: Add GPU painter support on macOS
With these changes it is now possible to create OpenGL context on macOS
and run GPU-painter. For now only QT client has a CLI param that turns
it on though.
2023-11-16 15:13:16 +01:00
Andreas Kling
ffe304e88b LibJS: Don't create arguments object due to o.arguments access
When deciding whether we need to create a full-blown `arguments` object,
we look at various things, starting as early as in the parser.

Until now, if the parser saw the identifier `arguments`, we'd decide
that it's enough of a clue that we should create the `arguments` object
since somebody is obviously accessing it.

However, that missed the case where someone is just accessing a property
named `arguments` on some object. In such cases (`o.arguments`), we now
hold off on creating an `arguments` object.

~11% speed-up on Octane/typescript.js :^)
2023-11-16 13:26:21 +01:00
Stephan Vedder
32352aa729 LibJS/JIT: Add a fast path for floating point comparisons 2023-11-16 11:43:44 +01:00
Aliaksandr Kalenik
4164af2ca4 LibWeb: Do not compensate padding for abspos boxes with static position
When a box does not have a top, left, bottom, or right, there is no
need to adjust the offset for positioning relative to the padding edge,
because the box remains in the normal flow.
2023-11-15 23:44:05 +01:00
Timothy Flynn
2c1bbf5a99 AK+LibIDL: Put IDL dbgln statement behind a debug flag
This is a bit spammy now that we are performing some overload resolution
at build time. The fallback to an interface has generally worked fine on
the types it warns about (BufferSource, Module, etc.) so let's not warn
about it for every build.
2023-11-15 23:42:53 +01:00
Timothy Flynn
e1092aed3c LibWeb: Don't reject worker scripts with a JavaScript MIME type
The condition for checking if a script has a JS MIME type is currently
flipped. Extract the check to a local to make it a bit easier to reason
about at quick glance.
2023-11-15 11:28:39 -05:00
Timothy Flynn
50406f541b Meta: Port recent changes to GN build
124c378472
2023-11-15 11:28:39 -05:00
Andrew Kaster
ea95256f83 LibWeb: Remove unused ResourceLoader::load(URL) overload
With the refactoring of Workers, nobody is calling this LoadRequest-less
overload. All new code should eventually be moved to fetch anyway.
2023-11-15 12:56:33 +01:00
Andrew Kaster
124c378472 LibWeb+WebWorker: Move worker execution into a new WebWorker process
We now create a WorkerAgent for the parent context, which is currently
only a Window. Note that Workers can have Workers per the spec.

The WorkerAgent spawns a WebWorker process to hold the actual
script execution of the Worker. This is modeled with the
DedicatedWorkerHost object in the WebWorker process.
A start_dedicated_worker IPC method in the WebWorker IPC creates the
WorkerHost object. Future different worker types may use different IPC
messages to create their WorkerHost instance.

This implementation cannot yet postMessage between the parent and the
child processes.

Co-Authored-By: Andreas Kling <kling@serenityos.org>
2023-11-15 12:56:33 +01:00