Commit Graph

17859 Commits

Author SHA1 Message Date
Andi Gallo
0ad131e13d LibGfx: Fix parsing of rgba values
Trim whitespace of the alpha component before calling
parse_first_floating_point, which doesn't handle it.
2023-05-23 06:02:35 +02:00
Andi Gallo
1bbfe4630d LibWeb: Preserve case for key events
Case-preserving behavior matches observed behavior of other browsers and
the specification.
2023-05-23 06:02:00 +02:00
thankyouverycool
02d94a303c Base+Userland: Apply Human Interface Guidelines to Object text
Corrects a slew of titles, buttons, labels, menu items and status bars
for capitalization, ellipses and punctuation.

Rewords a few actions and dialogs to use uniform language and
punctuation.
2023-05-23 05:59:49 +02:00
thankyouverycool
a03fb66216 LibGUI: Adjust size and layout of InputBox
Increases default dimensions of InputBox, giving it slightly more
divine proportions. Prompt text now always appears above the editor.
2023-05-23 05:59:49 +02:00
Tim Ledbetter
5dfb4e8066 LibC: Fix incorrect string length calculation in getsignalbyname()
This makes `kill` and `killall` work correctly with signal names.
2023-05-23 01:42:04 +02:00
Nico Weber
ae5d1d5a25 WebP: Let ALPH replace alpha channel instead of augmenting it
Pixels will leave the lossy decoder with alpha set to 255.
The old code would be a no-op in that case.

No observable behavior change yet, since there still is no
decoder for lossy webp.
2023-05-22 19:24:49 +02:00
Timothy Flynn
b865277275 LibWeb: Wait for media candidates without endlessly queueing microtasks
Rather than queueing microtasks ad nauseam to check if a media element
has a new source candidate, let the media element tell us when it might
have a new child to inspect. This removes endless CPU churn in cases
where there is never a candidate that we can play.
2023-05-22 15:11:08 +02:00
Aliaksandr Kalenik
76aa17be86 LibWeb: Make sure collapsed margins are not ignored if box creates FC
Fixes a bug that if box creates new formatting context then all already
collapsed margins are ignored and only margin_top is used.
2023-05-22 12:51:24 +02:00
Andi Gallo
668578ddc0 LibWeb: Propagate children_are_inline in wrap_in_anonymous
This fixes a crash in box_baseline, due to cells created for
display: table expecting a box child and getting the inline node wrapper
instead.

Fixes #18972.
2023-05-22 10:25:18 +02:00
Jelle Raaijmakers
4448a51824 LibGfx: Add search path to debug output in FontDatabase
This helps with debugging why fonts cannot be found.
2023-05-22 10:23:08 +02:00
Aliaksandr Kalenik
4fc4bd6c3f LibWeb: Set grid-auto-columns/rows in NodeWithStyle::apply_style() 2023-05-22 09:33:18 +02:00
Luke Wilde
a5936864d9 LibWeb: Stub AudioContext constructor
This is enough to make Discord not throw up "Well this is awkward" on
login.
2023-05-22 06:07:05 +02:00
Luke Wilde
78db4e683f LibJS: Add "Month dd, yy hh:mm:ss" Date format
Required by Discord's Birthday page.
2023-05-22 06:07:05 +02:00
Luke Wilde
e038901555 LibWeb: Fire the contextmenu event on right click (if not holding shift)
This now allows websites such as Discord, YouTube and your favourite
"Right Click" xkcd comic to open a custom context menu when you right
click. You can bypass this by holding shift, just like Firefox.
2023-05-22 06:07:05 +02:00
MacDue
91d8665ab4 LibWeb: Tidy up apply_clip_overflow_rect() a little
Avoid possible null optional dereference when creating border radius
clipper, and avoid creating clipper if the clip rect is empty (which
prevents some debug spam). Also remove an unnecessary lambda.
2023-05-22 06:05:47 +02:00
Aliaksandr Kalenik
193290b19a LibWeb: Support grid-auto-columns and grid-auto-rows properties in GFC
Implements assignment of sizes specified in grid-auto-columns/rows for
implicitly created tracks.
2023-05-22 06:05:19 +02:00
Aliaksandr Kalenik
6e0601a63e LibWeb/CSS: Implement parsing of grid-auto-columns and grid-auto-rows 2023-05-22 06:05:19 +02:00
Aliaksandr Kalenik
b49e9d2eab LibWeb: Check if line name is present in GridTrackSizeList::to_string()
Fixes crash in GridTrackSizeList::to_string() when line names are
missing.
2023-05-22 06:05:19 +02:00
Sam Atkins
ff70418ffc Revert "LibGfx: Add NearestFractional scaling type to painter"
This reverts commit df30440117.

This scaling type is now unused, and has issues with painting outside of
the Painter's clip-rect.
2023-05-22 01:38:41 +02:00
Andreas Kling
0d82cc8a67 LibWeb: Don't assume response object isn't null in fetch abort algorithm
The callee that we're passing it to expects a GCPtr anyway, so there's
no need to explicitly dereference this.

Fixes a crash when loading https://spotify.com/
2023-05-21 16:19:31 +02:00
Aliaksandr Kalenik
f9803a7319 LibWeb: Represent OccupationGrid using HashTable in GFC
Using HashTable of grid positions to represent OccupationGrid allows to
simplify positioning code. For example maybe_add_row() and
maybe_add_column() calls are not needed anymore because there is no
Vector<Vector<bool>> that need to be resized.

No observable changes in grid layout are expected :)
2023-05-21 16:18:46 +02:00
Andreas Kling
0f4b82bdea LibWeb: Move SVGElement's dataset construction to initialize()
It's not safe to allocate new cells while in a cell constructor.
2023-05-21 16:01:19 +02:00
Andreas Kling
055dabc123 LibWeb: Fix unsafe capture of stack variables in main_fetch() 2023-05-21 16:01:19 +02:00
Andreas Kling
e69a06b358 LibJS: Don't dereference well-known symbols when gathering roots
This fixes an issue where very early GC would crash trying to
dereference not-yet-initialized entries in the well-known symbol set.
2023-05-21 16:01:19 +02:00
Andreas Kling
cfe663435e LibWeb+LibJS: Don't lazily construct web prototypes in cell constructors
It's not safe to allocate from the GC heap while in the constructor of a
GC heap cell. (Because if this ends up triggering a collection, we may
end up trying to call through an uninitialized vtable).

This was already done safely in the initialize() virtual in much of
LibJS and LibWeb. This patch moves the logic for prototypes, mixins,
and CSSStyleDeclaration as well.

Fixes a long-standing GC crash that was pretty easy to reproduce by
refreshing https://vercel.com/
2023-05-21 14:23:58 +02:00
Andi Gallo
e6221117a5 LibWeb: Implement table rowspan
Adjust computing the table height and positioning of cells to account
for the rowspan property.

Fixes #18952.
2023-05-21 14:23:41 +02:00
Andreas Kling
6cb9d755d9 LibWeb: Don't crash on percentage values for CSS stroke-width
Fixes a crash when loading https://vercel.com/
2023-05-21 12:40:27 +02:00
Aliaksandr Kalenik
09ef2c14e9 LibWeb: Use code to size spanning tracks for non-spanning tracks in GFC
Since the specifications indicate that the algorithm for sizing tracks
without any spanning items is a simplified version of the more general
algorithm used for sizing tracks with spanning items, we can reuse the
code to size both cases.
2023-05-21 11:59:19 +02:00
Aliaksandr Kalenik
409333d80a LibWeb: Implement more of spanning tracks sizing in GFC
Implements more parts of sizing algorithm for tracks with spanning
items to archive parity with implementation for sizing of tracks
with non-spanning items.
2023-05-21 11:59:19 +02:00
Ben Wiederhake
943ecaede6 LibIPC: Remove redundant IPC::Dictionary type
We already have and use HashMap<DeprecatedString, DeprecatedString>
nearly everywhere, which is essentially equivalent.
2023-05-21 07:53:45 +02:00
Ben Wiederhake
d030f0fe9b WebSocket: Avoid unnecessary IPC::Dictionary wrapper
We already have and use HashMap<DeprecatedString, DeprecatedString>
nearly everywhere, which is equivalent.
2023-05-21 07:53:45 +02:00
Ben Wiederhake
9b9a38ec81 RequestServer: Avoid unnecessary IPC::Dictionary wrapper
We already have and use HashMap<DeprecatedString, DeprecatedString>
nearly everywhere, which is equivalent.
2023-05-21 07:53:45 +02:00
Ben Wiederhake
0ee5a4e308 Clipboard: Avoid unnecessary IPC::Dictionary wrapper
We already have and use HashMap<DeprecatedString, DeprecatedString>
nearly everywhere, which is equivalent.
2023-05-21 07:53:45 +02:00
Ben Wiederhake
67d9172885 LibIPC: Fix HashMap detection in case of non-trivial traits 2023-05-21 07:53:45 +02:00
Ben Wiederhake
81700d1b92 LibCodeComprehension: Remove unused #include <DeprecatedFile.h> 2023-05-21 07:52:41 +02:00
Andreas Kling
3c7b0192fa LibWeb: Load external images with image/svg+xml as SVG-as-image 2023-05-21 07:44:29 +02:00
Andreas Kling
94a26e2715 LibWeb: Include SVG-as-image isolated contexts in layout/DOM tree dumps
This allows us to see the inside of SVG-as-image in layout tests. :^)
2023-05-21 07:44:29 +02:00
Andreas Kling
b2c899af11 LibWeb: Make standalone SVG document roots the size of the viewport
We have to special-case these, otherwise our normal CSS layout algorithm
will see that some SVG roots have width/height assigned, and make those
the used width/height.

