Commit graph

59459 commits

Author SHA1 Message Date
Andreas Kling ea0b7192fa Revert "LibJS/Bytecode: Don't fuse unrelated compare and jump in peephole pass"
This reverts commit c1dbde72e9.
2024-03-06 08:39:29 +01:00
Timothy Flynn baf359354b LibWebView+WebContent: Use Web::InputEvent for WebContent input IPC
Now that all input events are handled by LibWebView, replace the IPCs
which send the fields of Web::KeyEvent / Web::MouseEvent individually
with one IPC per event type (key or mouse).

We can also replace the ad-hoc queued input structure with a smaller
struct that simply holds the tranferred Web::KeyEvent / Web::MouseEvent.

In the future, we can also adapt Web::EventHandler to use these structs.
2024-03-06 07:46:18 +01:00
Timothy Flynn 2c31ef11bc Ladybird/AppKit: Handle input events through LibWebView
The AppKit chrome currently handles all input events before selectively
forwarding those events to WebContent. This means that WebContent does
not see events like cmd+c.

Here, we make use of LibWebView's input handling and wait for LibWebView
to inform the chrome that it should handle the event itself.
2024-03-06 07:46:18 +01:00
Timothy Flynn c1476c3405 Ladybird/Qt: Handle input events through LibWebView
The Qt chrome currently handles all input events before selectively
forwarding those events to WebContent. This means that WebContent does
not see events like ctrl+c.

Here, we make use of LibWebView's input handling and wait for LibWebView
to inform the chrome that it should handle the event itself.
2024-03-06 07:46:18 +01:00
Timothy Flynn ea682207d0 LibWeb+LibWebView: Migrate Browser's input event handling to LibWebView
The Serenity chrome is the only chrome thus far that sends all input key
and mouse events to WebContent, including shortcut activations. This is
necessary for all chromes - we must give web pages a chance to intercept
input events before handling them ourselves.

To make this easier for other chromes, this patch moves Serenity's input
event handling to LibWebView. To do so, we add the Web::InputEvent type,
which models the event data we need within LibWeb. Chromes will then be
responsible for converting between this type and their native events.

This class lives in LibWeb (rather than LibWebView) because the plan is
to use it wholesale throughout the Page's event handler and across IPC.
Right now, we still send the individual fields of the event over IPC,
but it will be an easy refactor to send the event itself. We just can't
do this until all chromes have been ported to this event queueing.

Also note that we now only handle key input events back in the chrome.
WebContent handles all mouse events that it possibly can. If it was not
able to handle a mouse event, there's nothing for the chrome to do (i.e.
there is no clicking, scrolling, etc. the chrome is able to do if the
WebContent couldn't).
2024-03-06 07:46:18 +01:00
Timothy Flynn f2204e2b3a LibGUI: Define bitwise operations for GUI::MouseButton
This type is designed to be use as a flag. Define bitwise operations for
convenience.

(clang-format-17 caught an east-const conversion here as well).
2024-03-06 07:46:18 +01:00
Timothy Flynn 4b777397b5 Kernel: Define bitwise operations for KeyModifier
This type is designed to be use as a flag. Define bitwise operations for
convenience.
2024-03-06 07:46:18 +01:00
Matthew Olsson 8f3b97e095 LibWeb: Don't render elements with invalid interpolated transform values 2024-03-06 07:45:56 +01:00
Matthew Olsson e6aef49ef3 LibWeb: Consider fill state before calling Animation::play()
Animation::play_state() does not consider the fill state, and thus will
not return "Playing" for a fill-forward animation in the after phase.
It is still valid for paused, as pausing is not affected by the fill
mode.
2024-03-06 07:45:56 +01:00
Matthew Olsson 5dfe99e247 LibWeb: Do not assert the type of transformation style values
In this case, the StyleValue may be "unresolved", however let's just
avoid the assert altogether and treat all non-transform values as
"none".
2024-03-06 07:45:56 +01:00
Matthew Olsson 1ca31e0dc1 LibWeb: Remove unnecessary ErrorOr<> from StyleComputer
All of this error propogation came from a single call to
HashMap::try_ensure_capacity! As part of the ongoing effort to ignore
small allocation failures, lets just assert this works. This has the
nice side-effect of propogating out to a few other classes.
2024-03-06 07:45:56 +01:00
Matthew Olsson a511f1ef85 AK: Add HashMap::ensure_capacity 2024-03-06 07:45:56 +01:00
Matthew Olsson 8bb635bd33 LibWeb: Prevent transform interpolations from failing
Style computation should never fail. Instead, we just ignore the
transformation that led to the invalid matrix.
2024-03-06 07:45:56 +01:00
Aliaksandr Kalenik 4d8bc16812 LibWeb: Respect "auto flow" property in grid layout
Before this change, we only considering `grid-auto-flow` to determine
whether a row or column should be added when there was not enough space
in the implicit grid to fit the next unplaced item.

