Commit Graph

32286 Commits

Author SHA1 Message Date
Aliaksandr Kalenik
1bd20a4595 LibWeb: Skip large stacking context in gpu painter only if it allocates
Skipping all stacking contexts with a size larger than 10000px in one
dimension was a mistake because it also affects pages that are simply
tall due to having a lot of content. Instead, we only need to skip if
the stacking context requires the allocation of a framebuffer that
could possibly fail.

Fixes https://github.com/SerenityOS/serenity/issues/23397
2024-03-02 14:36:33 +01:00
Andreas Kling
d8e8293b7e LibWeb: Add PercentageOr<Length>::to_px() fast path for absolute lengths
We can avoid round-tripping through a temporary Length in the simple
case here.
2024-03-02 13:00:09 +01:00
Andreas Kling
1e14264d13 LibWeb: Avoid repeated layout lookups in resolve_paint_only_properties()
By caching the layout node and its computed values in locals, we can
avoid the small amount of redundant work needed to look them up every
single time.
2024-03-02 13:00:09 +01:00
Andreas Kling
8303e61912 LibWeb: Pass BorderRadiusData const& to normalize_border_radii_data()
This avoids making a bunch of temporary copies for no reason.
2024-03-02 13:00:09 +01:00
Andreas Kling
3ff5beb229 LibWeb: Add fast_is<T>() for SVGPaintable 2024-03-02 13:00:09 +01:00
Andreas Kling
b66033720a LibWeb: Let Length::to_px(Layout::Node) be inline for absolute lengths 2024-03-02 13:00:09 +01:00
Andreas Kling
881e7fcee1 LibWeb: Copy various flags from layout node to paintable
This removes indirection when asking if a paintable is positioned,
floating, etc.

Removes a bunch of 1-1.5% items in the profile when hovering links
on ziglang.org.
2024-03-02 13:00:09 +01:00
Andreas Kling
c69b266e43 LibGfx: Add fast path for multiply() with identity transforms
This is a no-op, and exiting early is useful as it cuts time spent in
AffineTransform::multiply() from 3% to 2% when hovering links on
ziglang.org.
2024-03-02 13:00:09 +01:00
Andreas Kling
e46deec846 LibGfx: Inline some AffineTransform functions
Asking if an AffineTransform is identity or translate-only can be done
inline and avoid the cost of a function call in tight loops.
2024-03-02 13:00:09 +01:00
Andreas Kling
2dacd1252c LibGfx: Add fast paths for identity/translate-only transforms
This shrinks time spent in AffineTransform::map() from 3.3% to 1.6%
when hovering links on ziglang.org.
2024-03-02 13:00:09 +01:00
Andreas Kling
20ff69cd41 LibWeb: Add fast_is<T>() for InlinePaintable
dynamic_cast<InlinePaintable> was showing up in profiles when hovering
links on ziglang.org.
2024-03-02 13:00:09 +01:00
Andreas Kling
c4403fd28c LibWeb: Fix bogus ReplacedBox type check in StackingContext
We should be asking if the layout node is a ReplacedBox, not the
paintable.
2024-03-02 13:00:09 +01:00
Shannon Booth
cb1c3e5ea5 LibJS: Use TimeZoneMethods in DisambiguatePossibleInstants
This commit partially updates the DisambiguatePossibleInstants AO to use
a time zone methods record in line with the latest spec.
2024-03-02 12:27:20 +01:00
Shannon Booth
f95117f75d LibJS: Use TimeZoneMethods in GetOffsetNanosecondsFor
Update to the latest version of the spec which was refactored to use
time zone methods record. This requires updating a whole bunch of
callers to pass through a record too.

This also ends up improving exceptions on a missing
getOffsetNanosecondsFor method.
2024-03-02 12:27:20 +01:00
Shannon Booth
230ffc022c LibJS: Update Temporal's GetPossibleInstantsFor to latest spec
The most noteworthy change is that we now pass through a Time Zone
Methods Record to this function instead of a raw object.
2024-03-02 12:27:20 +01:00
Shannon Booth
aa9cdc2205 LibJS: Make DisambiguatePossibleInstants take a vector of NonullGCPtr
Instead of a raw pointer. Then deal with the fallout of making that
change.
2024-03-02 12:27:20 +01:00
Matthew Olsson
6d0672eec0 LibWeb: Implement complex transform interpolation
With this commit, we can interpolate between transforms whose functions
don't match. For example:
    translate(100px) -> scale(2) translateX(50px)
2024-03-02 12:25:53 +01:00
Matthew Olsson
892f407d75 LibWeb: Do not abort interpolation if the StyleValue types differ
This can be perfectly valid, and depends on the property being animated.
For example, interpolating between the StyleValue "none" (an identifier)
and a TransformationStyleValue is perfectly defined.
2024-03-02 12:25:53 +01:00
Matthew Olsson
15942b4262 LibWeb: Revert changing transform's animation-type to by-computed-value
In the upcoming commits where we properly handle transformation
interpolation, it actually becomes easier to change this back to custom,
so lets do that since its more correct anyways.
2024-03-02 12:25:53 +01:00
Matthew Olsson
55dfeedc46 LibGfx: Add VectorN::operator== 2024-03-02 12:25:53 +01:00
Matthew Olsson
44afc8678d LibGfx: Add an indexing operator to Matrix 2024-03-02 12:25:53 +01:00
Nico Weber
9e502dcfe4 LibPDF: Honor writing mode in TJ operator as well 2024-03-02 12:25:09 +01:00
Nico Weber
c69797fda9 LibPDF: Implement support for vertical text for Type0
For Identity-V only for now.
2024-03-02 12:25:09 +01:00
Nico Weber
6348a857ea LibPDF: Prepare for more encodings than just Identity-H in Type0 code
Introduces CIDIterator, an iterator type for iterating over CIDs.

Also introduces Type0CMap which can return a CIDIterator given some
bytes.

The existing code of treating the bytes as an identity map of
big-endian u16s is now implemented in IdentityType0CMap.

No behavior change.
2024-03-02 12:25:09 +01:00
Nico Weber
b9a4689af3 LibPDF: In Type0Font, read metrics /DW2 and /W2 for vertical text
Not used for anything yet.
2024-03-02 12:25:09 +01:00
Nico Weber
ef5d7b685d LibPDF: In Type0::initialize(), move variable increment next to cause
No behavior change.
2024-03-02 12:25:09 +01:00
Nico Weber
fc9b2440bd LibPDF: Add some spec comments in Type0Font::initialize() 2024-03-02 12:25:09 +01:00
Nico Weber
004e47df88 LibPDF: Remove minor duplication in Renderer::text_show_string_array()
This "regressed" in #10080 (back then, the branches were smaller).

No behavior change.
2024-03-02 12:25:09 +01:00
Idan Horowitz
0b7e4b335a strace: Add support for pretty-printing the prctl syscall 2024-03-02 09:10:14 +01:00
Idan Horowitz
8c562a764d strace: Add support for printing the fourth syscall argument 2024-03-02 09:10:14 +01:00
Idan Horowitz
beca73e0fd strace: Add support for pretty-printing the kill syscall 2024-03-02 09:10:14 +01:00
Idan Horowitz
c55b4d49a3 strace: Replace incorrect syscall arg2 register
Since commit e6df1c9988 which switched us
over to using the syscall/sysret instruction the second syscall
argument changed from rcx to rdi. Update strace as well to print the
actually correct values for the second arg.
2024-03-02 09:10:14 +01:00
Aliaksandr Kalenik
06c176bbfb LibGfx+LibWeb: Use ref-counted object to store glyph run
...to avoid allocating a copy of glyph run for painting commands. We
can't simply save pointers to a glyph run in layout/paintable tree
because it should be safe to deallocate layout and paintable trees
after painting commands are recorded, if in the future we decide to
move command execution to a separate thread.
2024-03-02 09:09:10 +01:00
Aliaksandr Kalenik
cf6999f5f3 LibWeb: Remove glyph run allocation in paint_text_fragment()
Instead of allocating a new glyph run to scale glyph positions and
fonts, a scale factor could be encoded in a paint command and applied
later during command execution.
2024-03-02 09:09:10 +01:00
Aliaksandr Kalenik
aeb5a0d9e8 LibWeb: Remove glyph run allocation in RecordingPainter::draw_text_run
Instead of allocating a new glyph run solely to shift each glyph by the
painter's offset, this offset could be encoded in a paint command and
applied later during command execution.
2024-03-02 09:09:10 +01:00
Hendiadyoin1
2537efaf64 LibGUI: Use HashMap::keys() to hand out the available sizes of icons 2024-03-01 14:05:53 -07:00
Hendiadyoin1
e1c663ba27 LibTLS: Move Strings when creating RelativeDistinguishedNames
Also cleans up the organizational_unit() helper to use `value_or({})`
instead of doing the same thing manually.
2024-03-01 14:05:53 -07:00
Hendiadyoin1
f7329f89aa LibTLS: Prefer structured bindings when iterating over HashMaps 2024-03-01 14:05:53 -07:00
Hendiadyoin1
d6c631ebe0 WindowServer: Prefer structured bindings when iterating over HashMaps 2024-03-01 14:05:53 -07:00
Hendiadyoin1
773a280bdf LibPDF: Use a struct for the subsection in parse_xref_stream 2024-03-01 14:05:53 -07:00
Hendiadyoin1
fe0fde2154 Userland+Tests: Remove unused <AK/Tuple.h> includes 2024-03-01 14:05:53 -07:00
Andreas Kling
d1b5f55f91 LibWeb: Make Paintable::containing_block() return a PaintableBox*
Every single client of this function was immediately calling paintable()
on the result anyway, so there was no need to return a layout node!

