Commit Graph

28911 Commits

Author SHA1 Message Date
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