When used in an SVG-as-image context, the outermost viewport must be the
authoritative root size.
2023-05-21 07:44:29 +02:00
Andreas Kling
dcc561aa60 LibWeb: Calculate intrinsic size and aspect ratio for SVG-as-image
This finally makes SVG-as-image show up visually! :^)

We should find a way to share this logic with Layout::SVGSVGBox, but
that will require some finesse since they have to work at different
points in the layout/paint timeline.
2023-05-21 07:44:29 +02:00
Andreas Kling
41ab0837fa LibWeb: Render SVG-as-image into an isolated top-level browsing context
In order to separate the SVG content from the rest of the engine, it
gets its very own Page, PageClient, top-level browsing context, etc.

Unfortunately, we do have to get the palette and CSS/device pixel ratios
from the host Page for now, maybe that's something we could refactor in
the future.

Note that this doesn't work visually yet, since we don't calculate the
intrinsic sizes & ratio for SVG images. That comes next. :^)
2023-05-21 07:44:29 +02:00
Andreas Kling
e63f68661f LibWeb: Have ImageProvider bitmap getter take optional size argument
This allows the painting subsystem to request a bitmap with the exact
size needed for painting, instead of being limited to "just give me a
bitmap" (which was perfectly enough for raster images, but not for
vector graphics).
2023-05-21 07:44:29 +02:00
Andreas Kling
6f46bff4df LibWeb: Stub out a new SVGDecodedImageData class
This class will implement isolated SVG layout and rendering.
2023-05-21 07:44:29 +02:00
Andreas Kling
8d3240d633 LibWeb: Make ImageBox ask ImageProvider for intrinsic size and ratio
This paves the way for ImageProvider to have something vector-based
underneath. :^)
2023-05-21 07:44:29 +02:00
Andreas Kling
4ee1e5b224 LibWeb: Make DecodedImageData an abstract class
The existing implementation moves down into a new subclass called
AnimatedBitmapDecodedImageData.

The purpose of this change is to create an extension point where we can
plug in an SVG renderer. :^)
2023-05-21 07:44:29 +02:00
MacDue
00cda96e2d LibWeb: Implement SVG opacity properties
This implements the stop-opacity, fill-opacity, and stroke-opacity
properties (in CSS). This replaces the existing more ad-hoc
fill-opacity attribute handling.
2023-05-20 08:52:19 +02:00
MacDue
120e5b6b6f LibGfx: Add Color::with_opacity(float opacity)
This returns the color with its alpha scaled by the opacity.
2023-05-20 08:52:19 +02:00
Andreas Kling
f0560fd087 LibWeb: Support <svg> elements with display: block
There are a couple of things that went into this:

- We now calculate the intrinsic width/height and aspect ratio of <svg>
  elements based on the spec algorithm instead of our previous ad-hoc
  guesswork solution.

- Replaced elements with automatic size and intrinsic aspect ratio but
  no intrinsic dimensions are now sized with the stretch-fit width
  formula.

- We take care to assign both used width and used height to <svg>
  elements before running their SVG formatting contexts. This ensures
  that the inside SVG content is laid out with knowledge of its
  viewport geometry.

- We avoid infinite recursion in tentative_height_for_replaced_element()
  by using the already-calculated used width instead of calling the
  function that calculates the used width (since that may call us right
  back again).
2023-05-20 08:49:42 +02:00
Niklas Poslovski
fcbb8d63c0 LibWasm: Change dir_fd to auto instead of int 2023-05-20 03:27:38 +03:30
Tim Schumacher
d4b0e64825 LibCompress: Move two shared LZMA magic numbers into a common place 2023-05-19 23:40:33 +02:00
Tim Schumacher
a01968ee6d LibCompress: Handle arbitrarily long FF-chains in the LZMA encoder 2023-05-19 23:40:33 +02:00
Tim Schumacher
cb93186350 LibCompress: Add debug logging for handling LZMA direct bits 2023-05-19 23:40:33 +02:00
Ben Wiederhake
9474e0cd94 LibDebug: Prefer File::read_until_eof over DeprecatedFile 2023-05-19 23:31:20 +02:00
Ben Wiederhake
f9a24eb7eb LibCore: Migrate Command from Deprecated{File,String}
This gives us free error-propagation in Core::command(...) and
HackStudio::ProjectBuilder::for_each_library_dependencies.

The comment about "String will be in the null state" has been misleading
for a long time, so it is removed.
2023-05-19 23:31:20 +02:00
Ben Wiederhake
07dd719e3e LibCodeComprehension: Prefer File::read_until_eof over DeprecatedFile
Note that LibTest/Macros.h and therefore the macro TRY_OR_FAIL are not
available, so using these would require some in-depth rework.

release_value_but_fixme_should_propagate_errors should generate a
reasonably obvious hint that the test didn't find some expected file.
Note that I intentionally did not choose MUST(), since it should be a
TRY_OR_FAIL() in some form.
2023-05-19 23:31:20 +02:00
Ben Wiederhake
12d1ddbde5 LibWeb: Explicitly mark HashMap copy 2023-05-19 22:33:57 +02:00
Ben Wiederhake
2bb2a7097d LibTLS: Avoid unnecessary HashMap copies, improve const-correctness 2023-05-19 22:33:57 +02:00
Ben Wiederhake
f866c80222 LibPDF: Avoid unnecessary HashMap copy, mark other copies 2023-05-19 22:33:57 +02:00
Ben Wiederhake
362773d4a6 LibIPC: Explicitly mark HashMap copy, offer move interface 2023-05-19 22:33:57 +02:00
Ben Wiederhake
688d8febe4 LibIDL: Avoid unnecessary HashMap copy 2023-05-19 22:33:57 +02:00
Ben Wiederhake
31ba0a1a4c LibCore: Explicitly mark HashMap copy 2023-05-19 22:33:57 +02:00
Ben Wiederhake
9eeda5719e LibLine: Prefer File::read_until_eof over DeprecatedFile::read_all 2023-05-19 21:36:37 +02:00
Ben Wiederhake
33026bcefe LibCore: Remove recursive copy API from DeprecatedFile 2023-05-19 21:12:15 +02:00
Jelle Raaijmakers
5031603cdc LibGfx: Remove clip check in Painter::do_draw_scaled_bitmap
We were performing a check whether source pixels would fall into a
clipped rect too early. Since we already clamp the resulting source
coordinates to the clipped rect, we can just remove this code.
2023-05-19 18:36:36 +02:00
Jelle Raaijmakers
7652dbd983 LibWeb: Use box sampling instead of bilinear scaling when downscaling
As a heuristic, either the width or height of the scaled image should
decrease for box sampling to be used. Otherwise, we use bilinear
scaling.
2023-05-19 18:36:36 +02:00
Jelle Raaijmakers
6242d8e023 LibGfx: Implement box sampling image scaling
Box sampling is a scaling algorithm that averages all the pixels that
form the source for the target pixel. For example, if you would resize a
9x9 image to 3x3, each target pixel would encompass a 3x3 pixel area in
the source image.

