Commit Graph

56705 Commits

Author SHA1 Message Date
Aliaksandr Kalenik
17fb82d49b LibAccelGfx+LibWeb: Discard painting of commands outside of viewport 2023-11-26 21:26:26 +01:00
Aliaksandr Kalenik
c68a9b2cfe LibAccelGfx: Skip glyph atlas rebuild if all needed glyphs are present
Before this change, every repaint required a glyph atlas update, which
took 10-20% of the total painting time according to my testing on
different websites. This change improves that significantly by skipping
atlas updated when all glyphs are already present in the texture.
2023-11-26 21:26:26 +01:00
Aliaksandr Kalenik
28723d8be1 LibAccelGfx+LibWeb: Move glyph atlas into a singleton class
This is going to allow us reuse glyph texture across painters and page
repaints.
2023-11-26 21:26:26 +01:00
Aliaksandr Kalenik
4b23046a22 LibWeb: Add missing nullptr check in HTMLImageElement::bitmap()
Fixes crashing on https://discord.com/login
2023-11-26 21:26:09 +01:00
Andreas Kling
b2a1f39400 LibJS/JIT: Add fast path for JumpConditional where accumulator is Int32 2023-11-26 19:32:51 +01:00
Andreas Kling
cb46a7fd65 LibJS: Add specialized fast paths for 8/16/32-bit integer TypedArrays
By checking a few conditions up front, we can do a very specialized
direct access into the underlying byte storage for 8/16/32-bit typed
arrays. This relies on the fact that typed arrays are guaranteed to
be type-appropriately aligned within the underlying array buffer.
2023-11-26 19:32:51 +01:00
Andreas Kling
4cce181ece LibJS: Devirtualize Object::is_typed_array() 2023-11-26 19:32:51 +01:00
Andreas Kling
d154a758fa LibJS: Devirtualize TypedArrayBase::kind()
Let's put this in a member variable to avoid the virtual call.
2023-11-26 19:32:51 +01:00
Timothy Flynn
3fcb07597b LibWeb: Remove now-unneeded TypedArray OOM propagation
No longer throws after abcf71a8ca.
2023-11-26 08:23:37 -05:00
Aliaksandr Kalenik
a1c8fb10fa LibAccelGfx+LibWeb: Add texture cache for immutable bitmaps
This change introduces a texture cache for immutable bitmaps in the
GPU painter. The cache is persisted across page repaints, so now, on
page scroll repaint, in many cases, we won't need to upload any new
textures. Also, if the same image is painted more than once on a page,
its texture will only be uploaded once.

Generally, the GPU painter works much faster with this change on all
pages that have images.
2023-11-26 12:55:43 +01:00
Aliaksandr Kalenik
f4a5c136c3 LibGfx+LibWeb: Add ImmutableBitmap for images bitmap caching in painter
Before this change, we used Gfx::Bitmap to represent both decoded
images that are not going to be mutated and bitmaps corresponding
to canvases that could be mutated.

This change introduces a wrapper for bitmaps that are not going to be
mutated, so the painter could do caching: texture caching in the case
of GPU painter and potentially scaled bitmap caching in the case of CPU
painter.
2023-11-26 12:55:43 +01:00
Andreas Kling
abcf71a8ca LibJS: Remove unnecessary ThrowCompletionOr return types in TypedArray
We used to need these because we worried about tiny OOM errors.

Work towards #20449
2023-11-26 10:33:56 +01:00
Andreas Kling
1bc58333f8 LibJS: Add common fast path for GetByValue from TypedArray
Same exact idea as the previous commit, just for GetByValue. :^)
2023-11-26 10:14:55 +01:00
Andreas Kling
51ac0d8821 LibJS: Add common fast path for PutByValue into TypedArray
When putting to a numeric indexed property, we can skip a lot of the
ceremony and go directly to IntegerIndexedElementSet. :^)
2023-11-26 10:14:55 +01:00
Idan Horowitz
743a9e9ebf Kernel: Stop including the ethernet header in LoopbackAdapter's mtu
The networking subsystem currently assumes all adapters are Ethernet
adapters, including the LoopbackAdapter, so all packets are pre-pended
with an Ethernet Frame header. Since the MTU must not include any
overhead added by the data-link (Ethernet in this case) or physical
layers, we need to subtract it from the MTU.

