Commit Graph

58960 Commits

Author SHA1 Message Date
Shannon Booth
d18f7145ad patch: Remove empty files after patching 2024-02-21 14:11:49 +01:00
Shannon Booth
df6a627323 LibDiff: Reject patches adding files when a file already exists
We should still add an informational message about when this happens
before we even get here - but we still shouldn't be able to locate a
place to apply a hunk as it ends up producing unexpected results where
the patch is prepended to the existing file.
2024-02-21 14:11:49 +01:00
Shannon Booth
c72c3d5f3b LibDiff/Tests: Add support for expected patch failures 2024-02-21 14:11:49 +01:00
Shannon Booth
9e36ba0a55 LibDiff/Tests: Use ByteString for filepaths in tests 2024-02-21 14:11:49 +01:00
Shannon Booth
947075ea7b LibDiff/Tests: Make verifying against stdout optional
It's not always important to verify what the contents of stdout are when
adding a patch test - especially if it's not exactly what we want it to
be, so make this optional when running patch for a test.
2024-02-21 14:11:49 +01:00
Lucas CHOLLET
9ec3480207 LibGfx/TIFF: Add support for Group4Fax encoded images
Note that we don't parse the T6 option group yet.

The test case was generated with GIMP.
2024-02-21 13:49:43 +01:00
Lucas CHOLLET
d57d676425 LibGfx/CCITT: Add support for Group4
The API is currently pretty raw. Group4 has a bunch of options that we
don't support yet.
2024-02-21 13:49:43 +01:00
Lucas CHOLLET
e9dd1cda3e LibGfx/CCITT: Abstract the code to read a single CCITT 2D line 2024-02-21 13:49:43 +01:00
Nico Weber
e8133c8297 LibGfx/OpenType: Undo minor deletion in #23225
Check if we have a cmap before dereferencing it again.

Fixes a crash on page 8 of 0000188.pdf now that the font no
longer fails to load to due to a missing name table.

Looks like this is a Type2 truetype font, where we don't provide
an external cmap. How this font is supposed to work without a cmap
I don't know -- but for now, we no longer crash on it, and draw
some of the text with the previous font (which happens to work
fine in this particular case).
2024-02-21 13:38:33 +01:00
Nico Weber
08381b20e0 LibGfx/OpenType: Allow zero-sized table entries
Kind of reverts #21675, but #21744 made that better

4 of my 1000 test PDFs complained "Invalid table offset or length in
font" before.

For example, in 0000203.pdf, these tags had length 0: 'cvt ', 'fpgm',
'prep', 'name', 'OS/2'. (Generally it's tables that aren't needed
for rendering PDFs, and the PDF writer figured it's easier to zero
out these tables instead of omitting them altogether for some reason.)

Increases number of PDFs that render without diagnostics from
765 to 767.
2024-02-21 13:38:33 +01:00
Nico Weber
cade76d240 LibPDF+LibGfx: Do not try to read "OS/2" table for PDFs
It is sometimes truncated in fonts embedded in PDFs, and the data
is not needed to render PDFs. 2 of my 1000 test PDFs used to
complain "Could not load OS2 v1: Not enough data" and 1
"Could not load OS2 v2: Not enough data" before.

Increases number of PDFs that render without diagnostics from
764 to 765 (and decreases the number of distinct error messages
from 27 to 25).
2024-02-21 13:38:33 +01:00
Nico Weber
0dee94ef40 LibPDF+LibGfx: Do not try to read "hmtx" table for PDFs
It is sometimes truncated in fonts embedded in PDFs, and the data
is not needed to render PDFs. 26 of my 1000 test files complained
"Could not load Hmtx: Not enough data" before.

Increases number of PDFs that render without diagnostics from
743 to 764.
2024-02-21 13:38:33 +01:00
Nico Weber
5efe80af7f LibPDF+LibGfx: Do not try to read "name" table for PDFs
It is often missing in fonts embedded in PDFs. 75 of my 1000 test
files complained "Font is missing Name" when trying to read fonts
before.

