Commit graph

33299 commits

Author SHA1 Message Date
Aliaksandr Kalenik 9bc0552a80 LibWeb: Fix paint recording to stop visiting stacking context twice
...if its box is positioned and has z-index=0.
2024-04-29 17:26:13 +02:00
Andreas Kling 1db1ef9ea9 LibGfx: Make non-shared Bitmap used malloc() instead of mmap()
This drastically reduces the cost (in time AND space) of allocating
a Gfx::Bitmap.

Anything that needs to be shared is already using Core::AnonymousBuffer
anyway, so this shouldn't break anything important.

Do note that this makes it an error to create an empty (0x0) Bitmap,
which was previously allowed for some reason. Some small tweaks are
included to bail gracefully in such scenarios.
2024-04-29 09:49:28 +02:00
Andreas Kling db335f5f40 LibGfx+LibGUI: Move Bitmap volatility stuff to GUI::WindowBackingStore
This is only used by LibGUI to manage the volatility of window backing
stores, so let's move it out of Gfx::Bitmap.
2024-04-29 09:49:28 +02:00
Andreas Kling 0967bdad02 LibGfx: Remove the unused Bitmap::set_mmap_name() 2024-04-29 09:49:28 +02:00
Tim Ledbetter b9f0ea2178 LibWeb: Evaluate media rules for adopted style sheets
Previously, media rules were not evaluated for adopted style sheets.
2024-04-29 08:10:38 +02:00
Tim Ledbetter f4e0c5395a LibWeb: Don't apply disabled adopted style sheets to the document
Previously, we would apply any adopted style sheet to the document if
its alternate flag was not set. This meant that all adopted style
sheets would be applied, since constructed style sheets never have this
flag set.
2024-04-29 08:10:38 +02:00
Tim Ledbetter 84193f2746 LibWeb: Align StyleSheet title getter with the specification
The CSSOM specification says that StyleSheet.title should return null
if the title field is empty.
2024-04-29 08:10:38 +02:00
Aliaksandr Kalenik 7bea2b68f4 LibWeb: Paint non-positioned SC with z-index=0 in paint_descendants()
Fixes the bug when non-positioned boxes that establish a stacking
context and have z-index=0 are ignored during paint commands recording.
2024-04-28 22:28:18 +02:00
Aliaksandr Kalenik 15f69ffbba LibWeb: Use cached absolute rect and transform in refresh_clip_state()
Changes compute_absolute_padding_rect_with_css_transform_applied() to
use cached absolute rect and CSS transform instead of doing expensive
containing block chain traversal.

Reduces refresh_clip_state() from 4% to 2% in Discord profiles.
2024-04-28 17:47:03 +02:00
Timothy Flynn 34b446ab34 LibWeb: Assign the Content-Type fetch response header as appropriate
The condition here was inverted.
2024-04-28 12:32:04 +02:00
Timothy Flynn b04ef436fa LibWeb: Remove OOM propagation from Fetch::Response 2024-04-28 12:32:04 +02:00
Timothy Flynn 790589ceb0 LibWeb: Remove OOM propagation from Fetch::Request 2024-04-28 12:32:04 +02:00
Timothy Flynn d12c560859 LibWeb: Remove OOM propagation from Fetch::Headers 2024-04-28 12:32:04 +02:00
Timothy Flynn d327fa8135 LibWeb: Remove OOM propagation from Fetch::BodyInit 2024-04-28 12:32:04 +02:00
Timothy Flynn 3e991a55fa LibWeb: Remove OOM propagation from Fetch::Body 2024-04-28 12:32:04 +02:00
Andrew Kaster bc976fe7e1 LibWebView: Create plumbing for a single UI process
This allows main UI processes created while there is a currently
running one to request a new tab or a new window with the initial urls
provided on the command line. This matches (almost) the behavior of
Chromium and Firefox.

Add a new IPC protocol between two UI processes. The main UI process
will create an IPC server socket, while secondary UI processes will
connect to that socket and send over the URLs and action it wants the
main process to take.
2024-04-27 20:32:12 -04:00
Andrew Kaster 12a9702acb LibCore: Make singleton process helpers public 2024-04-27 20:32:12 -04:00
Andrew Kaster 70149079e4 LibCore: Add initializer for LocalServer from already connected socket 2024-04-27 20:32:12 -04:00
Andrew Kaster 4db0ec86c0 LibIPC: Allow creating MultiServer from an already existing LocalServer 2024-04-27 20:32:12 -04:00
Nico Weber f8362c8abf LibGfx/JPEG2000: Remove an incorrect VERIFY in TagTree construction
...and add a test case that shows why it's incorrect.

If one dimension is 2^n + 1 and the other side is just 1, then the
topmost node will have 2^n x 1 and 1 x 1 children. The first child will
have n levels of children. The 1 x 1 child could end immediately, or it
could require that it also has n levels of (all 1 x 1) children. The
spec isn't clear on which of the two alternatives should happen. We
currently have n levels of 1 x 1 blocks.

This test case shows that a VERIFY we had was incorrect, so remove it.

The alternative implementation is to keep the VERIFY and to add a

    if (x_count == 1 && y_count == 1)
        level = 0;

to the top of TagTreeNode::create(). Then we don't have multiple levels
of 1 x 1 nodes, and we need to read fewer bits.

The images in the spec suggest that all nodes should have the same
number of levels, so go with that interpretation for now. Once we can
actually decode images, we'll hopefully see which of the two
interpretations is correct.

(The removed VERIFY() is hit when decoding
Tests/LibGfx/test-inputs/jpeg2000/buggie-gray.jpf in a local branch that
has some image decoding implemented. That file contains a packet with
1x3 code-blocks, which hits this case.)
2024-04-28 01:12:20 +02:00
dgaston 342b358341 Utilities: Make uniq behavior consistent with coreutils
The main difference was that our implementation was writing
the final line of a series of repeated lines, whereas the
spec says "The second and succeeding copies of repeated adjacent
input lines shall not be written."

Additionally, there was a mistake in the -f flag implementation
causing the number of fields skipped to be one greater than
required.
2024-04-27 16:33:27 -06:00
dgaston 1d932d3ebf Utilities: Fix off by one error in uniq
Flags that rely on counting lines (-c and -d) were
producing results that were off by one. This is fixed
by initializing the `count` variable to 1, which is
consistent with behavior in the main loop, where it
is reset to 1 when lines don't match.
2024-04-27 16:33:27 -06:00
dgaston 82887473d2 Utilities: Allow uniq to work on lines of arbitrary length
Calls to `read_line` are replaced with `read_line_with_resize`
and `swap`s of StringViews, which assume a consistent location
of the underlying ByteBuffers, are replaced. A test file has
been added for uniq, which includes a test case for long lines.
2024-04-27 16:33:27 -06:00
Shannon Booth bad44f8fc9 LibWeb: Remove Bindings/Forward.h from LibWeb/Forward.h
This was resulting in a whole lot of rebuilding whenever a new IDL
interface was added.

Instead, just directly include the prototype in every C++ file which
needs it. While we only really need a forward declaration in each cpp
file; including the full prototype header (which itself only includes
LibJS/Object.h, which is already transitively brought in by
PlatformObject) - it seems like a small price to pay compared to what
feels like a full rebuild of LibWeb whenever a new IDL file is added.

Given all of these includes are only needed for the ::initialize
method, there is probably a smart way of avoiding this problem
altogether. I've considered both using some macro trickery or generating
these functions somehow instead.
2024-04-27 18:29:35 -04:00
Aliaksandr Kalenik b1205f0aa1 LibWeb: Skip unnecessary sample corner and blit corner commands
Before this change we were recording and executing sample/blit commands
for each painting phase, even if there are no painting commands
in-between sample and blit that produce result visible on a canvas.

This change adds an optimization pass that goes through recorded
painting commands list and marks sample and blit commands that could
be skipped.

Reduces sample and blit corners executing from 17% to 8% on Discord.
2024-04-27 21:06:16 +02:00
Andreas Kling b92839fad9 LibJS: Fix bug where argument++ happened before call
For this case to work correctly in the current bytecode world:

    func(a, a++)