Box sampling is a near perfect scaling algorithm for downscaling. When
upscaling with this algorithm, the result is similar to nearest neighbor
or smooth pixels.
2023-05-19 18:36:36 +02:00
Jelle Raaijmakers
31fa449538 LibGfx: Cleanup of Painter::do_draw_scaled_bitmap()
No functional changes.
2023-05-19 18:36:36 +02:00
Andreas Kling
6f204f8c32 LibWeb: Fix null dereference on SVG element with bogus fill URL
Fixes a crash seen on YouTube channel pages.
2023-05-19 15:41:34 +02:00
Andreas Kling
411b28fc59 LibWeb: Make sure that margins don't collapse across a nested BFC
In order to fix this, I also had to reorganize the code so that we
create an independent formatting context even for block-level boxes
that don't have any children. This accidentally improves a table
layout test as well (for empty tables).
2023-05-19 15:09:09 +02:00
Andreas Kling
9ce7681ff2 Revert "LibGfx: Implement alternative Rect right/bottom edge calculations"
This reverts commit 88a7bb5ba7.
2023-05-19 13:33:55 +02:00
Andreas Kling
3a670389d6 Revert "LibGfx: Cleanup of Painter::do_draw_scaled_bitmap()"
This reverts commit 4944b16bd5.
2023-05-19 13:33:54 +02:00
Andreas Kling
2d3b7eff15 Revert "LibGfx: Implement box sampling image scaling"
This reverts commit eb418bec32.
2023-05-19 13:33:54 +02:00
Andreas Kling
77db621be5 Revert "LibWeb: Use box sampling instead of bilinear scaling when downscaling"
This reverts commit b79fd3d1a9.
2023-05-19 13:33:52 +02:00
Andreas Kling
fb1a151fe3 Revert "LibGfx: Remove clip check in Painter::do_draw_scaled_bitmap"
This reverts commit 2959c2f2eb.
2023-05-19 13:33:50 +02:00
thankyouverycool
37e621a3c7 LibFileSystemAccessClient: Improve error propagation
Previously FSAC displayed some but not all errors and always
rejected directories and devices. This has led most apps to ignore
response errors in open/save actions or show redundant messages.

Now FSAC displays all errors including fd failures and has the ability
to silence messages for directories, devices and ENOENT, which some
apps handle differently. Silenced directory and device errors now
return files on success.

A request's access mode is now stored in RequestData to format more
accurate error messages from the user's perspective.

Resolved promises don't require callback propagation so they're voided
2023-05-19 06:20:41 +02:00
thankyouverycool
7a183ee568 LibGUI: Set Open/Save button as default in FilePicker
This makes it more obvious that enter will return the current
selection and prevents returning without a valid selection.
2023-05-19 06:20:41 +02:00
Andreas Kling
f823b297b4 LibWeb: Push the realm execution context while linking modules
If linking fails, we throw a JS exception, and if there's no execution
context on the VM stack at that time, we assert in VM::current_realm().

This is a hack to prevent crashing on failed module loads. Long term we
need to rewrite module loading since it has been refactored to share
code differently between HTML and ECMA262.
2023-05-19 06:20:14 +02:00
Andreas Kling
819fb39a87 LibWeb: Implement the "error to rethrow" mechanism in HTML::Script
This allows JS module loads to fail and throw without crashing the
WebContent process due to a TODO() assertion.
2023-05-19 06:20:14 +02:00
Jelle Raaijmakers
2959c2f2eb LibGfx: Remove clip check in Painter::do_draw_scaled_bitmap
We were performing a check whether source pixels would fall into a
clipped rect too early. Since we already clamp the resulting source
coordinates to the clipped rect, we can just remove this code.
2023-05-19 06:16:14 +02:00
Jelle Raaijmakers
b79fd3d1a9 LibWeb: Use box sampling instead of bilinear scaling when downscaling
As a heuristic, either the width or height of the scaled image should
decrease for box sampling to be used. Otherwise, we use bilinear
scaling.
2023-05-19 06:16:14 +02:00
Jelle Raaijmakers
eb418bec32 LibGfx: Implement box sampling image scaling
Box sampling is a scaling algorithm that averages all the pixels that
form the source for the target pixel. For example, if you would resize a
9x9 image to 3x3, each target pixel would encompass a 3x3 pixel area in
the source image.

Box sampling is a near perfect scaling algorithm for downscaling. When
upscaling with this algorithm, the result is similar to nearest neighbor
or smooth pixels.
2023-05-19 06:16:14 +02:00
Jelle Raaijmakers
4944b16bd5 LibGfx: Cleanup of Painter::do_draw_scaled_bitmap()
No functional changes.
2023-05-19 06:16:14 +02:00
Jelle Raaijmakers
88a7bb5ba7 LibGfx: Implement alternative Rect right/bottom edge calculations
For `IntRect`, we assume that the right/bottom edge is offset by minus
one. This obviously will not work for `FloatRect`, since those edges are
infinitely small.

Specialize `right()` and `bottom()` and add a `FIXME` to get rid of the
offset in the future.
2023-05-19 06:16:14 +02:00
Aliaksandr Kalenik
902ceb1675 LibWeb: Resolve grid item fixed size paddings in GFC
Adds support for grid items with fixed size paddings. Supporting
percentage paddings will probably require to do second pass of tracks
layout: second pass is needed to recalculate tracks sizes when final
items sizes are known when percentage paddings are already resolved.
2023-05-19 06:12:05 +02:00
Aliaksandr Kalenik
f8d6569841 LibWeb: Move resolving grid item heights into separate method in GFC 2023-05-19 06:12:05 +02:00
kleines Filmröllchen
3b8ccd123b LibAudio: Compute and verify FLAC frame header checksums
This is currently not a failure condition, but we will print out a
message to the console informing the user of a potential corrupted file.
2023-05-18 22:23:15 +02:00
kleines Filmröllchen
70ab4566f3 LibCrypto: Add a checksumming stream wrapper
This generic stream wrapper performs checksum calculations on all data
passed through it for reading or writing, and is therefore convenient
for calculating checksums while performing normal data input/output, as
well as computing streaming checksums on non-seekable streams.
2023-05-18 22:23:15 +02:00
kleines Filmröllchen
daf50ed885 LibCrypto: Add generic 8-bit CRC
The implementation of this is naive enough so it can handle all 8-bit
CRC polynomials, of which there are quite a few. The table generation
and update procedure is MSB first, which is backwards from the LSB first
method of CRC32.
2023-05-18 22:23:15 +02:00
kleines Filmröllchen
4f9c91e34d LibCrypto: Expose checksum type of ChecksumFunction 2023-05-18 22:23:15 +02:00
Andreas Kling
e3d182bfe2 LibWeb: Fix "Unsupported main size for flex-basis" spam about calc()
For flex items with a calc() value for a main size, we can just convert
them to a calculation-backed LengthPercentage.
2023-05-18 18:06:30 +02:00
Aliaksandr Kalenik
82aedfcaf0 LibWeb: Use grid item used width as available width during track sizing
This change addresses the incorrect assumption that the available width
inside a grid item is equal to the width of the track it belongs to.
For instance, if a grid item has a width of 200px, the available width
inside that item is also 200px regardless of its column(s) base size.

To solve this issue, it was necessary to move the final resolution of
grid items to occur immediately after the final column track sizes are
determined. By doing so, it becomes possible to obtain correct
available width inside grid items while resolving the row track sizes.
2023-05-18 18:06:05 +02:00
Sam Atkins
52e9dced1a LibWeb: Remove unitless-length quirk from properties that don't need it
A list of every property that has this quirk is available here:
https://quirks.spec.whatwg.org/#the-unitless-length-quirk
2023-05-18 18:04:48 +02:00
Liav A
0bbd9040ef Kernel+Userland: Split bind-mounting and re-mounting from mount syscall
These 2 are an actual separate types of syscalls, so let's stop using
special flags for bind mounting or re-mounting and instead let userspace
calling directly for this kind of actions.
2023-05-17 23:39:15 -06:00
kleines Filmröllchen
04b44a827a LibThreading: Only run on_error callback when action wasn't canceled
This mirrors the same UAF protection for event loops used by the
on_complete callback.
2023-05-17 22:40:15 -06:00
kleines Filmröllchen
7704d89496 LibCore: Cancel jobs on event loop exit
This important feature was regressed with the recent architectural
change.
2023-05-17 22:40:15 -06:00
Andreas Kling
f063eb3218 LibWeb: Add missing call to Base in VideoTrack::visit_edges()
This fixes a GC crash that happened after a while on the Steam store.
2023-05-17 13:09:02 -07:00
Andreas Kling
5bb6e2c80c LibWeb: Null-check layout node before dereferencing in HTMLVideoElement
DOM elements don't always have a corresponding layout node. This fixes a
crash soon after loading the Steam store.
2023-05-17 13:09:02 -07:00
Andreas Kling
fb722e69f3 LibWeb: Resolve CSS custom properties on pseudo elements
The resolved property sets are stored with the element in a
per-pseudo-element array (same as for pseudo element layout nodes).

Longer term, we should stop storing this with elements entirely and make
it temporary state in StyleComputer somehow, so we don't waste memory
keeping all the resolved properties around.

This makes various gradients show up on https://shopify.com/ :^)
2023-05-17 20:37:29 +02:00
Timothy Flynn
6970f1b6c1 Browser+Ladybird+LibWebView: Handle trivial content APIs in LibWebView
The goal here is to reduce the amount of WebContent client APIs that are
duplicated across every ViewImplementation. Across our three browsers,
we currently:

    Ladybird - Mix some AK::Function callbacks and Qt signals to notify
    tabs of WebContent events.

    Browser - Use only AK::Function callbacks.

    headless-browser - Drop most events on the floor.

