Commit graph

58556 commits

Author SHA1 Message Date
Nico Weber
c4780f4ee1 image: Add an --invert-cmyk option
This is useful for working with CMYK jpegs extracted from PDFs
by mutool. CMYK channels for jpegs in PDFs are inverted compared to
CMYK channels in standalone jpegs (!), and mutool doesn't compensate
for that.

You can now do:

    mutool extract  ~/Downloads/0000/0000711.pdf 461

Followed by:

    Build/lagom/bin/image -o out.png \
        --invert-cmyk \
        --assign-color-profile \
            Build/lagom/Root/res/icc/Adobe/CMYK/USWebCoatedSWOP.icc \
        --convert-to-color-profile serenity-sRGB.icc \
        cmyk.jpg

Doesn't exactly roll off the keyboard, but at least it's possible.

(We should probably add an implicit default CMYK color profile if
the input file doesn't have one, and assume conversion to sRGB when
saving to a format that can only store RGB.)
2024-02-04 21:34:53 +01:00
Nico Weber
fa3fead7a4 image: Move ppm_ascii down a bit
It belongs close to `quality` since it needed at output time.

No behavior change (except for `--help` output order).
2024-02-04 21:34:53 +01:00
Timothy Flynn
3bf90fdab1 LibTimeZone: Update to TZDB version 2024a
https://mm.icann.org/pipermail/tz-announce/2024-February/000081.html
2024-02-04 08:14:06 +01:00
Timothy Flynn
f30fd78d8d Meta: Port recent changes to the GN build
8e5410347b
2024-02-04 08:14:06 +01:00
Andrew Kaster
36cd2fb7c5 Ladybird+WebContent: Update IPC calls to handle multiple traversables
The IPC layer between chromes and LibWeb now understands that multiple
top level traversables can live in each WebContent process.

This largely mechanical change adds a billion page_id/page_index
arguments to make sure that pages that end up opening new WebViews
through mechanisms like window.open() still work properly with those
extra windows.
2024-02-03 20:51:37 -05:00
Andrew Kaster
adb5c27331 LibWeb: Create a new WebView for window.open()'d top level traversables 2024-02-03 20:51:37 -05:00
Andrew Kaster
677bdc2a4f Ladybird: Add IPC call for creating a new child tab
This will be used for choosing a navigable that requires opening a new
tab or new window. Such as calls to window.open(), or specific WebDriver
calls.
2024-02-03 20:51:37 -05:00
Andrew Kaster
7245f6f11c Ladybird: Open files from the open files dialog as a QURL
This prevents us from needing to properly prepend file:// to the
returned filename.
2024-02-03 20:51:37 -05:00
Andrew Kaster
c75bd4ed15 Ladybird/Qt: Rename new_tab to new_tab_from_url and make it take AK::URL
Instead of having QString be the API for these load() calls, just pipe
AK::URL throughout the UI.
2024-02-03 20:51:37 -05:00
Andrew Kaster
a91680dd55 Ladybird/Qt: Rename new_tab(StringView) to new_tab_from_content
Having an overload of new_tab with StringView and QString that each do
very different things is uncomfortable, to say the least.
2024-02-03 20:51:37 -05:00
Andrew Kaster
48ce8fb4e9 Ladybird: Add ability to create a tab without creating a new WebContent 2024-02-03 20:51:37 -05:00
Dan Klishch
506707cc2b LibCore: Allow listening for socket errors and hang-ups 2024-02-03 16:43:13 -07:00
Dan Klishch
6836091a21 LibCore: Switch from select(2) to poll(2) for the event loop 2024-02-03 16:43:13 -07:00
Dan Klishch
77e4f0d7d8 LibCore: Allow listening for multiple conditions using a single Notifier
While on it, implement currently unused Notifier::set_type correctly
(but not efficiently) by re-registering Notifier in the EventLoop.
2024-02-03 16:43:13 -07:00
Timothy Flynn
5d1657f57f LibWeb: Implement implicit submission of HTMLFormElement 2024-02-03 15:30:16 -07:00
Timothy Flynn
a17074422e LibWeb: Reset form association when any element with an ID changes
When an element with an ID is added to or removed from the DOM, or if
an ID is added, removed, or changed, then we must reset the form owner
of all form-associated elements who have a form attribute.

We do this in 2 steps, using the DOM document as the messenger to handle
these changes:

1. All form-associated elements with a form attribute are stored on the
   document. If the form attribute is removed, the element is removed
   from that list as well.

2. When a DOM element with an ID undergoes any of the aforementioned
   changes, it notifies the document of the change. The document then
   forwards that change to the stored form-associated elements.
