Commit Graph

59918 Commits

Author SHA1 Message Date
Nico Weber
a073b2d047 LibGfx/ISOBMFF: Read JPEG2000HeaderBox 2024-03-25 20:35:00 +01:00
Nico Weber
15ba0a7e18 LibGfx/ISOBMFF: Make BoxStream MaybeOwn its stream
...and make Reader always have a BoxStream.
2024-03-25 20:35:00 +01:00
Nico Weber
07750774cf AK: Allow creating a MaybeOwned<Superclass> from a MaybeOwned<Subclass> 2024-03-25 20:35:00 +01:00
Nico Weber
a72770cdf6 LibGfx/ISOBMFF: Add JPEG2000 box types
I prefixed the types that are labeled as "JPEG2000" on
https://mp4ra.org/registered-types/boxes with "JPEG2000".
2024-03-25 20:35:00 +01:00
Nico Weber
cdbdc334de LibGfx/ISOBMFF: Alphabetize box type ENUMERATE_ONE() lines 2024-03-25 20:35:00 +01:00
Nico Weber
e81009b338 LibGfx/ISOBMFF: Put string literals in box type ENUMERATE_ONE()
This allows types that have spaces in their FourCC.
2024-03-25 20:35:00 +01:00
Nico Weber
bdb4f6bd49 LibGfx/ISOBMFF: Remove prototypes for nonexistent methods 2024-03-25 20:35:00 +01:00
Nico Weber
270d3303ce LibGfx/ISOBMFF: FileTypeBox is not a FullBox 2024-03-25 20:35:00 +01:00
Nico Weber
1e31753382 Tests/LibGfx: Add a jbig2 file using refinement in the text segment
This adds a test for the code added in #23696.

I created this file using `jbig2` (see below for details), but as
usual it required a bunch of changes to it to make it actually produce
spec-compliant output. See the PR adding this image for my local diff.

I created the test image file by running this shell script with
`jbig2` tweaked as described above:

    #!/bin/bash
    set -eu

    S=Tests/LibGfx/test-inputs/bmp/bitmap.bmp

    # See make-symbol-jbig.sh (the script in #23659) for the general
    # setup and some comments. Note that the symbol section here only
    # has 3 symbols, instead of 4 over there.
    #
    # `-RefID` takes 6 arguments:
    # 1. The symbol ID of the base symbol (like after an `-ID`)
    # 2. A bmp file that the base symbol gets refined to
    # 3. y, x (like after an `-ID`)
    # 4. dx, dy (note swapped order to previous item)
    #
    # We also explicitly set refinement adaptive pixels, because the
    # default adaptive refinement pixels aren't the nominal pixels from
    # the spec.

    cat << EOF > jbig2-symbol-textrefine.ini
    -sym -Seg 1
    -sym -file -numClass -HeightClass 3 -WidthClass 1
    -sym -file -numSymbol 3
    -sym -file -Height 250
    -sym -file -Width 120 -Simple 0 mouth-1bpp.bmp
    -sym -file -EndOfHeightClass
    -sym -file -Height 100
    -sym -file -Width 100 -Simple 1 nose-1bpp.bmp
    -sym -file -EndOfHeightClass
    -sym -file -Height 30
    -sym -file -Width 30 -Simple 2 top_eye-1bpp.bmp
    -sym -file -EndOfHeightClass
    -sym -Param -Huff_DH 0
    -sym -Param -Huff_DW 0

    -txt -Seg 2
    -txt -Param -numInst 4
        -ID 2 108 50 -RefID 2 bottom_eye-1bpp.bmp 265 60 0 0
        -ID 1 100 135 -ID 0 70 232
    -txt -Param -RefCorner 1
    -txt -Param -Xlocation 0
    -txt -Param -Ylocation 0
    -txt -Param -W 399
    -txt -Param -H 400
    -txt -Param -rATX1 -1
    -txt -Param -rATY1 -1
    -txt -Param -rATX2 -1
    -txt -Param -rATY2 -1
    EOF

    J=$HOME/Downloads/T-REC-T.88-201808-I\!\!SOFT-ZST-E/Software
    J=$J/JBIG2_SampleSoftware-A20180829/source/jbig2

    $J -i "${S%.bmp}" -f bmp -o symbol-textrefine -F jb2 -ini \
        jbig2-symbol-textrefine.ini
