Commit graph

43944 commits

Author SHA1 Message Date
Andrew Kaster
77a22268c6 Documentation: Describe extra clang tools built alongside BuildClang.sh
Also rephrase some of the information on updated clang-format binaries
2022-12-10 03:00:24 -07:00
Rodrigo Tobar
67b50d7994 PDFViewer: Let users change image rendering
A new checkbox in the toolbar now allows users toggle image rendering. A
corresponding Config option makes this setting non-volatile. To void
clashing with the previous "show_clipping_paths" option when caching a
Page, we now use the RenderingPreferences.hash() and the pair_int_hash
funcitons to compute a unique key into the page cache map for a given
RenderingPreferences and zoom level.
2022-12-10 10:49:03 +01:00
Rodrigo Tobar
adc45635e9 LibPDF: Add initial image display support
After adding support for XObject Form rendering, the next was to display
XObject images. This commit adds this initial support,

Images come in many shapes and forms: encodings: color spaces, bits per
component, width, height, etc. This initial support is constrained to
the color spaces we currently support, to images that use 8 bits per
component, to images that do *not* use the JPXDecode filter, and that
are not Masks. There are surely other constraints that aren't considered
in this initial support, so expect breakage here and there.

In addition to supporting images, we also support applying an alpha mask
(SMask) on them. Additionally, a new rendering preference allows to skip
image loading and rendering altogether, instead showing an empty
rectangle as a placeholder (useful for when actual images are not
supported). Since RenderingPreferences is becoming a bit more complex,
we add a hash option that will allow us to keep track of different
preferences (e.g., in a HashMap).
2022-12-10 10:49:03 +01:00
Rodrigo Tobar
2331fe5e68 LibPDF: Add first interpolation methods
Interpolation is needed in more than one place, and I couldn't find a
central place where I could borrow a readily available interpolation
routine, so I've implemented the first simple interpolation object. More
will follow for more complex scenarios.
2022-12-10 10:49:03 +01:00
Rodrigo Tobar
e818c955b3 LibGfx: Allow creating Bitmaps from ReadonlyBytes objects
The existing try_create_from_serialized_byte_buffer function accepts a
ByteBuffer, but in reality it requires only a ReadonlyBytes, since
internally the only thing it does is calling buffer.bytes(). There is
thus no reason to have a function that simply accepts ReadonlyBytes, and
implement the former in terms of the newer.
2022-12-10 10:49:03 +01:00
Rodrigo Tobar
17676705a5 LibPDF: Add facility to obtain Vector<float> from ArrayObject
Arrays of float numbers are common in many PDF objects, and thus to
avoid code repetition I'm introducing a new method to ArrayObject that
will return exactly that.
2022-12-10 10:49:03 +01:00
Rodrigo Tobar
a63b93f724 LibPDF: Add new Error::Type for unsupported rendering features 2022-12-10 10:49:03 +01:00
Rodrigo Tobar
26f8c0b76c LibPDF: Add more knowledge to ColorSpaces classes
ColorSpaces now can tell users how many components they expect, and the
default decode array that should be used when converting unit bit
sequences into color space component input values during image
rendering.
2022-12-10 10:49:03 +01:00
Rodrigo Tobar
ba16310739 LibPDF: Refactor parsing of ColorSpaces
ColorSpaces can be specified in two ways: with a stream as operands of
the color space operations (CS/cs), or as a separate PDF object, which
is then referred to by other means (e.g., from Image XObjects and other
entities). These two modes of addressing a ColorSpace are slightly
different and need to be addressed separately. However, the current
implementation embedded the full logic of the first case in the routine
that created ColorSpace objects.

This commit refactors the creation of ColorSpace to support both cases.
First, a new ColorSpaceFamily class encapsulates the static aspects of a
family, like its name or whether color space construction never requires
parameters. Then we define the supported ColorSpaceFamily objects.

On top of this also sit a breakage on how ColorSpaces are created. Two
methods are now offered: one only providing construction of no-argument
color spaces (and thus taking a simple name), and another taking an
ArrayObject, hence used to create ColorSpaces requiring arguments.