Increases number of PDFs that render without diagnostics from
682 to 743.
2024-02-21 13:38:33 +01:00
Nico Weber
41eca52b50 LibGfx/OpenType: Tweak Font::try_load_from_externally_owned_memory()
It now takes an Options object instead of passing several default
parameters.

No behavior change.
2024-02-21 13:38:33 +01:00
Nico Weber
3b616b6af8 LibPDF: Use original error for failing ICC load 2024-02-21 13:37:08 +01:00
Nico Weber
275542aaf8 LibGfx/ICC: Add another version of the Apple P3 profile to quirks list
Improves appearance of page 6 of
https://fredrikbk.com/publications/copy-and-patch.pdf
2024-02-21 13:37:08 +01:00
Nico Weber
0160f737e2 LibGfx/ICC+icc: Be lenient about invalid profile creation datetimes
Before, we used to reject profiles where the creation datetime was
invalid per spec. But invalid dates happen in practice (most commonly,
all fields set to 0). They don't affect profile conversion at all,
so be lenient about this, in exchange for slightly more wordy code
in the places that want to show the creation datetime.

Fixes a crash rendering page 2 of
https://fredrikbk.com/publications/copy-and-patch.pdf
2024-02-21 13:37:08 +01:00
Tim Ledbetter
3b7c252175 LibWeb: Implement AbortSignal.abort()
This returns an AbortSignal that is already set as aborted.
2024-02-21 10:34:44 +01:00
Nico Weber
fa95e5ec0e LibPDF: Fix line drawing when line_width is 0
We used to skip lines with width 0. The correct behavior per spec
is to draw them one pixel wide instead.
2024-02-21 10:30:57 +01:00
Andrew Kaster
0dde88d714 LibWeb: Treat global as EventTarget in notify_about_rejected_promises
We only need to know that the Global Object of the environment is an
event target in order to dispatch an event on it. This resolves a FIXME
where we assumed that the only type of Global in LibWeb is HTML::Window.
2024-02-21 10:11:59 +01:00
Andrew Kaster
9d7e234439 Tests/WPT: Update expectations metadata for new passing tests 2024-02-21 10:10:44 +01:00
Andrew Kaster
cb68c6eaf1 LibWeb: Set size of canvas used to take WebDriver screenshots explicitly
The default canvas size is 300x150 pixels. If the element or document
we are trying to screenshot for the WebDriver is not at least that size,
then we will create a canvas that is wider or taller than the actual
element we are painting, resulting in a bunch of transparent pixels
falling off the end.

This fixes 14 WPT css/CSS2/floats tests that we run in CI, and
presumably a ton of other reftests in the WPT test suite.
2024-02-21 10:10:44 +01:00
Aliaksandr Kalenik
aee5120078 LibWeb: Fix infinite recursion when grid has "max-width: max-content"
With this change "max-width: max-content" is treated as "none" when
the available width is also "max-content". This fix prevents a stack
overflow in the grid track size maximization algorithm by avoiding
recursive calls to calculate_max_width() when determining the maximum
grid container size.
2024-02-21 10:06:19 +01:00
Lucas CHOLLET
8e2102fb73 ImageViewer: Transform the image's dimension accordingly to the metadata
Exif metadata have two tags to store the pixel density along each axis.
If both values are different and no action is taken, the resulting image
will appear deformed. This commit scales the displayed bitmap
accordingly to these tags in order to show the image in its intended
shape. This unfortunately includes a lot of plumbing to get this
information through IPC.
2024-02-21 08:31:17 +00:00
Lucas CHOLLET
8dd887b3c8 LibGfx: Make FloatPoint compatible with IPC 2024-02-21 08:31:17 +00:00
Lucas CHOLLET
41c76e6ba6 LibGfx/TIFF: Add Rational::as_double() 2024-02-21 08:31:17 +00:00
Andreas Kling
660d6d0c85 Meta: Add Polar to FUNDING.yml
Let's advertise the fact that we allow sponsoring work on specific
issues via Polar rewards. :^)
2024-02-21 07:36:55 +01:00
Timothy Flynn
e52c30cbd5 LibWeb: Allow bypassing transient activation checks for tests
We have a 5 second timeout between a user-activated event occurring and
an activation-gated API being invoked in order for that API to succeed.
This is quite fine in normal circumstances, but the machines used in CI
often exceed that limit (we see upwards of 10 seconds passing between
generating the user-activated event and the API call running).

