Commit graph

29021 commits

Author SHA1 Message Date
Aliaksandr Kalenik
2def1de4be LibWeb: Rerun rows sizings if grid auto height is less than min-height
If the first pass of rows sizing results in the container's automatic
height being less than the specified min-height, we need to run a
second pass using the updated available space.
2023-10-21 09:08:11 +02:00
Nico Weber
9442782881 LibPDF: Implement text_next_line_show_string_set_spacing
Not used terribly often, but e.g. used in 000333.pdf page 17 in
stillhq.com-pdfdb.
2023-10-20 14:24:31 -04:00
Nico Weber
78dea9500f LibPDF: Make operator parsing use ReadonlySpan instead of Vector
No behavior change.
2023-10-20 14:24:31 -04:00
Nico Weber
e0268dcc87 LibPDF: Allow /Pattern to be used directly as a color space name
Per spec:

"If the color space is one that can be specified by a name and no
additional parameters (DeviceGray, DeviceRGB, DeviceCMYK, and certain
cases of Pattern), the name may be specified directly."

We still don't implement /Pattern color spaces, but now we no longer
crash trying to look up the potentially-nonexistent /ColorSpace
dictionary on the page object when /Pattern is used directly as color
space name.

On top of #21514, reduces number of crashes on 300 random PDFs from the
web (the first 300 from 0000.zip from
https://pdfa.org/new-large-scale-pdf-corpus-now-publicly-available/)
from 42 (14%) to 34 (11%).
2023-10-20 10:35:54 -06:00
Nico Weber
aea0e2f313 LibPDF: Rename ColorSpaceFamily function to may_be_specified_directly()
It used to be called ColorSpaceFamily::never_needs_parameters().

But in the cpp file, the macro arg was called ever_needs_parameters,
and the spec says

"If the color space is one that can be specified by a name and no
additional parameters (DeviceGray, DeviceRGB, DeviceCMYK, and certain
cases of Pattern), the name may be specified directly."

so let's use that language here.

No behavior change.
2023-10-20 10:35:54 -06:00
Nico Weber
095a2a17ed LibPDF: Replace TODO()s in Type0Font code with Errors
...which causes us to not render these fonts instead of crashing.

Reduces number of crashes on 300 random PDFs from the web (the first 300
from 0000.zip from
https://pdfa.org/new-large-scale-pdf-corpus-now-publicly-available/)
from 64 (21%) to 42 (14%).
2023-10-20 10:33:59 -06:00
Nico Weber
33443f7991 LibPDF: Implement ICCBasedColorSpace::number_of_components()
We now no longer crash on images that use an ICC-based color space.
Reduces number of crashes on 300 random PDFs from the web (the first 300
from 0000.zip from
https://pdfa.org/new-large-scale-pdf-corpus-now-publicly-available/)
from 81 (27%) to 64 (21%).

Also fixes all remaining crashes in
411_getting_started_with_instruments.pdf and
513_high_efficiency_image_file_format.pdf.
2023-10-20 08:58:52 +02:00
Nico Weber
f5d3f47af3 LibPDF: Add spec comment about color spaces on images 2023-10-20 08:58:52 +02:00
Nico Weber
7c24a89acf LibPDF: Add spec comment about valid bits_per_component values 2023-10-20 08:58:52 +02:00
Nico Weber
64bb9aa8c7 LibPDF: Fix comment typo 2023-10-20 08:58:52 +02:00
Nico Weber
ea6fed627a LibPDF: Get color rendering intent from image dict
Still not used for anything, so no behavior change.
2023-10-20 08:58:52 +02:00
Bastiaan van der Plaat
b640747116 LibWeb: Add canvas context2d roundRect 2023-10-20 07:20:29 +02:00
Bastiaan van der Plaat
9997d8f178 LibWeb: Add spec comments to canvas context2d rect 2023-10-20 07:20:29 +02:00
Timothy Flynn
192aa0838a Browser: Use LibWebView to decide what parts of a URL to highlight 2023-10-20 07:18:54 +02:00
Timothy Flynn
55092dd164 LibGUI+Browser: Move GUI::UrlBox to the Browser application
Browser is the only user of this component. Move it to allow making use
of LibWebView for URL highlighting.
2023-10-20 07:18:54 +02:00
Timothy Flynn
0715ba889e LibWebView: Add method to break a URL into parts for eTLD+1 highlighting
This is meant to serve as the method all Ladybird chromes can use to
highlight the eTLD+1 substring of the URL. It uses the Public Suffix
List to break the URL into 3 parts: the scheme and subdomain, the
eTLD+1, and all remaining parts (port, path, query, etc.).
2023-10-20 07:18:54 +02:00
Tim Ledbetter
023309fdc4 LibGfx/JPEGLoader: Check array access bounds when building lookup table 2023-10-20 07:17:27 +02:00
Aliaksandr Kalenik
2f5ff14984 LibWeb: Fix spec implementation mistakes in destroy_the_child_navigable
Fixes two places in child navigable destroy procedure where we used
content navigable instead of container's navigable.

With this change, iframe's nested histories are actually destroyed
along with the document that created them.
2023-10-19 16:54:17 -04:00
Nico Weber
ebba24b848 LibPDF: Fix lookup of built-in Bold Italic strings
Liberation*-BoldItalic.ttf apparently self-identifies as "Bold Italic",
not "BoldItalic".
2023-10-19 16:52:49 -04:00
Nico Weber
708d5e2fe6 LibPDF: Implement color_rendering_intent operator
Implements the `ri` operator, and the `RI` key in a graphics state
dictionary.

We don't do anything yet with the color rendering intent except
store it.

No behavior change except removing a few "not yet implemented"
messages.
2023-10-19 16:51:16 -04:00
Nico Weber
609e640530 LibPDF: Try harder to use a RAII object to restore state
Follow-up to #21489. There, I made us use a RAII object.

That's great, but if the embedded instruction stream pushes
its own graphics state, then an early return would cause us to
not process graphics state pop instructions in the embedded stream.

To fix this, remember the graphics stack depth before entering
the nested instruction stream, and explicitly shrink the stack back
to that size upon exit.

Enables us to render all pages of
https://devstreaming-cdn.apple.com/videos/wwdc/2017/821kjtggolzxsv/821/821_get_started_with_display_p3.pdf
without crashing.
2023-10-19 16:49:00 -04:00
Tim Ledbetter
c5a4c22fa7 du: Add -x option to not traverse directories across filesystems 2023-10-19 14:41:09 +02:00
Tim Ledbetter
cc5c7d2a29 du: Remove unnecessary is_inside_dir function argument
This value can be computed using the `current_depth` parameter.
2023-10-19 14:41:09 +02:00
circl
a9208a18ca LibGfx/BMPLoader: Make sure height passed to Gfx::Bitmap is positive
BMP files encode the direction of the rows with the sign of the height.
Our BMP decoder already makes all the proper checks, however when
constructing the Gfx::Bitmap, didn't actually make the height positive.

Boog neutralized :^)
2023-10-19 08:31:36 +02:00
Aliaksandr Kalenik
99217bf6db LibWeb/Painting: Do not paint box outer shadows not visible in viewport
This change separates the box outer shadow metrics calculations into a
separate function. This function is then used to obtain the shadow
bounding rectangle and skip painting if the entire shadow is outside
of the viewport.
2023-10-19 08:29:06 +02:00
Aliaksandr Kalenik
596bc76b7a LibWeb: Remove unnecessary semicolons in RecordingPainter.cpp
Ooops, somehow I messed up formatting in this file.
2023-10-19 08:29:06 +02:00
Aliaksandr Kalenik
3fb2b008a2 LibWeb/Painting: Do not paint paths not visible in viewport
Painting optimization to do less unnecessary work
2023-10-19 08:29:06 +02:00
Aliaksandr Kalenik
708574d373 LibWeb/Painting: Do not clip border radius when it is out of viewport
Painting optimization to do less unnecessary work.
2023-10-19 08:29:06 +02:00
Nico Weber
b835d2bd66 LibPDF: Use a RAII object to restore state in recursive render
Previously, if one operator returned an error, the TRY() would cause
us to return without restoring the outer graphics state, leading to
problems such as handing a 3-tuple to a grayscale color space
(because the inner object set up a grayscale color space that we
failed to dispose of).

Makes us crash later on page 43 of
https://devstreaming-cdn.apple.com/videos/wwdc/2017/821kjtggolzxsv/821/821_get_started_with_display_p3.pdf
2023-10-18 19:43:31 -04:00
Jelle Raaijmakers
c58193bafa LibJS: Support large number of decimals in Number.prototype.toFixed
The spec asks us to perform some calculations that quickly exceed an
`u64`, but instead of jumping through hoops we can rely on our AK
implementation of floating point formatting to come up with the
correctly rounded result.

Note that most other JS engines seem to diverge from the spec as well
and fall back to a generic dtoa path.
2023-10-18 19:39:30 -04:00
Timothy Flynn
f8763c16b2 LibJS: Disable Temporal custom time zone test
This test has been flaky for quite some time. Disable it for now, and
revisit once we've caught up with the Temporal spec.

See also: b7676cc436
2023-10-18 16:29:27 -04:00
Nico Weber
3c2d820391 LibPDF: If softmask has different size than target bitmap, resize it
Size of smask and image aren't guaranteed to be equal by the spec
(...except for /Matte, see page 555 of the PDF 1.7 spec, but we
don't implement that), and in pratice they sometimes aren't.

Fixes an assert on page 4 of
https://devstreaming-cdn.apple.com/videos/wwdc/2017/821kjtggolzxsv/821/821_get_started_with_display_p3.pdf
We now make it all the way to page 43 of 64 before crashing.
2023-10-18 20:03:35 +01:00
Nico Weber
a4dec92ed0 LibGfx: Add Bitmap::scaled_to_size() 2023-10-18 20:03:35 +01:00
Nico Weber
3907374621 LibPDF: Implement support for callgsubr in CFF font programs
Font programs are bytecode programs defining glyphs. If several glyphs
share a piece of outline, that opcode sequence can be put in a
subroutine ("subr") table and the definition of those glyphs can then
call that subroutine by number, to reduce file size.

CFF fonts can in theory contain multiple fonts, and so there's a global
subr table shared by all the fonts in one CFF, and a local per-fornt
subr table.  We used to only implement the local subr table, now we
implement both.

(We only support one font per CFF, and at least in PDF files, that's
all that's ever used. So a global subr table isn't very useful.
But the spec explicitly allows it -- "Global subroutines may be used in
a FontSet even if it only contains one font." -- and it happens in
practice.)
2023-10-18 10:50:32 -04:00
Nico Weber
185573c03f LibPDF: Implement subr_number biasing for CFF font programs 2023-10-18 10:50:32 -04:00
Nico Weber
4dc4de052a LibPDF: Implement opcode 28 for CFF font programs 2023-10-18 10:50:32 -04:00
Nico Weber
44efff81b9 LibPDF: Remove a dbgln() call in CFF subrs decoding
This code is a lot more reliable now than it used to be, and this
dbgln() is quite noisy for some files. So let's remove it.
2023-10-18 10:43:51 -04:00
Tim Ledbetter
c006ebe5a3 find: Add the -path and -ipath options
These options behave the same way as `-name` and `-iname` but match
the full file path instead of just the basename.
2023-10-18 06:36:34 -04:00
Nico Weber
02d2d12592 LibPDF: Allow moving Reader::move_to() to end of data stream
CFF::parse_index_data() calls move_to() to put the reader's
current position behind the index data.

In several PDFs, the PrivDictOperator::Subrs case in CFF::create()
sets up a span that contains exactly the Subrs data and nothing
after it, so that finale move_to() call in parse_index_data()
would cause an assert.

This is similar to fe3612ebcb, where the caller was also in CFF.
So maybe CFF just has a different view of what valid values to pass
to Reader are, compared to the rest of the code? But having an iterator
point to one past the valid data in a container is common, so maybe
this is the Right Fix after all.

Fixes a crash opening 411_getting_started_with_instruments.pdf
(and a whole bunch of other WWDC slides). Rendering is pretty glitchy
and we still crash on page 14, but at least we can open the file now.

The file is currently available at:
https://devstreaming-cdn.apple.com/videos/wwdc/2019/411cbc60y12x68arcof/411/411_getting_started_with_instruments.pdf
2023-10-18 06:32:23 -04:00
Nico Weber
182639217f LibPDF: Implement GoTo action for outline
Outline items can contain either a /Dest key or an /A key.

The /Dest key points to a "Destination" (various ways to reference a
page in the same document).

The /A key points to an "Action" which can have several types.
One type, the /GoTo type, just also points to a Destination.

Implement GoTo actions. This makes clicking "Contents" in the outline of
https://developer.apple.com/library/archive/documentation/mac/pdf/Text.pdf
work. (Almost all other items in this file's outline use /Dest.
"Contents" could too, but it uses /A /GoTo for some reason.)

(Other action types are things like opening a hyperlink, opening a
different file, playing a sound, submitting a form, etc. Actions
are also used for in-page links, not just in outlines. Many of
these action types we'll likely never want to implement.)
2023-10-18 06:29:02 -04:00
Nico Weber
d9c9510d3c LibPDF: Rename x-macro argument name
I'd like to add a string called `A`, so the argument can't be called
`A` as well.

No behavior change.
2023-10-18 06:29:02 -04:00
Nico Weber
f646e47d46 LibPDF: Extract a create_destination_from_object() function
No big behavior change. The new function now produces an error
if a destination isn't in one of the supported formats.
2023-10-18 06:29:02 -04:00
Nico Weber
46fd6fdfa3 LibPDF: Read Global subr data in CFF reader
This was the last piece of data we didn't read yet.
(We also don't yet support multiple fonts per CFF, but I haven't
found a PDF using that yet.)

We still don't do anything with it, but now we at least print a
warning if this data is there and we ignore it.
2023-10-18 11:02:10 +02:00
Nico Weber
3be5719987 LibPDF: Rename subroutines to local_subroutines in CFF code 2023-10-18 11:02:10 +02:00
Nico Weber
9a0b559932 LibPDF: Tweak formatting of built-in CFF tables
This makes the code look more like the pages in the spec.

No behavior change, whitespace change only.
2023-10-18 11:00:17 +02:00
Nico Weber
f0e7fb7038 LibPDF: Make Subrs optional in PS1FontProgram
https://adobe-type-tools.github.io/font-tech-notes/pdfs/T1_SPEC.pdf :

"Using charstring subroutines is not a requirement of a Type 1
font program."

And some versions of Computer Modern do in fact not contain a Subrs
array.

Together with #21473, makes Problemset.pdf from the pdffiles repro
render ok instead of crashing.
2023-10-18 11:00:02 +02:00
Aliaksandr Kalenik
063e66cae9 LibWeb: Introduce RecordingPainter to serialize painting commands
This modification introduces a new layer to the painting process. The
stacking context traversal no longer immediately calls the
Gfx::Painter methods. Instead, it writes serialized painting commands
into newly introduced RecordingPainter. Created list of commands is
executed later to produce resulting bitmap.

Producing painting command list will make it easier to add new
optimizations:
- It's simpler to check if the painting result is not visible in the
  viewport at the command level rather than during stacking context
  traversal.
- Run painting in a separate thread. The painting thread can process
  serialized painting commands, while the main thread can work on the
  next paintable tree and safely invalidate the previous one.
- As we consider GPU-accelerated painting support, it would be easier
  to back each painting command rather than constructing an alternative
  for the entire Gfx::Painter API.
2023-10-18 10:58:42 +02:00
Aliaksandr Kalenik
8ebb4e8047 LibWeb: Forbid sharing image requests across documents
This change addresses the bug where images unable to load when the
reload button in the UI is clicked repeatedly. Before this fix, it was
possible to use SharedImageRequests across multiple documents. However,
when the document that initiated the request is gone, tasks scheduled
on the event loop remain in the fetching state because the originating
document is no longer active. Furthermore, another reason to prohibit
the sharing of image requests across documents is that the "Origin"
header in an image request is dependent on the document.
2023-10-18 10:58:01 +02:00
Aliaksandr Kalenik
c2eaa0eb1c LibGfx: Fix crash during rasterizing glyphs containing only one point
Fixes https://github.com/SerenityOS/serenity/issues/20179
2023-10-18 01:16:21 +02:00
Martin Janiczek
f568937133 LibTest: Remove the redefinition of VERIFY family of macros
Previously VERIFY et al. was redefined inside tests to not abort and
instead fail the test. This wouldn't apply to non-header code though,
and was not helpful, as it prevented you from easily attaching gdb near
the abort.

After this removal tests can still use the EXPECT family of macros, but
VERIFY will behave like it does in the rest of the codebase (abort
etc.).
2023-10-17 18:41:19 -04:00
Ali Mohammad Pur
f10dc9cb14 LibVT: Clear the href ID by setting it to None instead of "" 2023-10-17 11:02:48 -06:00
Ali Mohammad Pur
a8c7448ccb Shell: Implement the return POSIX builtin
This is also available in the regular shell mode, as it's a generally
useful builtin to have.
2023-10-17 11:02:48 -06:00
Ali Mohammad Pur
2d1c5dbfcb Shell: Allow word-expansion of ${var}, $N, $* and $-
Fixes #21463.
2023-10-17 11:02:48 -06:00
Andrew Kaster
639051d34e LibGfx: Inspect font paths using LexicalPath::has_extension()
This prevents us from trying to load a file named "fonts/.font"
2023-10-17 11:02:01 -06:00
Andrew Kaster
21d027129d LibGfx: Remove the ability to load fonts from a path directly 2023-10-17 11:02:01 -06:00
Andrew Kaster
1af3da39fd headless-browser: Load fonts via Core::Resource URIs 2023-10-17 11:02:01 -06:00
Andrew Kaster
74707d151b pdf: Load fonts in debug mode via Core::Resource URIs 2023-10-17 11:02:01 -06:00
Andrew Kaster
e03357308c LibGfx: Load fonts with new Resource API instead of filesystem paths
The old API is in place until we remove all the users.
2023-10-17 11:02:01 -06:00
Andrew Kaster
0d417cd604 LibCore: Add Resource for platform agnostic application resource loading
The first implementation is simply raw files.
2023-10-17 11:02:01 -06:00
Tim Ledbetter
f4a89c31c6 LibGfx/ILBM: Explicitly fail decoding if body chunk isn't present
Previously, the decoder would crash in this case.
2023-10-17 10:24:27 +02:00
Nico Weber
cb961101c7 LibPDF: Implement CFF built-in Standard and Expert encodings
With this, all tables from the spec appendixes are in CFF.cpp.

This fixes a crash reading page 2 (and onward) of
2ThestructureoftheCIE1997ColourAppearanceModelCIECAM97s.pdf in
the pdffiles repo.
2023-10-17 10:21:38 +02:00
Nico Weber
eeada4678c LibPDF: Postpone CFF encoding processing after Top DICT has been read
The encoding offset defaults to 0, i.e. the Standard Encoding.
That means reading the encoding only if the tag is present causes
us to not read it if a font uses the Standard Encoding.

Now, we always read an encoding, even if it's the (implicit) default
one.
2023-10-17 10:21:38 +02:00
Nico Weber
1cfe639b6c LibPDF: Implement CFF supplemental encoding
The main encoding data maps glyph ID ("GID") to its codepoint.
If a glyph has several codepoints, then a secondary table mapping
codepoint to string ID ("SID") of the glyph's name is present.

(A separate table associates each glyph with its name already.)

I haven't seen this used in the wild, but the structure of the
supplemental data is also going to be needed for built-in encodings.
2023-10-17 10:21:38 +02:00
Nico Weber
37daeae6fd LibPDF: Add spec comments, dbgln_if()s to CFF's parse_encoding() 2023-10-17 10:21:38 +02:00
Aliaksandr Kalenik
c41e742de4 LibWeb: Fix min-content width calculation in dimension_box_on_line()
If inline-block is sized under min-content width constraint we should
use its min-content width instead of max-content width like it was
before.
2023-10-16 21:44:48 +02:00
Ali Mohammad Pur
91bb3af505 Shell: Implement the '$*' special variable in the POSIX parser
Fixes #21421.
2023-10-16 19:11:37 +03:30
Ali Mohammad Pur
5cb994d4dd Shell: Minimally implement the 'set' builtin
This only implements the printing and argv setting behaviours.
2023-10-16 19:11:37 +03:30
Timothy Flynn
a8f0fa5dd4 LibWebView+LibPublicSuffix: Merge LibPublicSuffix into LibWebView
After d2c7e1ea7d, there is now only one
user of LibPublicSuffix - the URL sanitation utility within LibWebView.
Rather than having an entire library for the small Public Suffix data
accessor, merge it into LibWebView.
2023-10-16 09:06:02 -04:00
circl
a1cce69db0 LibWeb/HTMLInputElement: Improve appearance of color picker
Instead of a plain ButtonBox, it now appears as a color well styled
after the buttons.
2023-10-16 12:46:30 +01:00
circl
63cd6b0d3c LibWeb: Make Default.css clearer about the style of input elements
Previously, all input elements were given a textbox-like style by
default, this was then undone by another CSS rule in the case of certain
types of input element. This commit makes it so that the first rule
simply ignores those types instead.

Co-authored-by: Sam Atkins <atkinssj@serenityos.org>
2023-10-16 12:46:30 +01:00
circl
ce48ac3101 LibWeb/HTMLInputElement: Move text input shadow tree into a function 2023-10-16 12:46:30 +01:00
Liav A
81169ee6e6 DynamicLoader: Add an option to explicitly run an ELF executable binary
If the user runs /usr/lib/Loader.so and pass a second string to argv, we
will try to run it as if it was running that program without invoking
the dynamic loader explicitly.
2023-10-16 12:09:04 +02:00
Nico Weber
007d7cdd53 LibPDF: Fix sign (and fixed point) in glyph decoding opcode 24
Two bugs:

1. We decoded a u32, not an i32 as the spec wants
2. (minor) Our fixed-point divisor was off by one

Fixes text rendering in Bakke2010a.pdf in pdffiles, and rendering of
other fonts with negative width adjustments from optcode 255.
That PDF was produced by "Apple pstopdf" and uses font SFBX1200,
which is apparently a variant of Computer Modern. So maybe this
helps with lots of PDFs produced from TeX files, but I haven't
checked that.
2023-10-16 08:33:35 +02:00
Nico Weber
96a4936567 LibPDF: Checking for built-in CFF encodings
Only prints a warning for them for now.

Also warn on the not-yet-implemented encoding supplement.
2023-10-16 08:32:18 +02:00
Nico Weber
414a164850 LibPDF: Be louder about unimplemented CFF dict entries 2023-10-16 08:32:18 +02:00
Nico Weber
c825194fb9 LibPDF: Reject CFFs with more than one font
The code assumes that there's just one Top DICT, so let's be loud
when that isn't the case.
2023-10-16 08:32:18 +02:00
MacDue
95bf6ddb8e LibGfx: Fix serializing Gfx::Bitmaps
a396bb0 removed the palette field but did not update the allocation size
in `Bitmap::serialize_to_byte_buffer()`. This led to a few crashes (I
noticed this from a drag/drop crash in the file manager).

Fixes #21434
2023-10-15 20:34:29 +02:00
MacDue
f0cd7adaf8 LibGUI: Fix FileSystemModel/FileManager after aeee98b
Previously, the null state of m_root_path was use to (subtly) mark the
parent of the root. The empty path is always replaced with "." so after
aeee98b there was no "parent of root" node. This lead to the file
manager crashing when opened.
2023-10-15 21:34:15 +03:30
Nico Weber
6f783929dd LibPDF: Implement support for CFF charset format 2
I haven't seen this being used in the wild (yet), but it's easy
to implement, and with this we support all charset formats.

So we can now mention if we see a format we don't know about.
2023-10-15 15:27:15 +02:00
Nico Weber
5b915fb15c LibPDF: Add more spec comments to parse_charset() 2023-10-15 15:27:15 +02:00
Nico Weber
49275c4b17 LibPDF: Don't overflow SIDs in type 1 charset parsing
first_sid has type SID (aka u16), so don't store it in an u8.

This fixes (among other things) page 24 on the PDF 1.7 spec.
2023-10-15 15:27:15 +02:00
Jelle Raaijmakers
403d3bbdaf LibSoftGPU: Optimize GPU::Vertex lists
On my machine, benchmarking 3DFileViewer revealed ~2.5% of CPU time
spent in `Vector<GPU::Vertex>::try_append`. By carefully managing list
capacities, we can remove this method from profiles altogether.
2023-10-15 12:14:07 +02:00
Jelle Raaijmakers
c978891dda LibGL: Optimize appends in gl_vertex
Optimize a very hot function by always performing unchecked appends.
When benchmarking 3DFileViewer on my machine, this takes the time spent
in `gl_vertex` down from ~8% to ~2%.
2023-10-15 12:14:07 +02:00
Jelle Raaijmakers
edcb6176ce LibGL+Lib*GPU: Set model view and projection matrices separately
LibSoftGPU used to calculate the normal transformation based on the
model view transformation for every primitive, because that's when we
sent over the matrix. By making LibGL a bit smarter and only update the
matrices when they could have changed, we only need to calculate the
normal transformation once on every matrix update.

When viewing `Tuba.obj` in 3DFileViewer, this brings the percentage of
time spent in `FloatMatrix4x4::inverse()` down from 15% to 0%. :^)
2023-10-15 12:14:07 +02:00
Jelle Raaijmakers
126adfc392 3DFileViewer: Set timer to 15ms instead of 20ms
This approaches 60FPS and feels a bit smoother.
2023-10-15 12:14:07 +02:00
Jelle Raaijmakers
77c16d2ae7 3DFileViewer: Show correct framerate
We were confusing the time spent rendering with the time spent rendering
_and_ waiting for the next frame, which is important since we render
frames on a timer.
2023-10-15 12:14:07 +02:00
Nico Weber
23d6e9f577 LibPDF: Implement CFF built-in charsets ISOAdobe, Expert, Expert Subset 2023-10-15 09:33:34 +02:00
Nico Weber
8060957d8d LibPDF: Use Appendix A instead of Appendix C for standard names
From "10 String INDEX":

"Further space saving is obtained by allocating commonly occurring
strings to predefined SIDs. These strings, known as the standard
strings, describe all the names used in the ISOAdobe and Expert
character sets along with a few other strings common to Type 1 fonts. A
complete list of standard strings is given in Appendix A.  The client
program will contain an array of standard strings with nStoStrings
elements. Thus, the standard strings take SIDs in the range 0 to
(nStaStrings-1)."

And "13 Charsets" says that charsets store SIDs.

Fixes all

    "Couldn't find string for SID $n, going with space"

messages when going through the encoding pages (page 1010 and
thereabouts) in the PDF 1.7 spec.
2023-10-15 09:33:34 +02:00
Nico Weber
aba787a441 LibPDF: Implement reading of CFF String Index
Only really useful for reading SIDs in the Top DICT (copyright
text etc), which we currently don't do.

I haven't seen a difference from looking things up in the string
table. The only real effect from the commit that I need is that
it pulls a local resolve() labmda into a real function
resolve_sid(), which I want to call in a future commit.

But it makes things more spec-compliant, and if we ever want to
read SIDs in metadata in the future, now we can.
2023-10-15 09:33:34 +02:00
Tim Ledbetter
9e3ee0e2b5 LibGfx/ILBM: Avoid buffer overrun when reading header chunk 2023-10-15 08:37:27 +02:00
Cubic Love
f2b7224d93 GamesSettings+LibCards: Make 'Red' the default card back
The red back is a more suitable default as it's a traditional vanilla
design and red is one of Serenity's brand colors.
2023-10-15 07:25:20 +02:00
Timothy Flynn
94e4d59a08 LibWeb: Remove use of UnicodeData header from DOM::Element
The UnicodeData header cannot be included by any file other than .cpp
files within LibUnicode itself. Outside users cannot assume the header
will exist, as it will not be generated if the CMake option to do so is
disabled (ENABLE_UNICODE_DATABASE_DOWNLOAD).
2023-10-15 07:23:30 +02:00
Sam Atkins
c9c99b3c42 LibWeb: Produce resolved transform value according to spec algorithm
We now produce a `matrix3d()` value when appropriate.

Some sites (such as gsap.com) request the resolved style for `transform`
when there's no viewport paintable, but the element itself does already
have a stacking context. This fixes crashes in that case, because we now
do not access the stacking context at all.

We also do not wrap the result as a StyleValueList any more. The
returned StyleValue is only serialized and exposed to JS, so making it a
StyleValueList has no effect.
2023-10-15 07:14:39 +02:00
Sam Atkins
c65d6964ea LibWeb: Update layout if we lack a node when getting computed style
As noted, there are two situations where an element will have no layout
node here:
1. The element is invisible in a way that it generates no layout node.
2. We haven't built the layout yet.

This protects against the second case, which would otherwise incorrectly
send us down the path of looking directly at the computed style.
2023-10-15 07:14:39 +02:00
Sam Atkins
642ad80960 LibWeb: Make CSS Transformation struct a proper class
Move it out of ComputedValues.h into its own files, and take the
transformation-to-matrix code from StackingContext.
2023-10-15 07:14:39 +02:00
Nico Weber
3c49d0dad3 LibPDF: Add a CFF_DEBUG toggle
I'd like to put some debug prints behind this soon.

No behavior change.
2023-10-15 07:14:29 +02:00
MacDue
11f7db8f34 LibWeb: Fix null optional dereference in Node::name_or_description()
Regression/typo from aeee98b, this lead to a crash when opening the DOM
inspector.
2023-10-14 18:36:32 -04:00
Luke Wilde
7467307377 LibWeb: Use "POST" instead of "post" for POST resources in navigables
HTTP methods are case sensitive and the Fetch layer treats it as such.
For example, http_redirect_fetch case sensitively checks if the method
is "POST" to change the method to "GET" and nullify the body.
9d7e217566/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp (L1125-L1135)

Fixes https://github.com/SerenityOS/serenity/issues/21347
2023-10-14 14:26:31 -04:00
Sönke Holz
9d7e217566 LibELF: Handle TLSDESC relocations in .rela.plt for GNU ld
GNU ld for some reason might put R_*_TLSDESC relocations in .rela.plt.
2023-10-14 19:16:22 +02:00
Ali Mohammad Pur
0937d88869 LibWeb: Remove more DeprecatedString null state remnants 2023-10-14 09:12:41 -04:00
Ali Mohammad Pur
988c6568a9 LibWeb: Remove Element::set_attribute(name, value?)
That API came from a mistake in the IDL compiler, where reflected
nullable attributes would try to call set_attribute(name, null).
This commit fixes the mistake in the IDL generator, and removes the
meaningless API.
2023-10-14 09:12:41 -04:00
Timothy Flynn
d2c7e1ea7d Browser: Sanitize user-provided URLs with LibWebView 2023-10-13 13:37:11 -04:00
Timothy Flynn
191e20d639 LibWebView: Add a helper to sanitize a user-provided URL
We currently implement several forms of this method across the Ladybird
chromes. As such, we see commits to add special URL handling that only
affects a single chrome. Instead, let's consolidate all special handling
in a single location for all chromes to make use of.

This method can handle resolving file:// URLs, falling back to a search
engine query, and validation against the Public Suffix List. These cases
were gathered from the various chromes.
2023-10-13 13:37:11 -04:00
Tim Ledbetter
54a28afc13 LibIMAP: Stop parsing immediately on error
This makes the parser more resilient to invalid IMAP messages.

Usages of `Optional` have also been removed where the empty case is
equivalent to an empty object.
2023-10-13 11:12:18 -06:00
Tim Ledbetter
29c477598c LibIMAP: Rename Parser::try_consume() to consume_if() 2023-10-13 11:12:18 -06:00
Ali Mohammad Pur
aeee98b3a1 AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
2023-10-13 18:33:21 +03:30
Nico Weber
2249e79630 LibPDF: Add two FIXMEs 2023-10-13 07:53:27 +02:00
Nico Weber
d451197d3d LibPDF: Add spec comments to CFF 2023-10-13 07:53:27 +02:00
Nico Weber
349996f7f2 LibPDF: Don't crash on files with float CFF defaultWidthX
We'd unconditionally get the int from a Variant<int, float> here,
but PDFs often have a float for defaultWidthX and nominalWidthX.

Fixes crash opening Bakke2010a.pdf from pdffiles (but while the
file loads ok, it looks completely busted).
2023-10-12 19:43:57 +02:00
Sönke Holz
e7c8ff3839 LibC: Clean up crt0
We already set these variables and call `_init` in the dynamic linker.
As we don't care about static binaries, remove these assignments and the
call to `_init` from `_entry`.

The function referenced by DT_INIT is also not necessarily called
`_init`, so directly calling `_init` is not really correct.

`s_global_initializers_ran` and `__stack_chk_guard` are unused, so
remove them.
2023-10-12 15:20:50 +02:00
Sönke Holz
0bff1f61b6 LibC+LibELF: Correctly call destructors on exit()
We currently don't call any DT_FINI_ARRAY functions, so change that.

The call to `_fini` in `exit` is unnecessary, as we now call the
function referenced by DT_FINI in `__call_fini_functions`.
2023-10-12 15:20:50 +02:00
Kemal Zebari
dcff48356f LibWeb/HTML: Use MimeType::is_xml() in HTMLObjectElement for DRYness
Now that we implement this member function, let's use it to keep
things DRY.
2023-10-12 07:01:35 -04:00
Nico Weber
5c744a9fb0 pdf: Add a --render-repeats=N flag
It calls render() N times instead of just once. Useful for benchmarking.
2023-10-12 08:03:52 +02:00
Timothy Flynn
33443190d0 LibWeb: Store the SVG <use> element's referenced ID as a FlyString
We currently store a StringView into the DeprecatedString provided to
SVGUseElement::attribute_changed. This is a temporary string created by
String::to_deprecated_string, so this StringView is always a dangling
pointer.

Instead, since this string value is an ID and is primarily used as a
FlyString, store it as a FlyString from the get-go.
2023-10-12 07:39:37 +02:00
Andreas Kling
a396bb0c0b LibGfx: Remove indexed palette formats from Bitmap and Painter
Nobody was actually using these formats anymore, and this simplifies
and shrinks the code. :^)
2023-10-12 07:39:05 +02:00
Andreas Kling
bcbaad0b1d LibGfx: Make BMP decoder always produce BGRA8888 or BGRx8888 bitmaps
This was the only remaining codec that produced IndexedN bitmaps.
By removing them, we'll be able to get rid of those formats and simplify
the Bitmap and Painter classes.
2023-10-12 07:39:05 +02:00
Aliaksandr Kalenik
7803dcfcf9 LibWeb: Resolve backdrop filter length in apply_style()
Instead of resolving lengths used in the backdrop-filter during
painting, we can do that earlier in apply_style().

This change moves us a bit closer to the point when the stacking
context tree will be completely separated from the layout tree :)
2023-10-12 07:38:48 +02:00
Aliaksandr Kalenik
44f7d7406c LibWeb: Use struct to pass Navigable::navigate() params
Using structs makes the navigate() calls looks cleaner. No change
in behavior is intended.
2023-10-12 03:25:06 +02:00
Tim Ledbetter
a673062084 LibGfx/BMPLoader: Ensure data offset cannot point past EOF 2023-10-11 14:36:12 -04:00
Tim Ledbetter
9788576936 LibVideo/VP9: Ensure color space is not set to reserved value 2023-10-11 14:35:47 -04:00
Sam Atkins
2e615b5316 LibCards: Move Play cards closer together horizontally
With the recent adjustments to how cards are painted, this felt too
spaced out.
2023-10-11 10:56:43 +01:00
Sam Atkins
ff8969bd5f GamesSettings: Center cards vertically after recent size change 2023-10-11 10:56:43 +01:00
Sam Atkins
eff25f9116 LibCards: Stop calling the card back image a "background" image
It's not a background, past me!
2023-10-11 10:56:43 +01:00
Sam Atkins
d8e8b300c8 GamesSettings+LibCards: Add setting for card-front image sets 2023-10-11 10:56:43 +01:00
Sam Atkins
020b858fd0 LibCards: Paint images and number pips on card fronts :^) 2023-10-11 10:56:43 +01:00
Nico Weber
c8510b58a3 LibPDF: Cache fonts per page
Previously, every time a page switched fonts, we'd completely
re-parse the font.