2024-03-25 15:11:57 -04:00
Timothy Flynn
3b2f4a4041 CI: Revert ARCH_MMAP_RND_BITS libasan workaround
This reverts commit 5713c2ffdd.

This workaround is reportedly now applied in the base image.
2024-03-25 14:16:55 -04:00
Nico Weber
7dd5457b8f LibGfx/JBIG2: Add support for refinement coding template 1
This is used when refining a symbol in 0000337.pdf.
2024-03-25 13:16:02 -04:00
Nico Weber
ef9bfce0e7 LibGfx/JBIG2: Add support for SDREFAGG=1 symbol segments
...but only as long as REFAGGNINST == 1. That's enough for 0000337.pdf.
Except that it also needs GRTEMPLATE=1 support in the generic
refinement region decoding procedure, so no behaivor change yet.
2024-03-25 13:16:02 -04:00
Nico Weber
3fa2ecdd65 LibGfx/JBIG2: Extract read_id() into a class
We'll need this for refinement/aggregate coding of symbols.
2024-03-25 13:16:02 -04:00
Nico Weber
68d47cb84a LibGfx/JBIG2: Implement support for symbols segments with input symbols
Needed for 0000337.pdf. It now fails complaining about missing SDREFAGG
support.
2024-03-25 13:16:02 -04:00
Nico Weber
59e6a10f30 LibGfx/JBIG2: Initialize POD members of refinement region input struct
I missed putting this in #23696 while juggling local branches.

No behavior change.
2024-03-25 12:07:18 -04:00
Aliaksandr Kalenik
1036e104ef LibWeb: Remove cache for Paintable::is_visible()
...because it depends on computed values that could be changed without
rebuilding paintable tree.
2024-03-25 14:17:30 +01:00
Ali Mohammad Pur
61148e9bc2 LibCore: Ignore timer events after stop() has been called 2024-03-25 14:16:55 +01:00
Julian Offenhäuser
003ac1bd51 Ports: Update openrct2 to version 0.4.9 2024-03-25 14:11:26 +01:00
Julian Offenhäuser
87f51ef7dd Ports: Update gemrb to version 0.9.2 2024-03-25 14:11:26 +01:00
Nico Weber
8e9157d6ce LibGfx/JBIG2: Implement decode_end_of_stripe() a bit
This is enough to be able to decode 0000857.pdf p1-4 and
0000372.pdf p11.
2024-03-25 14:08:40 +01:00
Nico Weber
c4a45bb521 LibGfx/JBIG2: Make compute_context() a function pointer
...instead of a lambda that checks the template on every call.

Doesn't make a performance difference locally, but seems maybe nicer?