So instead of generating a user-activated event, add a hook to allow
tests to bypass the very next activation check.
2024-02-20 18:53:59 -05:00
Timothy Flynn
4bdcf9a4b7 LibJS: Revert the free stack limit back to 32 KiB 2024-02-20 16:24:09 -05:00
Timothy Flynn
8eaf48888e LibJS: Remove FLATTEN attribute from Interpreter::run_bytecode
This is what caused stack usage to increase so much with the new BC.
Revert it for now so we can restore our old stack limit.
2024-02-20 16:24:09 -05:00
Andreas Kling
9a0a5a79f4 LibJS/Bytecode: Put arguments directly in the Call instruction
Instead of having Call refer to a range of VM registers, it now has
a trailing list of argument operands as part of the instruction.

This means we no longer have to shuffle every argument value into
a register before making a call, making bytecode smaller & faster. :^)
2024-02-20 21:25:18 +01:00
Andreas Kling
da107ec9fb LibJS/Bytecode: Add fast paths for many binary expression instructions
By handling common cases like Int32 arithmetic directly in the
instruction handler, we can avoid the cost of calling the generic helper
functions in Value.cpp.
2024-02-20 21:25:18 +01:00
Andreas Kling
9d9b737a58 LibJS/Bytecode: Dedicated instructions for postfix increment/decrement
Instead of splitting the postfix variants into ToNumeric + Inc/Dec,
we now have dedicated PostfixIncrement and PostfixDecrement instructions
that handle both outputs in one go.
2024-02-20 21:25:18 +01:00
Aliaksandr Kalenik
c4f49e343a LibWeb: Fix division by zero in solve_replaced_size_constraint()
Fixes crashes that occur in Discord after clicking on a direct messages
conversation.
2024-02-20 20:35:34 +01:00
Timothy Flynn
3ac4b02604 LibJS: Further increase the free stack limit to 256 KiB
128 KiB seems to not be enough for CI.
2024-02-20 12:29:27 -05:00
Timothy Flynn
af57bd5cca LibWeb: Stop parsing after document.write at the insertion point
If a call to `document.write` inserts an incomplete HTML tag, e.g.:

    document.write("<p");

we would previously continue parsing the document until we reached a
closing angle bracket. However, the spec states we should stop once we
reach the new insertion point.
2024-02-20 17:04:36 +01:00
Timothy Flynn
64dcd3f1f4 LibWeb: Restore the previous tokenizer iterator after inserting input
Otherwise, m_prev_utf8_iterator still points at the old source.
2024-02-20 17:04:36 +01:00
Timothy Flynn
fcf83a8ed0 LibWeb: Allocate fewer strings during document.write 2024-02-20 17:04:36 +01:00
Timothy Flynn
338f0382d3 LibWebView: Escape HTML within attribute values in the Inspector HTML
If an attribute value contains HTML, let's make sure we render it as
text, instead of injecting HTML in the middle of an Inspector field.
2024-02-20 17:04:36 +01:00
Timothy Flynn
fd558a012b LibWebView: Do not embed text as data in the Inspector HTML
We were previously embedding the original text to handle the special
case where the text is empty. We generate an extra span to hold the
string "#text" as a placeholder, so that we don't generate a 0px-wide,
unclickable (and therefore uneditable) node. Instead, we can just detect
when this is the case in the Inspector JS.