Now, we cache fonts in Renderer, effectively caching them per page.

It'd be nice to have an LRU cache across pages too, but that's a
bigger change, and this already helps a lot.

Font size is part of the cache key, which means we re-parse the same
font at different font sizes. That could be better too, but again,
it's a big help as-is already.

Takes rendering the 1310 pages of the PDF 1.7 reference with

    Build/lagom/bin/pdf --debugging-stats \
        ~/Downloads/pdf_reference_1-7.pdf

from 71 s to 11s :^)

Going through pages especially in the index is noticeably snappier.

(On the PDF 2.0 spec, ISO_32000-2-2020_sponsored.pdf, it's less
dramatic: From 19s to 16s.)
2023-10-11 07:10:19 +02:00
Tim Ledbetter
e6d9bb0774 LibTLS: Don't attempt to read past EOF when parsing TBSCertificate
This allows the decoder to fail gracefully when reading a partial or
malformed TBSCertificate. We also now ensure that the certificate data
is valid before making a copy of it.
2023-10-11 07:08:22 +02:00
Aliaksandr Kalenik
65b50ecc1a LibWeb/CSS: Parser should treat calc() with flex values as invalid
Fixes crash on https://signal.org/
2023-10-11 07:07:29 +02:00
Sam Atkins
1132c858e9 LibWeb: Stop inserting inline nodes into a generated wrapper box
493dd5d93c caused the `::before`
pseudo-element node to be inserted before the element's content, which
caused issues with how we determine where to insert inline nodes into
the layout tree. At the time, I noticed the issue with contents of flex
containers, and prevented them from merging into a `::before` box.