We have to put the function arguments in temporaries instead of allowing
the postfix increment to modify `a` in place.

This fixes a problem where jQuery.each() would skip over items.
2024-04-27 17:24:29 +02:00
Aliaksandr Kalenik 776951b7ff LibWeb: Cache combined CSS transform on pre-paint phase
Makes 5% of `compute_combined_css_transform()` in Discord profiles gone.
2024-04-27 16:00:26 +02:00
Aliaksandr Kalenik cd07249482 LibWeb/Painting: Add ClippableAndScrollable mixin
Moves code that was duplicated across PaintableBox and InlinePaintable
into separate class.
2024-04-27 16:00:26 +02:00
Timothy Flynn 207f3f1cb4 LibCore: Remove unnecessary lifetime extension from ProcessSpawnOptions
We don't need `file_actions` to be a constant-reference. It's created
in-place by its one user (HackStudio). Because it is currently a const-
ref, if we try to create a ProcessSpawnOptions like so:

    Core::ProcessSpawnOptions options { .name = "foo"sv };

We get the following error with clang 18:

    lifetime extension of temporary created by aggregate initialization
    using a default member initializer is not yet supported; lifetime of
    temporary will end at the end of the full-expression
2024-04-27 15:17:31 +02:00
Shannon Booth 91efa1d568 LibWeb: Add skeleton for OfflineAudioContext
Implement enough to construct the object itself, with most parts stubbed
out.
2024-04-27 07:11:02 +02:00
Shannon Booth d27b70ae24 LibWeb: Add HTML event 'complete' 2024-04-27 07:11:02 +02:00
Aliaksandr Kalenik 613cd6104d LibWeb: Support masking of SVGForeignObjectPaintable 2024-04-27 07:10:20 +02:00
Aliaksandr Kalenik 7d05fe84bc LibWeb: Add layout node and paintable for SVGForeignObjectElement
Introduces separate layout and paintable type for foreign element.
It is necessary to inherit SVGForeignObjectPaintable from SVGMaskable
in upcoming changes.
2024-04-27 07:10:20 +02:00
Aliaksandr Kalenik acd5369774 LibWeb: Separate svg mask calculation into SVGMaskable
Preparation work before adding support for SVGForeignObjectElement
masking.

Having a mixin makes possible sharing mask calculation between
SVGForeignObjectElement's paintable and SVGGraphicsPaintable.

Both has to support masking:
- PaintableWithLines (from SVGForeignObjectElement) -> PaintableBox
- SVGGraphicsPaintable -> SVGPaintable -> PaintableBox

After this change it will be possible to introduce a new paintable type
for foreignObject that inherits from both PaintableWithLines and
SVGMaskable.
2024-04-27 07:10:20 +02:00
Timothy Flynn c9a461ee75 LibWeb: Remove OOM propagation from Fetch::Infrastructure::HTTP 2024-04-27 07:08:14 +02:00
Timothy Flynn 1ffda6a805 LibWeb: Propagate OOM in Body::fully_read() through its error callback
Fetched bodies can be on the order of gigabytes, so rather than crashing
when we hit OOM here, we can simply invoke the error callback with a DOM
exception. We use "UnknownError" here as the spec directly supports this
for OOM errors:

    UnknownError: The operation failed for an unknown transient reason
                  (e.g. out of memory).

This is still an ad-hoc implementation. We should be using streams, and
we do have the AOs available to do so. But they need to be massaged to
be compatible with callers of Body::fully_read. And once we do use
streams, this function will become infallible - so making it infallible
here is at least a step in the right direction.
2024-04-27 07:08:14 +02:00
Timothy Flynn ec5988d56b LibWeb: Mark the task in the success steps of reading a body as mutable
Otherwise, the `move(bytes_copy)` in the body of the steps does not
actually act as a `move`.
2024-04-27 07:08:14 +02:00
Timothy Flynn 5f51a11618 LibWeb: Remove OOM propagation from Fetch::Infrastructure::Responses 2024-04-27 07:08:14 +02:00
Timothy Flynn 5a4f13dcd4 LibWeb: Remove OOM propagation from Fetch::Infrastructure::Requests 2024-04-27 07:08:14 +02:00
Timothy Flynn b3032befe0 LibWeb: Remove OOM propagation from Fetch::Infrastructure::Methods 2024-04-27 07:08:14 +02:00
Timothy Flynn c79f46fe6f LibWeb: Remove OOM propagation from Fetch::Infrastructure::Headers 2024-04-27 07:08:14 +02:00
Dan Klishch 2925fcd4bc Userland: Compile a special version of LibELF for DynamicLoader
... instead of shamelessly stealing its sources.
2024-04-26 19:08:13 -06:00
Dan Klishch be9ca65179 Meta: Use stripped-down version of LibELF on Lagom 2024-04-26 19:08:13 -06:00
Dan Klishch 7b88363490 Meta+Userland: Make LibELF a proper library on Serenity
Dynamically loaded LibC doesn't need LibELF definitions, so let's not
put them there.
2024-04-26 19:08:13 -06:00
Dan Klishch 19206f75ee DynamicLoader: Ensure that optimizer won't interfere with early init 2024-04-26 19:08:13 -06:00
Tim Ledbetter dda730c46b LibWeb: Exclude [Global] interfaces from legacy platform object method
Previously, [Global] interfaces were not excluded from the
`internal_own_property_keys()` call. This caused a crash when iterating
over the properties of the Window object.
2024-04-26 20:02:21 +02:00
Andreas Kling ff9ae5ff40 LibWeb: Bring document & browsing context creation in line with spec
We had drifted away from the spec steps a little bit here. This patch
brings us back in line and knocks off some FIXMEs in the process.
2024-04-26 20:01:58 +02:00
Andreas Kling a5c62b953f LibWeb: Take care of some FIXMEs in auxiliary browsing context creation 2024-04-26 20:01:58 +02:00
Andreas Kling 0ebfc0a4c4 LibWeb: Move event handling & cursor from BrowsingContext to Navigable
This was a long standing FIXME since the introduction of navigables.
2024-04-26 20:01:58 +02:00
Andreas Kling 9cd4a65071 LibWeb: Move TraversableNavigable::m_page up to Navigable
This will allow anyone who has a Navigable to reach the Page.
2024-04-26 20:01:58 +02:00
Aliaksandr Kalenik dc4192c149 LibWeb: Remove CSS transform from InlinePaintable's clip rectangle
Fixes bug when CSS transform is applied twice to clip rect:
- While calculating absolute clip rectangles in `refresh_clip_state()`
- While executing `PushStackingContext` painting command.