This further reduces the generated HTML for the Inspector on
https://github.com/SerenityOS/serenity from 1.9MB to 1.8MB (about 94KB,
or 4.7%).
2024-02-20 17:04:36 +01:00
Timothy Flynn
f07f5a2622 LibWeb+WebContent: Do not embed attributes as data in the Inspector HTML
Attribute values may contain HTML, and may contain invalid HTML at that.
If the latter occurs, let's not generate invalid Inspector HTML when we
embed the attribute values as data attributes. Instead, cache the values
in the InspectorClient, and embed just a lookup index into the HTML.

This also nicely reduces the size of the generated HTML. The Inspector
on https://github.com/SerenityOS/serenity reduces from 2.3MB to 1.9MB
(about 318KB, or 13.8%).
2024-02-20 17:04:36 +01:00
Timothy Flynn
939779cad3 LibWeb: Support nullable integral IDL types
We currently support optional integral types, but not nullable types. So
if an IDL contains e.g. "long?", passing null will be coerced to 0.

This will be used by the Inspector, but will also eventually be used by
real IDL interfaces (e.g. HTMLInputElement's selectionStart).
2024-02-20 17:04:36 +01:00
Nico Weber
1cb450e9a3 LibPDF: Give CFF Glyph 0 the name .notdef
This is required by the CFF spec, and is consistent with what we do for
the encoding 24 lines down.

As far as I can tell, nothing in `Type1FontProgram::rasterize_glyph()`
or in Type1Font.cpp implements the "If an encoding maps to a character
name that does not exist in the Type 1 font pro- gram, the .notdef glyph
is substituted." line from the PDF 1.7 spec (in 5.5.5 Character
Encoding, Encodings for Type 1 Fonts) yet, so this does yet have an
effect.
2024-02-20 06:54:50 -05:00
Shannon Booth
0b457f90e0 LibJS: Fix copy paste errors in Temporal's Calendar Methods Record
This adapts our implementation to the editorial change in the temporal
proposal: https://github.com/tc39/proposal-temporal/commit/737baf2d

The changes to CalendarMethodsRecordLookup had already been implemented,
but we had followed the typo in the spec for CalendarMethodsRecordCall.
The issue in CalendarMethodsRecordCall hasn't surfaced yet, as the AOs
using Calendar Methods Record are currently not passing through a String
to represent a Calendar builtin.

No change to test-262.
2024-02-20 06:54:32 -05:00
Ali Mohammad Pur
99f8ac84ef Tests/LibWeb: Make the WPT runner grab only the one commit it needs 2024-02-20 11:11:19 +01:00
Aliaksandr Kalenik
036cd9b2dd LibWeb: Null layout and paintable pointers of removed DOM::Node
When a node is removed from the DOM tree, its paintable needs to be
removed to ensure that it is not used to obtain sizes that are no
longer valid.

This change enables the ResizeObserver to send a notification if a node
is removed, as it should, because a removed node now has a size of zero

It should be okay to nullify pointers without concerning
parent/sibling/child relationships because the layout and paintable
trees will be rebuilt following any DOM mutation anyway.
2024-02-20 10:55:10 +01:00
Aliaksandr Kalenik
2b7e7cc1ad LibWeb: Implement ResizeObserver::disconnect() 2024-02-20 10:55:10 +01:00
Aliaksandr Kalenik
70a0f07732 LibWeb: Implement ResizeObserver::unobserve() 2024-02-20 10:55:10 +01:00
Aliaksandr Kalenik
fcf293a8df LibWeb: Implement gathering and broadcasting of resize observations
Extends event loop processing steps to include gathering and
broadcasting resize observations.

Moves layout updates from Navigable::paint() to event loop processing
steps. This ensures resize observation processing occurs between layout
updates and painting.
2024-02-20 10:55:10 +01:00
Aliaksandr Kalenik
8ba18dfd40 LibWeb: Schedule repainting from EventLoop::process()
In this change, updating layout and painting are moved to the EventLoop
processing steps. This modification allows the addition of resize
observation dispatching that needs to happen in event loop processing
steps and must occur in the following order relative to layout and
painting:

1. Update layout.
2. Gather and broadcast resize observations.
3. Paint.
2024-02-20 10:55:10 +01:00