Now, we also choose the direction in which the "auto placement cursor"
is moved, based on the auto flow property.
2024-03-06 07:23:27 +01:00
Andrew Kaster f9f98016e2 Tests: Add test for loading module scripts in Workers 2024-03-06 07:19:10 +01:00
Andrew Kaster f67bc591a0 LibWeb: Implement and use the fetch a module worker script graph AO
This involves plumbing the perform the fetch hook argument throughout
all of the module fetch implementation AOs, where it was left as a FIXME
before.

With this change we can load module scripts in DedicatedWorkers.
2024-03-06 07:19:10 +01:00
Andrew Kaster b5acc5f2df LibWeb: Serialize and pass to the WebWorker the current ESO
This allows the initial fetch() in the run a worker AO to use the proper
values from the outside settings.
2024-03-06 07:19:10 +01:00
Andrew Kaster 4d22358e05 LibWeb: Add facilities to serialize EnvironmentSettingsObjects
This will be used to transfer information about the parent context to
DedicatedWorkers and future out-of-process Worker/Worklet
implementations for fetching purposes. In order to properly check
same-origin and other policies, we need to know more about the outside
settings than we were previously passing to the WebWorker process.
2024-03-06 07:19:10 +01:00
Andrew Kaster c79bac70f4 LibWeb: Consistently use the EmptyString state of ReferrerPolicy
We previously used an empty optional to denote that a ReferrerPolicy is
in the default empty string state. However, later additions added an
explicit EmptyString state. This patch moves all users to the explicit
state, and stops using `Optional<ReferrerPolicy>` everywhere except for
when an option not being passed from JavaScript has meaning.
2024-03-06 07:19:10 +01:00
Andrew Kaster 637f2f2ed6 LibProtocol: Keep reading until an error occurs for buffered reads
When buffering is enabled for the entire protocol request, it's possible
that the entirety of the file data might be available on the first read
of the pipe passed from RequestServer. If the file is then closed on the
RequestServer end, the client would never realize that the file is EOF
and call the user-provided on_finish callback.

By reading until there's an error, we expect to get an EAGAIN or similar
non-blocking pipe error message if there is still more data.
2024-03-06 07:19:10 +01:00
Andrew Kaster 7e6918e14a LibIPC: Add support for encoding and decoding Array<T, N>
Also add a note to the Concepts header that the reason we have all the
strange concepts in place for container types is to work around the
language limitation that we cannot partially specialize function
templates.
2024-03-06 07:19:10 +01:00
Andrew Kaster e09bfc1a8c LibCore: Recognize .mjs as a common extension for application/javascript 2024-03-06 07:19:10 +01:00
Andrew Kaster 285df77fb8 Meta: Port recent changes to the GN build
5b29974bfa
c5860d1d70
2024-03-06 07:19:10 +01:00
Nico Weber ab143e9b0e LibGfx/BMP: Clear alpha in palette entries
The semantics of BGRx8888 aren't super clear and it means different
things for different parts of the codebase. In particular, the PNG
writer still writes the x channel to the alpha channel of its output.