This automatically leverages the cached containing block pointer we
already have in Paintable, which melts away a bunch of unnecessary
traversal in hit testing and painting. :^)
2024-03-01 17:57:10 +01:00
Nico Weber
c3980eda9e LibPDF: Give Type0 CIDFontType2 a ScaledFont instead of a Font
...with the same reasoning as the previous commit.

No behavior change.
2024-03-01 17:56:59 +01:00
Nico Weber
f374ad50a1 LibPDF: Give TrueTypePainter a ScaledFont instead of a Font
This will allow us to get at the font's glyphs as paths, which will
eventually enable us to implement glyph rotation. We'll have to do our
own caching then, but we can then hopefully share the caching across the
Type0 / Type1 / TrueType codepaths.

It also gives us access to a font's glyphs by glyph id, which will help
us implementing looking up glyph ids by postscript name.  (Else we'd
have to plumb through a whole Painter::draw_glyph_by_postscript_name()
API just for LibPDF.)

No behavior change.
2024-03-01 17:56:59 +01:00
Nico Weber
5dad8b693e LibPDF: Make PDFFont::replacement_for() return a ScaledFont
We only want to load non-bitmap fallback fonts as PDF fallback fonts,
so let's make the return type represent that.

No behavior change.
2024-03-01 17:56:59 +01:00
Nico Weber
7d9294b9a4 LibGfx: Add ScaledFont::scaled_with_size()
It's like ScaledFont::with_size(), except that it guarantees that the
result is non-null and ScaledFont. (Smart pointers don't allow
covariant return types, else we could just narrow down the return
type of with_size() while still overriding the base method.)

No behavior change.
2024-03-01 17:56:59 +01:00
Andreas Kling
bc21ed151e LibJS/Bytecode: Handle awkward initialization case for duplicate var
`var` declarations can have duplicates, but duplicate `let` or `const`
bindings are a syntax error.

Because of this, we can sink `let` and `const` directly into the
preferred_dst if available. This is not safe for `var` since the
preferred_dst may be used in the initializer.

This patch fixes the issue by simply skipping the preferred_dst
optimization for `var` declarations.
2024-03-01 14:51:08 +01:00
Nico Weber
2bbdfe0fba LibPDF: Treat "Oblique" as italic indicator
The standard 14 fonts include e.g. "CourierBoldOblique" and
"HelveticaOblique". Let's map them to italic fonts :^)
2024-03-01 14:17:42 +01:00
Nico Weber
8e3c54f203 LibPDF: Implement ZapfDingbats clause of the adobe glphy list algorithm
Liberation Sans still doesn't have the vast majority of the
Zapf Dingbats glyphs, but now we map the Zapf Dingbats names to good
unicode values.  So we only need to use a different font and all should
work.  (And Liberation Sans has _some_ of the glyphs, like 13 of the
223.) And we now render empty squares instead of wrong glyphs for the
ones we don't have.

I haven't seen any PDFs using ZapfDingbats in the wild, but they
probably exist somewhere.
(Tests/LibPDF/standard-14-fonts.pdf is a synthetic PDF using it.)
2024-03-01 14:17:42 +01:00
Nico Weber
2eb099aabe LibPDF: Implement some of the AdobeGlyphList algorithm
Turns out there's a spec that goes with the table.

The big change here is that we can now map `uni1234` to 0x1234 and
`u123456` to 0x123456.

The parts where we split a name on `_` and map each component
and the part where we're supposed to allow multiple groups of 4
after `uni` aren't implemented yet.

The ZapfDingbats lookup is also still missing.

I haven't seen this have an effect in practice, but it's easy to
construct a PDF with a custom encoding where it would make a
difference.
2024-03-01 14:17:42 +01:00
Aliaksandr Kalenik
2764966ccc LibWeb: Reduce paintable tree traversals during hit-testing
By storing a list of positioned and floating descendants within the
stacking context tree node, we can eliminate the need for costly
paintable tree traversals during hit-testing.

This optimization results in hit-testing being 2 to 2.5 times faster
on https://ziglang.org/documentation/master/
2024-03-01 13:03:53 +01:00
Luke Wilde
48e11a1f12 LibWeb: Empty CE reaction queue instead of destroying it on exception
If an exception occurs in a custom element constructor, we clear the
reaction queue by destroying it, instead of emptying the Vector.
3da6916383/Userland/Libraries/LibWeb/DOM/Element.cpp (L2033)

This causes a UAF here, as async upgrades (i.e. custom elements not
created by document.createElement) are performed in this loop:
3da6916383/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp (L657)

Fixes crash when loading https://github.com/SerenityOS/serenity
2024-02-29 21:58:01 -05:00
Tim Ledbetter
5b4533cab8 LibWeb: Don't crash in offset_parent() if no ancestor element found
The specification says the final step of this algorithm is to return
null. Previously, the browser would crash if the content of an iframe
was appended to the document before its offsetParent property was
queried.
2024-02-29 21:54:53 -05:00
Aliaksandr Kalenik
90879a07ba LibWeb: Skip page scrolling for wheel events consumed by scrollable box
Fixes the bug when we scroll both scrollable box and page.
2024-02-29 13:18:57 +01:00
Gabriel Tassinari
30d8c5f301 LibLine: Ensure suggestions are reset after ^C 2024-02-29 09:09:47 +01:00
Timothy Flynn
d878975f95 AK+LibJS: Remove OFFSET_OF and its users
With the LibJS JIT removed, let's not expose pointers to internal
members.
2024-02-29 09:00:00 +01:00
Tim Ledbetter
4646a87eba LibWeb: Make CSSConditionRule.conditionText read-only
Previously @media rule conditions could be updated by assigning to
`conditionText`. This change aligns our implementation with the CSSOM
specification, which says `CSSConditionRule.conditionText` should be
read-only.
2024-02-28 22:14:58 +01:00
implicitfield
b08fd1b9ae LibWeb: Improve support for 'vertical-align: middle'
This rebaselines a few table-related layout tests since our default
stylesheet applies 'vertical-align: middle' to a few table-related
elements.
2024-02-28 16:11:05 -05:00
Nico Weber
41e0a0f0aa LibGfx/OpenType: Add named constants for header tags
...together with spec comments.

No behavior change.
2024-02-28 16:00:07 -05:00
Nico Weber
36bbf12b73 LibGfx: Add FourCC::from_u32() 2024-02-28 16:00:07 -05:00
Nico Weber
53c6dfacd7 LibGfx: IWYU for FourCC.h
Makes clangd-induced red squigglies disappear when editing this file.

No behavior change.
2024-02-28 16:00:07 -05:00
Nico Weber
86203974f5 LibGfx/OpenType: Extract read_tag() function 2024-02-28 16:00:07 -05:00
Nico Weber
93038f6f24 LibGfx/OpenType: Extract for_each_table_record() helper
Separates table record iteration from doing something with the table
records, which is arguably easier to read.

No behavior change.
2024-02-28 16:00:07 -05:00
Andreas Kling
953573565c LibJS/Bytecode: Cache realm, global object, and more in interpreter
Instead of looking these up in the VM execution context stack whenever
we need them, we now just cache them in the interpreter when entering
a new call frame.
2024-02-28 21:09:09 +01:00
Andreas Kling
01e9eee7dd LibJS/Bytecode: Avoid Value==Value in Call built-in fast path
Comparing two Values has to call the generic same_value() helper,
and we can avoid this by simply using a stronger type for built-in
native function handlers.
2024-02-28 21:09:09 +01:00
Andreas Kling
1060c63bd8 LibJS: Mark ThrowCompletionOr member functions as ALWAYS_INLINE
Some of them stood out in a profile, and they have no business doing so.
2024-02-28 21:09:09 +01:00
Timothy Flynn
3d2794d062 LibJS: Add a fast path for setting valid u32 values in Uint32TypedArray
The exisiting fast path only permits for valid i32 values.

On https://cyxx.github.io/another_js, this eliminates the runtime of
typed_array_set_element, and reduces the runtime of put_by_value from
11.1% to 7.7%.
2024-02-28 19:41:11 +01:00
Timothy Flynn
d0d22304e4 Revert "LibJS: Add fast path for getting the TA length of valid TAs"
This reverts commit 9c943f36ed.

This optimization is superseded by optimizing IsValidIntegerIndex for
TypedArrays with non-resizable ArrayBuffers. Reverting this commit has
no impact on test-js, test262, or live website performance.
2024-02-28 19:41:11 +01:00
Timothy Flynn
98552bf4c9 Revert "LibJS: Add fast path for checking if attached TAs are OOB"
This reverts commit 5fd53652b7.

This optimization is superseded by optimizing IsValidIntegerIndex for
TypedArrays with non-resizable ArrayBuffers. Reverting this commit has
no impact on test-js, test262, or live website performance.
2024-02-28 19:41:11 +01:00
Timothy Flynn
d8eb297b95 Revert "LibJS: Add fast path for creating a TA record for attached TAs"
This reverts commit 72cee4c88b.

This optimization is superseded by optimizing IsValidIntegerIndex for
TypedArrays with non-resizable ArrayBuffers. Reverting this commit has
no impact on test-js, test262, or live website performance.
2024-02-28 19:41:11 +01:00
Timothy Flynn
08ad2d774e LibJS: Optimize IsValidIntegerIndex for TAs with non-resizable buffers
If we know the TA does not have a resizable ArrayBuffer, we can avoid
most of the heavy lifting that IsValidIntegerIndex performs.