Finally, on top of *that* two ways to get a color space in the Renderer
are made available: the first creates a ColorSpace with a name and a
Resources dictionary, and another takes an Object. These model the two
addressing modes described above.
2022-12-10 10:49:03 +01:00
Rodrigo Tobar
287bb0feac LibPDF: Return results directly and avoid unpacking+packing 2022-12-10 10:49:03 +01:00
Liav A
aa9fab9c3a Kernel/FileSystem: Convert the mount table from Vector to IntrusiveList
The fact that we used a Vector meant that even if creating a Mount
object succeeded, we were still at a risk that appending to the actual
mounts Vector could fail due to OOM condition. To guard against this,
the mount table is now an IntrusiveList, which always means that when
allocation of a Mount object succeeded, then inserting that object to
the list will succeed, which allows us to fail early in case of OOM
condition.
2022-12-09 23:29:33 -07:00
Liav A
905becc991 Base: Add a note about Jails open access in the Mitigations(7) document 2022-12-09 23:09:00 -07:00
Liav A
d4b65f644e Kernel: Allow opening some device nodes sparingly for jailed processes
From now on, we don't allow jailed processes to open all device nodes in
/dev, but only allow jailed processes to open /dev/full, /dev/zero,
/dev/null, and various TTY and PTY devices (and not including virtual
consoles) so we basically restrict applications to what they can do when
they are in jail.
The motivation for this type of restriction is to ensure that even if a
remote code execution occurred, the damage that can be done is very
small.
We also don't restrict reading and writing on device nodes that were
already opened, because that limit seems not useful, especially in the
case where we do want to provide an OpenFileDescription to such device
but nothing further than that.
2022-12-09 23:09:00 -07:00
Liav A
968e1a6efc Documentation: Add a note on paths in the kernel development guidelines
Add a note on hardcoded paths so everyone know that this is not an
appropriate thing to do when writing kernel code.
2022-12-09 22:59:50 -07:00
Liav A
6a555af1f1 Kernel: Add callback on ".." directory entry for a TmpFS root directory 2022-12-09 22:59:08 -07:00
Linus Groh
5ee1758f46 LibJS: Use ToPropertyKey AO for computed member expression value
This ensures the value goes through the regular ToPrimitive mechanism,
which PropertyKey::from_value() bypasses. This is relevant for objects
with a @@toPrimitive method, for example.
Also enables one skipped test in delete-basic.js, which now passes.
2022-12-10 01:08:34 +00:00
Rafał Babiarz
227d860d6b LibWeb: Implement Selection.collapse_to_end 2022-12-10 01:45:21 +01:00
Rafał Babiarz
bb5da1b4e2 LibWeb: Implement Selection.collapse_to_start 2022-12-10 01:45:21 +01:00
Rafał Babiarz
6d46ebfe8a LibWeb: Implement Selection.collapse 2022-12-10 01:45:21 +01:00
Linus Groh
4cdfe684b8 LibJS: Remove redundant starts_with()s from is_less_than() string branch
This is not in the spec and does pointless work:
- If either of them is true, we would determine the same result with the
  manual code point iteration and comparison
- If neither of them is true, we iterate from the start again and repeat
  the work that was just done

Instead, only have the manual loop from the spec and do a length
comparison at the end.

Removing it brings the following microbenchmark from ~5.5s down to ~3.5s
on my machine:

```js
const a = "x".repeat(100_000_000) + "a";
const b = "x".repeat(100_000_000) + "b";
a < b
```
2022-12-10 00:40:52 +00:00
Luke Wilde
2b55ccf6e5 LibWeb: Actually hit-test child stacking contents with z-index of 0
Discord modals/pop-outs are in a "layerContainer" <div> with
`z-index: 1002`, which then has an immediate child <div> called
"positionLayer" with `z-index: 0`. We only ever hit test child stacking
contexts with z-index set to anything but 0 (step 7 and step 1 of the
hit test), but not for exactly 0 (step 6). This made it impossible to
hit any element inside positionLayer, making pop-ups such as the emojis
and GIFs unusable.
2022-12-10 00:21:10 +00:00
Luke Wilde
919aa45017 LibWeb: Implement Selection.setBaseAndExtent 2022-12-10 00:21:10 +00:00
Luke Wilde
b47aceb480 LibWeb: Add Document.getSelection 2022-12-10 00:21:10 +00:00
Luke Wilde
565dc0f296 LibWeb: Add namespace qualifier to type names equal to a C++ namespace
For example, Document.getSelection returns Selection, which is in the
Selection namespace.