Instead, let's only use AK::Function callbacks across all three browsers
to propagate events to tabs. This allows us to invoke those callbacks
directly from LibWebView instead of all three browsers needing to define
a trivial `if (callback) callback();` override of a LibWebView virtual
function. For headless-browser, we can simply not set these callbacks.

As a first pass, this only converts WebContent events that are trivial
to this approach. That is, events that were simply passed onto the tab
or handled without much fuss.
2023-05-17 19:47:05 +02:00
Timothy Flynn
c113d780c6 Ladybird: Move ownership of the JS console/inspector to the tab object
This is to match Browser, where ownership of all "subwidgets" is placed
on the tab as well. This further lets us align the web view callbacks to
match Browser's OOPWV as well, which will later let us move them into
the base LibWebView class.
2023-05-17 19:47:05 +02:00
Timothy Flynn
2d51b8c286 Browser+Ladybird+LibWebView: Virtualize computing content/widget points
This will allow moving some copy-pasted functionality from web view
implementations to the base LibWebView class.
2023-05-17 19:47:05 +02:00
Timothy Flynn
d8b14da380 Browser+Ladybird+LibWebView: Move some common functions to LibWebView
The implementations of handle_web_content_process_crash and
take_screenshot are exactly the same across Browser and Ladybird. Let's
reduce some code duplication and move them to LibWebView.
2023-05-17 19:47:05 +02:00
Aliaksandr Kalenik
5312a140fe LibWeb: Add for_each_spanned_track to iterate spanned tracks in GFC
Introducing for_each_spanned_track that allows to iterate tracks
spanned by a specific items allow to delete a lot of repeated code.
2023-05-17 15:55:14 +02:00
Aliaksandr Kalenik
628efda754 LibWeb: Consider span > 1 while getting available space for items in GFC 2023-05-17 15:55:14 +02:00
Aliaksandr Kalenik
d6d097b671 LibWeb: Remove borders from TemporaryTrack in GFC
This change makes grid items be responsible for their borders instead
of grid tracks which can not have borders itself.

There are changes in layout tests but those are improvements :)
2023-05-17 09:11:29 +02:00
Tim Schumacher
df071d8a76 LibCompress: Add a lot of debug logging to LZMA 2023-05-17 09:08:53 +02:00
Tim Schumacher
85a54cc796 LibCompress: Add an LZMA encoder 2023-05-17 09:08:53 +02:00
Tim Schumacher
9ab3646bc7 LibCompress: Use the variable for LZMA "normalized to real distance"
The variable already existed, but I forgot to use it earlier.
2023-05-17 09:08:53 +02:00
Tim Schumacher
42514c6961 LibCompress: Decode the LZMA match type in a separate function
This should keep the `read_some` function a bit flatter and shorter, and
make it easier to match the match type decoding process with the
specification.
2023-05-17 09:08:53 +02:00
Tim Schumacher
4a37bac374 LibCompress: Make LzmaHeader a POD-like type
This allows us to initialize the struct using an aggregate initializer.
2023-05-17 09:08:53 +02:00
Tim Schumacher
440d8f908f LibCompress: Extract the LZMA state to a separate class
We will also need this in the compressor, as it needs to do the exact
same calculations in reverse.
2023-05-17 09:08:53 +02:00
Aliaksandr Kalenik
c61bb1706f LibWeb: Use auto minimimum size while resolving flexible tracks in GFC 2023-05-17 07:48:38 +02:00
Aliaksandr Kalenik
5f2264a2bd LibWeb: Skip non-spanning items sizing if there are no such items
Otherwise base_size and growth_limit for tracks that do not have any
spanning items will be overriden with wrong values.
2023-05-17 07:48:38 +02:00
Aliaksandr Kalenik
95d17ee875 LibWeb: Rename flexible_length to flex_factor in GridSize
Let's match the name used in the spec.
2023-05-17 07:48:38 +02:00
Aliaksandr Kalenik
a3759b6e76 LibWeb: Implement more of "Expand Flexible Tracks" in GFC
Implements "Otherwise, if the free space is an indefinite length:" from
the spec.
2023-05-17 07:48:38 +02:00
Andreas Kling
2e13f65ff4 LibWeb: Support flex-basis: calc(...)
1. Propagate calc() values from StyleProperties to ComputedValues.
2. Actually resolve calc() values when determining the used flex basis.

This makes the "support" section on https://shopify.com/ show up
correctly as a 2x2 grid (instead of 1x4). :^)
2023-05-17 07:40:17 +02:00
Andreas Kling
e81d4ca1ac LibWeb: Fix off-by-one in CSS calc() "negate" operation
When negating a number, we should subtract it from 0, not 1. :^)
2023-05-17 07:40:17 +02:00
Timothy Flynn
d1a1b1ab75 LibWebView: Remove the DumpLayoutTree program
This program's purpose is now achieved with headless-browser, which has
the added benefit of being runnable outside of Serenity.
2023-05-16 13:22:23 -07:00
Andreas Kling
e938860126 LibWeb: Make text justification work between floats
While inline content between floating elements was broken correctly,
text justification was still using the original amount of available
space (without accounting for floats) when justifying fragments.
2023-05-16 14:35:10 +02:00
Andreas Kling
bab6796099 LibWeb: Rewrite calculation of available space between floats
This code now works in terms of *intrusion* by left and right side
floats into a given box whose insides we're trying to layout.

Previously, it worked in terms of space occupied by floats in the root
box of the BFC they participated in. That created a bunch of edge cases
since the code asking about the information wasn't operating in root
coordinate space, but in the coordinate space of some arbitrarily nested
block descendant of the root.

This finally allows horizontal margins in the containing block chain to
affect floats and nested content correctly, and it also allows us to
remove a bogus workaround in InlineFormattingContext.
2023-05-16 14:35:10 +02:00
Andreas Kling
9bd4add734 LibGfx: Make FontDatabase lookups case insensitive
This seems mostly harmless and matches what CSS expects from us at the
moment. Eventually our CSS font selection will become more sophisticated
and stop relying on Gfx::FontDatabase for things like this, but for now
it's a simple stopgap that lets websites do "font-family: arial" :^)
2023-05-16 14:35:10 +02:00
Andi Gallo
9a6a635e51 LibWeb: Fix for absolutely positioned elements with specified height
Use inner height since the paintable adds padding back.

Fixes #18842.
2023-05-16 14:34:53 +02:00
Karol Kosek
3e12d84f0f LibGUI: Actually set the first allowed file extension list in FilePicker
Previously, the File Picker didn't activate the pre-selected filter.
2023-05-16 12:57:34 +01:00
Timothy Flynn
c82f678fc6 LibWeb+WebContent: Add APIs to control video playback state
This allows for the browser process to control the play/pause state,
whether we paint user agent controls on the video, and whether the video
loops when it finishes playing.
2023-05-16 12:48:39 +02:00
Timothy Flynn
d8f03dda08 Browser+LibWeb+WebContent: Broadcast video element context menu requests
This just sets up the IPC to notify the browser process of context menu
requests on video elements. The IPC contains a few pieces of information
about the state of the video element.
2023-05-16 12:48:39 +02:00
Timothy Flynn
5f473bcb5f LibWeb: Propagate non-primary mouse button clicks on video elements
Otherwise, returning "no" here will disallow the browser process from
showing a context menu, as the event handler will bail early.
2023-05-16 12:48:39 +02:00
Timothy Flynn
bcfa4a34a1 LibCore: Support the WebM file extension when determining MIME type
This enables, for example, navigating to a file:// URL in Ladybird with
a .webm file extension.
2023-05-16 12:48:39 +02:00
networkException
63d2b26b17 LibVT: Correctly wrap text when the scrollbar is hidden 2023-05-16 12:47:16 +02:00
Luke Wilde
b15128c45b LibJS/Bytecode: Implement initial support for super member expressions 2023-05-16 11:26:31 +02:00
Luke Wilde
00493687f2 LibWeb: Implement location.assign 2023-05-16 11:25:44 +02:00
Aliaksandr Kalenik
2d05c63c7c LibWeb: Skip frozen tracks while distributing space in GFC 2023-05-16 07:47:47 +02:00
Aliaksandr Kalenik
a613a0973e LibWeb: Reset item_incurred_increase before distributing space in GFC
item_incurred_increase should be reset before every next distirbution
because otherwise it will accumulate increases from previous
distributions which is not supposed to happen.
2023-05-16 07:47:47 +02:00
Andreas Kling
5d4e9a0673 LibWeb: Basic support for CSS text-indent: <length-percentage>
Note that this simple form of text-indent only affects the first line
of formatted content in each block.