On https://cyxx.github.io/another_js, this reduces the runtime of
IsValidIntegerIndex from 7.1% to 3.7%.
2024-02-28 19:41:11 +01:00
Aliaksandr Kalenik
b821f7b283 LibWeb: Implement scrollbar painting
Introduces the rendering of scroll thumbs in vertical and horizontal
directions. Currently, the thumbs are purely graphical elements that
do not respond to mouse events. Nevertheless, this is beneficial as it
makes it easier to identify elements that should respond to scrolling
events.

Painting of scrollbars uncovers numerous bugs in the calculation of
scrollable overflow rectangles highlighting all the places where
elements are made scrollable whey they shouldn't be. Positively, this
issue might motivate us to pay more attention to this problem to
eliminate unnecessary scrollbars.

Currently, the scrollbar style is uniform across all platforms: a
semi-transparent gray rectangle with rounded corners.

Also here we add `scrollbar-width: none` to all existing scrolling
ref-tests, so they keep working with this change.
2024-02-28 07:51:13 -05:00
Aliaksandr Kalenik
8d9e20cb03 LibWeb: Parse the CSS scrollbar-width property 2024-02-28 07:51:13 -05:00
Aliaksandr Kalenik
c74fc4c171 LibWeb: Clean previous border radii clips in refresh_clip_state()
The list of border radii clips needs to be reset before being populated
with new clips that have refreshed positions. Besides fixing painting,
this also improves performance because the number of sample/blit
commands does not increase as we scroll.
2024-02-28 07:44:12 -05:00
Aliaksandr Kalenik
91378ded96 LibWeb: Apply scroll offset after clip in PaintableBox::before_paint()
The order is important because clip rectangles are calculated with the
scroll offset taken into account. Therefore, they need to be applied
before the scroll offset is changed, to avoid accounting for the scroll
offset twice.
2024-02-28 07:44:12 -05:00
Tim Ledbetter
ae42c6ed80 LibWeb: Implement AbortSignal.timeout()
This method returns a signal that will automatically abort after a
given number of milliseconds.
2024-02-28 07:42:43 -05:00
Tim Ledbetter
3c288c96e6 LibWeb: Extract run_steps_after_a_timeout() into a separate function 2024-02-28 07:42:43 -05:00
Matthew Olsson
aca32e298d LibWeb: Expand shorthand properties in CSS @keyframes 2024-02-28 08:05:41 +00:00
Bastiaan van der Plaat
05e78dabdb LibWeb: Add textarea readonly support 2024-02-27 18:03:20 -05:00
Nico Weber
9aa31157d5 LibPDF: Use right encoding for standard fonts Symbol and ZapfDingbats
We use Liberation Sans for the actual glyph for these, and that's
missing some (Symbol) / all (ZapfDingbats) of the glyphs we need
for these two standard fonts (...or at least the mapping from
name to glyph, not sure). But still, better rendering squares than
completely incorrect glpyhs.

Our code deciding what to do when a value isn't found in an encoding,
or when the name doesn't map to a glpyh, also needs work, but that's
mostly independent of this change. I think this is a nice small
standalone progression.
2024-02-27 17:42:08 -05:00
Nico Weber
76105d5d7f LibPDF: Resize images to the larger of image and mask dimensions
Makes text show up on 0000646.pdf pages 87-92, which for some reason
renders all text using 2x2 images with huge masks that contain
rendered text outlines.
2024-02-27 17:39:13 -05:00
Nico Weber
472bc367d3 LibPDF: Do not have redundant variables for image size
This way, the size of the bitmap cannot become out of sync with these
variables.

No behavior change.
2024-02-27 17:39:13 -05:00
Timothy Flynn
c7c4987967 LibJS: Store a TypeArray's element size upon construction
This avoids a virtual dispatch upon invoking the element size getter.
The size is static, so we could make TypedArrayBase templated with a
NTTP for the size, but let's not undergo such a wide-spread refactor.

On https://cyxx.github.io/another_js, this reduces the runtime of
IsValidIntegerIndex from 8.9% to 7.1%.
2024-02-27 20:02:07 +01:00
Timothy Flynn
17e2f751c5 LibJS: Add an explicit DataBlock::size method
This avoids visiting the underlying buffer twice from ArrayBuffer's
byte_length.

On https://cyxx.github.io/another_js, this reduces the runtime of
IsValidIntegerIndex from 9.9% to 8.9%.
2024-02-27 20:02:07 +01:00
Timothy Flynn
72cee4c88b LibJS: Add a fast path for creating a TA witness record for attached TAs
In IsValidIntegerIndex, we check if the TA is detached before invoking
MakeTypedArrayWithBufferWitnessRecord. There's no need to check it
again.

On https://cyxx.github.io/another_js, this reduces the runtime of
IsValidIntegerIndex from 10.7% to 9.9%.
2024-02-27 20:02:07 +01:00
Timothy Flynn
5fd53652b7 LibJS: Add a fast path for checking if attached TAs are out of bounds
In IsValidIntegerIndex, we check if the TA is detached before invoking
IsTypedArrayOutOfBounds. There's no need to check it again.

On https://cyxx.github.io/another_js, this reduces the runtime of
IsValidIntegerIndex from 11.5% to 10.7%.
2024-02-27 20:02:07 +01:00
Timothy Flynn
84936c9ab6 LibJS: Inline the ArrayBufferByteLength implementation
Note: When we better support SharedArrayBuffer, that part of this AO
might not be inlined, as it looks a bit expensive.

On https://cyxx.github.io/another_js, this reduces the runtime of
IsValidIntegerIndex from 12.5% to 11.5%.
2024-02-27 20:02:07 +01:00
Timothy Flynn
9c943f36ed LibJS: Add a fast path for getting the TA length of known valid TAs
In IsValidIntegerIndex, we check IsTypedArrayOutOfBounds before invoking
TypedArrayLength. There's no need to check it again.

On https://cyxx.github.io/another_js, this reduces the runtime of
IsValidIntegerIndex from 16% to 12.5%.
2024-02-27 20:02:07 +01:00
Timothy Flynn
6656f70387 LibWeb: Use TypedArray as a forward-declaration where appropriate
This reduces the number of files needed to be recompiled when TypedArray
changes from ~1000 to ~600. The remaining ~600 are almost all generated
constructors and prototypes.
2024-02-27 20:02:07 +01:00
Aliaksandr Kalenik
a0dc9584de LibWeb: Add "object-position" CSS property into ComputedValues 2024-02-27 16:53:13 +01:00
Aliaksandr Kalenik
677a00ed92 LibWeb: Add "object-fit" CSS property into ComputedValues 2024-02-27 16:53:13 +01:00
Aliaksandr Kalenik
22da83c295 LibWeb: Resolve "object-position" without unwrapping raw percentage
Use `to_px()` that accepts reference value instead.

No behaviour change intended.
2024-02-27 16:53:13 +01:00
Aliaksandr Kalenik
6f5a0bd5de LibWeb: Save image provider in ImagePaintable
Refactoring towards making paintable be independant from layout nodes.

No behaviour change intended.
2024-02-27 16:53:13 +01:00
Aliaksandr Kalenik
ef01c735cd LibWeb: Visit ImageProvider from Layout::ImageBox
Adds missing visit of HTMLElement that serves as image provider of
image layout node.
2024-02-27 16:53:13 +01:00
Aliaksandr Kalenik
9fa22b60cf LibWeb: Save alt text in ImagePaintable
By saving string with alt text, image paintable no longer need to reach
into layout and DOM nodes while painting commands recording.

No behaviour change intended.
2024-02-27 16:53:13 +01:00
Sam Atkins
c2bc07ef7c LibCore: Use Core::Environment::raw_environ() instead of environment() 2024-02-27 08:33:48 +00:00
Sam Atkins
40b04d4da5 Shell: Use Core::Environment instead of manually iterating environ 2024-02-27 08:33:48 +00:00
Sam Atkins
97cb9cf469 LibCore: Use Core::Environment instead of manually iterating environ 2024-02-27 08:33:48 +00:00
Sam Atkins
56b8e248a5 LibCore: Remove now-unused Core::System::*env() functions
These have been moved to Core::Environment.
2024-02-27 08:33:48 +00:00
Sam Atkins
c6b9ce22ef LibSQL: Use Core::Environment instead of Core::System::*env() 2024-02-27 08:33:48 +00:00
Sam Atkins
f4e6f5c1cc SystemServer: Use Core::Environment instead of Core::System::*env() 2024-02-27 08:33:48 +00:00
Sam Atkins
7109f3706e Utilities: Use Core::Environment instead of Core::System::*env() 2024-02-27 08:33:48 +00:00
Sam Atkins
b9dc2d7ebf LibCore: Introduce Core::Environment wrapper
Core::System already had some wrappers for *env() functions, which I've
copied over. But 1) the set of functions there was incomplete, and 2)
the environment feels like an object in its own right, so let's treat it
as one. :^)

Also add `Core::Environment::has(StringView)` for situations where we
just care if a variable is defined.
2024-02-27 08:33:48 +00:00
Andreas Kling
55dc69625a LibJS/Bytecode: Fix formatting of operand lists in bytecode dumps
There was an unterminated color escape sequence which caused "args"
to look like "rgs" when dumping Call instructions.
2024-02-27 07:44:18 +01:00
Nico Weber
83d29b3e45 LibPDF: Hack around a FIXME in TrueTypePainter::get_glyph_width()
This will need further thought once we implement support for the
truetype 'post' table, but for now it's correct most of the time,
and better than not doing it.
2024-02-27 07:02:27 +01:00
Nico Weber
448eaa2966 LibPDF: Let Type1Font use TrueTypePainter for standard fonts
...and for fallback fonts too.

We use Liberation Sans (a truetype font) for standard and fallback
fonts. So we should use the standard PDF algorithm for mapping bytes
to truetype glyphs. TrueTypePainter knows how to do this.