2024-02-03 15:30:16 -07:00
Timothy Flynn
960dcf0e56 LibWeb: Reset form association when the element's form attribute changes 2024-02-03 15:30:16 -07:00
Timothy Flynn
23fb1209af LibWeb: Add FormAssociatedElement to the forwarding header 2024-02-03 15:30:16 -07:00
Timothy Flynn
fb270289a4 LibWeb: Store HTMLFormElement associated elements as nonnull GC pointers
We never store null elements in this list, so let's avoid confusion and
store the elements as NonnullGCPtr.
2024-02-03 15:30:16 -07:00
Timothy Flynn
c5f8f940f0 LibWeb: Convert some tabs to spaces in an HTMLFormElement comment block 2024-02-03 15:30:16 -07:00
Tim Ledbetter
d73979e0a8 LibWeb: Don't update input text if Ctrl or Alt are pressed
With this change, input elements ignore keypresses while Ctrl or Alt
are pressed. This matches the behavior of Chrome and Firefox
2024-02-03 14:07:37 -05:00
Timothy Flynn
0d3072bdac LibJS: Use IteratorStepValue in ECMA-402
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/e295500
2024-02-03 14:07:26 -05:00
Timothy Flynn
18847fca50 LibJS: Use IteratorStepValue in ECMA-262
This is an editorial change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/12d3687

Note they have not yet updated all potential consumers to use this new
AO.
2024-02-03 14:07:26 -05:00
Timothy Flynn
2b96e732dd LibJS: Implement the IteratorStepValue AO
This is an editorial change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/12d3687

This AO is meant to replace usages of IteratorNext followed by
IteratorValue with a single operation.
2024-02-03 14:07:26 -05:00
Timothy Flynn
3ca86cd044 LibJS: Allow creating the specialized Optional<Value> from OptionalNone
This allows, for example:

    ThrowCompletionOr<Optional<Value>> foo()
    {
        return OptionalNone {};
    }

The constructors and constraints here are lifted verbatim from
AK::Optional.
2024-02-03 14:07:26 -05:00
Aliaksandr Kalenik
36553d4566 LibWeb: Do not add CSS transforms into clip rect in PaintableWithLines
Painting command executor already accounts for CSS transforms so clip
rect only needs to be adjusted by scroll offset.
2024-02-03 20:05:09 +01:00
Aliaksandr Kalenik
7ad0767aa0 LibWeb: Remove BrowsingContext::scroll_to()
Let's use navigable directly instead of going through browsing context
to request a scroll.
2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
0c92c80544 LibWeb: Redirect wheel events to iframe if needed in EventHandler 2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
bf14de4118 LibWeb: Remove direct calls of page_did_request_scroll_to()
By replacing the `page_did_request_scroll_to()` calls with a request
to perform scrolling in the corresponding navigable, we ensure that
the scrolling of iframes will scroll within them instead of triggering
scroll of top level document.
2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
607e4cab0a LibWeb: Use associated navigable in scrollX and scrollY in Window
If these functions are invoked from inside an iframe, we should use
the navigable associated with the iframe to get the viewport.
2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
531025465a LibWeb: Remove list_of_descendant_browsing_contexts()
No longer used after migrating to navigables.
2024-02-03 14:54:55 +01:00
Aliaksandr Kalenik
2175c85cea LibWeb: Remove did_stop_being_active_document_in_browsing_context()
No longer used after migrating to navigables.
2024-02-03 14:54:55 +01:00
Kyle Lanmon
f757a7cfa8 LibJS: Support more weird date formats found on the web 2024-02-03 09:29:40 +01:00
Kyle Lanmon
05b30ece17 LibCore: Add DateTime parser for milliseconds 2024-02-03 09:29:40 +01:00
Kyle Lanmon
f7efbba32d LibCore: Add parser for time offset without a sign
There is already a parser for the time offset but it requires a positive
or negative sign. There are some weird formats on the web that do not
have the sign, so let's support that. I chose to implement this as a new
option instead of editing the old one to avoid any unknown breaking
changes.
2024-02-03 09:29:40 +01:00
Aliaksandr Kalenik
1af466babf LibWeb: Fix invalidation of CSS properties that do not affect layout
Recently, we moved the resolution of CSS properties that do not affect
layout to occur within LayoutState::commit(). This decision was a
mistake as it breaks invalidation. With this change, we now re-resolve
all properties that do not affect layout before each repaint.
2024-02-03 09:28:03 +01:00
Nico Weber
955d73657e LibPDF: Make pdf --dump-contents dump less binary data
For pages containing images or embedded fonts, --dump-contents
used to dump a ton of binary data. That isn't very useful, so
stop doing it.

Before:

    % time Build/lagom/bin/pdf --render out.png \
        ~/Downloads/0000/0000711.pdf --dump-contents | wc -l
      937972

