Commit Graph

31966 Commits

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