In BMPs, the 4th palette byte is usually 0, which means after #21412 we
started writing all .bmp files with <= 8bpp as completely transparent
to PNGs.

This works around that.

(See also #19464 for previous similar workarounds.)

The added `bitmap.bmp` is a 1bpp file I drew in Photoshop and saved
using its "Save as..." saving path.
2024-03-05 21:27:41 +00:00
Tim Schumacher b9a5442b59 Ports/zlib: Switch to tarball copies hosted on GitHub
zlib.net uses DDoS protection, which results in broken downloads
whenever a browser validation page is served instead. The tarballs that
are uploaded to GitHub releases are identical with the ones that are
served on zlib.net.
2024-03-05 18:16:09 +01:00
Aliaksandr Kalenik 16f33aafda LibWeb: Always check paintable boxes children during hit-testing
Children of a paintable box are not guaranteed to be contained within
its border box. Therefore, during hit-testing, we must always check
them.

Fixes https://github.com/SerenityOS/serenity/issues/23219
2024-03-05 15:43:17 +01:00
Andreas Kling c1dbde72e9 LibJS/Bytecode: Don't fuse unrelated compare and jump in peephole pass
Fixes an issue where https://x.com/awesomekling crashed on load. :^)
2024-03-05 13:39:25 +01:00
Andreas Kling 0f8c6dc9ad LibJS/Bytecode: Always evaluate LHS first in assignment expressions
This fixes an issue where expressions like `a[i] = a[++i]` could
evaluate `++i` before `a[i]`.
2024-03-05 10:19:38 +01:00
ddorando 1986693edc Ports: Fix libjodycode and jdupes download
The author unpublished everything on github and moved to codeberg.
The different hashes come from the new platform packaging the
tarfiles differently than before.
2024-03-05 03:24:16 +01:00
Andreas Kling 17c1f742a9 LibJS/Bytecode: Increase coverage of left/shift expression fast paths
As long as the inputs are Int32, we can convert them to UInt32 in a
spec-compliant way with a simple static_cast<u32>.

This allows calculations like `-3 >>> 2` to take the fast path as well,
which is extremely valuable for stuff like crypto code.

While we're doing this, also remove the fast paths from the generic
shift functions in Value.cpp, since we only end up there if we *didn't*
take the same fast path in the interpreter.
2024-03-04 20:54:51 +01:00
Andreas Kling a5e1e66abc LibJS/Bytecode: Add fast path for LeftShift with Int32 operands 2024-03-04 20:54:51 +01:00
Andreas Kling 8e04791480 LibJS/Bytecode: Combine has_index() and get() in GetByVal and PutByVal
Since get() returns an empty Optional if the index is not present, we
can combine these two into a single get() operation and save the cost of
a virtual call.
2024-03-04 20:54:51 +01:00
Andreas Kling 55e9df4954 LibJS/Bytecode: Add fast paths for equality checks with same-tag values 2024-03-04 20:54:51 +01:00
Andreas Kling 795149e585 LibJS/Bytecode: Fuse [Not, JumpIf] instructions into JumpIfNot 2024-03-04 20:54:51 +01:00
Andreas Kling 4438ec481c LibJS/Bytecode: Add peephole optimization pass and fuse compare+jump
This patch adds a new "Peephole" pass for performing small, local
optimizations to bytecode.

We also introduce the first such optimization, fusing a sequence of
some comparison instruction FooCompare followed by a JumpIf into a
new set of JumpFooCompare instructions.

This gives a ~50% speed-up on the following microbenchmark:

    for (let i = 0; i < 10_000_000; ++i) {
    }

But more traditional benchmarks see a pretty sizable speed-up as well,
for example 15% on Kraken/ai-astar.js and 16% on Kraken/audio-dft.js :^)
2024-03-04 20:54:51 +01:00
Andreas Kling acd29e064c LibJS/Bytecode: Don't replace the entry block in MergeBlocks
The entry block must stay in place, although it's okay to merge stuff
into it.

