Commit graph

58381 commits

Author SHA1 Message Date
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
Lucas CHOLLET 984272d83e LibGfx/TIFF: Put manage_extra_channels in its own function 2024-01-24 22:16:22 -07:00
Lucas CHOLLET 3f4bf7a0c7 LibGfx/ExifOrientedBitmap: Add support for CMYKBitmap 2024-01-24 22:16:22 -07:00
Lucas CHOLLET c80b2cf782 LibGfx/ExifOrientedBitmap: Use scanline instead of set_pixel()
The former has the advantage to be available in CMYKBitmap too.

No behavior change.
2024-01-24 22:16:22 -07:00
Lucas CHOLLET 8229a19081 LibGfx/ExifOrientedBitmap: Reorganize create parameters
No behavior change.
2024-01-24 22:16:22 -07:00
Lucas CHOLLET 09b2b3539b LibGfx/JPEG+CMYKBitmap: Extract the CMYK to RGB conversion code
Right now, the JPEG decoder is the only one supporting CMYK, but that
won't last for long. So, let's move the conversion to CMYKBitmap.
2024-01-24 22:16:22 -07:00
Lucas CHOLLET 0462858247 LibGfx/JPEG: Keep the original CMYK data in memory
When decoding a CMYK image and asked for a normal `frame()`, the decoder
would convert the CMYK bitmap into an RGB bitmap. Calling `cmyk_frame()`
after that point will provoke a null-dereference.
2024-01-24 22:16:22 -07:00
Aliaksandr Kalenik 980b61470c LibAccelGfx+LibWeb+WebContent: Handle OpenGL Context init errors
Now, if OpenGL context fails, an error will be returned and a message
printed, instead of crashing.
2024-01-24 19:43:51 +01:00
Sam Atkins 315c95a1ce HackStudio: Replace custom recent-project management with the LibGUI one
The only downside is we are limited to 4 recent projects now. LibGUI
currently relies on the number of recent files being constexpr, so that
will take some more work to make it variable.
2024-01-24 11:07:03 +00:00
Sam Atkins 343de324db LibGUI: Don't update the recent files if we haven't created them yet
We previously assumed that `set_most_recently_open_file()` would only be
called after `Menu::add_recent_files_list()` had been called, and would
crash if we hadn't called it yet. This stops the crash. We're fine to
do this, because we always call `update_recent_file_actions()` in
`register_recent_file_actions()` so it's guaranteed to be up to date
when we do need it.
2024-01-24 11:07:03 +00:00
Sam Atkins f8fe6d11b2 LibGUI: Allow creating a recent-files list without a trailing separator
This is useful in situations where we want this list in a submenu.
2024-01-24 11:07:03 +00:00
Sam Atkins 9657f4cabb LibGUI+Userland: Take ByteString in set_most_recently_open_file() 2024-01-24 11:07:03 +00:00
Sam Atkins d30f13a88d HackStudio: Jump to file location when choosing a Locator suggestion
A couple of tweaks here to make it work better:
- Call `set_cursor_and_focus_line()` to make the Editor scroll to the
  symbol's location.
- Remove focus from the Locator's text box so your cursor jumps to the
  Editor instead of staying in the Locator.
2024-01-24 11:05:54 +00:00
Sam Atkins 9322f0d110 HackStudio: Use Autocomplete window type for Locator pop-up
This being a Popup window meant it behaved in a couple of janky ways:
- It would steal the focus each time it was shown, so after every key
  press in the TextBox.
- It would disappear when you focused that TextBox again.

Using the Autocomplete window type fixes both of these. While the
Locator is not technically an autocomplete, it shares the general "type
and get suggestions based on the input, which you can select" behavior,
so this is close enough.
2024-01-24 11:05:54 +00:00
Andreas Kling b84056c05b LibWeb: Add missing visits in MessageEvent
Also change a Vector<Handle> to a Vector<NonnullGCPtr> while we're
here, since there's no need to use handles for members of a cell.

Fixes an ASAN error on the HTML/Window-postMessage.html test.
2024-01-24 10:52:02 +01:00
Andreas Kling 413eb19579 LibWeb: Skip UTF-8 validation in Node::descendant_text_content()
Since we're just concatenating a bunch of strings that are already
UTF-8, we don't need to check that the result is also UTF-8.
2024-01-24 07:55:13 +01:00
Andreas Kling 7fedf806c2 LibWeb: Cache pointer to UsedValues for each FlexItem
This avoids expensive repeated LayoutState hash lookups.
2024-01-24 07:53:33 +01:00
Andreas Kling 4e6de47f93 LibWeb: Avoid LayoutState hash lookups in more parts of float layout 2024-01-24 07:53:16 +01:00
Timothy Flynn 11d2e6101f Meta: Add AK and LibRIFF to macOS bundles in GN build 2024-01-23 14:07:46 -07:00