Makes the "fi" ligature in the title on page 1 of 5014.CIDFont_Spec.pdf
or the dotless-i in the title of page 2 of ThinkingInPostScript.pdf
show up. They use Helvetica and TImes, and Helvetica and Symbol
respecitively (with -Bold variants).
2024-02-27 07:02:27 +01:00
Nico Weber
86a7753d65 LibPDF: Move TrueType painting into a new class
No behavior change.
2024-02-27 07:02:27 +01:00
Nico Weber
84d1e3956f LibPDF: Make truetype ascent adjustment more local
It's only used in this function.

No behavior change.
2024-02-27 07:02:27 +01:00
Nico Weber
b11aaca609 pdf: Honor page rotation 2024-02-27 07:02:02 +01:00
Nico Weber
03fab7089a LibPDF+PDFViewer: Extract Renderer::apply_page_rotation()
No behavior change.
2024-02-27 07:02:02 +01:00
Nico Weber
5e9395b808 pdf: Make render_page() take a Page instead of page_index
No behavior change.
2024-02-27 07:02:02 +01:00
Nico Weber
29f5182e51 LibGfx+PDFViewer: Add RotationDirection::Flip and use it in PDFViewer
No behavior change.
2024-02-27 07:02:02 +01:00
Nico Weber
5b223080ae LibGfx: Make RotationDirection an enum class
All code pretended it was one already.

No behavior change.
2024-02-27 07:02:02 +01:00
Nico Weber
75e5ed7aea LibGfx: Survive empty simple glyphs with 0 contours
Some fonts have empty slices for glyphs with 0 contours, even though
the spec requires them to store a 0 for instructionLength as far as
I can tell. But let's not assert on invalid fonts like this, but instead
handle them gracefully.

Supersedes #22570.

Fixes the last two crashes on my 1000-file test set: 0000246.pdf and
0000431.pdf.
2024-02-27 07:01:05 +01:00
Nico Weber
cafaaa0e76 LibPDF: Don't crash on zero-width characters in type1 fonts
Since ScaledFont bakes the size of the font into the font type, we
do the same for Type1 fonts, and then have to divide by the font height
when figuring out what to scale by. For a target width of 0, chances are
the source width is also 0, and we end up with NaN due to dividing
0 by 0. This then triggered the `VERIFY(isfinite(error))` in
can_approximate_bezier_curve() in Painter.cpp.

Check for this case and scale by 0 instead of dividing.

It could happen that the denominator is 0 without the numerator being 0,
but it's not clear what that's supposed to mean. In this case we'd end
up with +inf/-inf, which would also trigger the assert. I haven't seen
this case in practice, so let's not worry about that for now.

(A nicer longer-term fix is probably to make LibPDF use VectorFont
instead of ScaledFont, so that we don't have to bake the font size into
the font type. Then we won't need this division at all. In the meantime,
this fixes the crash.)

Fixes a crash on page 66 of
https://developer.apple.com/library/archive/documentation/mac/pdf/Text.pdf

Fixes a crash on page 37 of
https://open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf

Fixes crashes in `0000310.pdf`, `0000430.pdf`, `0000229.pdf`.

Brings down the number of crashes on my 1000 file test set from
5 with 3 distinct stacks to 2 with 1 distinct stack.

(The number went up from 3 crashes with 2 distinct stacks to 5/3 when we
started rendering much more text when Type0 font support was added.
This fixes the crashes we had before Type0 support.)
2024-02-27 07:01:05 +01:00
Tim Ledbetter
ee765e241e LibWeb: Allow performance timestamps to have sub-millisecond precision
Rather than returning the number of whole elapsed milliseconds, we now
return the number of elapsed nanoseconds divided by one million. This
allows us to make use of the fractional part of the double that is
returned.
2024-02-26 16:12:20 -07:00
Tim Ledbetter
05c571bf9b LibWeb: Use a precise timer for performance timestamps 2024-02-26 16:12:20 -07:00
Tim Ledbetter
679fe00d10 LibCore+Utilities: Replace ElapsedTimer precise flag with an enum
Previously, `true` was passed into the ElapsedTimer constructor if a
precise timer was required. We now use an enum to more explicitly
specify whether we would like a precise or a coarse timer.
2024-02-26 16:12:20 -07:00
Kenneth Myhra
0b64a71603 LibWeb: Make File a Serializable object 2024-02-26 16:10:20 -07:00
Kenneth Myhra
27445f3132 LibWeb: Add ability to {,de}serialize platform objects
This adds the ability to serialize and deserialize serializable platform
object in structured_serialize() and structured_deserialize().
2024-02-26 16:10:20 -07:00
Kenneth Myhra
394c38729f LibWeb: Make Blob a Serializable object 2024-02-26 16:10:20 -07:00
Kenneth Myhra
fc12402b49 LibWeb: Add abstract class Serializable
This adds the abstract class Serializable which platform objects defined
as Serializable objects can implement to support their appropriate
serialization and deserialization steps.
2024-02-26 16:10:20 -07:00
Kenneth Myhra
dcf5ff5178 LibWeb: Move serialize_* methods outside scope of Serializer class
These methods are useful independent of the class Serializer, so let's
move their declarations to the header file and and outside the scope of
the Serializer class.
2024-02-26 16:10:20 -07:00
Kenneth Myhra
985d0dd270 LibWeb: Move deserialize_* methods outside scope of Deserializer class
These methods are useful independent of the class Deserializer, so let's
move their declarations to the header file and and outside the scope of
the Deserializer class.
2024-02-26 16:10:20 -07:00
implicitfield
414bfed6fe mkfs.fat: Add support for autodetecting FAT type based on file size 2024-02-26 13:26:47 -07:00
implicitfield
f4112a0f65 mkfs.fat: Prefer using AK::Array over C-style arrays 2024-02-26 13:26:47 -07:00
implicitfield
012f2fd712 mkfs.fat: Fill in the last known free cluster count hint
This allows generated FAT32 file systems to pass fsck.fat without
tripping any warnings.
2024-02-26 13:26:47 -07:00
implicitfield
e91f60e0f5 CMake: Replace bespoke utility name mangling logic
Instead of manually removing the '.cpp' extension, we can simply ask
CMake to give us the file name without the last extension.
2024-02-26 13:26:47 -07:00
Aarushi Chauhan
564e619f57 AboutDialog: Port to GML Complier 2024-02-26 13:20:42 -07:00
Andrew Kaster
0a55749a39 Ladybird+Userland: Use ByteString for candidate server paths
We've adopted a stance that paths should be ByteStrings rather than
UTF-8 strings, so apply that to the Ladybird helpers.
2024-02-26 13:16:27 -07:00
Andrew Kaster
9918dcd4d5 LibWebView: Extend GENERATED_SOURCES list instead of replacing 2024-02-26 13:16:27 -07:00
Lucas CHOLLET
fb81668d8f LibGfx/JPEGLoader: Check earlier for quantization tables presence
This patch brings few small QoL improvements:
 - We don't need to read the Huffman stream before returning an error
   due to a missing quantization table.
 - We check the table presence only once per scan instead of once per
   MCU.
 - `dequantize()` is now infallible.
2024-02-26 20:13:25 +00:00
Bastiaan van der Plaat
c41b359ca5 LibWeb: Use WebIDL types where possible instead of C types 2024-02-26 19:26:13 +00:00
Timothy Flynn
f1d6693990 LibWebView: Reduce overhead of updating a cookie's last access time
Getting a document's cookie value currently involves:

1. Doing a large SELECT statement and filtering the results to match
   the document and some query parameters based on the cookie RFC.
2. For every cookie selected this way, doing an UPDATE to set its last
   access time.
3. For every UPDATE, do a DELETE to remove all expired cookies.

There's no need to perform cookie expiration for every UPDATE. Instead,
we can do the expiration once after all the UPDATEs are complete.

This reduces time spent waiting for cookies on https://twinings.co.uk
from ~1.9s to ~1.3s on my machine.
2024-02-26 19:59:09 +01:00
Timothy Flynn
ab4d4f0711 Browser: Implement the <input type=file> UI 2024-02-26 14:18:49 +01:00
Timothy Flynn
108521a566 LibWeb+LibWebView+WebContent: Implement more <input type=file> behavior
We had previous implemented some plumbing for file input elements in
commit 636602a54e.

This implements the return path for chromes to inform WebContent of the
file(s) the user selected. This patch includes a dummy implementation
for headless-browser to enable testing.
2024-02-26 14:18:49 +01:00
Timothy Flynn
435c2c24d1 LibWeb: Create a shadow tree for <input type=file> elements
This creates a button to prompt users to select a file, and a label to
show information about the selected file(s). Clicking either shadow
element will activate the input element.
2024-02-26 14:18:49 +01:00
Timothy Flynn
8319c7cfb8 LibWeb: Move code to update HTMLInputElement's shadow tree to a helper
We currently copy-paste a series of if statements to selectively update
the shadow tree elements for some <input> types. This will soon become
longer as more shadow trees are implemented for other types.

This patch just moves those checks to a single location to make adding
more shadow trees easier.
2024-02-26 14:18:49 +01:00
Ali Mohammad Pur
5232afa13d RequestServer+LibProtocol: Make starting requests fully async
This makes it so the clients don't have to wait for RS to become
responsive, potentially allowing them to do other things while RS
handles the connections.
Fixes #23306.
2024-02-26 14:13:37 +01:00
Aliaksandr Kalenik
18d26142f0 LibWeb: Skip StackingContext with erroneously large rect in GPU painter
If the GPU painter encounters a stacking context that requires the
allocation of a framebuffer so large, it is likely due to a layout
mistake, for now, we can skip it instead of crashing because of a
failed allocation.

