Commit graph

58399 commits

Author SHA1 Message Date
Sam Atkins
e025bcc4f9 LibWeb: Make use of transform-box when calculating transforms
We don't currently calculate the fill- or stroke-boxes of SVG elements,
so for now we use the content- and border-boxes respectively, as those
are the closest equivalents. The test will need updating when we do
support them.

Also, the test is a screenshot because of rendering differences when
applying transforms: a 20px box does not get painted the same as a 10px
box scaled up 2x. Otherwise that would be the more ideal form of test.
2024-01-27 07:46:37 +01:00
Sam Atkins
391cfdc085 LibWeb: Parse the CSS transform-box property 2024-01-27 07:46:37 +01:00
Nico Weber
c3c7707de4 LibGfx/JPEGWriter: Don't throw away highest-frequency component in FDCT 2024-01-26 20:19:55 -05:00
Timothy Flynn
83d2f59e2a LibWebView: Port the CookieJar to String 2024-01-26 20:22:39 +01:00
Timothy Flynn
30fae8fa1d LibSQL: Allow constructing SQL values from a String
LibSQL still uses ByteString internally for storage, but to help outside
application port to String, add helpers to construct values from String
and to convert a value to a String.
2024-01-26 20:22:39 +01:00
Timothy Flynn
c4820838bf LibWeb+WebContent: Port the did_request_named_cookie IPC to String 2024-01-26 20:22:39 +01:00
Timothy Flynn
9b957ead13 LibWebView+WebContent: Do not manually serialize cookie sources over IPC
LibIPC can serialize enumeration automatically (this was not the case
when these IPCs were added).
2024-01-26 20:22:39 +01:00
Timothy Flynn
85b8971a80 Ladybird+LibWeb+WebContent: Port the did_request_cookie IPC to String 2024-01-26 20:22:39 +01:00
Timothy Flynn
dcd9962d7b Browser: Remove some needless indirection from Cookie-related IPCs
We don't need to forward Cookie-related IPCs from the WebView through
the Tab to the BrowserWindow. We can skip the Tab like we do in other
chromes.

This is primarily to reduce overhead when changing Cookie IPCs in future
patches.
2024-01-26 20:22:39 +01:00
Timothy Flynn
8ea4e37c27 LibWebView: Convert trivial ByteString uses to StringView in CookieJar 2024-01-26 20:22:39 +01:00
Nico Weber
db4982bd29 LibGfx+image: Implement writing ICC profiles to jpeg files 2024-01-26 14:03:20 -05:00
Nico Weber
83ab9f7c2d LibGfx/PNM: Remove unnecessary line
This is already done at the caller decode() in
PortableImageLoaderCommon.h, as pointed out by @LucasChollet at
https://github.com/SerenityOS/serenity/pull/22935#discussion_r1467158789

No behavior change.
2024-01-26 14:53:33 +01:00
Nico Weber
c694d4326b Tests: Add a pam cmyk test file
Hand-written in a text editor.

I verified that `convert` converts it to a png that looks like the
rgb test expectations.
2024-01-26 07:36:53 +01:00
Nico Weber
c431cf4907 LibGfx: Add comparison operators to CMYK 2024-01-26 07:36:53 +01:00
Nico Weber
ba8f4e73bf Tests: Add a pam test file
Hand-written in a text editor.

I verified that `convert` converts it to a png that looks like the
test expectations.
2024-01-26 07:36:53 +01:00
Nico Weber
556addc5cb LibGFX/PAM: Allow reading CMYK .pam files
These are written by `mutool extract` for CMYK images.

They don't contain color profiles so they're not super convenient.
But `image` can convert them (*) to sRGB as long as you use it with
`--assign-color-profile` pointing to some CMYK icc profile of your
choice.

*: Once #22922 is merged.
2024-01-26 07:36:53 +01:00
Nico Weber
187862ebe0 LibGfx: Add a .pam loader
.pam is a "portrable arbitrarymap" as documented at
https://netpbm.sourceforge.net/doc/pam.html

It's very similar to .pbm, .pgm, and .ppm, so this uses the
PortableImageMapLoader framework. The header is slightly different,
so this has a custom header parsing function.

Also, .pam only exixts in binary form, so the ascii form support
becomes optional.
2024-01-26 07:36:53 +01:00
Aliaksandr Kalenik
0d76a9da17 LibWeb: Resolve text-decoration-thickness during layout commit
Refactoring towards stop resolving CSS lengths during paintable
commands recording.
2024-01-26 07:36:40 +01:00
Aliaksandr Kalenik
d5e3158cfe LibWeb: Use PaintableFragment::baseline() in paint_text_decoration()
No need to calculate baseline based on glyph height when we can get
this information from a fragment.
2024-01-26 07:36:40 +01:00
Aliaksandr Kalenik
1c4ce2c5f1 LibWeb: Don't check containing block of fragments in hit testing
We do not rely on existence of containing block in
`PaintableWithLines::hit_test()` so it should be safe to remove this
check.
2024-01-26 07:36:40 +01:00
Aliaksandr Kalenik
270bbf43ab LibWeb: Remove is<BlockContainer> check for fragments in hit testing
This change introduces a method for direct access to the paintable of
a PaintableFragment. This method is intended to replace the usage of
the layout node pointer. Currently, we are only eliminating the use
of `layout_node()` in hit testing.