Percentages are resolved against the width of the block.
2023-05-15 19:31:09 +02:00
Sam Atkins
9c2d496dbe LibWeb: Make processBodyError take an optional exception
Changed here:
018ac19838
2023-05-15 16:28:16 +02:00
Aliaksandr Kalenik
ae5bb13f1f LibWeb: Do not layout grid items during grid container intrinsic sizing
There is not need to run layout inside grid items for intrinsic sizing
of grid container.
2023-05-15 16:27:53 +02:00
Aliaksandr Kalenik
1ecbbadf3a LibWeb: Fix specified_size_suggestion to use size of dimension
specified_size_suggestion() should use width or height depending on
specified dimension.
2023-05-15 16:20:51 +02:00
Aliaksandr Kalenik
daf86eaabc LibWeb: Fix UBSAN issue caused by invalid TemporaryTrack pointer in GFC
Fixes the issue when if there are enough rows/column to force
m_row_gap_tracks or m_column_gap_tracks be resized during gaps
initialization then pointers stored in m_grid_columns_and_gaps or
m_grid_rows_and_gaps become invalid.
2023-05-15 15:35:34 +02:00
Andreas Kling
4d0d0a99b4 LibGUI: Fix bad title alignment in GroupBox
Make a separate rect for the text and use IntRect::centered_within()
to sidestep any subpixel jitter. This way it looks good with both bitmap
and vector fonts.
2023-05-15 14:15:53 +02:00
Andreas Kling
20e2c9a7dd LibWeb: Cache state of the contenteditable attribute on HTMLElement
Instead of recomputing the state whenever someone asks for it, we now
cache it when the attribute is added/changed/removed.

Before this change, HTMLElement::is_editable() was 6.5% of CPU time
when furiously resizing Hacker News. After, it's less than 0.5%. :^)
2023-05-15 14:08:20 +02:00
Andreas Kling
990e7219d6 LibWeb: Fix iframes flickering on window resize
After finishing layout, iframe layout boxes (FrameBox) get notified
about their new size by LayoutState::commit(). This information is
forwarded to the nested browsing context, where it can be used for
layout of the nested document.

The problem here was that we notified the FrameBox twice. Once when
assigning the used offset to its paintable, and once when assigning its
size. Because the offset was assigned first, we ended up telling the
FrameBox "btw, your size is 0x0". This caused us to throw away all
the layout information we had for the nested document.

We'd then say "actually, your size is 300x200" (or something) but by
then it was already too late, and we had to do a full relayout.
This caused iframes to flicker as every time their containing document
was laid out, we'd nuke the iframe layout and redo it (on a zero timer).

The fix is pleasantly simple: we didn't need to inform the nested
document of its offset in the containing document's layout anyway. Only
its size is relevant. So we can simply remove the first call, which
removes the bogus 0x0 temporary size.

Note that iframes may still flicker if they change size in the
containing document. That's a separate issue that will require more
finesse to solve. However, this fixes a very noticeable common case.
2023-05-15 14:08:08 +02:00
thankyouverycool
c87c4f6d94 LibGUI: Put a governor on Action activation
Many actions affect Window modality, so let's put a temporary change
governor on activation to stop race conditions.

Fixes being able to spam open/close shortcuts and spawn multiple
FilePickers, among other things.
2023-05-15 12:15:39 +02:00
thankyouverycool
7323a54e59 LibGUI+FileSystemAccessServer: Avoid using dummy windows
Creates two new gatekept helpers for FilePicker and MessageBox to be
used by FSAS to replace the "dummy window" approach to centering
Dialogs. There was a slight delay in creating two windows, one a
transparent intermediary hidden behind the second, to display FSAS
Dialogs. Now we only need to make the window we actually see.
2023-05-15 12:15:39 +02:00
thankyouverycool
f76d24c2ec LibGUI: Simplify Dialog::ScreenPosition and allow Dialogs to opt out
These options were created 2 years ago but the only use cases thus far
are for Center and CenterWithinParent, so let's chuck the rest for now.

Adds a new DoNotPosition option to opt out of automatic centering and
a ScreenPosition setter and getter for configuration before exec()
2023-05-15 12:15:39 +02:00
thankyouverycool
dfe06096c7 LibGUI: Add Window::constrain_to_desktop() helper
And a center_within(IntRect const&) overload
2023-05-15 12:15:39 +02:00
thankyouverycool
2d64147f02 LibGfx: Reverse coordinate subtraction in Rect::constrained_to()
Fixes translating in the wrong direction or not at all in the case of
a constraint at (0,0). This doesn't appear to be used anywhere yet but
is needed in the upcoming patch.
2023-05-15 12:15:39 +02:00
Andreas Kling
85c542ab00 Ladybird+LibWebView: Move backing store management code to LibWebView
This lets us share this code on all platforms, and makes resizing the
window much faster on SerenityOS as well. :^)
2023-05-15 12:13:34 +02:00
Andreas Kling
def37e65f3 Ladybird+LibWebView: Remember the size of the last paint
This will allow us to change the size of the backing store bitmap
without conflating the size of the bitmap and the size of the paint.
2023-05-15 10:04:29 +02:00
Daniel Bertalan
fc003cd248 Userland: Silence or resolve new GCC 13 warnings
GCC 13 produces the following true positive warnings:
- `-Wredundant-move` when trying to move `result->tooltip()`, which
  is a const reference in `Assistant/main.cpp`
- `-Wuse-after-free` when freeing an environment variable before
  removing it from `s_malloced_environment_variables`
- `-Wdangling-pointer` when storing an AST node's `this` pointer to the
  interpreter's node stack in LibJS. This is not actually an issue, as
  it is popped when the scope ends, but GCC has no way of telling this.
2023-05-15 07:00:29 +02:00
Ben Wiederhake
4de99d553e LibCore: Remove DeprecatedFile::read_link 2023-05-15 06:50:43 +02:00
Karol Kosek
b7558a5ce4 LibGUI+Userland: Store column names in JsonArrayModel as String 2023-05-15 06:42:10 +02:00
Karol Kosek
945f05ed76 Userland: Port Model::column_name() to String 2023-05-15 06:42:10 +02:00
MacDue
741f07dedf LibGUI: Increase the min width of the vertical opacity slider
This prevents the <opacity>% text on the slider being clipped.
2023-05-15 06:40:18 +02:00
MacDue
9685d54291 LibGUI: Ensure final stop of the opacity slider gradient has 255 alpha
Otherwise, if you change the opacity in the color picker, the slider's
opacity changes.
2023-05-15 06:40:18 +02:00
Karol Kosek
acf8e19eac LibCore: Use StringView in Object::find_{child,descendant}_of_type_named
It's unnecessary to allocate a string when we only want to compare it
with another string.

This change also adds a helper for string literals, so that we won't
need to add -sv suffix everywhere. :^)
2023-05-15 06:39:22 +02:00
MacDue
631fe129e9 LibGfx: Stop assuming the target format is always BGRA8888
...and instead assume it's BGRx8888 or BGRA8888, for now. Always
treating the target as BGRA8888 leads to the alpha channel being
interpreted incorrectly sometimes (as can be seen with WindowServer
overlays).

Fixes #18749
2023-05-15 06:38:22 +02:00
Caoimhe
465fa3460f LibVideo: Add PlaybackManager::from_mapped_file
This allows us to create a PlaybackManager from a file which has already
been mapped, instead of passing a file name.

This means that anyone who uses `PlaybackManager` can now use LibFSAC :)
2023-05-14 15:56:49 -06:00
Ben Wiederhake
d5c13a3cbc LibCore: Remove standard I/O from DeprecatedFile 2023-05-14 15:42:57 -06:00
Aliaksandr Kalenik
87a7299078 LibWeb: Start implementing sizing for tracks with span > 1 items in GFC
Partially implements:
- Increase sizes to accommodate spanning items crossing content-sized
  tracks
- Increase sizes to accommodate spanning items crossing flexible tracks

from https://www.w3.org/TR/css-grid-2/#algo-content
2023-05-14 19:32:34 +02:00
Aliaksandr Kalenik
7a5603052a LibWeb: Separate grid tracks from gaps in GFC
This change is supposed to solve the problem that currenty when grid
tracks are interleaved with gaps it is impossible to iterate tracks
spanned by a specific grid item. There is a pair of functions:
gap_adjusted_row() and gap_adjusted_column() but they won't work
when it comes to items spanning > 1 track.

Separating gaps from tracks is going to make it possible to iterate
just tracks or both tracks and gaps when it is required. And now tracks
spanned by an item can be accessed by just index without doing any
additional math.
2023-05-14 18:18:31 +02:00
Luke Wilde
8bacd569ff LibWeb: Make the dblclick event bubble, cancelable and composed 2023-05-14 13:51:05 +02:00
Daniel Bertalan
e2b1f9447c LibELF: Only call IFUNC resolvers after populating the PLT
As IFUNC resolvers may call arbitrary functions though the PLT, they can
only be called after the PLT has been populated. This is true of the
`[[gnu::target_clones]]` attribute, which makes a call to
`__cpu_indicator_init`, which is defined in `libgcc_s.so`, through the
PLT.