Duplicated transform is already removed for PaintableBox and this change
adds this for InlinePaintable.
2024-04-26 18:40:45 +02:00
Timothy Flynn 13422b5116 LibWeb: Remove OOM error propagation from HTMLMediaElement (and friends) 2024-04-26 12:21:57 -04:00
Timothy Flynn dd16ea87c3 LibWeb: Make HTMLMediaElement::set_decoder_error infallible
This used to propagate an OOM error, but that was removed, and this
method can no longer throw.
2024-04-26 12:21:57 -04:00
MINAqwq 7c54a32870 LibWeb: Set decoder error when decoding fails 2024-04-26 11:48:48 -04:00
Ali Mohammad Pur 2f10243fa2 LibTLS: Ignore empty reads from underlying socket while connecting
We should not expect the server to respond immediately after connecting,
this can manifest as random requests failing (e.g. on https://null.com).
2024-04-26 15:53:00 +02:00
Timothy Flynn 6f90495512 ImageDecoder: Add the 'thread' pledge for background actions 2024-04-26 09:29:02 -04:00
Tim Ledbetter 4d9b6645d7 LibIDL: Remove unused required_imported_paths field from Interface 2024-04-26 08:00:32 -04:00
Tim Ledbetter fcf1a2a287 LibWeb: Remove data from WebAssembly cache when namespace is finalized
Previously, the cache held on to data for objects that had already been
garbage collected.
2024-04-26 13:56:39 +02:00
Tim Ledbetter 6d4b8bde55 LibWeb: Isolate WebAssembly cache by global object
This change moves WebAssembly related data that was previously globally
accessible into the `WebAssemblyCache` object and creates one of these
per global object. This ensures that WebAssembly data cannot be
accessed across realms.
2024-04-26 13:56:39 +02:00
Tim Ledbetter 5e75afd549 LibWeb: Fix typo in extended WithGCVisitor extended attribute name 2024-04-26 13:56:39 +02:00
Shannon Booth baaaa0008e LibWeb: Look for first ID _or_ name in HTMLCollection::named_item
Previously we would look for a matching ID, and then for a matching
name. If there was an element in the collection which had a matching ID
as well as an element with a matching name, we would always return the
element with a matching ID irrespective of what order that element was
in.
2024-04-26 07:44:01 -04:00
Andreas Kling e6c0b4631f WebContent: Send tooltip screen location in device coordinate space
This makes tooltips pop up in the right location when zoomed in and
using the Qt chrome.
2024-04-26 10:42:18 +02:00
Andreas Kling a4625e3943 LibWeb: Only react to link element attribute changes when BC connected
Link elements that aren't "browsing-context connected" should not
trigger a resource fetch when their attributes change.

This fixes an issue where we'd waste time by loading every style sheet
twice! :^)
2024-04-26 10:40:43 +02:00
Timothy Flynn c4750f6eec LibWeb: Run page activation behavior when skipping context menu events
We partially supported this feature, but not enough for the chrome's
context menu to open. We now propagate the event back to the chrome.
2024-04-26 09:50:48 +02:00
Timothy Flynn f6407276f7 LibWeb: Stop the video decoder thread when the video element is GC'd
Otherwise, the thread will continue to run and access the media data
buffer, which will have been freed.

The test here is a bit strange, but the issue would only consistently
repro after several GC runs.
2024-04-26 09:49:11 +02:00
Timothy Flynn f13ccb9a61 LibWeb: Add missing call to Base::finalize() in HTMLMediaElement 2024-04-26 09:49:11 +02:00
Timothy Flynn 84fd37704e LibVideo: Allow PlaybackManager owners to terminate the decoder thread
This will be needed by LibWeb to explicitly stop the decoder thread just
before the media element is garbage collected.
2024-04-26 09:49:11 +02:00
Andrew Kaster ce9eed918f ImageDecoder: Schedule decode jobs on the LibThreading background thread
This allows the ImageDecoder service to handle new IPC requests while
decoding in parallel.
2024-04-26 09:41:24 +02:00
Andrew Kaster e16bdb4a3c LibThreading: Add a way to cancel and join the background thread
This allows processes using BackgroundAction to actually exit when all
their threads have exited.
2024-04-26 09:41:24 +02:00
Shannon Booth 0c8a98ac94 LibWeb: Begin implementing the interface for AudioBuffer
Implement the constructor and getChannelData function, working towards
the functionality that we need in order to implement
OfflineAudioContext.
2024-04-25 19:26:19 -04:00
Shannon Booth 5cb6d495bb LibWeb: Implement verification of 'nominal' audio options
The spec doesn't tell us the exact value to use, but a minumum & maximum
range of supported values. Just to be consistent with another browser,
we follow the values that firefox appears to support from testing the
interface on my machine.

This function will be used in the AudioBuffer constructor, but is
defined in the spec as part of BaseAudioContext.
2024-04-25 19:26:19 -04:00
Shannon Booth 46ec3681a4 LibWeb: Verify document is fully ready in AudioContext
This was just a trival FIXME to resolve as I was in the area.
2024-04-25 19:26:19 -04:00
Shannon Booth 9abce21435 LibWeb: Add missing CellAllocator.h include for Buffers.h
My clangd was (rightly) complaining that this include was missing.
2024-04-25 19:26:19 -04:00
Nico Weber b364a58753 LibGfx/JPEG2000: Read COC marker segments, both in main and tile headers
Not yet used for anything.
2024-04-25 09:00:46 -04:00
Nico Weber 8eb3d436e6 LibGfx/JPEG2000: Extract CodingStyleParameters
This is the data shared between COD and COC marker segments.

No behavior change.
2024-04-25 09:00:46 -04:00
Nico Weber 3735f2cbed LibGfx/JPEG2000: Read COD on tile headers too
I haven't seen this in the wild yet, but it is allowed per spec
and easy to do.
2024-04-25 09:00:46 -04:00
goldenzach 65eb7699f4 LibWeb: Resolve vertical padding of inline elements 2024-04-25 12:45:39 +02:00
Aliaksandr Kalenik 988c8451d4 LibWeb: Skip HTMLLinkElement resource fetching for documents without BC
Fixes crashing after following steps:
1. Open https://github.com/SerenityOS/serenity
2. Click on "Pull requests" tab

The problem was `navigable` null pointer dereferencing in
`decode_favicon()`. But navigable is null because the document was
created by `parseFromString()` DOMParser API.

With this change we skip fetching initiated by HTMLLinkElement if
document does not have a browsing context:
- Favicon is not displayed for such documents so no need to fetch.
- Stylesheets fetching won't affect such document because style or
  layout does not run for them.
2024-04-25 09:31:01 +02:00
Andreas Kling 4c921e17b7 LibWeb: Allocate dataset lazily for HTML/SVG/MathML elements
Most elements never need a dataset object, so we can avoid creating lots
of objects by making them lazy.
2024-04-25 09:30:30 +02:00
Timothy Flynn 1560d6ad62 LibCore: Remove the now-obsolete SingletonProcess helper files 2024-04-24 15:51:58 -06:00
Timothy Flynn eb990fcecd sql: Use Core::Process facilities to spawn singleton processes 2024-04-24 15:51:58 -06:00
Timothy Flynn c723fc9611 LibCore: Support launching a singleton process with an IPC connection
This largely adapts the code from SingletonProcess.cpp to work a bit
closer with Core::Process. Ideally, we'll move the daemonizing feature
into Core::Process::disown() eventually.
2024-04-24 15:51:58 -06:00
Timothy Flynn 8448897f14 LibCore: Implement a move operator for Core::Process
We implement the move constructor already. A future commit will have
code of the form:

    process = move(other_process);