Additionally, we no longer check if a fragment's layout node is a
`BlockContainer` before recursing into its children during hit testing.
This check was likely relevant when all fragments were owned by
`PaintableWithLines`, but now it should be safe to remove this check.
2024-01-26 07:36:40 +01:00
Timothy Flynn
09124fc3a5 LibWeb: Set up the Fetch response's body with the appropriate stream 2024-01-25 21:34:03 +01:00
Timothy Flynn
2bb751eab9 Meta: Port recent changes to the GN build
b12541b286
2024-01-25 21:34:03 +01:00
Aliaksandr Kalenik
a319037706 LibWeb: Remove SetFont painting command
It was only used in ImagePaintable for alt text and now it is replaced
by saving font inside DrawText command.
2024-01-25 21:33:54 +01:00
Andrew Kaster
d85a0e306a headless-browser: Add option to filter which tests are run with a glob
This is the same feature that run-tests has on Serenity.
2024-01-25 09:44:42 -07:00
Nico Weber
550937f5dd Tests: Add a test cmyk jpeg file with an embedded color profile
I opened Base/res/graphics/buggie.png in Photoshop, converted it
to U.S. Web Coated (SWOP) v2, flattened the image so we don't have
CMYK with alpha, and saved it as a jpeg (with color profile embedded).
2024-01-25 15:53:44 +01:00
Nico Weber
fac48fdda4 image: Allow converting CMYK inputs to RGB
This worked in PDFs for a while, but now `image` can also do
CMYK->RGB conversions that actually use color profiles :^)
2024-01-25 15:53:44 +01:00
Nico Weber
88b49a639e LibGfx/ICC: Add a convert_cmyk_image() method
It converts from a CMYKBitmap to an (rgb) bitmap, using a real
color profile.

The API design here isn't super scalable (what if we want to also
handle grayscale inputs? What if we also want to convert _to_ cmyk
or grayscale?), but we have to start somewhere. Uses of this can
inform future API improvements.
2024-01-25 15:53:44 +01:00
Nico Weber
11b623b1fd LibGfx: Add data_size() accessors to Bitmap and CMYKBitmap
These return the size of the data in bytes.
2024-01-25 15:53:44 +01:00
Nico Weber
0acc370f7b image: Load images that contain CMYK data into a CMYKBitmap
Every single of images's functions then go ahead and error out on
CMYKBitmaps for now.

(Alternatively, we could make them the low-quality CMYK->RGB
conversion that previously happened implicitly, but let's go
with this for now.)

(With this structure, we could also do something smarter for
Vector images in the future.)

Here's how this looks:

    % Build/lagom/bin/image \
        -o out.png Tests/LibGfx/test-inputs/jpg/ycck-2111.jpg
    Runtime error: Can't save CMYK bitmaps yet, convert to RGB first
                   with --convert-to-color-profile

    % Build/lagom/bin/image \
        --convert-to-color-profile serenity-sRGB.icc \
        -o out.png Tests/LibGfx/test-inputs/jpg/ycck-2111.jpg
    Runtime error: No source color space embedded in image.
                   Pass one with --assign-color-profile.

    % Build/lagom/bin/image \
        --assign-color-profile path/to/CMYK/USWebCoatedSWOP.icc \
        --convert-to-color-profile serenity-sRGB.icc \
        -o out.png Tests/LibGfx/test-inputs/jpg/ycck-2111.jpg
    Runtime error: Psych, can't convert CMYK bitmaps yet either

As usual, serenity-sRGB.icc is from
`Build/lagom/bin/icc  -n sRGB --reencode-to serenity-sRGB.icc` and
the adobe cmyk profiles are available at
https://www.adobe.com/support/downloads/iccprofiles/iccprofiles_win.html
which ultimately leads to:
https://download.adobe.com/pub/adobe/iccprofiles/win/AdobeICCProfilesCS4Win_end-user.zip
2024-01-25 15:53:44 +01:00
Nico Weber
c6eac16d00 LibGfx: Remove unused parameter from cmyk_frame() 2024-01-25 15:53:44 +01:00
Nico Weber
2c40886851 image: Update an error string
We have been able to write .jpg files for a while now.
2024-01-25 15:53:44 +01:00
Nico Weber
8a56abf48b image: Move image writers up that don't return bytes
Makes the early returns a bit easier to see.