This fixes a kernel panic which occurs when sending a packet that is at
least 65523 bytes long through the loopback adapter, which results in
the kernel "receiving" a packet which is larger than the support MTU
out the other end. (As the actual final size was increased by the
addition of the ethernet frame header)
2023-11-25 16:34:38 +01:00
Idan Horowitz
16a53c811e Kernel: Treat a backlog argument of 0 to listen() as if it was 1
As per POSIX, the behavior of listen() with a backlog value of 0 is
implementation defined: "A backlog argument of 0 may allow the socket
to accept connections, in which case the length of the listen queue may
be set to an implementation-defined minimum value."
Since creating a socket that can't accept any connections seems
relatively useless, and as other platforms (Linux, FreeBSD, etc) chose
to support accepting connections with this backlog value, support it as
well by normalizing it to 1.
2023-11-25 16:34:38 +01:00
Aliaksandr Kalenik
afe24883b7 LibWeb: Remove exit for javascript urls in anchor activation_behavior()
This early return is no longer needed because Navigable::navigate()
can process `javascript:` urls.

Fixes https://github.com/SerenityOS/serenity/issues/22052
2023-11-25 16:33:54 +01:00
Dan Klishch
80d1c93edf AK+Applications: Return value from JsonObject::get_double more often
Previously, we were returning an empty optional if key contained a
numerical value which was not stored as double. Stop doing that and
rename the method to signify the change in the behavior.

Apparently, this fixes bug in an InspectorWidget in Ladybird on
Serenity: it showed 0 for element's boxes with integer sizes.
2023-11-25 11:02:17 +01:00
Timothy Flynn
7cdd07b89a LibWebView: Scroll inspected elements into view with a slight offset
When scrolling to the inspected element, if we scroll to its exact
position, it would often be placed behind the fixed header at the top of
the WebView. This patch gives the scroll a bit of an offset to scroll
comfortably beneath the header.
2023-11-24 17:19:08 -05:00
Timothy Flynn
aa4dcda5dc LibWeb+LibWebView+Ladybird: Scale scroll-to CSS positions in PageHost
The `page_did_request_scroll_to` API takes a CSS position, and thus
callers should not scale to device pixels before invoking it. Instead,
align this API with (most) other PageHost APIs which scale to device
pixels before sending the corresponding IPC message.

In the AppKit chrome, convert the provided device pixel position to a
widget position.
2023-11-24 17:19:08 -05:00
Timothy Flynn
778f10fb26 Revert "Meta: Port recent changes to GN build"
This reverts commit 754ecc56dd.

This was handled by: 49b7539290.
2023-11-24 11:24:58 -05:00
Timothy Flynn
fb1845f294 Ladybird/AppKit: Invert the horizontal delta scroll value
This matches the negation of the vertical scroll delta value. This makes
the scroll events behave as follows on macOS:

Natural scrolling enabled:
* Scrolling up on the trackpad scrolls down on the page.
* Scrolling right on the trackpad scrolls left on the page.

Natural scrolling disabled:
* Scrolling up on the trackpad scrolls up on the page.
* Scrolling right on the trackpad scrolls right on the page.
2023-11-24 11:22:17 -05:00
Timothy Flynn
754ecc56dd Meta: Port recent changes to GN build
a6106ca221
04c094343f
2023-11-24 11:22:17 -05:00
Sönke Holz
185715d832 Kernel/riscv64: Generate Kernel.bin from kernel ELF
This is necessary for being able to use the qemu `-kernel` option.
The QEMU virt machine uses OpenSBI's FW_DYNAMIC feature to pass
the kernel entry address, which is the virtual entry point address
specified in the kernel ELF. If we instead `objcopy` the kernel into a
raw binary, OpenSBI will jump to the physical kernel load address, which
is what we want it to do.
2023-11-24 08:52:02 -07:00
Sönke Holz
fa39a57474 Kernel/riscv64: Add missing input sections to linker script
The linker would otherwise put those sections after
`end_of_kernel_image`.
2023-11-24 08:50:19 -07:00
Andrew Kaster
49b7539290 Meta: Port recent changes to gn build
b7f8d7e357
048e179572
6d1a1daff9
04c094343f
a6106ca221
2023-11-24 08:43:01 -07:00
Andreas Kling
afeb551d57 LibJS/JIT: Add builtin for Math.exp() 2023-11-24 12:49:15 +01:00
Andreas Kling
8447544e17 LibJS/JIT: Add builtin for Math.round() 2023-11-24 12:49:15 +01:00
Andreas Kling
c2ff238467 LibJS/JIT: Add builtin for Math.ceil() 2023-11-24 12:49:15 +01:00
Andreas Kling
08590adf40 LibJS/JIT: Add builtin for Math.floor() 2023-11-24 12:49:15 +01:00
Andreas Kling
5e976d611e LibJS/JIT: Add builtin for Math.pow() 2023-11-24 12:49:15 +01:00
Andreas Kling
94b634f029 LibJS/JIT: Add builtin for Math.sqrt() 2023-11-24 12:49:15 +01:00
Andreas Kling
1d8a601f96 LibJS/JIT: Add builtin for Math.log()
Note that we still call out to a C++ helper, but by having a builtin,
we still avoid the cost of a full JS function call.
2023-11-24 12:49:15 +01:00
Andreas Kling
a6106ca221 AK: Use __builtin_offsetof() + -Wno-invalid-offsetof to silence ASAN
ASAN was crying way too much when running the LibJS JIT since the old
OFFSET_OF implementation was too wild for its liking.