However, a similar situation happens when we're not in a flex container,
but the pseudo-element has `display: block`. This commit fixes that
situation by using the same logic in both places, so a similar mistake
can't be made again.

This fixes the tab text being invisible on GitHub project pages. :^)
2023-10-11 07:05:23 +02:00
Tim Ledbetter
068f6771ad LibVideo/VP9: Check for invalid subsampled block sizes
Previously, a corrupted block could cause
`Parser::get_subsampled_block_size()` to return an invalid value. We
now return an error in this case.
2023-10-10 23:47:13 +01:00
Tim Ledbetter
569e7173cc LibVideo/VP9: Avoid integer overflow during in place butterfly rotation 2023-10-10 23:47:13 +01:00
Tim Ledbetter
fd3837c63b LibVideo/VP9: Return error for frames with invalid subsampling format
Previously, the program would crash if this condition was encountered.
We now return a decoder error allowing for graceful failure.
2023-10-10 23:47:13 +01:00
Sam Atkins
18dfc61280 LibGfx: Expose BitmapFont glyph data as Spans instead of raw pointers 2023-10-10 14:36:25 +02:00
Sam Atkins
80e756daef LibGfx: Load BitmapFont data more safely
Previously, `load_from_memory()` just took a raw pointer to the data,
and then manually calculated offsets from that pointer. Instead, let's
use the MappedFile we already have, to stream in the data, to make
things a bit safer. We also now check that the entire file's data was
read, since if there was data left over, then either the file is bad or
we've done something wrong.