Fixes https://github.com/SerenityOS/serenity/issues/22608
2024-02-26 07:40:42 +01:00
Sönke Holz
6d48b6724d LibELF: Ignore mapping symbols when symbolicating RISC-V ELFs 2024-02-25 17:33:39 -07:00
Dan Klishch
120d6b2f21 LibCore: Decouple handling of timers and waiting for events
This introduces a new TimeoutSet class for use in
EventLoopImplementationUnix. It is responsible for finding a timer that
expires the soonest and for firing expired timers. TimeoutSet expects
timeouts to be subclasses of EventLoopTimeout, of which EventLoopTimer
is now a subclass, obviously.

TimeoutSet stores timeouts in a binary heap, so
EventLoopImplementationUnix should handle large amounts of timers a lot
better now.

TimeoutSet also supports scheduling of timeouts whose fire time is
relative to the start of the next event loop iteration (i. e. ones
that directly bound polling time). This functionality will reveal its
full potential later with the implementation of asynchronous sockets but
it is currently used to implement zero-timeout timers that are an analog
of Core::deferred_invoke with slightly different semantics.
2024-02-25 17:24:36 -07:00
Dan Klishch
b77996884e LibCore+Ladybird: Don't force timer ids to be integer just to remap them
If we don't force event loop to fit timer id into integer, we can
eliminate awkward IDAllocator inside EventLoopImplementations.
2024-02-25 17:24:36 -07:00
Dan Klishch
bed4af6fef LibCore+Ladybird: Make unregistering timer infallible
Let's force calling code to provide valid timer ids. No code changes are
required since, surprise, nobody used this obscure functionality.
2024-02-25 17:24:36 -07:00
Dan Klishch
21097d1c9e LibCore+Ladybird: Don't store timer_id in Core::TimerEvent 2024-02-25 17:24:36 -07:00
Matthew Olsson
0f54d797d2 LibWeb: Handle pre-existing animations when considering animation-name
If a DOM::Element has an animation-name property, then in addition to
remembering where it came from, it will also remember the
Animations::Animation object that was created for it. This allows
StyleComputer to cancel that animation if the animation-name property
changes as well as to apply any changes required (for example, if
animation-play-state changes from "running" to "paused", it needs to
call .pause() on the animation).
2024-02-25 21:12:42 +00:00
Matthew Olsson
b235620315 LibWeb: Pause keyframe animations during creation when necessary 2024-02-25 21:12:42 +00:00
Matthew Olsson
2ee022dead LibWeb: Set KeyframeEffect's pseudo-element if applicable 2024-02-25 21:12:42 +00:00
Matthew Olsson
921f6c1e78 LibWeb: Run play tasks before pause tasks
The logic of play() and pause() assumes this to be the case
2024-02-25 21:12:42 +00:00
Timothy Flynn
090dbac5a3 Revert "LibWeb: Allow bypassing transient activation checks for tests"
This reverts commit e52c30cbd5.

It's highly possible that this test was flaky on CI due to mixing units
of seconds and milliseconds in the transient activation calculation.
Revert the workaround for that commit in an attempt to avoid needless
ad-hoc behavior.
2024-02-25 12:35:49 -05:00
Timothy Flynn
8d7a5afe58 LibWeb: Increase the transient activation duration from 5ms to 5s
It seems we were errantly mixing seconds and milliseconds in this
transient activation timeout. Increase it to 5 seconds, and be explicit
about its type - DOMHighResTimeStamp is by definition milliseconds.
2024-02-25 12:35:49 -05:00
Nico Weber
83128d093e LibPDF: Implement most of the spec algorithm for picking TrueType glyphs
Non-CID-keyed fonts in PDFs have 8-bit codepoints which are mapped from
bytes to character names via encoding.

TrueType fonts don't index glyphs by name (Type1 fonts do), so the fix
(codified in the spec) was to make a list of all possible glyph names
and map those to (16-bit) unicode values, and then pass those into the
truetype cmap.

(As a fallback, we're supposed to look at the optional names in the
font's "post" table. That part isn't implemented here yet.)

(Note that this affects the behavior of fallback fonts for TrueType
fonts, but not yet fallback fonts for Type1 fonts, and neither the
behavior of the 14 built-in Type1 fonts (which we implement as
fallback fonts), since the TrueType fallback in Type1Font.cpp does
not use this algorithm yet. This will be fixed in a future patch.)
2024-02-25 15:15:20 +01:00
Nico Weber
207717982c LibPDF: Read /Flags off font descriptors 2024-02-25 15:15:20 +01:00
Andreas Kling
a61f09a010 LibWeb: Stretch-fit flex items with aspect ratio but no fixed sizes
This solves a particular issue with SVG as flex items, where the SVG has
an intrinsic aspect ratio via its viewBox, but no explicit natural width
or height.

Makes all corporate sponsor logos show up on https://ziglang.org/ :^)
2024-02-25 14:06:06 +01:00
Shannon Booth
92a7fd77f4 LibJS: Crash on allocation failure in DurationPrototype
The String::from_utf8 calls here are also guaranteed to be given a valid
UTF-8 string.
2024-02-25 07:51:28 -05:00
Shannon Booth
c063bf39a9 LibJS: Make ToRelativeTemporalObject return a RelativeTo struct
This follows a change in the spec which refactored this function and its
callers to make use of a record instead of stuffing all of the possible
return values into a single Value.

As always in temporal land, this AO remains out of date, as well of all
its callers. Update all of these callers to the new API where possible,
and use an ad-hoc function to convert this struct back to a JS::Value
for APIs that have not been updated yet.
2024-02-25 07:51:28 -05:00
Shannon Booth
fa692ae3f6 LibJS: Implement Temporal's Time Zone Methods Record
Similar to 'Calendar Methods Record', this is part of a refactor to the
temporal spec which will need much work for all of the corresponding AOs
to be updated to use.

Put in a new header file to prevent circular include problems when using
this new record.
2024-02-25 07:51:28 -05:00
Shannon Booth
15977ea42f LibJS: Put roundTo argument into a variable
Following the pattern we have in other protoypes to avoid a magic
number index into the zeroth argument.
2024-02-25 07:51:28 -05:00
Andreas Kling
b7f80e7081 LibWeb: Put debug spam about failed favicon decodes behind a flag 2024-02-25 13:34:21 +01:00
Aliaksandr Kalenik
bc640b72b1 LibWeb: Remove spammy dbgln about unsupported SVG mask content units
This one was annoying because it was printed before each repaint on
pages where this FIXME is relevant.
2024-02-25 11:11:25 +01:00
Aliaksandr Kalenik
e3c75d7b6f LibWeb: Add HTMLElement::is_content_editable() 2024-02-25 10:17:25 +01:00
Aliaksandr Kalenik
934aa6af6a LibWeb: Emit "focusin" and "focusout" events 2024-02-25 10:17:25 +01:00
Aliaksandr Kalenik
cd7b5b18e4 LibWeb: Emit "selectionchange" event on document 2024-02-25 10:17:25 +01:00
Shannon Booth
9ce8189f21 Everywhere: Use unqualified AK::URL
Now possible in LibWeb now that there is no longer a Web::URL.
2024-02-25 08:54:31 +01:00
Shannon Booth
f9e5b43b7a LibWeb: Rename URL platform object to DOMURL
Along with putting functions in the URL namespace into a DOMURL
namespace.

This is done as LibWeb is in an awkward situation where it needs
two URL classes. AK::URL is the general purpose URL class which
is all that is needed in 95% of cases. URL in the Web namespace
is needed predominantly for interfacing with the javascript
interfaces.

Because of two URLs in the same namespace, AK::URL has had to be
used throughout LibWeb. If we move AK::URL into a URL namespace,
this becomes more painful - where ::URL::URL is required to
specify the constructor (and something like
::URL::create_with_url_or_path in other places).

To fix this problem - rename the class in LibWeb implementing the
URL IDL interface to DOMURL, along with moving the other Web URL
related classes into this DOMURL folder.

One could argue that this name also makes the situation a little
more clear in LibWeb for why these two URL classes need be used
in the first place.
2024-02-25 08:54:31 +01:00
Shannon Booth
1b6346ee1c LibWeb: Add support for implementing an IDL class with a different name
Add support for the extended attribute "ImplementedAs" for IDL
interfaces too. This allows a class which implements an IDL interface to
have a different class name than the interface itself.
2024-02-25 08:54:31 +01:00
Matthew Olsson
62f62a0e52 LibWeb: Correctly set timing function in AnimationEffect::update_timing
Also pulls out the parse_easing_string function out since it will be
needed elsewhere
2024-02-25 08:51:50 +01:00
Matthew Olsson
b33bb0997a LibWeb: Move easing parsing code out into a dedicated function
This will be used outside of StyleComputer
2024-02-25 08:51:50 +01:00
Matthew Olsson
c8b9c137a1 LibWeb: Handle discrete properties
This also changes transform's animation-type to by-computed-value. It is
far easier to handle since we switch on StyleValue::type(), and it might
be the case that this applies to all custom animated properties and we
don't need "custom" at all, but let's wait until we get to those
properties to make that decision.
2024-02-25 08:51:50 +01:00
Matthew Olsson
ee63c729e5 LibWeb: Expand shorthand properties in KeyframeEffect 2024-02-25 08:51:50 +01:00
Matthew Olsson
9e0ff9c140 LibWeb: Expose CSS shorthand -> longhand conversion
This conversion needs to be done by KeyframEffect as well
2024-02-25 08:51:50 +01:00
Matthew Olsson
af1f0c673e LibWeb: Remove old animation-direction handling from StyleComputer
This is now handled by Web Animations, so if the animation was ever
running backwards, this logic would re-reverse it so that it played
forwards again.
2024-02-25 08:51:50 +01:00
Matthew Olsson
70ded2ef42 LibGfx: Add Oklab support to Gfx::Color
Interpolation of color on the web is done via the oklab colorspace
2024-02-25 08:51:50 +01:00
Domenico Iezzi
71a784741f LibGUI: Add Calendar property for mode
If a user selects Year as the default view mode for Calendar app, then
all apps using Calendar widget will default to this view if not
manually overridden with a Calendar::toggle_mode call.