`do_plt_relocation` and `do_direct_relocation` are given a parameter
that controls whether IFUNCs are immediately resolved. In the first
pass, relocations pointing to IFUNCs are put on a worklist, while all
other relocations are performed. Only after non-IFUNC relocations are
done and the PLT is set up do we deal with these.
2023-05-14 13:47:53 +02:00
Daniel Bertalan
cd45c2d295 LibELF: Split do_relocation into do_{direct,plt}_relocation
No functional changes intended. This is in preparation of a commit that
overhauls how IFUNCs are resolved.

This commit lets us move the implementation of PLT patching from
`DynamicObject` to `DynamicLoader` where all other relocation code
lives. For this, got[2] now stores the loader's address instead of the
object's.
2023-05-14 13:47:53 +02:00
Daniel Bertalan
c4e0f5e5ee LibC+LibELF: Handle the R_AARCH64_IRELATIVE relocation type
This is the AArch64 equivalent of `R_X86_64_IRELATIVE`, which specifies
a symbol whose address is determined by calling a local IFUNC resolver
function.
2023-05-14 13:47:53 +02:00
Aliaksandr Kalenik
07b6fb9104 LibWeb: Remove unused line in calculate_min_content_size() in GFC 2023-05-14 13:45:29 +02:00
Aliaksandr Kalenik
46db51a8c0 LibWeb: Remove excessive spec referencing in GridFormattingContext
Removes unrelated to the code copy paste from spec (sometimes
duplicated).
2023-05-14 13:45:29 +02:00
Aliaksandr Kalenik
6f82079a93 LibWeb: Remove dead code in resolve_intrinsic_track_sizes() in GFC
Removes partially implemented algorithm for distributing extra space
from spanning item:
https://www.w3.org/TR/css-grid-2/#extra-space

This algorithm should not be part of resolving track sizing on its own
but instead be a subfunction of step 3:
https://www.w3.org/TR/css-grid-2/#track-size-max-content-min

There are changes in layout tests but those are not regressions.
2023-05-14 13:45:29 +02:00
Rimvydas Naktinis
42bfe5db5f LibWeb: Change implicit background-size height to auto
The spec says: "The first value gives the width of the corresponding
image, the second value its height. If only one value is given the
second is assumed to be auto."

Fixes #18782
2023-05-14 13:02:32 +02:00
Andreas Kling
719f1db6c9 LibWeb: Protect against dereferencing a null pending image request
The spec seems to neglect the potential nullity of an image's pending
request in various cases.

Let's protect against crashing and mark these cases with a FIXME about
figuring out whether they are really spec bugs or not.
2023-05-14 10:25:25 +02:00
MacDue
cf79df0edb LibDebug: Stub out LocListX and remove stub expression evaluator
The expression evaluator is dead code that does nothing but crash on
all paths, as no opcodes are implemented.

Stubbing out the LocListX form fixes a crash while reading DWARF 5
debug data that contains location lists. These are just a new way
to store location expressions, and since we never implemented
expressions, we can just ignore these too.

As far as I can tell this is enough for DWARF 5 to work for us (since
we mainly just use the line tables).
2023-05-14 09:21:08 +02:00
Andreas Kling
ce634957c1 LibJS/Bytecode: Restore old environments when an exception is caught
Unwind contexts now remember the lexical and variable environments in
effect when they were created. If an exception is caught, we revert
to those environments in the running execution context.
2023-05-14 06:18:28 +02:00
Andreas Kling
81a62f4f59 LibJS/Bytecode: Fix bogus program termination after try with catch
For `try` statements with a `catch` clause, we were generating *two*
"next" blocks. This meant that not throwing an exception would cause
execution to stop.

Fix this by using the "next" block pointer for the try "entry" and
"handler" blocks.
2023-05-14 06:18:28 +02:00
Fabian Dellwing
059904371f Userland: Allow our access check to pass flags to faccessat syscall 2023-05-13 17:59:37 -06:00
Aliaksandr Kalenik
dbafb11a7e LibWeb: Flesh out basic support of min-width/height for grid items
This change brings calculate_minimum_contribution() for grid items and
supporting functions.
2023-05-13 18:43:34 +02:00
Andreas Kling
0b49b93e98 LibJS/Bytecode: Variable declarators should always prefer lexical env
This fixes an issue where object environments (from `with` statement)
were bypassed by statements like `var x = 1` (for objects with an `x`
property).

Fixes 25 tests in test262. :^)
2023-05-13 17:01:45 +02:00
Luke Wilde
036e1e1bcf LibWeb: Implement performance.{measure,clearMeasures} 2023-05-13 16:31:10 +02:00
Luke Wilde
f62bcba56a LibWeb: Specify snake case names for navigation timing entries too
This will be used by performance.measure to read the value of a given
entry in the NavigationTiming interface.
2023-05-13 16:31:10 +02:00
Timothy Flynn
05019746d2 LibWeb: Partially implement HTMLSourceElement's insertion/removal steps
This implements the substeps which concern HTMLMediaElement parents.
2023-05-13 15:51:44 +02:00
Timothy Flynn
c161a0fc49 LibWeb: Implement the HTMLMediaElement child <source> selection steps
Rather than setting the src attribute on the HTMLMediaElement, websites
may append a list of HTMLSourceElement nodes to the media element. There
is a series of "try the next source" steps to attempt to fetch/load each
source until we find one that works.
2023-05-13 15:51:44 +02:00
Timothy Flynn
5bc386cc96 LibWeb: Change Document::parse_url to accept a StringView
There's no need for this to require a DeprecatedString - the method it
wraps around already only expects a StringView. This allows passing a
String instance without any conversion.
2023-05-13 15:51:44 +02:00
thankyouverycool
aaf60053f1 LibGUI: Use ColorRole::DisabledText when AbstractView is disabled
And only paint GlyphMapWidget's frame if disabled
2023-05-13 12:53:49 +02:00
thankyouverycool
ec29d3abae LibGUI: Allow setting and clearing text in SpinBox 2023-05-13 12:53:49 +02:00
thankyouverycool
0ad5e85163 LibGUI+Applications: Let GlyphMapWidget initialize a null Font
FontEditor will need to clear references to its mutable font in
the future while CharacterMap has no use for the highlights clone,
so let's convert GlyphMapWidget's set_font wrapper into a separate
initialize function for the editor and stop hiding the base function
for others. Setting font null in either ultimately points the map to
the system's default font.
2023-05-13 12:53:49 +02:00
thankyouverycool
e4ab9a799d LibGfx: Convert FontStyleMappings to Arrays
This will let us neatly ensure capacities, do unchecked appends, and
iterate by size() on FontEditor's models.
2023-05-13 12:53:49 +02:00
thankyouverycool
8dda4e4ab5 LibGUI: Add fallible factories to ItemListModel 2023-05-13 12:53:49 +02:00
thankyouverycool
023c1dffab LibGUI: Ignore Alt+{Left,Right} key events in GlyphMapWidget
Fixes seek actions not activating by keyboard shortcut when
GlyphMapWidget has focus.
2023-05-13 12:53:49 +02:00
Aliaksandr Kalenik
d187862f76 LibWeb: Return grid container width from automatic_content_width in GFC
automatic_content_width() should return grid container width that is
supposed to be set by determine_intrinsic_size_of_grid_container().
2023-05-13 12:53:25 +02:00
Aliaksandr Kalenik
644e4f4c99 LibWeb: Implement grid container intrinsic sizes calculation
When a width/height constraint is applied to GFC it should set its own
width/height to the sum of track sizes according to the spec.

Changes in layout tests are improvement over what we had before.
2023-05-13 12:53:25 +02:00
Aliaksandr Kalenik
d0ce61bf13 LibWeb: Fix condition to determine auto tracks while sizing in GFC
This solves the issue when track with "fixed" min sizing function were
treated like "auto" during sizing.
2023-05-13 12:53:25 +02:00
Andreas Kling
9d78619b59 LibWeb: Let HTMLImageElement delay the document load event again 2023-05-13 09:08:42 +02:00
Andreas Kling
c648e24cff LibWeb: Don't force HTMLImageElement to have a legacy ImageLoader
We achieve this by adding a new Layout::ImageProvider class and having
both HTMLImageElement and HTMLObjectElement inherit from it.

The HTML spec is vague on how object image loading should work, which
is why this first pass is focusing on image elements.
2023-05-13 09:08:42 +02:00
Andreas Kling
3cf73ca0b3 LibWeb: Implement enough of "update the image data" to load images
This first pass is enough to get us:
- Image loading via fetch
- Source selection via srcset and sizes attributes
2023-05-13 09:08:42 +02:00
Andreas Kling
6fe4fcb74b LibWeb: Add a class to represent the "source set" concept from HTML
Also comes with a little extra CSS parser helper for parsing "sizes"
attributes in images.
2023-05-13 09:08:42 +02:00
Andreas Kling
9281bf7a01 LibWeb: Add class to represent "list of available images" from HTML spec 2023-05-13 09:08:42 +02:00
Andreas Kling
596eabe9e6 LibWeb: Start fleshing out HTML "image requests" and "image data"
This patch adds HTML::ImageRequest and HTML::DecodedImageData.