which there is no reason to forbid.
2024-04-24 15:51:58 -06:00
Timothy Flynn 9986350e97 LibCore: Support launching a process with an IPC connection
Much of the code here is adapted from Ladybird. But rather than doing a
manual fork, we use Core::Process to spawn the underlying process.
2024-04-24 15:51:58 -06:00
Timothy Flynn dc52404aec LibCore: Add a Core::Process action to close a file after spawning 2024-04-24 15:51:58 -06:00
Timothy Flynn fecd08ce64 Everywhere: Remove 'clang-format off' comments that are no longer needed 2024-04-24 16:50:01 -04:00
Timothy Flynn ec492a1a08 Everywhere: Run clang-format
The following command was used to clang-format these files:

    clang-format-18 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Base/*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -not \( -path "./Ports/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.mm" -o -name "*.h")

There are a couple of weird cases where clang-format now thinks that a
pointer access in an initializer list, e.g. `m_member(ptr->foo)`, is a
lambda return statement, and it puts spaces around the `->`.
2024-04-24 16:50:01 -04:00
Cnidarias 1a1e5aaf54 LibWeb: Add null check for get_client_rects() on non paintable elements 2024-04-24 18:04:28 +02:00
Andreas Kling c186ab96ac LibWeb: Explicitly ignore PageClient::m_console_clients
This map is managed entirely by manual insertion/removal when a document
is created/destroyed, so we should just ignore it in visit_edges().
2024-04-24 17:04:43 +02:00
Andreas Kling f60d82eb85 LibWeb: Make HTML::Environment a GC-allocated type
The only subclass was already GC-allocated, so let's hoist the JS::Cell
inheritance up one level. This ends up simplifying a bit of rather
dubious looking code where we were previously slicing ESOs.
2024-04-24 17:04:43 +02:00
Bastiaan van der Plaat 7fa45c5fdf LibWeb: Add map element areas property 2024-04-24 15:23:45 +02:00
Bastiaan van der Plaat 3e507102ea LibWeb: Add datalist element options property 2024-04-24 15:23:45 +02:00
Aliaksandr Kalenik 1072d9f15d LibJS: Save min and max block addresses in CellAllocator
This allows to skip iterating through all allocated blocks in
`find_min_and_max_block_addresses()`.

With this change `collect_garbage()` in profiles of Discord goes down
from 17% to 8%.
2024-04-24 11:42:15 +02:00
Aliaksandr Kalenik 55154b6c68 LibWeb: Use SafeFunction for completion steps in "populate SHE"
...to visit GC-allocated objects captured by this callback.
2024-04-24 10:22:29 +02:00
Aliaksandr Kalenik 64ad536dbb LibWeb: Create HeapFunction for after_document_populated
...to make it visited by SafeFunction callback of deferred_invoke().

Fixes use-after-free ASAN error that happens if you try to reload the
page.
2024-04-24 10:22:29 +02:00
ronak69 b25d220a2c headless-browser: Call platform_init() for path of resources folder
For `AK_OS_SERENITY`, the root path of the resources folder is "/res";
but otherwise it should be the `s_serenity_resource_root` variable set
in `platform_init()`.

However, a path provided on the command line, will override the default
path in both of those cases.

This change also makes sure that `RequestServer` can find the
certificates file `serenity/Build/lagom/share/Lagom/ladybird/cacert.pem`
2024-04-24 10:21:20 +02:00
Dan Klishch 49e09507d7 LibELF: Perform weak relocations in much more straight-forward manner
There is no need to defer unresolved weak relocations until stage 3 --
it is not like we will magically find new symbols in the same objects.
2024-04-23 23:26:00 -06:00
kleines Filmröllchen e74b34b69e LibC: Fix extended floating point software rounding
Contrary to IEEE formats, x86's 80-bit extended floats need the topmost
mantissa bit to be 1 or else a special kind of NaN is produced. We fix
this by reinserting the special bit if necessary.
2024-04-23 19:18:09 -06:00
kleines Filmröllchen 0c1ad05f50 LibC: Add rounding specializations for RISC-V
Whenever the floating-point values are in integer range, we can use the
various FCVT functions with static rounding mode to perform fast
rounding. I took this opportunity to clean up the architecture
differentiation for these functions, which allows us to use the software
rounding implementation for all extreme and unimplemented cases,
including AArch64.

Also adds more round & trunc tests.
2024-04-23 19:18:09 -06:00
kleines Filmröllchen 334f5e319c LibC: Prevent undefined shift in internal_to_integer
New tests will hit a dead bit count of 64, leading to an undefined
shift.
2024-04-23 19:18:09 -06:00
kleines Filmröllchen 24af4f1882 LibC: Start on fenv support for RISC-V
Co-Authored-By: Sönke Holz <sholz8530@gmail.com>
2024-04-23 19:18:09 -06:00
Dan Klishch a4a8dd29ba LibC: Read correct FP register in fegetround on x86-64 :^) 2024-04-23 19:18:09 -06:00
Andrew Kaster 1c3f11a5a6 Userland: Remove remaining callers of synchronous ImageDecoder API
Most of these now just await the image decoding, equivalent (ish) to
the old behavior. A more async-aware refactor should happen some time
in the future.
2024-04-23 12:32:04 -06:00
Andrew Kaster 651e78fedb LibWeb: Convert callers of ImageCodecPlugin to the async API
The HTMLLinkElement caller is a bit hairy, so we shove an await() in
there temporarily. This is sure to cause fun times for anyone debugging
task/microtask execution order.
2024-04-23 12:32:04 -06:00
Andrew Kaster 39dfb659cf LibWeb+WebContent: Convert ImageCodecPlugin to use the promise-based API 2024-04-23 12:32:04 -06:00
Andrew Kaster b871bc082c ImageDecoder: Handle decoding of images in an asynchronous manner
ImageDecoder now queues up image decoding requests and returns the
images back to the caller later. ImageDecoderClient has a new
promise-based API that allows callers to attach their own resolve/reject
handlers to the responses from ImageDecoder.
2024-04-23 12:32:04 -06:00
Idan Horowitz 0d8064fafc DynamicLoader: Resolve missing weak absolute symbols to null
Weak symbols can be left unresolved, and code is supposed to check if
they're null at runtime before using them. Handle them appropriately
instead of refusing to load.
2024-04-23 20:27:51 +02:00
Tim Ledbetter 4611a58f8c PixelPaint: Avoid infinite loop when updating zoom level ComboBox text
After 8b4e2e20, `Combobox::set_text()` invokes the `on_change` event by
default. This led to an infinite loop at program startup which caused a
crash.
2024-04-23 16:26:39 +02:00
Michal Grich 7a6d84d036 LibTextCodec: Add Windows-1250 text decoder
This commit is adding Windows-1250 decoding based on unicode.org
mapping table.
2024-04-23 16:26:16 +02:00
Aliaksandr Kalenik d4f08fb0a1 LibWeb: Fix division by zero in solve_replaced_size_constraint()
Happened when input_width > 0 but input_height == 0.

Fixes crashing on Discord that happens after clicking on direct
messages conversation.
2024-04-23 16:21:48 +02:00
Andreas Kling 184368285c LibWeb: Fix GC leaks in Fetch::Infrastructure::Body::fully_read()
By making this function accept the success and error steps as
HeapFunction rather than SafeFunction, we break a bunch of strong
GC cycles.
2024-04-23 12:50:40 +02:00
Andreas Kling 0c84508f87 LibJS: Fix GC leaks in promise reaction job setup
There's no need to capture things as Handle when using HeapFunction.
In this case, it was even creating a strong reference cycle, which ended
up leaking.
2024-04-23 12:50:40 +02:00
Aliaksandr Kalenik a044e9cf4f LibWeb: Add background-clip: text support for InlinePaintable
Moves background mask calculation into `paint_background()` that is
shared between PaintableBox and InlinePaintable.
2024-04-23 12:50:07 +02:00
Tim Ledbetter 3aea14093f LibWeb: Don't crash if the document element is not visible
Previously, setting the `hidden` property on the `<html>` element would
cause a crash.
2024-04-23 11:17:54 +02:00
Aliaksandr Kalenik dd73cccf8f LibWeb: Fire "scroll" events on DOM elements
Before this change "scroll" events were only fired on document but now
it happens for all elements with scrollable overflow.
2024-04-23 11:00:35 +02:00
Timothy Flynn 771054bff7 Ladybird: Slightly increase the size of the Task Manager window
This adds a bit more room to see most titles on one line.
2024-04-22 14:46:10 -06:00
Timothy Flynn 2851c05dee LibWebView: Display each tab's title in the Task Manager
This allows us to more easily differentiate between WebContent processes
in the Task Manager at a glance.
2024-04-22 14:46:10 -06:00
Timothy Flynn 2fc52657b6 LibWebView: Set a title on the Inspector and Task Manager views
These will be used to display the titles in the Task Manager window.
2024-04-22 14:46:10 -06:00
Timothy Flynn c7ef8530bf LibWebView: Explicitly inititalize the ProcessHandle PID
Avoids UB if the PID is read from without otherwise being initialized.
2024-04-22 14:46:10 -06:00
Timothy Flynn f16f89eb32 Ladybird+LibWebView: Move SQLServer launcher to Ladybird
It previously resided in LibWebView to hide the details of launching a
singleton process. That functionality now lives in LibCore. By moving
this to Ladybird, we will be able to register the process with the task
manager.
2024-04-22 14:46:10 -06:00
Timothy Flynn 76af4503c1 LibCore: Return the singleton process's PID along with its IPC client
The PID will be used for Ladybird's task manager.
2024-04-22 14:46:10 -06:00
Timothy Flynn bf50881e61 LibCore+LibSQL+LibWebView: Move launching a singleton process to LibCore
This just moves the code to launch a single process such as SQLServer to
LibCore. This will allow re-using this feature for other processes, and
will allow moving the launching of SQLServer to Ladybird.
2024-04-22 14:46:10 -06:00
Timothy Flynn 5dd3b91f0e LibCore+LibWebView: Move process statistics to LibCore
This will be needed to collect statistics from processes that do not
have anything to do with LibWebView. The ProcessInfo structure must be
virtual to allow callers to add application-specific information.
2024-04-22 14:46:10 -06:00
Aliaksandr Kalenik 376427380e LibWeb: Make NavigationParams be GC-allocated
Fixes GC-leak caused by using JS::Handle for navigable.
2024-04-22 17:10:11 +02:00
Shannon Booth 1ec6399c00 Everywhere: Remove uneeded short option argument where possible 2024-04-22 08:10:08 +02:00
Shannon Booth 88b343061e LibCore: Make short_name optional for ArgsParser
This allows us to not need to pass through a 0 in many cases for
options which do not support a short value.
2024-04-22 08:10:08 +02:00
Sam Atkins 59c79e848c LibWeb: Parse dimension values using TokenStream 2024-04-22 06:47:05 +02:00
Sam Atkins efce563abd LibWeb: Parse identifier values using TokenStream 2024-04-22 06:47:05 +02:00
Sam Atkins e8115d6a56 LibWeb: Parse transform values using the existing comma-parsing code
Also add a spec link and grammar comment.
2024-04-22 06:47:05 +02:00
Sam Atkins e4e048f278 LibWeb: Parse color values using TokenStream 2024-04-22 06:47:05 +02:00
Sam Atkins 710e5c24d3 LibWeb: Parse string values using TokenStream 2024-04-22 06:47:05 +02:00
Sam Atkins e42f052b00 LibWeb: Parse rect() values using TokenStream 2024-04-22 06:47:05 +02:00
Sam Atkins e00f41a274 LibWeb: Parse URL values using TokenStream 2024-04-22 06:47:05 +02:00
Sam Atkins cfa221944c LibWeb: Parse image values using TokenStream 2024-04-22 06:47:05 +02:00
Sam Atkins 384b18b271 LibWeb: Make parse_color_stop_list() a CSS Parser method
This lets us remove the color/dimension-parsing lambdas, since these
always forwarded to the same methods. This will make it easier to later
convert those methods to take a TokenStream.
2024-04-22 06:47:05 +02:00
Andreas Kling 8e56367092 LibWeb: Allow moving StyleSheets between documents without falling apart
We have to unregister link element stylesheets from the old document's
StyleSheetList when moving them into a new document.

This makes it possible to load GitHub contributor graphs. :^)
2024-04-22 06:43:05 +02:00
Dan Klishch cf92efc497 LibELF: Get rid of DynamicLoader::m_cached_dynamic_object
The strategy of recreating an object for the second time after
DynamicLoader::map is interesting, of course, but it doesn't help
comprehensibility of the code, unfortunately.
2024-04-21 13:35:12 -06:00
Dan Klishch c9a6bcf81d LibC+LibELF: Use AT_RANDOM ELF auxiliary vector for __stack_chk_guard
Kernel provided it for about 4 years at this point. I think it is about
time to finally use it in userspace.
2024-04-21 13:34:04 -06:00
Dan Klishch bdfc77b725 LibELF: Treat STB_WEAK like STB_GLOBAL during global symbol lookup
This is what POSIX mandates and this also matches the behavior of modern
Linux.
2024-04-21 13:34:04 -06:00
Dan Klishch d8119c4b4a LibLocale: Statically link LibLocaleData into LibLocale 2024-04-21 13:34:04 -06:00
Dan Klishch 932a722623 LibC+LibELF: Do not override existing weak symbols during magic lookup
Previously, the actual behavior of magic lookup and one described in its
commit description have not matched. Instead of being weak definitions
in a library that is always in the end of load order, the definitions
were normal ones and thus were able to override other weak definitions
in LibC. While this was consistent with how DynamicLoader resolves
ambiguity between normal and weak relocations, this is not the behavior
POSIX mandates -- we should always choose first available definition wrt
load order. To fix this problem, the patch makes sure we don't define
any of magic symbols in LibC.

In addition to this, it makes all provided magic symbols functions
(instead of objects), what renders MagicWeakSymbol class unnecessary.
2024-04-21 13:34:04 -06:00
Timothy Flynn 306041f4ac LibWebView: Do not update cookie access time when fetched with WebDriver
When WebDriver accesses cookies, it specifically says to run:

    the first step of the algorithm in RFC6265 to compute cookie-string

So we should skip subsequent steps. We already skip step 2, which sorts
the cookies, but neglected to skip step 3 to update their last access
time.
2024-04-21 14:46:54 -04:00
Andreas Kling 193fc7ef98 LibWeb: Allow cloneNode() to clone elements with weird attributes
We can't rely on Element.setAttribute() in cloneNode() since that will
throw on weird attribute names. Instead, just follow the spec and copy
attributes into cloned elements verbatim.

This fixes a crash when loading the "issues" tab on GitHub repos.
They are actually sending us unintentionally broken markup, but we
should still support cloning it. :^)
2024-04-21 19:51:24 +02:00
Andreas Kling d94a6d8873 LibWeb: Avoid creating tons of temporary FlyStrings in HTMLParser 2024-04-21 19:32:49 +02:00
Andreas Kling 990f8e10a5 LibWeb: Avoid redundant UTF-8 validation in HTML tokenizer 2024-04-21 19:32:49 +02:00
Andreas Kling df547bb321 LibUnicode: Avoid redundant UTF-8 validation in AK::String helpers 2024-04-21 19:32:49 +02:00
Andreas Kling 819f2c1df6 LibWeb: Don't redundantly re-sort StyleSheetList on sheet removal
The list is already kept sorted. Removing one sheet anywhere from the
list will not make it unsorted.
2024-04-21 19:32:49 +02:00
MacDue 9d8ab826cb LibWeb: Add an initial implementation of the SVG .getBBox() method
This just reuses the layout to compute the bounding box rather than
implementing the full bounding box algorithm, which is likely the slower
option, but also much simpler to implement.

This is enough to fix the faces on https://zengm.com/facesjs/.
2024-04-21 17:30:51 +02:00
Aliaksandr Kalenik 3c33e1eba9 LibWeb: Make ChangingNavigableContinuationState be GC-allocated
This struct is captured by `after_document_populated` callback so making
it be GC-allocated results in more understandable GC-graph.
2024-04-21 16:44:05 +02:00
Aliaksandr Kalenik 2f345c4ab5 LibWeb: Use HeapFunction for update_document callback 2024-04-21 16:44:05 +02:00
Aliaksandr Kalenik 3b3816e683 LibWeb: Remove changing_navigable_continuation capture in callback
Capturing a struct that owns bunch of JS::Handle makes it very hard to
understand what keeps these handles alive in the GC-graph.

Instead let's capture only members of a struct used in the callback.
2024-04-21 16:44:05 +02:00
Undefine 5e87b78935 LibFileSystem: Ignore ENOTSUP when using chown and chmod during copy
With FAT write support copying the file would show two errors because
it does not support chown and chmod and would return ENOTSUP. After
this commit these errors are ignored in that case.
2024-04-21 15:34:33 +02:00
Aliaksandr Kalenik 23d683cf6b LibWeb: Update document url after same-document back/forward navigation
Seems like a specification bug, but other browsers update url before
popstate event is fired and so should we.

Fixes back/forward navigation on GitHub.
2024-04-21 12:41:36 +02:00
Andreas Kling 4db1712f90 LibJS+LibWeb: Make Console, ConsoleClient & subclasses GC-allocated
These objects had confusing ownership semantics. Let's just throw them
all on the GC heap and stop worrying about it.
2024-04-21 09:12:25 +02:00
Andreas Kling 44659f2f2a LibWeb+WebContent: Don't let PageClient keep documents alive
We were inadvertently keeping all documents alive by installing a
console client for them. This patch fixes the issue by adding a
finalizer to Document, and having that be the way we detach console
clients. This breaks the cycle.

With this change, we can spam set .innerHTML in a loop and memory
usage remains stable.

Fixes #14612
2024-04-21 09:12:25 +02:00
Andreas Kling cd6a458e83 headless-browser: Add -G option to dump GC graph on exit
This will be useful in tracking down the list of GC leaks that occur
across a run of our test suite.
2024-04-21 09:12:25 +02:00
Andreas Kling e993fb53d5 LibJS: Simplify iteration in GC heap dumping code 2024-04-21 09:12:25 +02:00
Jess ecb7d4b40f LibJS: Throw RangeError in StringPrototype::repeat if OOM
currently crashes with an assertion failure in `String::repeated` if
malloc can't serve a `count * input_size` sized request, so add
`String::repeated_with_error` to propagate the error.
2024-04-20 19:23:46 -04:00
Daniel Bertalan cc92c3f551 LibCrypto+LibGfx: Fix GCC 14 compile errors
The C++ standard does not allow specifying the template parameters in
constructor declarations, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202#c8.

Converting constructors have a higher priority that user-defined
conversion functions; let's constrain `Gfx::Size<T>(Gfx::Size<U>)` to
only be considered when `U` is convertible to `T`. This lets us fall
back to conversion operators in the case of `UISize` -> `IntSize`, for
instance. Clang is still okay without this, but MSVC would error out
similarly: https://godbolt.org/z/PTbeYPM7s

Note that a not-yet-committed patch is required for full compilation:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114784#c3
2024-04-20 15:52:29 -06:00
Kenneth Myhra 291d0e5de8 LibWeb: Let queue_fetch_task() take a JS::HeapFunction
Changes the signature of queue_fetch_task() from AK:Function to
JS::HeapFunction to be more clear to the user of the function that this
is what it uses internally.
2024-04-20 18:11:01 +02:00
Kenneth Myhra a3661fd7f2 LibWeb: Let queue_global_task() take a JS::HeapFunction
Changes the signature of queue_global_task() from AK:Function to
JS::HeapFunction to be more clear to the user of the function that this
is what it uses internally.
2024-04-20 18:11:01 +02:00
Aliaksandr Kalenik 9540af6489 LibWeb: Fix nodesToRemove collecting traversal in Range::delete_contents
With this change children are no longer skipped in tree traversal when
start node of range equals to end node of range.

Fixes https://github.com/SerenityOS/serenity/issues/24036
2024-04-20 13:32:24 +02:00
Aliaksandr Kalenik cedf6dd2c3 LibWeb: Remove unused blend mode param in FillEllipse painting command 2024-04-20 12:42:02 +02:00
Aliaksandr Kalenik d3cfe35fbd LibWeb: Do not destroy document until whole subtree completed unloading
Fixes crashing when "unload" event handler tries to access active
document that has already been destroyed.
2024-04-20 10:22:14 +02:00
Sönke Holz 9437b29b43 LibELF+LibC: Add support for Variant I of the TLS data structures
We currently only supported Variant II which is used by x86-64.
Variant I is used by both AArch64 (when using the traditional
non-TLSDESC model) and RISC-V, although with small differences.

The TLS layout for Variant I is essentially flipped. The static TLS
blocks are after the thread pointer for Variant I, while on Variant II
they are before it.

Some code using ELF TLS already worked on AArch64 and RISC-V even though
we only support Variant II. This is because only the local-exec model
directly uses TLS offsets, other models use relocations or
__tls_get_addr().
2024-04-19 16:46:47 -06:00
Sönke Holz 3af793abfd LibELF: Correct the comment at the top of AArch64's tls.S 2024-04-19 16:46:47 -06:00
Sönke Holz 74a51505f0 LibELF: Add headers describing the TLS layout of each architecture
All of our architectures sadly use a slightly different TLS layout.
These headers try to abstract the differences in a nice way.
2024-04-19 16:46:47 -06:00
Sönke Holz 243d7003a2 Kernel+LibC+LibELF: Move TLS handling to userspace
This removes the allocate_tls syscall and adds an archctl option to set
the fs_base for the current thread on x86-64, since you can't set that
register from userspace. enter_thread_context loads the fs_base for the
next thread on each context switch.
This also moves tpidr_el0 (the thread pointer register on AArch64) to
the register state, so it gets properly saved/restored on context
switches.

The userspace TLS allocation code is kept pretty similar to the original
kernel TLS code, aside from a couple of style changes.

We also have to add a new argument "tls_pointer" to
SC_create_thread_params, as we otherwise can't prevent race conditions
between setting the thread pointer register and signal handling code
that might be triggered before the thread pointer was set, which could
use TLS.
2024-04-19 16:46:47 -06:00
Sönke Holz aa44fe860d LibELF: Change copy_initial_tls_data_into argument type to Bytes 2024-04-19 16:46:47 -06:00
Sönke Holz 8f0ebce404 LibELF: Reorganize TLS-related variables in DynamicLinker.cpp 2024-04-19 16:46:47 -06:00
Sönke Holz cb48f31d79 LibELF: Add helpers for setting the thread pointer register 2024-04-19 16:46:47 -06:00
Sönke Holz 57f4f8caf8 Kernel+LibC: Introduce new archctl syscall
This syscall will be used for architecture-specific operations.
2024-04-19 16:46:47 -06:00
Andrew Kaster 5e1d678bae Ladybird+Userland: Remove use of unnecessary fd passing socket concept
Now that LibIPC is using SCM_RIGHTS properly, we can go back to only
having one socket laying around when needing to transfer fds to peers.
2024-04-19 16:38:55 -04:00
Andrew Kaster cb87725ec8 LibIPC+LibWeb: Transfer IPC::Files using sendmsg/recvmsg directly
This refactor eliminates the need for a second "fd passing socket" on
Lagom, as it uses SCM_RIGHTS in the expected fashion, to send fds along
with the data of our Unix socket message.
2024-04-19 16:38:55 -04:00
Andrew Kaster a18c7c4405 LibCore: Let LocalSocket send and receive messages with SCM_RIGHTS
These new methods combine send/receive with send_fd/receive_fd.

This is the 'correct' way to use SCM_RIGHTS, rather than trying to
emulate the Serenity behavior on other Unixes.
2024-04-19 16:38:55 -04:00
Andrew Kaster 0e699743c4 LibCore: Move PosixSocketHelper's read EOF handling to a helper
We'll call this from upcoming LocalSocket methods directly
2024-04-19 16:38:55 -04:00
Nico Weber 0c935f8f42 LibGfx/JPEG2000: Support reading raw jpeg2000 codestreams
Most JPEG2000 files put the codestream in an ISOBMFF box structure
(which is useful for including metadata that's bigger than the
~65k marker segment data limit, such as large ICC profiles), but
some files just store the codestream directly, for example
https://sembiance.com/fileFormatSamples/image/jpeg2000/balloon.j2c

See https://www.iana.org/assignments/media-types/image/j2c for the
mime type.

The main motivation is to be able to use the test data in J.10 in
the spec as a test case.
2024-04-19 12:42:34 -04:00
Nico Weber 5695acf328 LibGfx/JPEG2000: Add comment mentioning J.10 2024-04-19 12:42:34 -04:00
Nico Weber 1a232ba2a6 LibGfx/JPEG2000: Check SIZ marker (w, h) against JP2 header (w, h) 2024-04-19 12:42:34 -04:00
Nico Weber f2e381ae19 LibCore: Add ".jpf" as a JPEG2000 extension
This is what Photoshop uses for JPEG2000 outputs.
2024-04-19 12:42:34 -04:00
Nico Weber 2467374ea9 LibCore: Add comment with link to mime registry to MimeData.cpp 2024-04-19 12:42:34 -04:00
Andrew Kaster 6d4ba21832 LibIPC+Userland: Make IPC::File always own its file descriptor
Add factory functions to distinguish between when the owner of the File
wants to transfer ownership to the new IPC object (adopt) or to send a
copy of the same fd to the IPC peer (clone).

This behavior is more intuitive than the previous behavior. Previously,
an IPC::File would default to a shallow clone of the file descriptor,
only *actually* calling dup(2) for the fd when encoding or it into an
IPC MessageBuffer. Now the dup(2) for the fd is explicit in the clone_fd
factory function.
2024-04-19 06:34:07 -04:00
Andrew Kaster 26ce8ad40f LibWeb: Stop leaking socket fds when sending them over IPC
The implicit constructor for IPC::File does not take ownership of the
file, which is surprising.
2024-04-19 06:34:07 -04:00
Alex 13abb1b2c7 LibWeb: Add name validation and document check to setAttribute
Co-authored-by: Rayyan Hamid <rayyanbwp@gmail.com>
Co-authored-by: Christian Ewing <u1273549@utah.edu>
Co-authored-by: Austin Fashimpaur <austin.fashimpaur@gmail.com>
2024-04-19 06:32:41 -04:00
Dan Klishch 5ed7cd6e32 Everywhere: Use east const in more places
These changes are compatible with clang-format 16 and will be mandatory
when we eventually bump clang-format version. So, since there are no
real downsides, let's commit them now.
2024-04-19 06:31:19 -04:00
Andreas Kling 5ef6df79ed LibWeb: Generate a simple error page when XML decode/parse fails
This fixes a regression on Acid3, since we are not expected to "best
effort" parse XML. The test specifically checks that you don't create an
incomplete, incorrect DOM.
2024-04-19 11:44:32 +02:00
Nico Weber ca3a62a6bb LibGfx: Add a comment to QMArithmeticDecoder.h 2024-04-19 10:59:11 +02:00
Nico Weber ea441fea95 LibGfx: Move QMArithmeticDecoder to its own file
It will be used by the JPEG2000 decoder as well.

Pure code move, no behavior change.
2024-04-19 10:59:11 +02:00
Nico Weber 5ff75ce5fb LibGfx/JBIG2: Rename JBIG2::ArithmeticDecoder to QMArithmeticDecoder
In preparation of moving it to its own file.

No behavior change.
2024-04-19 10:59:11 +02:00
PGHales 75626c6cd2 LibWeb/DOM: Implement the Document object's partial attributes 2024-04-19 10:58:45 +02:00
PGHales ded344aa2c LibWeb/DOM: Rename link_color to normal_link_color 2024-04-19 10:58:45 +02:00
Aliaksandr Kalenik 7b75d0c1f0 LibWeb: Fix height distribution in "vertical-align: baseline" in TFC
This line changes padding top to align cell content to baseline:
`cell.padding_top += m_rows[cell.row_index].baseline - cell.baseline`

Which means available for distribution height `height_diff` could have
changed so it needs to be refreshed before assigning the rest of it to
padding bottom:
`cell_state.padding_bottom += height_diff;`

Fixes https://github.com/SerenityOS/serenity/issues/22032
2024-04-19 10:55:28 +02:00
Dan Klishch b8c3e75573 Meta+Userland: Fix more instances of bad lambda-Variant interaction
These don't cause compilation to fail but they still crash crashd.
2024-04-18 13:14:33 -06:00
Daniel Bertalan d282066ba4 LibGfx: Spell IPCEncode::encode definitions instead of abusing concepts
The original approach failed to link with LLVM 18 because of the changed
symbol mangling.
2024-04-18 13:14:33 -06:00
implicitfield 1159cd9390 AK+Kernel+LibSanitizer: Implement __ubsan_handle_function_type_mismatch 2024-04-18 13:14:33 -06:00
Daniel Bertalan 8366c9f55a LibGUI+PixelPaint: Move virtual destructors out-of-line for Clang 17 2024-04-18 13:14:33 -06:00
Andreas Kling fa43321938 LibWeb: Fire iframe load event for frames with badly encoded XML
When loading an XML resource into an iframe and the resource fails to
decode (e.g due to invalid UTF-8), we must still fire a load event.

This fixes the regression in subtest 69 of Acid3.
2024-04-18 15:40:16 +00:00
Aliaksandr Kalenik bad86ca6b4 LibWeb: Ignore mousewheel events in ViewportPaintable
That allow EventHandler process wheel event on corresponding navigable.
For top-level navigable that means IPC call to let chrome know about
scrollbar position update.

Fixes https://github.com/SerenityOS/serenity/issues/23599
Fixes https://github.com/SerenityOS/serenity/issues/23493
Fixes https://github.com/SerenityOS/serenity/issues/23966
2024-04-18 12:27:24 +02:00
Aliaksandr Kalenik d53058421a LibWeb: Do not paint scrollbar of ViewportPaintable
Scrollbar of viewport is supposed to be painted by chrome.
2024-04-18 12:27:24 +02:00
Aliaksandr Kalenik fea58a4160 LibCore: Support xml in guess_mime_type_based_on_filename() 2024-04-18 08:10:05 +00:00
Aliaksandr Kalenik d876f32e5d LibWeb: Skip creating a navigable for <object> not connected to document
Navigation should not run for <object> element until it is inserted into
a document. Spec deoes not seem to explicitely say that, but that
matches other browsers behavior.

Fixes hanging after reloading in Acid3 test.
2024-04-18 08:09:51 +00:00
Aliaksandr Kalenik 68440ed02d LibWeb: Destroy associated navigable when <object> is removed from DOM 2024-04-18 08:09:51 +00:00
circl 5639ff5f97 Screenshot: Add graphical frontend to shot
Co-authored-by: cubiclove <7754483+cubiclove@users.noreply.github.com>
2024-04-17 11:25:40 -06:00
Andrew Kaster c87e32154a Ladybird+headless-browser: Make RequestServer single instance on Lagom
Co-Authored-By: Timothy Flynn <trflynn89@pm.me>
2024-04-17 10:09:49 -04:00
Andrew Kaster 5e18d157d0 RequestServer: Add IPC to create a new client and return the sockets
We'll need this to implement single-instance RS for the Browser.
2024-04-17 10:09:49 -04:00
Andreas Kling 41667f969d LibWeb: Fix two problems where media queries didn't invalidate properly
There were two things going wrong here:

- Transformed text (via CSS text-transform) was not invalidated after a
  `@media` rule changed state.

- Removing the `style` attribute from an element didn't trigger a style
  update.

This fixes the regression in subtest 46 of Acid3.

Fixes #21777
2024-04-17 14:18:31 +02:00
Ali Mohammad Pur 06386ab2b5 LibTLS+LibHTTP: Tolerate improperly closed TLS sockets
Some really cursed servers simply drop the TCP socket on the floor when
they're trying to close an HTTP connection going through a TLS socket.
This commit makes LibTLS tolerate these silly servers, and LibHTTP
accept their idea of "EOF == connection closed".

Fixes loading wpt.live/acid/acid3/test.html.

Note that this means TLSv12::on_ready_to_read can fire with an empty
buffer signifying EOF; one test refused this behaviour, and has been
changed in this commit.
2024-04-17 07:19:03 +02:00
Jamie Mansfield 2d90317c20 LibWeb: Implement <desc> SVG element 2024-04-17 07:17:27 +02:00
Jamie Mansfield bb37451fe5 LibWeb: Fix spec link to SVGTitleElement 2024-04-17 07:17:27 +02:00
Andreas Kling 1cb5385a29 LibCore: Stop obsessing about tiny OOMs in Core::Timer
Work towards #20405
2024-04-17 07:16:52 +02:00
Timothy Flynn bf1c82724f LibWeb: Default to an empty string when a string attr substitution fails
When a string-type attr() substitution produces no value and no fallback
had been specified, the spec mandates we default to the empty string.
2024-04-17 07:13:26 +02:00
Tim Ledbetter 4a3497e9cd LibWeb: Support loading alternative style sheets
Alternative style sheets are now fetched and are applied to the
document if they are explicitly enabled by removing the disabled
attribute.
2024-04-17 07:12:44 +02:00
Tim Ledbetter 25f8c26624 LibWeb: Flesh out StyleSheetList::add_a_css_style_sheet() steps
This is required to support loading alternative style sheets.
2024-04-17 07:12:44 +02:00
Aliaksandr Kalenik 890da021c4 LibWeb: Abort ongoing navigation before firing next navigation event
I haven't found this being mentioned in the current spec, but that is
what chromium (atm the only other Navigation API implementer) does.

Fixes crashing when location.hash is changed subsequently more than once
using JS.
2024-04-16 19:51:56 +02:00
Andreas Kling 0389f01cc8 LibWeb: Make document.createEvent("hashchangeevent") produce right type
This is supposed to return a HashChangeEvent, and now it does.
2024-04-16 19:50:45 +02:00
Andreas Kling f4f4f7781d Ladybird+LibWeb: Add optional IDL call tracing
When launched with the new --enable-idl-tracing option, we now log
every call to web platform APIs declared via IDL, along with the
arguments passed.

This can be very helpful when trying to figure out what a site is
doing, especially if it's not doing what you'd expect.
2024-04-16 16:57:06 +02:00
Andreas Kling 5f9a905793 Ladybird+LibJS: Add optional logging of *all* JS exceptions
When running with --log-all-js-exceptions, we will print the message
and backtrace for every single JS exception that is thrown, not just
the ones nobody caught.

This can sometimes be very helpful in debugging sites that swallow
important exceptions.
2024-04-16 16:57:06 +02:00
Aliaksandr Kalenik 9f4b922f1c LibWeb: Look into nested session histories to find max history step
Fixes bug when "navigate forward" button in UI is disabled after
performing following steps:
1. Load page with an iframe (top step = 0, iframe step = 0)
2. Navigate iframe to different document (top step = 0, iframe step = 1)
3. Navigate back from browser UI (top step = 0, iframe step = 0)

No test because change is only observable from browser UI.
2024-04-16 05:59:19 -07:00
Aliaksandr Kalenik 768b1455d6 LibWeb: Run <object> fallback steps if data type is not supported
Progress on fixing regressed Acid2.
2024-04-16 13:47:38 +02:00
Tim Ledbetter d5cddd4696 LibWeb: Unset stylesheet properties when removing from a StyleSheetList
Previously, the parent CSS stylesheet, owner node and owner CSS rule
properties were not unset when removing a sheet from a StyleSheetList.

This change moves the methods for adding and removing sheets to and
from a StyleSheetList, directly into the StyleSheetList class and
ensures they are called as required by the CSSOM specification.
2024-04-16 07:41:33 +02:00
Andreas Kling 53d0dd4a2e LibJS+LibWeb: Use new Cell::Visitor helpers to avoid manual iteration 2024-04-16 07:40:01 +02:00
Andreas Kling 1a6d025793 LibJS: Add helpers to Cell::Visitor for visiting AK collections 2024-04-16 07:40:01 +02:00
Space Meyer 106d4636a4 Revert "Kernel+SystemServer: Make KCOVDevice a character device"
This reverts commit 9dbec601b0.

For KCOV to be performant (or at least not even slower) we need to
mmap the PC buffer from both user and kernel space at the same time.
You can't mmap a character device, so this change didn't make sense.

Plus even if we did invent a new method to exfiltrate the coverage
information out of the kernel, it would be incompatible with existing
kernel fuzzers. That would be kind of annoying. 🙃
2024-04-15 21:16:22 -06:00
Space Meyer f870841bee LibJS: Use toolchain agnostic NO_SANITIZE_ADDRESS 2024-04-15 21:16:22 -06:00
Dan Klishch 50911e6f96 Utilities/w: Work around Clang 18 bug with templated lambda + Variant
This was missed in 6f972c1 since this file is not compiled as a part of 
a Lagom build.
2024-04-15 17:58:47 -06:00
Nico Weber 7296b0fa43 LibGfx/JPEG2000: Implement tag trees
A tag tree is a data structure used for deserializing JPEG2000
packet headers.

We don't use them for anything yet, except from tests.

The implementation feels a bit awkward to me, but we can always polish
it later.

The spec thankfully includes two concrete examples. The code is
correct enough to pass those -- I added them as test.
2024-04-16 00:40:16 +02:00
Tim Ledbetter 99b2eff988 LibWeb: Invalidate style when CSSStyleRule selectorText changes
Previously, any change to the selectorText of a CSSStyleRule was not
reflected in the document style.
2024-04-15 22:12:49 +02:00
Nico Weber 69fa1d1b6e LibGfx/WebP: Remove a bounds check that is never hit
No behavior change.
2024-04-15 15:53:52 +02:00
Nico Weber 04c6af7dfd LibGfx/WebP: Add two spec comments 2024-04-15 15:53:52 +02:00
Aryan Baburajan def486305a SQLStudio: Port to GML Compilation 2024-04-15 14:01:13 +02:00
Aryan Baburajan 3336d00241 IncrementalSearchBanner: Port to GML compilation 2024-04-15 14:01:13 +02:00
Aryan Baburajan b2587cb11b EmojiInputDialog: Port to GML compilation 2024-04-15 14:01:13 +02:00
Aryan Baburajan 72a5c8f3d8 TwentyFourtyEight: Port to GML compilation 2024-04-15 14:01:13 +02:00
Aryan Baburajan 1c75aa98b8 2048: Rename to TwentyFourtyEight for GML compatibility 2024-04-15 14:01:13 +02:00
Aryan Baburajan 342fb906cf MouseSettingsWidget: Port to GML compilation 2024-04-15 14:01:13 +02:00
Aryan Baburajan 03f4ec8032 MailSettingsWidget: Port to GML compilation 2024-04-15 14:01:13 +02:00
Aryan Baburajan e488928509 FontPickerDialog: Port to GML compilation 2024-04-15 14:01:13 +02:00
Aryan Baburajan 3ab05dbbb9 FilePickerDialog: Port to GML compilation 2024-04-15 14:01:13 +02:00
Aryan Baburajan ddbed25bb5 PasswordInputDialog: Port to GML compilation 2024-04-15 14:01:13 +02:00
Andreas Kling 24157e4d1b LibWeb: Only invalidate style/layout on mutation for connected DOM nodes
If a DOM node isn't connected, there's no need to invalidate, since it's
not going to be visible anyway. The node will be automatically inserted
if/when it becomes connected in the future.
2024-04-15 12:58:27 +02:00
Andreas Kling 2fbcaadef0 LibWeb: Don't schedule style/layout updates in detached documents
There's no need to do any kind of style or layout work in documents that
aren't attached to a browsing context.
2024-04-15 12:58:27 +02:00
Andreas Kling d0076aaa24 LibWeb: Remove unnecessary Document::force_layout() API
The only remaining client of this API can simply not call it, and let
normal DOM layout invalidation happen.
2024-04-15 12:58:27 +02:00
Andreas Kling c08ba8ac4c LibWeb: Fix new ImageData(width, height) when width != height 2024-04-15 11:27:34 +02:00
Andreas Kling 134c4b6335 LibWeb: Fix CRC2D.getImageData() when width != height
We were mistakenly using the width as both width and height when getting
ImageData from a 2D canvas.
2024-04-15 11:27:34 +02:00
Jamie Mansfield e487f70bbf LibWeb: Support "importmap" scripts 2024-04-15 10:11:54 +02:00
Aliaksandr Kalenik ccb363c443 LibWeb: Add hashchange event support 2024-04-15 01:02:51 -07:00
Aliaksandr Kalenik efefd44a9f LibWeb: Navigate to changed url in Location::set_hash()
This step assumes copyURL is modified in place, while
`URL::Parser::basic_parse()` returns it as a result.

> 6. Basic URL parse input, with copyURL as url and fragment state as
  state override.

So copyURL has to be reassigned to navigate to new url on step 8:

> 8. Location-object navigate this to copyURL.
2024-04-15 01:02:51 -07:00
Andreas Kling 037b395b5d LibWeb: Try to parse WOFF and WOFF2 even if MIME type says otherwise
As it turns out, websites can lie about this, and it doesn't really cost
us much to try decoding as other formats before giving up.
2024-04-15 10:01:05 +02:00
Timothy Flynn 9c608b46fd LibWeb+LibWebView+WebContent: Remove now-unused history change IPC 2024-04-14 18:53:58 -07:00
Timothy Flynn 6eb2052d40 LibWebView: Remove now-unused history object 2024-04-14 18:53:58 -07:00