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.
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.
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.
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.
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.
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.
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/
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 :)
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/
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.
Implements more parts of sizing algorithm for tracks with spanning
items to archive parity with implementation for sizing of tracks
with non-spanning items.
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.
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.
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. :^)
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).
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. :^)
This implements the stop-opacity, fill-opacity, and stroke-opacity
properties (in CSS). This replaces the existing more ad-hoc
fill-opacity attribute handling.
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).
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.
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.
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.
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.
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).
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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/ :^)
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.
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.
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.
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 :)
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.
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). :^)
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.
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.
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" :^)
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.
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.
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.
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.
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.
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.
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%. :^)
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.
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.
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.
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()
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.
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.
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. :^)
...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
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 :)
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.
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.
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.
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.
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
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.
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).
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.
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.
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. :^)
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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>
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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().
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).
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.
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.
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>