The latter had to use a different name than "ImageData", as there is
already an IDL-exposed ImageData class in HTML.
2023-05-13 09:08:42 +02:00
Ben Wiederhake
c5d3de3f7d LibDebug: Propagate errors around LineProgram
Found while playing Fixme-Roulette.
2023-05-13 07:54:34 +02:00
Ben Wiederhake
960822ef74 LibCore: Remove unused API from DeprecatedFile
It looks like this migration it taking a while, so let's make sure noone
accidentally introduces new usages of this currently-unused API.
2023-05-13 07:53:13 +02:00
Ben Wiederhake
bc2a517ade Userland: Merge DEFAULT_PATH into LibFileSystem/FileSystem.h 2023-05-13 07:53:13 +02:00
Andreas Kling
c8cf599c44 LibWeb: Make PercentageOr<T> equality comparison work for calc() values
This makes hovering around on GitHub fast again, as it no longer
believes that the grid-template-areas property keeps changing
when it didn't :^)

Also made to_string() work for calc() values as well, since I stumbled
upon that while debugging this.
2023-05-13 07:38:08 +02:00
Aliaksandr Kalenik
d7ca52afaf LibWeb: Fix typo in containing_block_size_for_item in GFC 2023-05-13 06:48:55 +02:00
Aliaksandr Kalenik
4ef997c47c LibWeb: Align calculate_min/max_content_contribution with the spec
This change brings more spec compliant implementation of functions to
calculate min/max contributions of grid items in containing block size.
2023-05-13 06:29:42 +02:00
Ben Wiederhake
97e60f2c7d LibKeyboard: Read keymap through File, not DeprecatedFile
This results in a new OOM prevention. Hooray!
2023-05-12 19:46:54 +01:00
Ben Wiederhake
da394abe04 LibGfx+Fuzz: Convert ImageDecoder::initialize to ErrorOr
This prevents callers from accidentally discarding the result of
initialize(), which was the root cause of this OSS Fuzz bug:

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=55896&q=label%3AProj-serenity&sort=summary
2023-05-12 09:40:24 +01:00
Timothy Flynn
a84e64ed22 LibWeb: Implement fetching classic scripts using Fetch infrastructure 2023-05-12 05:47:36 +02:00
Timothy Flynn
12976b74ca LibWeb: Implement the fetch a classic script AO
Note that this unfortunately requires the same workaround as <link>
elements to handle CORS cross-origin responses.
2023-05-12 05:47:36 +02:00
Timothy Flynn
00fa23237a LibTextCodec: Change UTF-8's decoder to replace invalid code points
The UTF-8 decoder will currently crash if it is provided invalid UTF-8
input. Instead, change its behavior to match that of all other decoders
to replace invalid code points with U+FFFD. This is required by the web.
2023-05-12 05:47:36 +02:00
Timothy Flynn
cb32bb3502 LibWeb: Add an alias for FetchAlgorithm's consume-body callback argument
This will make it more convenient in places where the Variant would need
to be re-typed outside of this class.
2023-05-12 05:47:36 +02:00
Timothy Flynn
567b8da1e0 LibWeb: Change the script fetch completion callback to accept any script
The completion callback currently only accepts a JavaScriptModuleScript.
The same callback will need to be used for ClassicScript scripts as well
so allow the callback to accept any Script type. The single existing
outside caller already stores the result as a Script.
2023-05-12 05:47:36 +02:00
Timothy Flynn
dff0e8a0dc LibWeb: Implement the fetch response's unsafe response AO 2023-05-12 05:47:36 +02:00
Timothy Flynn
e4cb27050a LibWeb: Implement the fetch response is CORS-cross-origin AO 2023-05-12 05:47:36 +02:00
Timothy Flynn
29d90ccf3b LibWeb: Implement the legacy extracting an encoding AO 2023-05-12 05:47:36 +02:00
Timothy Flynn
9701128145 LibWeb: Implement the CORS settings attribute credentials mode AO 2023-05-12 05:47:36 +02:00
MacDue
9070aaebee LibGfx: VERIFY() error is finite when splitting bezier curves
If this value somehow becomes nan/inf the painter will keep splitting
the path till the process OOMs, a simple crash would be preferable.
2023-05-12 05:37:44 +02:00
MacDue
1012947a30 LibWeb: Use .to_px_or_zero() in tentative_height_for_replaced_element()
If just .to_px() is used the height can end up as the float `inf` or
`nan`. This caused an OOM when loading Polygon as this `inf` would
become a `nan` and propagate to the SVG painting, which then attempts
to draw a path with nan control points, which would make the
Gfx::Painter infinitely split the path till it OOM'd.
2023-05-12 05:37:44 +02:00
Aliaksandr Kalenik
de970c2dce LibWeb: Resolve grid items preferred width in GFC
Previously, the width and height of grid items were set to match the
size of the grid area they belonged to. With this change, if a grid
item has preferred width or height specified to not "auto" value it
will be resolved using grid area as containing block and used instead.
2023-05-11 18:37:06 +02:00
Aliaksandr Kalenik
c2f6ba8f5f LibWeb: Parse calc() function in grid sizes
Adds missing part of grid size parsing function to handle calc().
2023-05-11 18:36:56 +02:00
Aliaksandr Kalenik
7fee05e18c LibWeb: Use LengthPercentage in CSS::GridSize
Using LengthPercentage instead of Length and Percentage separately
is going to allow GridSize to store calc() values. It also allows
to simplify some parts of layout code.
2023-05-11 18:36:56 +02:00
Andreas Kling
b98252728e LibWeb: Fix percentage min/max sizes on flex items with intrinsic ratio
We were resolving percentage values against the containing block size in
the wrong axis.
2023-05-10 18:46:04 +02:00
Andreas Kling
89ba7246dd LibWeb: Don't resolve CSS property values for unconnected elements
While it's possible to getComputedStyle() on an unconnected element,
the resulting object is not supposed to have any values, since we can't
resolve style without a document root anyway.

This fixes a crash on https://bandcamp.com
2023-05-10 17:27:07 +02:00
Andreas Kling
4005793e79 LibWeb: Handle CSS "color: currentcolor"
Per CSS-COLOR-4, when `color` is `currentcolor`, it should resolve to
the inherited value.
2023-05-10 15:36:34 +02:00
Andreas Kling
0c26717ba3 LibWeb: Adjust flex item main size through aspect ratio if needed
If there are min or max size constraints in the cross axis for a flex
item that has a desired aspect ratio, we may need to adjust the main
size *after* applying the cross size constraints.

All the steps to achieving this aren't mentioned in the spec, but it
seems that all other browsers behave this way, so we should too.
2023-05-10 13:03:05 +02:00
Aliaksandr Kalenik
14cb0067bb LibWeb: Implement more of "Resolve Intrinsic Track Sizes" in GFC
Implements some parts of "Resolve Intrinsic Track Sizes" algorithm
from spec to make it more spec compliant.
2023-05-10 05:52:47 +02:00
Aliaksandr Kalenik
1ada6a43e2 LibWeb: Split run_track_sizing into smaller method in GFC
Splits run_track_sizing into following methods:
- initialize_track_sizes (12.4. Initialize Track Sizes)
- resolve_intrinsic_track_sizes (12.5. Resolve Intrinsic Track Sizes)
- maximize_tracks (12.6. Maximize Tracks)
- expand_flexible_tracks (12.7 Expand Flexible Tracks)
- stretch_auto_tracks (12.8. Stretch auto Tracks)
2023-05-10 05:52:47 +02:00
Aliaksandr Kalenik
352037664d LibWeb: Use size_t instead of int when appropriate in GFC
size_t should be used instead of int in loop counter and to store
rows/columns positions because they can't be negative values.
This allows to remove some static casts to int.
2023-05-09 20:34:28 +02:00
Aliaksandr Kalenik
d9960a8d1d LibWeb: Refactor tracks initialization in GFC to reduce code duplication
This change moves code that was duplicated for rows and columns into
separate function.
2023-05-09 20:34:28 +02:00
Aliaksandr Kalenik
0a1bffdd92 LibWeb: Move gap tracks initialization into separate method in GFC 2023-05-09 20:34:28 +02:00
Aliaksandr Kalenik
62d26a5afb LibWeb: Move grid items placement algorithm into separate method in GFC
Let's follow pattern of other formatting context where steps of layout
are separated into method.
2023-05-09 20:34:28 +02:00
Nico Weber
9e8b507fad LibGfx/WebP: Do not add alpha channel for animated images without alpha
In practice, it looks like e.g. the animaged webp file on
https://mathiasbynens.be/demo/animated-webp has the header flag set,
because 2 of the frames have alpha, but they're composited on top of
the final bitmap, but the final bitmap isn't transparent there. So
that image still gets a useless alpha channel. Oh well.
2023-05-09 17:46:37 +02:00
Andreas Kling
197efc8985 LibWeb: Improve handling of min/max constraint violations on images
Instead of bailing after resolving one violated constraint, we have to
continue down the list of remaining constraints.