Namespaces.h has Linus' copyright since he changed the "is_one_of" list
to an Array.
2022-12-10 00:21:10 +00:00
Luke Wilde
34c130b336 LibWeb: Stub Range.getBoundingClientRect
This seems to be used by Discord around the chat message box, but
didn't explore very far.
2022-12-10 00:21:10 +00:00
Luke Wilde
1e9cc2e211 LibWeb: Stub HTMLMediaElement.pause
Required for rendering GIFs on Discord.
2022-12-10 00:21:10 +00:00
Luke Wilde
2c77364716 LibWeb: Add spec link to HTMLMediaElement::load 2022-12-10 00:21:10 +00:00
Luke Wilde
4db2efaecb LibJS/Bytecode: Implement yield* 2022-12-10 00:21:10 +00:00
Luke Wilde
758a4cb1a6 LibJS/Bytecode: Implement var/lexical binding destructuring in for/of 2022-12-10 00:21:10 +00:00
Sam Atkins
64cfe2b163 SpaceAnalyzer: Display the current location in the window title :^) 2022-12-09 23:23:00 +00:00
Sam Atkins
d8ceaf7870 SpaceAnalyzer: Add a tooltip for the hovered tree node
Many of the nodes are visually too small to show their full name and
file size, so this makes that information visible.
2022-12-09 23:23:00 +00:00
Sam Atkins
6d64e650f1 SpaceAnalyzer: Remove declaration for unimplemented method 2022-12-09 23:23:00 +00:00
Timothy Flynn
5ece0a13c4 SQLServer: Add a hook to inform owners of disconnected SQL clients 2022-12-09 20:33:19 +00:00
Andreas Kling
fbf9cb3387 WebContent+LibWeb+LibJS: Simplify injection of JS console globals
Instead of creating a new global object and proxying everything through
it, we now evaluate console inputs inside a `with` environment.

This seems to match the behavior of WebKit and Gecko in my basic
testing, and removes the ConsoleGlobalObject which has been a source of
confusion and invalid downcasts.