I've moved the code directly into `try_load_from_mapped_file()` since
`load_from_memory()` was only called from there. The extra indirection
wasn't adding anything.
2023-10-10 14:36:25 +02:00
Sam Atkins
8e51c7112c LibGfx: Store BitmapFont glyph widths as a Span<u8>
More raw pointer removal.
2023-10-10 14:36:25 +02:00
Sam Atkins
f6c40abdb1 LibGfx: Give GlyphBitmap its rows data as Bytes
Instead of giving it a raw pointer to the start of the font's rows data
and an offset, give it the Bytes for its rows only.
2023-10-10 14:36:25 +02:00
Sam Atkins
a3b91378df LibGfx: Store BitmapFont rows data as Bytes 2023-10-10 14:36:25 +02:00
Sam Atkins
415a024bc8 LibGfx: Store BitmapFont range mask as Bytes instead of pointer and size 2023-10-10 14:36:25 +02:00
Sam Atkins
533ec5a06f LibGfx: Use Core::System helper for BitmapFont memory allocation 2023-10-10 14:36:25 +02:00
Sam Atkins
57497c6ab2 LibCore: Add a Core::System wrapper for memory allocation
Allocating raw memory isn't something we do often, but it does happen.
Let's make it comfier.
2023-10-10 14:36:25 +02:00
Sam Atkins
89ef3ed4ce LibGfx: Mark BitmapFont::try_clone() as virtual 2023-10-10 14:36:25 +02:00
Sam Atkins
a1c24ef3ad LibGfx: Remove infallible BitmapFont::create() factory function
This was only used in TestFontHandling. So, let's remove it, and use
the "create" name for the fallible one.
2023-10-10 14:36:25 +02:00
Tim Ledbetter
2f26a7bb12 LibCompress: Avoid buffer overrun when building canonical Huffman code
Previously, decompressing a DEFLATE stream an invalid canonical
Huffman code could cause a buffer overrun. We now return an error in
this case.
2023-10-10 13:24:05 +02:00
Tim Ledbetter
bc6638682d LibGfx/BMPLoader: Ensure DIB size and offset are within expected range 2023-10-10 05:50:02 +02:00
Tim Schumacher
127f6ed6eb LibCompress: Fix a typo in m_read_final_block 2023-10-09 23:40:10 +02:00
Andreas Kling
13057812d5 LibJS: Remove inline capacity from MarkedVector
Turns out this was hurting performance instead of helping it.
By removing the inline capacity, we shrink the size of ExecutionContext
by 512 bytes, which substantially reduces the stack pressure created by
JS recursion (each call creates a new ExecutionContext on the stack).