This fixes 4 test262 tests and brings us to parity with optimization
disabled. :^)
2024-03-04 20:54:51 +01:00
Andreas Kling 5b29974bfa LibJS/Bytecode: Bring back the bytecode optimization pipeline
...minus the EliminateLoads pass, since it was not compatible with the
new bytecode format.
2024-03-04 20:54:51 +01:00
Timothy Flynn 836d93f7e3 Kernel: Replace C-idioms with AK types in RTL8168 network adapter
Instead of using C-arrays, and manually counting their lengths, use
AK::Array. And pass these arrays around as spans, instead of as pointer-
and-length pairs.
2024-03-04 20:00:52 +01:00
Hugh Davenport d8f756ce1d Escalator: Allow failed password attempts to be retried
There is a limit of 3 attempts before quitting, but the user can try
again after that.

The error messages now display to help the user understand the issue.
2024-03-04 13:25:22 -05:00
MacDue 74b655d035 LibWeb: Update SVG <circle> element to use geometry properties
With this the `<circle>` element now correctly parses percentage sizes,
and resolves them relative to the viewport.

The rest of the geometry elements are still left TODO.
2024-03-04 10:50:32 +01:00
MacDue 344eb98b3c LibWeb: Add helper to convert CSS LengthPercentage to SVGLength 2024-03-04 10:50:32 +01:00
MacDue 4f78ddd6a2 LibWeb: Setup computed values for SVG geometry properties 2024-03-04 10:50:32 +01:00
MacDue b9afea40e6 LibWeb: Update SVG get_path() API to take a viewport size
This will allow resolving paths that use sizes that are relative to the
viewport. This necessarily removes the on element caching, which has
been redundant for a while as computed paths are stored on the
paintable.
2024-03-04 10:50:32 +01:00
MacDue 1fbf1073ab LibWeb: Define the rest of the SVG geometry properties
This defines all the (remaining) geometry properties from
https://svgwg.org/svg2-draft/geometry.html#Sizing.
2024-03-04 10:50:32 +01:00
Timothy Flynn 552f63a283 LibWebView: Protect the Inspector against rapid inspection requests
This was seen in Browser when hotkey activations were processed twice.
If we open the Inspector with a hotkey (F12) and quickly activate that
hotkey again, we could try sending a JS command (inspector.loadDOMTree)
before the inspector.js file was actually loaded in the WebContent.

The window for this bug is larger on Serenity, where loading WebContent
is a bit slower than on Linux. So even with the Browser bug fixed, it is
pretty easy to hit this window still.
2024-03-04 10:49:43 +01:00
Timothy Flynn d392375a08 Revert "Browser: Allow system shortcuts to function"
This reverts commit 2e8ff1855c.

We had some awkward timing around the merging of this commit and commit
b073fdd570. With both commits in tree, we
are now processing hotkey activations twice. For example, ctrl+t will
open 2 tabs.
2024-03-04 10:49:43 +01:00
Kyle Lanmon a099d0e140 PDFViewer: Hide the rendering diagnostics window by default
You can enable it in the Debug menu and we will remember your choice.
2024-03-04 10:43:41 +01:00
Filiph Siitam Sandström d6ab5c9b7d LibCore: Fix AK_OS_ANDROID build
b9dc2d7 accidentally broke Android builds, this fixes that regression.
2024-03-04 07:55:39 +00:00
Sönke Holz c20bc22bae DynamicLoader: Disable stack protector in some files for RISC-V 2024-03-04 01:44:11 +01:00
Linus Groh 872bf51d8f Ports: Update Python to 3.12.2
Released on 2024-02-06.
https://www.python.org/downloads/release/python-3122/
2024-03-04 00:36:42 +01:00