The globals now live in a class called ConsoleGlobalObjectExtensions
(renamed from ConsoleGlobalObject since it's no longer a global object).

To make this possible, I had to add a way to override the initial
lexical environment when calling JS::Interpreter::run(). This is plumbed
via Web::HTML::ClassicScript::run().
2022-12-09 18:51:03 +00:00
Xexxa
23b07b3408 Base: Add emoji flags for French subdivisions
🏴󠁦󠁲󠁢󠁲󠁥󠁿 -
U+1F3F4 U+E0066 U+E0072 U+E0062 U+E0072 U+E0065 U+E007F FR-BRE
Bretagne
🏴󠁦󠁲󠁯󠁣󠁣󠁿 -
U+1F3F4 U+E0066 U+E0072 U+E006F U+E0063 U+E0063 U+E007F FR-OCC
Occitanie
🏴󠁦󠁲󠁮󠁡󠁱󠁿 -
U+1F3F4 U+E0066 U+E0072 U+E006E U+E0061 U+E0071 U+E007F FR-NAQ
Nouvelle-Aquitaine
🏴󠁦󠁲󠁰󠁡󠁣󠁿 -
U+1F3F4 U+E0066 U+E0072 U+E0070 U+E0061 U+E0063 U+E007F FR-PAC
Provence-Alpes-Côte-d’Azur
🏴󠁦󠁲󠁮󠁯󠁲󠁿 -
U+1F3F4 U+E0066 U+E0072 U+E006E U+E006F U+E0072 U+E007F FR-NOR
Normandie
🏴󠁦󠁲󠁰󠁤󠁬󠁿 -
U+1F3F4 U+E0066 U+E0072 U+E0070 U+E0064 U+E006C U+E007F FR-PDL
Pays-de-la-Loire
🏴󠁦󠁲󠁣󠁯󠁲󠁿 -
U+1F3F4 U+E0066 U+E0072 U+E0063 U+E006F U+E0072 U+E007F FR-COR
Corse
🏴󠁦󠁲󠁡󠁲󠁡󠁿 -
U+1F3F4 U+E0066 U+E0072 U+E0061 U+E0072 U+E0061 U+E007F FR-ARA
Auvergne-Rhône-Alpes
🏴󠁦󠁲󠁣󠁶󠁬󠁿 -
U+1F3F4 U+E0066 U+E0072 U+E0063 U+E0076 U+E006C U+E007F FR-CVL
Centre-Val de Loire
🏴󠁦󠁲󠁢󠁦󠁣󠁿 -
U+1F3F4 U+E0066 U+E0072 U+E0062 U+E0066 U+E0063 U+E007F FR-BFC
Bourgogne-Franche-Comté
2022-12-09 18:50:52 +00:00
Arda Cinar
d46315bcc0 SpaceAnalyzer: Propagate possible errors up
These include a JSON parse error, file open errors, and vector appends.
These fix a bunch of calls to functions with `fixme` in them.
2022-12-09 16:14:32 +00:00
Arda Cinar
f0b61e1443 SpaceAnalyzer: Use raw_delta_y in TreeMapWidget::mousewheel_event
There was a FIXME about using raw delta y value of the mousewheel event
in TreeMapWidget::mousewheel_event. Some time after that code was
written, a raw delta x/y API was added to GUI::MouseEvent. This patch
simply uses that API and removes the FIXME message there.
2022-12-09 16:14:32 +00:00
Undefine
e0a904c852 LibWeb: Display DragonFly in the user agent string
Previously when build for DragonFly BSD we would error out with
unknown os error. Now we just define OS_STRING as DragonFly.
2022-12-09 12:08:05 +00:00
Aliaksandr Kalenik
2e1113cb88 LibWeb: Fix child wrapping in table fix up
- Wrapped sequence should be inserted before first non-match
node instead of next sibling of first non-match node
- If sequence is not empty after sibling traversal it should be
wrapped
2022-12-09 12:53:05 +01:00
Aliaksandr Kalenik
1a81521dd9 LibWeb: Consider specified cell widths in a table
This change makes outer min-content width and outer max-content
width for cells to be calculated in the way specifed in the spec:
- The outer min-content width of a table-cell is max(min-width,
min-content width) adjusted by the cell intrinsic offsets.
- The outer max-content width of a table-cell in a non-constrained
column is max(min-width, width, min-content width, min(max-width,
max-content width)) adjusted by the cell intrinsic offsets.
- The outer max-content width of a table-cell in a constrained
column is max(min-width, width, min-content width, min(max-width,
width)) adjusted by the cell intrinsic offsets.
2022-12-09 12:53:05 +01:00
Aliaksandr Kalenik
1da26f7395 LibWeb: Fix typo in TableFormattingContext.h 2022-12-09 12:53:05 +01:00
Aliaksandr Kalenik
c302c4081b LibWeb: Layout table rows that do not belong to table row group 2022-12-09 12:53:05 +01:00
Moustafa Raafat
b8f1e1bed2 Everywhere: Remove unnecessary AK and Detail namespace scoping 2022-12-09 11:25:30 +00:00
Moustafa Raafat
ae2abcebbb Everywhere: Use C++ concepts instead of requires clauses 2022-12-09 11:25:30 +00:00
Andreas Kling
9721da2e6a LibJS: Call shrink_to_fit() on various Vectors created during parse
Vectors that stick around in the AST were wasting a fair bit of memory
due to the growth padding we keep by default. This patch goes after some
of these vectors with the shrink_to_fit() stick to reduce waste.

Since the AST can stay around for a long time, it is worth making an
effort to shrink it down when we have a chance.
2022-12-08 23:36:17 +00:00
Andreas Kling
2e98c17347 LibJS: Shrink DeclarativeEnvironment bindings vector to fit
After setting up all the bindings in function_declaration_instantiation,
we now ask DeclarativeEnvironment to do a shrink_to_fit() on its vector
of bindings.

This ends up saving 5.6 MiB on twitter.com/awesomekling :^)
2022-12-08 23:36:17 +00:00
Andreas Kling
d77ce7bae9 AK: Add Vector::shrink_to_fit()
If there's more capacity than size, the vector is reallocated to have
capacity == size.
2022-12-08 23:36:17 +00:00
Andreas Kling
35ed82d5e6 LibJS: Shrink FunctionNode by using bitfields
By making the boolean members be bitfields, we shrink FunctionNode by a
total of 8 bytes.
2022-12-08 23:36:17 +00:00
Andreas Kling
0b2f86de71 LibJS: Make FunctionKind enum class a u8 2022-12-08 23:36:17 +00:00
Andreas Kling
dd1720f2cb LibJS: Shrink ObjectProperty AST nodes by rearranging members
By putting smaller members in the padding hole after the ASTNode base
class, we shrink ObjectProperty by 8 bytes.
2022-12-08 23:36:17 +00:00