We now also call the constraint solver for all replaced elements with
"auto" for both width and height.

Co-authored-by: 0GreenClover0 <clovers02123@gmail.com>
2023-05-09 12:11:28 +02:00
Andreas Kling
90b21890c5 LibWeb: Remove dead code in compute_width_for_replaced_element() 2023-05-09 12:11:28 +02:00
Lucas CHOLLET
a08de19922 LibGfx/PortableFormat: Use FixedArray::unchecked_at
This allows us to drop from 7% to 5% passed on `add_pixels` when using
`image` to do conversions from JPEG to PPM.
2023-05-09 11:18:46 +02:00
Lucas CHOLLET
44905ed395 LibGfx/PortableFormat: Write to the output stream row by row
This is done by adding an intermediate buffer and flush it at the end of
every row. This makes the `add_pixels` method to drop from 50% to 7% in
profiles.
2023-05-09 11:18:46 +02:00
Lucas CHOLLET
d4d3c3f262 LibGfx/PortableFormat+image: Make encode take a Stream
As we directly write to the stream, we don't need to store a copy of the
entire image in memory. However, writing to a stream is heavier on the
CPU than to a ByteBuffer. This commit unfortunately makes `add_pixels`
two times slower.
2023-05-09 11:18:46 +02:00
Lucas CHOLLET
af6dc267d3 AK: Add OutputBufferedStream
This class, in a similar fashion to what has been done with
`InputBufferedStream`, postpones write to the stream until an internal
buffer is full.

This patch also adds the `OutputBufferedFile` alias.
2023-05-09 11:18:46 +02:00
Lucas CHOLLET
8c34959b53 AK: Add the Input word to input-only buffered streams
This concerns both `BufferedSeekable` and `BufferedFile`.
2023-05-09 11:18:46 +02:00
Emil Militzer
8200d1f68b LibWeb: Initial offset in reverse flex layout moved to opposite side
This change moves the initial offset for justify-content: center to the
opposite side if the flex layout is in the reverse direction.
2023-05-09 10:32:09 +02:00
Andreas Kling
6ae208dbf6 LibWeb: Broadcast the viewport rect to clients immediately after layout
This lets elements figure out if they're visible within the viewport or
not, so they take appropriate action.

Fixes the issues with animations not starting until the viewport was
resized or scrolled.
2023-05-09 09:48:49 +02:00
Andreas Kling
dbe961ca02 LibWeb: Move image viewport awareness from ImageBox to ImagePaintable
Images being aware of being visible inside the viewport is a painting
concern, not a layout concern.
2023-05-09 09:48:49 +02:00
Lucas CHOLLET
312c398b59 LibGfx/JPEG: Add support for 12 bits JPEGs
This is done by two distinct things:
- Allowing 12 bits AC and DC coefficients
- Adjusting coefficients in the IDCT

While this patch allows to display them we still don't correctly do
the color transformation and ultimately only truncating coefficients to
8 bits.
2023-05-09 07:00:15 +02:00
Lucas CHOLLET
9b5050a11c LibGfx/JPEG: Add support for SOF1 images
More precisely, it allows the decoder to try `SOF1` images. There are
still some sub-kind of this kind of JPEG that we don't support. In a
nutshell `SOF1` images allow more Huffman and quantization tables, 12
bits precision and arithmetic encoding. This patch only brings support
for the "more tables" part.

Please note that `SOF2` images are also allowed to have more tables, so
we gave the decoder the ability to handle these in the same time.
2023-05-09 07:00:15 +02:00
Aliaksandr Kalenik
fb6b52b3fb LibWeb: Align GridFormattingContext::run_track_sizing() with the spec
1. Stop using -1 to indicate infinity value of growth limit. Just use
   INFINITY for that.
2. More complete implementation of "Expand Flexible Tracks" step.
3. Return AvailableSize from get_free_space: spec says that this
   function can return indefinite size and it is ok.
2023-05-09 06:37:30 +02:00
Nico Weber
dd2ca56ee4 LibGfx/WebP: Add two missing closing quotes for spec comments 2023-05-09 06:35:56 +02:00
Nico Weber
bc207fd0a0 LibGfx/WebP: Move lossy decoder to its own file
Pure code move (except of removing `static` on the two public functions
in the new header), not behavior change.

There isn't a lot of lossy decoder yet, but it'll make implementing it
more convenient.

No behavior change.
2023-05-09 06:35:56 +02:00
Nico Weber
83da7ad875 LibGfx/WebP: Give VP8 decoding functions same interface as VP8L ones
Namely:
* Store compressed data in VP8Header
* Make the functions just take ReadonlyBytes instead of a Chunk

Having a function that takes a header and does decoding of the data
after the header isn't really necessary for VP8. For VP8L, it's needed
because the ALPH chunk stores VP8L data without the VP8L header.
But it's nice to make the functions consistent, and it's kind of a
nice structure.

No behavior change.
2023-05-09 06:35:56 +02:00
Nico Weber
d15dc28833 LibGfx/WebP: Tell decode_webp_chunk_VP8() if it needs an alpha channel
decode_webp_chunk_VP8() itself will only ever decode RGB data from a
lossy webp stream, but a separate ALPH chunk could add alpha data
later on. Let the function know if that will happen, so that it can
return a bitmap with an alpha channel if appropriate.

Since lossy decoding isn't implemented yet, no behavior change. But it
makes it a bit easier to implement lossy decoding in the future.
2023-05-09 06:35:56 +02:00
Nico Weber
e13c319972 LibGfx/WebP: Remove pointless decode_webp_chunk_VP8L() function
The one caller checked the chunk type, so the VERIFY() for that did
nothing.

The VERIFY() for vp8l data only being in files that start with
VP8L or VP8X chunks wasn't completely useless, but also not very
useful.

Remove the now-unused context parameter of decode_webp_image_data().
2023-05-09 06:35:56 +02:00
Nico Weber
1ec5c8395c LibGfx/WebP: Remove context.error() now that it is a no-op
Also remove `context` from many function parameter lists where the
parameter is now no longer needed.
2023-05-09 06:35:56 +02:00
Nico Weber
ddc2cc886b LibGfx/WebP: Redo error handling
Most places used to call `context.error()` to report an error,
which would set the context's state to `Error` and then return an
`Error::from_string_literal()`.

This is somewhat elegant, but it doesn't work: Some functions this
code calls returns ErrorOr<>s that aren't created by `context.error()`,
and for these we wouldn't enter the error state.

Instead, manually check error-ness at the leaf entry functions of the
class:

1. Add a set_error() helper for functions returning bool
2. In the two functions returning ErrorOr<>, awkwardly check the error
   manually.  If this becomes a very common pattern, maybe we can add
   a `TRY_WITH_HANDLER(expr, error_lambda)` which would invoke a
   lambda on error. We could use that here to set the error code.

No real behavior change (except we enter the error state more often
when something goes wrong).
2023-05-09 06:35:56 +02:00
Nico Weber
bdba70b38f LibGfx/WebP: Change ImageData optional-ness
Instead of ImageData having an Optional<Chunk> for the image data,
have it have a Chunk, and give the context an Optional<ImageData>.

This allows sharing a single code path for checking that either the
main image or an animation frame has a main image data chunk, and
that an alpha chunk is only present with a lossy main image data
chunk.

No behavior change.
2023-05-09 06:35:56 +02:00
Nico Weber
119ccfe5da LibGfx/WebP: Minor cosmetical changes in WebPLoaderLossless.h
Add a comment, remove a parameter name that doesn't add anything,
and remove a weird newline in WebPLoader.cpp too.

No behavior change.
2023-05-09 06:35:56 +02:00
Kemal Zebari
eda2a2f5da AK: Remove must_set() from JsonArray
Due to 582c55a, both `must_set()` and `set()` should be providing the
same behavior. Not only is that a reason to remove `must_set()`, but
it also performs erroneous behavior since it inserts an element at
a specified index instead of modifying an element at that index.
2023-05-09 06:21:34 +02:00
Lucas CHOLLET
07c6cebbab Applets/ClipboardHistory: Add persistent storage
Clipboard entries are now preserved upon reboot :^). Unfortunately, it
only supports data with the mimetype "text/".

This is done by writing all entries as a JSON object in a file located
in ~/.data.

Co-authored-by: Sagittarius-a <sagittarius-a@users.noreply.github.com>
2023-05-08 21:06:13 -06:00