Now:

    % time Build/lagom/bin/pdf --render out.png \
        ~/Downloads/0000/0000711.pdf --dump-contents | wc -l
        6566

Printing 7k lines is also much faster than printing 940k,
0.15s instead of 2s.
2024-02-03 08:26:29 +00:00
Aliaksandr Kalenik
5a29440bdf LibWeb: Create AccelGfx context only once in PageClient
Fixes silly bug when AccelGfx always was created twice.
2024-02-03 07:03:42 +01:00
Kemal Zebari
dbb3c07e56 LibWeb/HTML: Sniff text or binary resources in HTMLObjectElement 2024-02-02 14:34:17 -05:00
Kemal Zebari
8e5410347b LibWeb/MimeSniff: Add non-standard text or binary context sniffing
This is used in cases where the spec expects us to only run the
"rules for distinguishing if a resource is a text or binary" algo.
2024-02-02 14:34:17 -05:00
Sam Atkins
8a974ca91a SystemServer: Correct logic for services exiting successfully
WIFEXITED() returns a bool, so previously we were setting
exited_successfully to true when the service was terminated by a signal,
and false if it exited, regardless of the exit status. To test the exit
status, we have to use WEXITSTATUS() instead.

This causes us to correctly use the "3 tries then give up" logic for
services that crash, instead of infinitely attempting to respawn them.
2024-02-02 16:08:23 +00:00
Nico Weber
e269526020 LibGfx/PNM: Remove two fixmes
bab2113ec1 made read_whitespace() return ErrorOr, which makes this
easy to do.

(7cafd7d177, which added the fixmes, landed slightly after bab2113ec1,
so not quite sure why it wasn't like this immediately. Maybe commit
order got changed during review; both commits were in #17831.)

No behavior change.
2024-02-02 08:26:40 +00:00
Nico Weber
eeb0d6f52b image: Remove "do_" prefix on two function names
These were here due to the prefix-less name conflicting with a local
bool, but now that options are in a struct that's no longer a problem.

No behavior change.
2024-02-02 07:20:02 +01:00
Nico Weber
d575d4fb9b image: Extract option parsing to separate function
No behavior change.
2024-02-02 07:20:02 +01:00
Nico Weber
6dc5608d95 image: Allow saving CMYK jpegs
`image` can't transform from RGB to CMYK yet, so the only way to
do this is by having a CMYK input.

For example, this works now (and it does a full decode and re-encode):

    Build/lagom/bin/image -o out.jpg \
        Tests/LibGfx/test-inputs/jpg/buggie-cmyk.jpg

Using this to convert `.pam` files written by `mutool extract`
to jpegs is a somewhat convenient method of looking at these
.pam files.
2024-02-02 07:19:18 +01:00
Nico Weber
2298aac1d1 image: Only create output file for known extensions
Previously `image -o foo.asdf foo.png` would create a 0-byte foo.asdf
before complaining that it doesn't know how to write .asdf images.

(Lifetimes of temporaries are extended to the end of the full
expresion, so this is fine.)
2024-02-02 07:19:18 +01:00
Nico Weber
1dfd68c798 LibGfx/JPEGWriter: Make it possible to write CMYKBitmaps
We always store CMYK data as YCCK, for two reasons:

1. If we ever want to do subsampling, then doing 2111 or
   2112 makes sense with YCCK, while it doesn't make sense
   if we store CMYK directly.
2. It forces us to write a color transform header. With a color
   transform header, everyone agrees that the CMYK channels should
   be stored inverted, while without it behavior between decoders
   is inconsistent. (We could write an explicit  color transform header
   for CMYK too though, but with YCCK it's harder to forget since the
   output will look wrong everywhere without it.)

initialize_mcu() grows a full CMYKBitmap override. Some of the
macroblock traversal could probably shared with some kind of
for_all_macroblocks() type function in the future, but the color
conversion math is different enough that this should be a separate
function.

Other than that, we pass around a mode parameter and make a few fuctions
write 4 instead of 3 channels, and that's it.

We use the luminance quantization and huffman tables for the K
channel.
2024-02-02 07:19:18 +01:00
Nico Weber
e8788d4023 LibGfx/JPEGWriter: Move image data writing into new add_image() function
No behavior change.
2024-02-02 07:19:18 +01:00
Nico Weber
e449dba85b LibGfx/JPEGWriter: Move header writing into new add_headers() function
No behavior change.
2024-02-02 07:19:18 +01:00
Nico Weber
4e637fa1d2 LibGfx/JPEGWriter: Pass IntSize instead of Bitmap to add_frame_header()
No behavior change.
2024-02-02 07:19:18 +01:00