Commit graph

58570 commits

Author SHA1 Message Date
Andrew Kaster
813c66403d LibWeb: Catch null browsing context in destroy_top_level_traversable
When WebDriver asks to destroy a window, we can hit this case with no
active browsing context. This seems odd, but perhaps is a spec issue as
well. Just log to dbgln for now.
2024-02-05 08:05:48 -07:00
Andrew Kaster
d508a02f25 LibWeb: Ensure that load events are fired for window.open('about:blank') 2024-02-05 08:05:48 -07:00
Andrew Kaster
888e67992a LibWeb: Remove unused BrowsingContext functions and data members
This aligns it better with the current state of the spec.

There's still some functions and data members that need moved into
Navigable or TraversableNavigable, but we can leave those for the next
cleanup PR.
2024-02-05 08:05:48 -07:00
Andrew Kaster
9645daaf6c LibWeb: Remove RemoteBrowsingContext and AbstractBrowsingContext
With the transition to Navigables, and a working implementation of
window.open(), we no longer need this abstraction layer.
2024-02-05 08:05:48 -07:00
Andrew Kaster
6e75440d5a LibWeb: Bring Document::fallback_base_url closer to the spec 2024-02-05 08:05:48 -07:00
Andrew Kaster
5d9d0aa267 LibWeb: Replace check for BrowsingContext's about blank state with false
This check has been if (false && stuff) for quite a while, since the
transition to Navigables. No one updates the BrowsingContext's session
history, so the check for it having an about blank document and only an
about blank document is always false.
2024-02-05 08:05:48 -07:00
Andrew Kaster
b6fc29ca21 LibWeb: Always use Navigable to translate CSS positions to top-level 2024-02-05 08:05:48 -07:00
Andrew Kaster
3aee787539 LibWeb+WebContent: Convert WebDriver to choose a navigable AO
Also use the TraversableNavigable's window_handle instead of the
BrowsingContext's.
2024-02-05 08:05:48 -07:00
Andrew Kaster
713698d2ca Documentation: Recommend disabling clangd's IncludeCleaner feature 2024-02-05 08:04:24 -07:00
Andrew Kaster
e6762e8d4d Meta: Disable readability-function-cognitive-complexity in clang-tidy
Feedback from contributors suggests that this warning doesn't help code
quality, and is seen as noisy.
2024-02-05 08:04:24 -07:00
Andrew Kaster
3078572f0d Meta: Disable misc-include-cleaner in clang-tidy
IncludeCleaner is a new feature of clang-tidy/clangd that adds upstream
support for the include-what-you-use (IWYU) tool's checks.

However, this tool is very noisy on our codebase. It can be enabled by
individual contributors at their leisure.
2024-02-05 08:04:24 -07:00
Dan Klishch
3e43d15440 Everywhere: Prefer VERIFY over assert() 2024-02-05 07:03:53 -05:00
Fabian Dellwing
ef9bfe3499 Ports: Update poppler to 24.02.0 2024-02-04 23:58:52 +01:00
Nico Weber
f562c470e2 LibGfx+LibPDF: Simpler and faster N-D linear sampling
Previously, if we wanted to to e.g. do linear interpolation in 2-D,
we'd get a sample point like (1.3, 4.4), then get 4 samples around
it at (1, 4), (2, 4), (1, 5), (2, 5), then reduce the 4 samples
to 2 samples by computing the combined samples
`0.3 * f(1, 4) + 0.7 * f(2, 4)` and `0.3 * f(1, 5) + 0.8 * f(2, 5)`,
and then 1-D linearly blending between these two samples with the
factor 0.4. In the end we'd multiply the first value by 0.3 * 0.4,
the second by 0.7 * 0.4, the third by 0.3 * 0.6, and the third by
0.7 * 0.6, and then sum them all up.

This requires computing and storing 2**N samples, followed by
another 2**N iterations to combine the 2**N sampls to a single value.
(N is in practice either 4 or 3, so 2**N isn't super huge.)

Instead, for every sample we can directly compute the product of
weights and sum them up directly. This lets us omit the second loop
and storing 2**N values, in exchange for doing an additional O(n)
work to compute the product.

Takes

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

form 3.42s to 3.08s on my machine, almost 10% faster (and less code).

Here cmyk.jpg is a 2253x3080 cmyk jpeg, and USWebCoatedSWOP.icc is an
mft2 profile with input tables with 256 samples and a 9x9x9x9 CLUT.

The LibPDF change is covered by TEST_CASE(sampled) in LibPDF.cpp,
and the LibGfx change is basically the same change as the one in
LibPDF (where the test results don't change) and the output
subjectively looks identical. So hopefully this causes indeed no
behavior change :^)
2024-02-04 21:49:23 +01:00
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