No behavior change.
2024-03-25 14:08:40 +01:00
Nico Weber
828c640087 LibGfx/JBIG2: Make get_pixel static constexpr
...so it doesn't need to be captured.
2024-03-25 14:08:40 +01:00
Nico Weber
b45a4508c7 LibGfx/JBIG2: Implement support for context templates 1, 2, and 3
Template 2 is needed by some symbols in 0000372.pdf page 11 and
0000857.pdf pages 1-4. Implement the others too while here.  (The
mentioned pages in those two PDFs also use the "end of stripe" segment,
so they still don't render yet.

We still don't support EXTTEMPLATE.
2024-03-25 14:08:40 +01:00
Nico Weber
e2f02f4df7 Tests/JBIG2: Add test images for non-0 templates
Produced by this shell script:

```sh
S=Tests/LibGfx/test-inputs/bmp/bitmap.bmp
J=$HOME/Downloads/T-REC-T.88-201808-I\!\!SOFT-ZST-E/Software
J=$J/JBIG2_SampleSoftware-A20180829/source/jbig2

for t in template1 template1-tpgdon \
         template2 template2-tpgdon \
         template3 template3-tpgdon; do
  echo $t.ini
  cat $t.ini
  echo
  $J -i "${S%.bmp}" -f bmp -o bitmap-$t -F jb2 -ini $t.ini
  echo
done
```

Producing this output:

```sh
% ./make-templates.sh
template1.ini
-Gen -Seg 1
-Gen -Param -Template 1
-Gen -Param -ATX1 3
-Gen -Param -ATY1 -1

ENC Start ===>complete

template1-tpgdon.ini
-Gen -Seg 1
-Gen -Param -Template 1
-Gen -Param -ATX1 3
-Gen -Param -ATY1 -1
-Gen -Param -TpGDon 1

ENC Start ===>complete

template2.ini
-Gen -Seg 1
-Gen -Param -Template 2
-Gen -Param -TpGDon 1
-Gen -Param -ATX1 2
-Gen -Param -ATY1 -1

ENC Start ===>complete

template2-tpgdon.ini
-Gen -Seg 1
-Gen -Param -Template 2
-Gen -Param -ATX1 2
-Gen -Param -ATY1 -1
-Gen -Param -TpGDon 1

ENC Start ===>complete

template3.ini
-Gen -Seg 1
-Gen -Param -Template 3
-Gen -Param -ATX1 2
-Gen -Param -ATY1 -1

ENC Start ===>complete

template3-tpgdon.ini
-Gen -Seg 1
-Gen -Param -Template 3
-Gen -Param -ATX1 2
-Gen -Param -ATY1 -1
-Gen -Param -TpGDon 1

ENC Start ===>complete
```

`jbig2` still has the local patch mentioned in #23608 to make it write
correct TPGDON data.
2024-03-25 14:08:40 +01:00
Nico Weber
7035c2a2ff LibGfx/JBIG2: Add some debug logging to decode_page_information() 2024-03-25 14:08:40 +01:00
Andreas Kling
9af966f87d LibWeb: Avoid unnecessary Vector copying when generating line boxes
Carry the same Vector<Gfx::DrawGlyphOrEmoji> all the way from the inline
level iterator to the final line box fragment.
2024-03-25 12:39:23 +01:00
Andreas Kling
f48024c2d1 LibGfx/OpenType: Make glyph_width() only fetch the glyph advance
Instead of fetching a generic set of metrics for each glyph, only fetch
the advance when that's all we need.

This is extremely hot in LibWeb text layout, where it makes a nice dent.
2024-03-25 12:39:23 +01:00
Andreas Kling
2b8a920a7c AK: Don't blindly use SipHash as default hash function
Although it has some interesting properties, SipHash is brutally slow
compared to our previous hash function. Since its introduction, it has
been highly visible in every profile of doing anything interesting with
LibJS or LibWeb.

By switching back, we gain a 10x speedup for 32-bit hashes, and "only"
a 3x speedup for 64-bit hashes.

This comes out to roughly 1.10x faster HashTable insertion, and roughly
2.25x faster HashTable lookup. Hashing is no longer at the top of
profiles and everything runs measurably faster.

For security-sensitive hash tables with user-controlled inputs, we can
opt into SipHash selectively on a case-by-case basis. The vast majority
of our uses don't fit that description though.
2024-03-25 12:39:23 +01:00
Nico Weber
d2998c1f5e LibGfx/JBIG2: Implement generic_refinement_region_decoding_procedure()
With this, we can decode all pages of 0000425.pdf, 0000215.pdf,
0000882.pdf, and 0000057.pdf.
2024-03-25 08:15:36 +01:00
Nico Weber
0d2e91b4ea LibGfx/JBIG2: Reject things in refinement decoding
These aren't hit for my 1000 page PDF test set.
2024-03-25 08:15:36 +01:00
Nico Weber
562d8ed619 LibGfx/JBIG2: Stub out generic_refinement_region_decoding_procedure()
...and make text_region_decoding_procedure() call it.

generic_refinement_region_decoding_procedure() still just returns
"unimplemented", so no behavior change yet.
2024-03-25 08:15:36 +01:00
Nico Weber
c4c48c1d5f LibGfx/JBIG2: Sketch out text segment refinement coding a bit 2024-03-25 08:15:36 +01:00
Nico Weber
9f327833c0 LibGfx/JBIG2: Read refinement adaptive template pixels for text segments
Text segments using refinement are still rejected later, by
text_region_decoding_procedure(). But we deserialize the input data now,
and the error when this feature is used is now slightly different.
2024-03-25 08:15:36 +01:00
Aliaksandr Kalenik
0652d159cf LibWeb: Add a test for mouse{over,out,enter,leave} events 2024-03-25 08:14:13 +01:00
Aliaksandr Kalenik
4ae2eaead1 LibWeb: Dispatch mouseout and mouseover events 2024-03-25 08:14:13 +01:00
Timothy Flynn
ed24d8f2b5 Ladybird/AppKit: Implement pasting content from the clipboard 2024-03-25 08:14:00 +01:00
Timothy Flynn
0069390e1c Browser: Implement pasting content from the clipboard 2024-03-25 08:14:00 +01:00
Timothy Flynn
7e38653492 AK: Reject invalid Base64 encoded string lengths 2024-03-25 08:13:27 +01:00
Timothy Flynn
4ecf4c7617 AK: Compute the exact size of decoded Base64 strings 2024-03-25 08:13:27 +01:00
Timothy Flynn
754ff41b9c AK: Remove whitespace skipping feature from AK's Base64 decoder
This was added in commit f2663f477f as a
partial implementation of what is now LibWeb's forgiving Base64 decoder.
All use cases within LibWeb that require whitespace skipping now use
that implementation instead.

Removing this feature from AK allows us to know the exact output size of
a decoded Base64 string. We can still trim whitespace at the start and
end of the input though; for example, this is useful when reading from a
file that may have a newline at the end of the file.
2024-03-25 08:13:27 +01:00
Timothy Flynn
690db10463 AK: Convert Base64 template parameters to regular function parameters
The generated function name is otherwise very long, which makes stack
traces a bit more difficult to sift through.
2024-03-25 08:13:27 +01:00
Timothy Flynn
f292746134 AK: Convert some west-consts to east-const in Base64.cpp
Caught by clang-format-17. Note that clang-format-16 is fine with this
as well (it leaves the const placement alone), it just doesn't perform
the formatting to east-const itself.
2024-03-25 08:13:27 +01:00
Timothy Flynn
74377618b1 LibWeb: Process Base64 data URLs with the forgiving Base64 algorithm 2024-03-25 08:13:27 +01:00
Timothy Flynn
24ecf31ff5 LibURL+LibWeb: Move data URL processing to LibWeb's fetch infrastructure
This is a fetching AO and is only used by LibWeb in the context of fetch
tasks. Move it to LibWeb with other fetch methods.

The main reason for this is that it requires the use of other LibWeb AOs
such as the forgiving Base64 decoder and MIME sniffing. These AOs aren't
available within LibURL.
2024-03-25 08:13:27 +01:00
Timothy Flynn
2118cdfcaa Meta: Add LibWeb unit tests to the GN build 2024-03-25 08:13:27 +01:00
Timothy Flynn
a88ee029d7 Meta: Add the base64 utility to the GN build 2024-03-25 08:13:27 +01:00
MacDue
c6899b79b6 LibWeb: Normalize the angle delta in CanvasPath::ellipse()
This fixes both the incorrect arc and ellipse from #22817.
2024-03-24 18:37:44 +01:00
Aliaksandr Kalenik
b31fb36ed3 LibWeb: Reschedule repaint for navigables with ongoing painting
Fixes delayed repainting in the following case:
1. Style or layout invalidation triggers html event loop processing.
2. Event loop processing does nothing because there is no rendering
   opportunity.
3. Style or layout change won't be reflected until something else
   triggers event loop processing
2024-03-24 16:30:31 +01:00
Andreas Kling
3bdfca1119 AK: Make FlyString::from_utf8*() avoid allocation if possible
If we already have a FlyString instantiated for the given string,
look that up and return it instead of making a temporary String just to
use as a key into the FlyString table.
2024-03-24 13:28:24 +01:00
Andreas Kling
8d7a1e5654 LibWeb: Skip some redundant UTF-8 validation in CSS tokenizer
If we're just adding code points to a StringBuilder, there's no need to
revalidate the result.
2024-03-24 13:28:24 +01:00