This commit introduces a "mode" property that allows the selection of
the default mode for the calendar widget in GML files. In this way
there is no need to manually call toggle_mode when constructing
UIs with Calendar widget.
2024-02-24 18:54:51 -07:00
Domenico Iezzi
1153068407 LibGUI: Remove redundant Widget::update calls from DatePicker
In DatePicker constructor, calling to Widget::update after
Calendar::update_tiles is redundant since it is already called
internally by update_tiles.

This commit also remove unused header files from DatePicker header.
2024-02-24 18:54:51 -07:00
Domenico Iezzi
bc9bba1d9b LibGUI: Explicitly fire a resize event when toggling Calendar mode
Calendar::toggle_mode function performed a call to Widget::resize with
swapped width and height parameters as a quick way to trigger a
resize_event (resize event is generated only when the new rect size is
different from the old one, hence the swapped parameters).

This method does not work when width and height are equal, such as in
the DatePicker widget where width and height are fixed to 200x200. In
such case, calls to Calendar::toggle_mode would not generate a resize
event, leaving tiles uninitialized, therefore the widget was not able
to properly paint the Month view.

This commit replaces Widget::resize call with a manual triggering of
the event.
2024-02-24 18:54:51 -07:00
Hediadyoin1
21a21c6a11 LibDeviceTree: Add a simple DeviceTree class
This makes it easier to work with device tree nodes and properties, then
writing simple state machines to parse the device tree.
This also makes the old slow traversal methods use the
DeviceTreeProperty helper class, and adds a simple test.
2024-02-24 16:43:44 -07:00
Hendiadyoin1
d6bb5579ad LibDeviceTree: Make the dump more akin to the original fdtdump
This also makes it possible to compile the library in the Kernel
2024-02-24 16:43:44 -07:00
Bastiaan van der Plaat
089a98607c LibWeb: Add HTMLPreElement width property 2024-02-24 16:35:11 -07:00
Hugh Davenport
2e8ff1855c Browser: Allow system shortcuts to function
Before shortcuts like ALT-F4, etc did not work. This makes the window
ignore keydown events. In the future this may be altered to allow for
custom shortcuts from within ladybird?
2024-02-24 16:30:50 -07:00
Lucas CHOLLET
cb03ab4a5a LibPDF: Handle the BlackIs1 parameter of the CCITTFaxDecode Filter 2024-02-24 16:24:45 -07:00
Lucas CHOLLET
6b3bab5c8a LibPDF: Plug in the CCITTFaxDecode filter to our CCITT decoder
We only call the decoder for Group 4 images. We do support Group 3
images, but let's wait to find a PDF with these before adding support.
2024-02-24 16:24:45 -07:00
Sönke Holz
0b0ea19d12 LibELF+readelf: Add support for RISC-V dynamic relocation types 2024-02-24 16:05:50 -07:00
Sönke Holz
f8628f94b8 LibELF: Refactor how arch-specific dynamic relocation types are handled
We currently expect that the relocation type numbers are unique across
all architectures. But RISC-V and x86_64 use the same numbers for
different relocation types (R_X86_64_COPY = R_RISCV_JUMP_SLOT = 5).

So create a generic reloc type enum which maps to the arch-specific
reloc types instead of checking for all arch reloc types individually
everywhere.
2024-02-24 16:05:50 -07:00
Tim Ledbetter
f3a68fc80d mktemp: Ensure --tmpdir and template paths are concatenated correctly
Previously, using the `--tempdir` option with a template containing a
path didn't work correctly, as the template path would be discarded.
2024-02-24 15:57:14 -07:00
implicitfield
84252db976 Utilities: Add mkfs.fat
This adds a basic `mkfs.fat` utility, which can format FAT12, FAT16
and FAT32 partitions.

This does have a few limitations, namely in that FAT12 formatting is
limited to a set known floppy disk sizes, and we can only generate
512-byte sectors.
2024-02-24 15:54:52 -07:00
implicitfield
f2503b2048 CMake: Allow the names of utilities to contain extensions
Previously, we would remove the "longest extension" from each file name
when parsing it as the name of a utility, which made it impossible for
the names of utilities to contain any extensions.
2024-02-24 15:54:52 -07:00
implicitfield
8384bb138e LibFileSystem: Add a helper to get the size of a block device 2024-02-24 15:54:52 -07:00
implicitfield
a70d79ff98 LibFileSystem: Add a helper to get the file size from fstat 2024-02-24 15:54:52 -07:00
implicitfield
896f213c6f LibFileSystem+Userland: Rename size() to size_from_stat()
This reflects what the functions does more accurately, and allows for
adding functions to get sizes through other methods.

This also corrects the return type of said function, as size_t may only
hold sizes up to 4GB on 32-bit platforms.
2024-02-24 15:54:52 -07:00
Fabian Dellwing
29ef508b4e tail: Collapse repeated error handling into statement expression
Co-authored-by: Timothy Flynn <trflynn89@pm.me>
2024-02-24 15:48:36 -07:00
Fabian Dellwing
e40aca2d77 tail: Handle truncation in follow mode 2024-02-24 15:48:36 -07:00
Sönke Holz
525555181e LibELF: Add riscv64 PLT trampoline
This code is based on the aarch64 implementation.
2024-02-24 15:41:23 -07:00
Dan Klishch
8ac0e3f0e5 AK+LibJS: Remove null state from DeprecatedFlyString :^) 2024-02-24 15:06:52 -07:00
Dan Klishch
026c1caba0 LibJS: Don't use null DFS for binding_name parameters in ClassExpression 2024-02-24 15:06:52 -07:00
Dan Klishch
d558468d03 LibJS: Don't differentiate between empty and null DFS in CatchClause 2024-02-24 15:06:52 -07:00
Dan Klishch
fb2c929310 LibJS: Don't use null DFS in {Import,Export}Entry 2024-02-24 15:06:52 -07:00
Dan Klishch
78491204d9 LibJS: Don't use null DFS for break/continue statements without a label 2024-02-24 15:06:52 -07:00
Dan Klishch
761d16141d LibJS: Store DFS instead of opaque StringImpl inside StringOrSymbol
Additionally, use the second bit (instead of the first) to differentiate
between strings and symbols there. This will allow transparent
conversion of DFS to StringBase in the future.
2024-02-24 15:06:52 -07:00
Dan Klishch
a53911717f LibJS: Remove DeprecatedFlyString::impl use in PrimitiveString 2024-02-24 15:06:52 -07:00
Dan Klishch
061f902f95 AK+Userland: Introduce ByteString::create_and_overwrite
And replace two users of raw StringImpl with it.
2024-02-24 15:06:52 -07:00
Dan Klishch
86d54a8684 JSSpecCompiler: Parse arbitrarily large rational numbers in xspec mode 2024-02-24 15:03:08 -07:00
Dan Klishch
2a2e31f2ed LibCrypto: Avoid UB in BigFraction::to_byte_string for 0/x fractions 2024-02-24 15:03:08 -07:00
Tim Ledbetter
1d825f17c0 LibWeb: Remove first rule if no argument is given for remove_rule()
While this isn't explicitly mentioned in the specification, there is a
WPT test that checks for this behavior.
2024-02-24 21:59:28 +01:00
Tim Ledbetter
3ea318ca8b LibWeb: Implement CSSStyleSheet.addRule()
This is a legacy method that has been superseded by `insertRule()`,
although it is supported by all modern browser engines.
2024-02-24 21:59:28 +01:00
Tim Ledbetter
87b52a1816 LibWeb: Implement CSSStyleSheet.replaceSync()
This method behaves the same as `CSSStyleSheet.replace()` but the
operation is performed synchronously.
2024-02-24 21:59:28 +01:00
Tim Ledbetter
81c67d34eb LibWeb: Implement CSSStyleSheet.replace()
This method asynchronously replaces the content of the given stylesheet
with the content passed to it.

An exception is thrown if this method is used by a stylesheet not
created with the `CSSStyleSheet()` constructor.
2024-02-24 21:59:28 +01:00
Tim Ledbetter
d209d5a84f LibWeb: Ensure CSSStyleSheet::css_rules() always returns the same object
Instead of having a method that replaces the stylesheet's CSSRuleList,
we now have a method on CSSRuleList to modify it's underlying CSSRules.
2024-02-24 21:59:28 +01:00
Tim Ledbetter
811033ec19 LibWeb: Disallow inserting @import rules into a constructed stylesheet 2024-02-24 21:59:28 +01:00
Tim Ledbetter
b0f57a2785 LibWeb: Add CSSStyleSheet constructor binding 2024-02-24 21:59:28 +01:00
Tim Ledbetter
f303905875 LibWeb: Add the CSSStyleSheet.rules alias for CSSStyleSheet.cssRules 2024-02-24 21:59:28 +01:00
Tim Ledbetter
9b1ea4e2fc LibWeb: Add CSSStyleSheet.ownerRule attribute
This returns the `CSSImportRule` corresponding to the `@import` at-rule
that imported the stylesheet into the document. If the stylesheet
wasn't imported then this property is null.
2024-02-24 21:59:28 +01:00
Tim Ledbetter
588a031e2d LibWeb: Clamp calculated border width values to zero
Previously, a calculated CSS border-width property with a resolved
value of less than zero pixels would cause a crash.
2024-02-24 21:57:24 +01:00
Andreas Kling
8addfc14af LibWeb: Implement IntersectionObserver "intersection roots" per spec
In particular, get the implicit root correctly for intersection
observers that don't have an explicit root specified.