By turning off the invalid-offsetof warnings, we can use the offsetof
builtin instead. However, I'm leaving this as a wrapper macro, since
we may still want to do something different for other compilers.
2023-11-24 12:49:15 +01:00
david072
1541942e10 LibCards/CardPainter: Add a helper for accessing the caches
The CardPainter in LibCards caches already painted bitmaps. This adds a
helper that gets the bitmap from a cache or creates a new one, if the it
doesn't exist yet. It does this by calling a creator function with the
new bitmap, which can then paint into the bitmap. This makes the code a
bit simpler and shorter.
2023-11-24 11:45:32 +00:00
david072
bac7c057e9 Spider: Make non-movable cards disabled :^)
In Spider, cards that can't be moved are now shown as disabled using the
helpers in LibCards. This makes it much easier to see what can be moved
and to where, overall improving the game significantly!
2023-11-24 11:45:32 +00:00
david072
0a806837b5 LibCards/CardStack: Helper to update the cards' disabled flags
This adds a little helper in Cards::CardStack that updates the disabled
flags for its cards depending on a movement rule. It does this by
searching from the bottom up for the last card that is valid. It then
sets the disabled flag for all cards above that card, if it isn't upside
down.
2023-11-24 11:45:32 +00:00
david072
55168b50dc LibCards: Painting disabled cards 2023-11-24 11:45:32 +00:00
david072
65b9cb63ee Spider: Port to the GML compiler 2023-11-24 11:45:32 +00:00
Shannon Booth
b7bcdf7c53 LibWeb: Fix UAF in CSSStyleSheet
CSSNamespaceRule returns a copy of a DeprecatedString, meaning that the
view returned by the namespace in CSSStyleSheet is into a temporary
string.
2023-11-24 10:57:17 +01:00
Shannon Booth
673329e1bd LibWeb: Use ArrayBufferView for ReadableStreamBYOBReader
Which means that we now have support for DataViews.

Using the ArrayBufferView class also seems to make this read a whole
bunch nicer as well.
2023-11-24 08:43:35 +01:00
Shannon Booth
eab20129b9 LibWeb: Use ArrayBufferView for Crypto::getRandomValues
Co-Authored-By: Matthew Olsson <mattco@serenityos.org>
2023-11-24 08:43:35 +01:00
Shannon Booth
04c094343f LibWeb+Meta: Add wrapper for the BufferSource/ArrayBufferView IDL types
These wrappers will make it much easier to do various operations on the
different ArrayBuffer-related classes in LibWeb compared to the current
solution, which is to just accept a Handle<Object> everywhere (and use
"any" in the *.idl files).

Co-Authored-By: Matthew Olsson <mattco@serenityos.org>
2023-11-24 08:43:35 +01:00
Sam Atkins
54d0aafff0 LibGfx: Use FourCC as OpenType::Tag type
The one deviation from the spec here is to use this in the WOFF
TableDirectoryEntry's tag field. However, *not* making that a Tag made
a lot of things more complicated than they need to be.
2023-11-24 08:42:46 +01:00
Sam Atkins
0423225290 LibGfx: Make FourCC more useful
A few small changes that didn't seem to deserve separate commits:
- Mark it as packed to remove compiler complaints when it's a member of
  a packed struct.
- Add a default constructor for places where we fill in a struct
  gradually.
- Restrict the constructor to exactly 4-character string literals.
- Add a to_u32() method for the one place that needs that.
2023-11-24 08:42:46 +01:00
Sam Atkins
2c24192e1f LibGfx: Move FourCC to its own file
These are used in fonts too, so let's not limit them to ImageLoader.
2023-11-24 08:42:46 +01:00
timmot
9f2ee86e4d Tests/LibWeb: Test canvas fillStyle parsing of rgb strings 2023-11-24 08:42:18 +01:00
timmot
c713445253 LibWeb: Report when CanvasFillOrStrokeStyle parsing fails 2023-11-24 08:42:18 +01:00
timmot
2ecc1d64d8 LibGfx: Accept decimal numbers when parsing rgb and rgba strings
This will round all numbers and clamp them within the limits of a u8.
This also standardises on returning u8 instead of uint/int.
2023-11-24 08:42:18 +01:00
timmot
da3cfd5bbc AK+LibWeb: Make clamp_to_int generic over all integrals 2023-11-24 08:42:18 +01:00