Also alphabetize them while touching these lines.

No behavior change.
2024-01-25 15:53:44 +01:00
Nico Weber
96c71b7042 image: Move image loading code into a separate function
Haters will say this is overkill, but this function will do a bit more
once we allow loading CMYK data.

No behavior change.
2024-01-25 15:53:44 +01:00
Nico Weber
653b614611 image: Move image saving code into helper function
No behavior change.
2024-01-25 15:53:44 +01:00
Nico Weber
0681df7f3b image: Move profile conversion code into helper function
No behavior change.
2024-01-25 15:53:44 +01:00
Nico Weber
48a0fb1e8e image: Introduce a struct "LoadedImage" to hold bitmap and icc data
This makes it easier to move the color space conversion code out
into a helper function, and will be used to pass around CMYK bitmaps.

No behavior change.
2024-01-25 15:53:44 +01:00
Nico Weber
a339f297d1 image: Move image modification code to helper functions
No behavior change.
2024-01-25 15:53:44 +01:00
Nico Weber
da243ebb8b image: Use Error::from_string_view() for errors
...instead of warn() + manual return.

Before:

    % Build/lagom/bin/image -o out.asdf in.png
    can only write .bmp, .png, .ppm, and .qoi

Now:

    % Build/lagom/bin/image -o out.asdf in.png
    Runtime error: can only write .bmp, .png, .ppm, and .qoi

That doesn't look worse, and it's less code (and makes moving the
code into helper functions easier).
2024-01-25 15:53:44 +01:00
Aliaksandr Kalenik
c02820759b LibWeb: Test nested elements in InlinePaintable::hit_test()
Before this change we were ignoring nested paintables inside inline
paintable during hit-testing, but now we recurse into subtree.

Fixes https://github.com/SerenityOS/serenity/issues/22927
2024-01-25 15:53:18 +01:00
Andreas Kling
1583e6ce07 LibWeb: Clamp justification space between flex items to 0
Before this change, it was possible for flex lines with negative
remaining space (due to overflowing items) to put a negative amount
of space between items for some values of `justify-content`.

This makes https://polar.sh/SerenityOS look much better :^)
2024-01-25 15:10:21 +01:00
Andreas Kling
e668cdcf22 Tests/LibWeb: Skip HTML/Window-postMessage.html since it's flakey 2024-01-25 13:50:40 +01:00
Sam Atkins
7bcb560060 uptime: Add -s/--since option to output only when the system came online
This also matches Linux and the BSDs.
2024-01-25 09:07:32 +01:00
Sam Atkins
8faeb13036 uptime: Bring output closer to Linux/BSDs, and add -p flag
The -p flag is equivalent to the previous behavior: outputting the
uptime in a human-readable form.

We don't seem to expose the number of online users or the load averages,
so those sections are missing from the output compared to those OSes.
2024-01-25 09:07:32 +01:00
Sam Atkins
388856dc7e AK+Userland: Return String from human_readable_size() functions 2024-01-25 09:07:32 +01:00
Sam Atkins
7e8cfb60eb AK+Userland: Return String from human_readable_[digital_]time() 2024-01-25 09:07:32 +01:00
Andreas Kling
b12541b286 LibWeb: Add SVGSVGElement.viewBox attribute
This attribute has some compatbility issues...
- The spec says it should be an SVGAnimatedRect which contains
  a DOMRect and a DOMReadOnlyRect.
- Blink gives you an SVGAnimatedRect with 2x SVGRect
- Gecko gives you an SVGAnimatedRect with 2x SVGRect? (nullable)

I ended up with something similar to Gecko, an SVGAnimatedRect
with 2x DOMRect? (nullable)

With this fixed, we can now load https://polar.sh/ :^)
2024-01-25 08:23:41 +01:00
Timothy Flynn
2fd034d1df LibWebView: Prevent quoting attribute values twice in the Inspector
As of commit ccd701809f, the formatter for
JsonValue now fully serializes the value. The serializer will surround
the string value with quotes. We want control over when we add quotes to
the generated Inspector HTML, so avoid formatting attributes as raw JSON
values.
2024-01-25 08:22:24 +01:00
Dan Klishch
982799f7a0 LibC+LibELF: Pass information from linker via magic lookup
This works by defining a set of weak symbols in dynamic linker whose
value would be provided by it. This has the same effect as preloading
library that magically knows right addresses of functions shared between
dynamic linker and LibC.

We were previously passing the same information by rewriting values
based on hardcoded library name, so the new approach seems a little
nicer to me.
2024-01-24 22:17:49 -07:00
Lucas CHOLLET
a17041fe7f LibGfx/TIFF: Add support for CMYK
The test case has been generated with Krita.
2024-01-24 22:16:22 -07:00