This makes it possible to load the Terminal app on https://puter.com/
2024-02-24 19:56:08 +01:00
Andreas Kling
8586897928 headless-browser: Don't choke on subframe load completions
This didn't break any existing tests, but I have to do this for an
upcoming test to not bring everything down.
2024-02-24 19:56:08 +01:00
Andreas Kling
9759f44faf LibWeb: Allow SVGDecodedImageData to cache bitmaps at different sizes
This avoids constantly re-rendering the same SVG image over and over
during painting when it's being used at a couple of different sizes
(for example when used as a CSS background).
2024-02-24 19:56:08 +01:00
Andreas Kling
2484324f9a LibGfx: Add hash traits for the Size family 2024-02-24 19:56:08 +01:00
Andreas Kling
11b4216e65 LibWeb: Run IntersectionObserver steps only when needed
Instead of updating IOs in every iteration of the HTML event loop,
we now only do it after a relayout, or after the viewport changes.
2024-02-24 19:56:08 +01:00
Aliaksandr Kalenik
d3f8d24abb LibWeb+WebContent: Remove PageClient::page_did_invalidate()
...and schedule repainting directly from Navigable::set_needs_display()
bypassing PageClient.
2024-02-24 16:54:55 +01:00
Aliaksandr Kalenik
c3f5dbb101 LibWeb: Paint page only if something that requires repaint happened
Resolves a performance regression from
8ba18dfd40, where moving paint scheduling
to `EventLoop::process()` led to unnecessary repaints.

This update introduces a flag to trigger repaints only when necessary,
addressing the issue where repaints previously occurred with each event
loop process, irrespective of actual changes.
2024-02-24 16:54:55 +01:00
Aliaksandr Kalenik
906ac71eca LibWeb: Fix crashing after input into empty contenteditable
Change `EventHandler::handle_keydown()` to no longer assume the cursor
position's node is always a `DOM::Text`. While this assumption holds
for `HTMLInputElement` that has a shadow DOM with a text node, an empty
`contenteditable` might not have any children. With this change,
`handle_keydown()` creates a new text node if the cursor position's
node is not a text node.
2024-02-24 08:09:01 +01:00
Aliaksandr Kalenik
5d76fa72e9 LibWeb: Add HTMLElement::did_receive_focus() 2024-02-24 08:09:01 +01:00
Aliaksandr Kalenik
6b17ab77f3 LibWeb: Do not delete empty range in EventHandler::handle_keydown()
Fixes a crash that occurs when inputting into an empty contenteditable
element (`EditEventHandler::handle_delete()` assumes the cursor
position's node is always `DOM::Text`, which is not the case for an
empty `contenteditable`).
2024-02-24 08:09:01 +01:00
Aliaksandr Kalenik
05d5e11966 LibWeb: Allow HTMLElement with contenteditable=true to be focusable 2024-02-24 00:19:55 +01:00
Matthew Olsson
d2cfea5acc LibWeb: Add Animation event handler attributes 2024-02-23 21:23:57 +01:00
Matthew Olsson
2dd5d0c310 LibWeb: Implement Animation.reverse() 2024-02-23 21:23:57 +01:00
Matthew Olsson
9ab73f2675 LibWeb: Implement Animation.updatePlaybackRate() 2024-02-23 21:23:57 +01:00
Matthew Olsson
d351389d72 LibWeb: Implement Animation.persist() 2024-02-23 21:23:57 +01:00
Matthew Olsson
3c055ff76d LibWeb: Implement Animation.cancel() 2024-02-23 21:23:57 +01:00
Matthew Olsson
9abe472928 LibWeb: Implement Animation.finish() 2024-02-23 21:23:57 +01:00
Matthew Olsson
c0b9179d9a LibWeb: Implement Animation.pause() 2024-02-23 21:23:57 +01:00
Matthew Olsson
fc62989f1a LibWeb: Add missing visits for Document's pending animation event queue 2024-02-23 20:52:37 +01:00
Matthew Olsson
4e27d07ff2 LibWeb: Use initial value for animation start if it does not exist
This fixes an issue where a property could not be animated unless the
element had a specified value for that property somewhere in its
styling.
2024-02-23 20:52:37 +01:00
Matthew Olsson
65858154de LibWeb: Dispatch Animation events 2024-02-23 20:52:37 +01:00
Matthew Olsson
ae3326a447 LibWeb: Transition StyleComputer to Web Animations
With this commit, we are finally running animations off of the web
animations spec! A lot of the work StyleComputer is doing is now done
elsewhere. For example, fill-forward animations are handled by
Animation::is_relevant() returning true in the after phase, meaning the
"active_state_if_fill_forward" map is no longer needed.
2024-02-23 20:52:37 +01:00
Nico Weber
b258ba2767 LibPDF: Use decode_hex_digit() more
For `:#xx` in names, we now also handle lower-case hex digits.
The spec is silent on the case of these hex digits.
Our previous check (isxdigit(), and now is_ascii_hex_digit()) lets
through lower-case hex digits, so it seems better to handle them
rather than computing e.g. `'a' - 'A' + 10` (== 42 -- off by 32!).
I don't know if this has any visible effect on any files, but it's
more correct, and less code, and the code looks more like the code
in Filter::decode_ascii_hex().
2024-02-23 12:11:25 -05:00
Nico Weber
783b1d1c11 LibPDF: Use is_ascii_hex_digit() instead of isxdigit()
See description of #7684 for motivation.

Also, makes this code look more like the hex code in
Filter::decode_ascii_hex().

No behavior change.
2024-02-23 12:11:25 -05:00
Andreas Kling
6402ad29a6 LibJS/Bytecode: Don't clobber dst when assigning from object expression
When compiling code like this:

    x = { foo: x }

We don't want to put a new JS::Object in `x` until *after* we've
evaluated `x` for the `foo` field.

This fixes an issue when loading https://puter.com/ :^)
2024-02-23 14:34:00 +01:00
Tim Ledbetter
b073fdd570 LibWeb: Invert return value from EventHandler key event handling methods
`EventHandler::handle_keyup()` and `EventHandler::handle_keydown()`
return true if the event has been handled and false otherwise. This is
the opposite behavior to `EventHandler::fire_keyboard_event()`.
This change inverts the return value from `fire_keyboard_event` in
these methods, allowing shortcut keys to be propagated to the Serenity
Browser UI as expected.
2024-02-23 09:53:00 +01:00
ddorando
7eec2d6c21 useradd: Don't crash on -m if directory already exists 2024-02-23 09:52:08 +01:00
Kemal Zebari
111e4162d0 LibGUI/Application: Resize recent files list to max open file size
Since it's possible to have the actual recently opened files <
max_recently_open_files(), which causes us to crash when we try to
access new_recent_files_list where index >= the list's size.
2024-02-23 09:51:42 +01:00
Hugh Davenport
b365356eba Assistant: Check for access before showing file results
Fixing up from #22597.

This change checks whether a file is readable to the user before adding
files to the cache.
2024-02-23 09:48:28 +01:00
Hugh Davenport
bba53441ef Assistant: Enable escalation of commands that need it
Ideal for applications such as PartitionEditor. Previously an error
about how it needs to run as root was displayed which differed from
the behaviour when clicking from the system menus.

Use the new AppFile::spawn_with_escalation to perform the escalation
2024-02-23 09:47:27 +01:00
Hugh Davenport
45c35267f6 Taskbar: Use AppFile::spawn_with_escalation 2024-02-23 09:47:27 +01:00
Hugh Davenport
c4abb367a4 AppFile: Add spawn_with_escalation 2024-02-23 09:47:27 +01:00
Lucas CHOLLET
83f1775f15 LibGfx/CCITT: Reimplement PassMode in a less naive way
The old implementation of PassMode has only been tested with a single
image, and let's say that it didn't survive long in the wild. A few
cases were not considered:
 - We only supported VerticalMode right after PassMode.
 - It can happen that token need to be used but not consumed from the
 reference line.

 With that fix, we are able to decode every single PDF file from the
 1000-file zip "0000" (except 0000871.pdf, which uses byte alignment).
 This is massive progress compared to the hundred of errors that we were
 previously receiving.
2024-02-22 16:45:03 +01:00
Andreas Kling
883b2268c0 LibJS: Protect private elements from GC during class construction
Fixes an issue caught by test-js -g + UBSAN.
2024-02-22 16:44:54 +01:00
Andreas Kling
4bbb0a5c35 LibJS: Add ConservativeVector<T>
This works very similarly to MarkedVector<T>, but instead of expecting
T to be Value or a GC-allocated pointer type, T can be anything.
Every pointer-sized value in the vector's storage will be checked during
conservative root scanning.

In other words, this allows you to put something like this in a
ConservativeVector<Foo> and it will be protected from GC:

    struct Foo {
        i64 number;
        Value some_value;
        GCPtr<Object> some_object;
    };
2024-02-22 16:44:54 +01:00
Aliaksandr Kalenik
9968c9f7a6 LibWeb: Fix hit-testing by excluding CSS transform from clip rect check
Transforms are applied to both clip rectangle and position, so we need
to remove the transform from clip rectangle before checking if position
falls within the clip rectangle.