4.4% speed-up on the entire Kraken benchmark :^)
2023-10-09 09:32:24 +02:00
Karol Kosek
2ea45f4881 LibJS: Forward-declare RegexTable and BasicBlock in Executable.h
Previously every file that included Executable.h (which is pretty much
most LibJS and LibHTML files, given that VM.h needs it) had the whole
definition of LibRegex, which was slowing down source parsing.
2023-10-09 07:29:27 +02:00
Karol Kosek
426b7ffa41 LibWeb: Don't include Window.h in Element.h and Document.h
Window.h is a rather heavy file, so let's try not to include it in
header files when we can!

Element.h now also includes LibWeb/Bindings/Intrinsics.h, but that's
just out of my laziness. Most if not all objects call
`Bindings::ensure_web_prototype<>()` anyway, so I don't think we would
gain much by sticking the header to source files instead.
2023-10-09 07:29:27 +02:00
MacDue
92fc426562 LibWeb: Add basic support for maskUnits=userSpaceOnUse
This still does not use the x, y, width, or height attributes on the
mask, but this allows at least displaying these masks.
2023-10-09 07:28:18 +02:00
MacDue
479451498b LibWeb: Implement mask-type CSS property
This property allows specifying if a mask is an alpha or luminance mask.

See: https://drafts.fxtf.org/css-masking/#the-mask-type
2023-10-09 07:28:18 +02:00