Commit Graph

31717 Commits

Author SHA1 Message Date
Timothy Flynn
7bee1c9897 LibWeb: Store the input image button's selected coordinates as integers
The spec has prose which states, e.g., "The x-component must be a valid
integer".
2024-02-21 19:52:59 +01:00
Timothy Flynn
3f3db34587 LibWeb: Support setting dimensions on input image buttons
Users are allowed to specify the height and width of an image button
directly in the HTML.
2024-02-21 19:52:59 +01:00
Matthew Olsson
3ea26327c7 LibWeb: Implement Animatable::get_animations() 2024-02-21 19:52:35 +01:00
Matthew Olsson
145ae54718 LibWeb: Add a few Animation/AnimationEffect getters 2024-02-21 19:52:35 +01:00
Matthew Olsson
06a8674eec LibWeb: Simplify Animation::update_finished_state a bit
This removes the two boolean hack in favor of using the existing
mechanism to remove queued tasks. It also exposes the element
invalidation behavior for call sites that don't necessarily want to
update the finished state, but still need to invalidate the associated
target.
2024-02-21 19:52:35 +01:00
Matthew Olsson
1e37ba5515 LibWeb: Expose Animation::is_finished()
This will be required to handle forward-fill state in StyleComputer
2024-02-21 19:52:35 +01:00
Matthew Olsson
5eea53f27a LibWeb: Keep track of associated AnimationEffects in Animatable 2024-02-21 19:52:35 +01:00
Matthew Olsson
2ade834655 LibWeb: Add Animation::is_replaceable() 2024-02-21 19:52:35 +01:00
Matthew Olsson
4e6c74dcf6 LibWeb: Define the composite order between two animations 2024-02-21 19:52:35 +01:00
Matthew Olsson
ceb9d0f8dc LibWeb: Record position of Animations in global animation list
"position of an Animation in the global animation list" is a fancy way
of saying "which animation object was created first"
2024-02-21 19:52:35 +01:00
Matthew Olsson
c3b689488e LibWeb: Implement animation class-specific composite order
This is a part of determining the composite order of two animations
2024-02-21 19:52:35 +01:00
Nico Weber
78b3c552c2 LibGfx: Tweak semantics of some SkipTables enum values
It turns out that hmtx and OS/2 table values _are_ used when
rendering OpenType for PDFs: hmtx is used for the left-side bearing
value (which is read in `Painter::draw_glyph()`), and OS/2 is used
for the ascender, which Type0's CIDFontType2::draw_glyph()
and TrueTypeFont::draw_glyph() read.

So instead of not trying to read these tables, instead try to read
them but tolerate them failing to read and ignore them then.

Follow-up to #23276.

(I've seen weird glyph positioning from not reading the hmtx table.
I haven't seen any problems caused by not reading the OS/2 table yet,
but since the PDF code does use the ascender value, let's read that
too.)
2024-02-21 19:52:03 +01:00
Tim Ledbetter
1560bfc6c9 LibWeb: Ensure DOMRect top, bottom, left and right handle NaN correctly 2024-02-21 19:38:17 +01:00
Tim Ledbetter
fe66aeb225 LibWeb: Validate arguments when creating DOMPoint from matrix transform
Previously, it was possible to create a DOMPoint from a matrix
transform with inconsistent arguments. A TypeError is now thrown in
this case.
2024-02-21 19:38:17 +01:00
Tim Ledbetter
c5d1ec4dea LibWeb/CSS: Ensure length is absolute before converting to pixels
Previously, creating a DOMMatrix with a transform that contained
non-absolute units would cause a crash.
2024-02-21 19:38:17 +01:00
Tim Ledbetter
5136b495a6 LibWeb: Use NaN safe min() and max() functions to compute DOMQuad bounds 2024-02-21 19:38:17 +01:00
Nico Weber
607880cbd3 LibGfx/JPEGLoader: Add dbgln_if() when hitting unsupported marker 2024-02-21 17:54:53 +01:00
Nico Weber
95391fafcb LibGfx/JPEGLoader: Print offset in an error dbgln() in hex 2024-02-21 17:54:53 +01:00
Nico Weber
24a469f521 Everywhere: Prefer {:#x} over 0x{:x} in format strings
The former automatically adapts the prefix to binary and octal
output, and is what we already use in the majority of cases.

Patch generated by:

    rg -l '0x\{' | xargs sed -i '' -e 's/0x{:/{:#/'

I ran it 4 times (until it stopped changing things) since each
invocation only converted one instance per line.

No behavior change.
2024-02-21 17:54:38 +01:00
Andreas Kling
f963bb4f36 LibWeb: Don't mark heights as definite in set_content_height()
Height definiteness is now preserved as intended by CSS-SIZING-3
(assuming I've understood it correctly) and not implicitly granted by
layout algorithms when they assign height.

For the specific special/magical cases where some sizes become definite
during layout, the preceding commits have made them explicit in code.

This fixes a number of flex layout issues where we were previously
resolving percentage values against post-layout flex container heights,
but other browsers don't.
2024-02-21 17:54:05 +01:00
Andreas Kling
0dd8458683 LibWeb: Add FIXME about definiteness to UsedValues::set_content_width()
Fixing this function will be quite an undertaking since a *lot* of code
relies on set_content_width() implicitly flipping the definiteness of
the width. It is wrong though, so we do need to fix it eventually.
2024-02-21 17:54:05 +01:00
Andreas Kling
221650f3cd LibWeb: Mark fixed-length abspos element sizes as definite
In particular, these two interesting cases:

- The containing block of an abspos box is always definite from the
  perspective of the abspos box.

- When resolving abspos box sizes from two opposing fixed insets,
  we now mark those sizes as definite (since no layout was required
  to resolve them).
2024-02-21 17:54:05 +01:00
Andreas Kling
70ce77fc72 LibWeb: Make SVGFormattingContext treat all sizes as definite for now
The whole way we lay out SVG content is ad-hoc, so this doesn't follow
any particular spec. However, our viewport transform logic depends on
having definite sizes, so let's just mark them as such for now.
2024-02-21 17:54:05 +01:00
Andreas Kling
f0269b0a94 LibWeb: Mark root element height as definite when affected by quirk
This will be required for percentages to resolve against it correctly
after we make set_content_height() not automatically mark heights as
definite sizes.
2024-02-21 17:54:05 +01:00
Andreas Kling
b079f4d590 LibWeb: Make flexbox special definite size cases explicit
The CSS-FLEXBOX-1 spec has a bunch of special cases where sizes are
considered definite after reaching a specific point of the layout
algorithm.

Before this change, we were relying on set_content_width/height also
implicitly marking those content sizes as definite.

To prepare for that implicit behavior going away, this patch makes
the special cases explicit.
2024-02-21 17:54:05 +01:00
Andreas Kling
5a995e95e3 LibWeb: Add UsedValues::set_has_definite_width/height()
These will be used to explicitly mark some box geometry as definite
at various stages of layout. It's gonna get finicky.
2024-02-21 17:54:05 +01:00
Andreas Kling
b83e41c9b5 LibWeb: Only assign block container heights during BFC intrinsic sizing
Before this change, we were always assigning the calculated height to
each block container after laying it out in BFC.

This should really only happen during intrinsic sizing, since that is
how measurements are communicated to the client there.
2024-02-21 17:54:05 +01:00
auipc
6a662e0d43 LibWeb: Add various window transformation methods 2024-02-21 15:53:27 +00:00
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
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
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