In this change, the removal of transform is moved into
`Paintable::clip_rect()` that is shared between hit-testing and
painting.

This change fixes hit-testing in Discord's multifactor authentication
form.
2024-02-22 07:36:20 +01:00
Aliaksandr Kalenik
309259aeb6 LibWeb: Clamp scroll offset into valid range after relayout
If the layout has been recalculated and the sizes of scrollable
overflow rectangles could have changed, we need to ensure that scroll
offsets remain within the valid range.
2024-02-22 07:35:30 +01:00
Aliaksandr Kalenik
155070cfd8 LibWeb: Clamp scroll offset to valid range in set_scroll_offset()
By moving scroll offset clamp from `PaintableBox::scroll_by()` to
`PaintableBox::set_scroll_offset()`, we ensure that updates from
`Element::set_scroll_top()` and `Element::set_scroll_left()` are
constrained to a valid range.
2024-02-22 07:35:30 +01:00
Matthew Olsson
ee4abacde6 LibWeb: Add AnimationEffect::target_properties() 2024-02-22 07:31:54 +01:00
Matthew Olsson
10fddb99fc LibWeb: Implement Document::remove_replaced_animations() 2024-02-22 07:31:54 +01:00
Matthew Olsson
fe848487db LibWeb: Add Document::update_animations_and_send_events 2024-02-22 07:31:54 +01:00
Matthew Olsson
9bab1a95a5 LibWeb: Keep track of AnimationEffect's previous phase and iteration
This will be required for detecting transitions in StyleComputer
2024-02-22 07:31:54 +01:00
Matthew Olsson
35859c0467 LibWeb: Add helpers to convert between FillMode and Direction enums 2024-02-22 07:31:54 +01:00
Nico Weber
c9234f35f1 LibPDF/CFF: Clear stack after "endchar" commands
Both type 1 and type 2 spec tell us to do this.

I haven't observed a difference from this, but I noticed it in the
spec while I was touching this code. Probably good to do what the
spec tells us to do.
2024-02-22 06:59:28 +01:00
Nico Weber
020c00ede2 LibPDF/CFF: Use offset in accented_character() data
Without this, the dieresis above an a is all the way to the left
instead of over the letter.
2024-02-22 06:59:28 +01:00
Nico Weber
12859dfde5 LibPDF/CFF: Treat endchar in type 2 as type 2 "seac" when requested
With this, a character can be defined that uses two existing glyphs.
This is useful for umlauts and the like, which then just need to
reference e.g. the glyphs named "a" and "dieresis" and provide a
translation.

Makes umlauts appear on some PDFs using CFF type2 data in Type 1
fonts.
2024-02-22 06:59:28 +01:00
Jelle Raaijmakers
857ab2e06d LibGL: Create symlinks for headers and shared library
This allows ports to access the OpenGL headers using `#include
<GL/gl.h>` and find the shared library at `/usr/lib/libGL.so` or
`/usr/lib/libGL.so.1`, removing the need for explicit include paths or
changed library names.
2024-02-22 03:48:08 +01:00
Jelle Raaijmakers
5cff59557e LibGL: Add all glPushAttrib bit flags
This is required to build the `sdl12-compat` port when it's using our
header files to compile.
2024-02-22 03:48:08 +01:00
Tim Ledbetter
3f6f3a90c1 HexEditor: Fix typo in parameter name 2024-02-21 23:32:15 +01:00
Tim Ledbetter
f742334b93 HexEditor: Prefer enum class to enum for FindDialog::OptionId 2024-02-21 23:32:15 +01:00
Tim Ledbetter
b330d83be4 HexEditor: Prefer ErrorOr to Result in FindDialog 2024-02-21 23:32:15 +01:00
ronak69
a42cf020ea LibTest: Return 0 if all test cases pass and 1 otherwise from TEST_MAIN
Before, TEST_MAIN used to return the return value of TestSuite::main()
function (which returns the number of test cases that did not pass, so
it can be >=256) directly.

The run-tests utility determines the success / failure of a test suite
binary by examining its (or i.e. TEST_MAIN's) exit status.

But as exit status values are supposed to be between 0 and 255, values
>=256 will get wrapped around (modulo 256), converting a return value of
256 to 0.

So, in a rare case where exactly 256 test cases are failing in your test
suite, run-tests utility will display that the test suite passed without
any failures.

Now, TEST_MAIN just returns 0 if all of the test cases pass and returns
1 otherwise.
2024-02-21 22:45:51 +01:00
Tim Ledbetter
1a223d07e1 LibGUI: Assert that most recently open file path isn't empty
Attempting to do this causes a crash. It's better to fail early in this
case, so that the cause of the failure is clear.
2024-02-21 22:37:34 +01:00
Tim Ledbetter
ad62e433f0 PixelPaint: Don't crash when cancel is pressed when saving a file
Previously, we were attempting to add an empty string to the most
recently open files list when no file was saved.
2024-02-21 22:37:34 +01:00
Sönke Holz
a203837b1f LibC: Save callee-saved floating-point registers in setjmp for riscv64 2024-02-21 21:59:01 +01:00
Dan Klishch
56d355a15e LibWeb: Properly round CSSPixels values in device_to_css_rect
Ceiling width or height of a chrome viewport (this function is only used
when a chrome notifies LibWeb about a new viewport size) is never
correct. If we do that, PageClient::page_did_layout will set content
size to be 1 larger than an actual physical width or height respectively
(it always ceils) and thus a spurious scrollbar will appear.

This prevents occasional scrollbar flickering in Ladybird/Qt on Wayland
with fractional scaling enabled on compositors supporting
wp-fractional-scale-v1.
2024-02-21 20:08:25 +01:00
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
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
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
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
Aliaksandr Kalenik
fb8edcea00 LibWeb: Flesh out implementation of ResizeObserver interfaces
Adds the initial implementation for interfaces defined in the
ResizeObserver specification. These interfaces will be used to
construct and send observation events in the upcoming changes.
2024-02-20 10:55:10 +01:00
Andreas Kling
fb4c632309 LibJS: Throw "call stack size exceeded" exception a bit earlier
This number is pure guesswork but it appears to fix GCC builds with
both ASAN and UBSAN hitting a native stack overflow before we have
a chance to catch it on our Azure CI.
2024-02-20 10:54:52 +01:00
Nico Weber
05a7482118 LibPDF/CFF: Add dbgln() when failing encoding bounds check 2024-02-20 08:43:10 +00:00
Nico Weber
4705d38fa7 LibPDF/CFF: Fix off-by-one when reading internal encoding
We use `i - 1` to index these arrays, so that's what we should use
for the bounds check as well.
2024-02-20 08:43:10 +00:00
Jelle Raaijmakers
aa3a6767f6 LibGL+LibGPU+LibSoftGPU: Implement blend equations
This implements support for `glBlendEquation` and
`glBlendEquationSeparate`. These functions modify the calculation of the
resulting color in blending mode.
2024-02-19 23:23:40 +01:00
Jelle Raaijmakers
55668c3e48 LibGfx: Implement AK::min/max for Gfx::VectorN
These return a new `Gfx::VectorN` with the minimum or maximum value of
each element.
2024-02-19 23:23:40 +01:00
Andreas Kling
e46b217e42 LibJS/Bytecode: Move to a new bytecode format
This patch moves us away from the accumulator-based bytecode format to
one with explicit source and destination registers.

The new format has multiple benefits:

- ~25% faster on the Kraken and Octane benchmarks :^)
- Fewer instructions to accomplish the same thing
- Much easier for humans to read(!)

Because this change requires a fundamental shift in how bytecode is
generated, it is quite comprehensive.

Main implementation mechanism: generate_bytecode() virtual function now
takes an optional "preferred dst" operand, which allows callers to
communicate when they have an operand that would be optimal for the
result to go into. It also returns an optional "actual dst" operand,
which is where the completion value (if any) of the AST node is stored
after the node has "executed".

One thing of note that's new: because instructions can now take locals
as operands, this means we got rid of the GetLocal instruction.
A side-effect of that is we have to think about the temporal deadzone
(TDZ) a bit differently for locals (GetLocal would previously check
for empty values and interpret that as a TDZ access and throw).
We now insert special ThrowIfTDZ instructions in places where a local
access may be in the TDZ, to maintain the correct behavior.

There are a number of progressions and regressions from this test:

A number of async generator tests have been accidentally fixed while
converting the implementation to the new bytecode format. It didn't
seem useful to preserve bugs in the original code when converting it.

Some "does eval() return the correct completion value" tests have
regressed, in particular ones related to propagating the appropriate
completion after control flow statements like continue and break.
These are all fairly obscure issues, and I believe we can continue
working on them separately.

The net test262 result is a progression though. :^)
2024-02-19 21:45:27 +01:00
Andreas Kling
7f1a62a1d3 LibJS/Bytecode: Add Operand in/out to all the bytecode codegen helpers
This is pure prep work for refactoring the bytecode to use more operands
instead of only registers.

generate_bytecode() virtuals now return an Optional<Operand>, and the
idea is to return an Operand referring to the value produced by this
AST node.

They also take an Optional<Operand> "preferred_dst" input. This is
intended to communicate the caller's preference for an output operand,
if any. This will be used to elide temporaries when we can store the
result directly in a local, for example.
2024-02-19 21:45:27 +01:00
Andreas Kling
e46de4eb59 LibJS/Bytecode: Add constants table to Bytecode::Executable 2024-02-19 21:45:27 +01:00
Andreas Kling
3466771492 LibJS/Bytecode: Add Bytecode::Operand
An Operand is either a register, a local, or a constant (index into the
executable's constant table)
2024-02-19 21:45:27 +01:00