Commit graph

23400 commits

Author SHA1 Message Date
MacDue
b698d64ee9 LibGfx: Use StringView literals for CSS color list
And also remove the null terminating entry in favour of for-each loop.
2023-03-12 12:46:24 +00:00
Nico Weber
b10ec6743f Userland: Add an image utility
At the moment, all it can do is read all image formats that LibGfx can
read and save to any image format that LibGfx can write (currently bmp,
png, qoi).

Currently, it drops all image metadata (including color profiles).

Over time, this could learn tricks like keeping color profiles,
converting an image to a different color profile, cropping out a part of
an image, and so on.
2023-03-12 12:17:26 +00:00
MacDue
952222ec4d LibGfx: Fix segfault and painting off-by-one in fill_path()
Previously, this would paint scanlines one pixel too long and segfault
when painting AA scanlines that were <= 1px long.
2023-03-11 23:51:20 +01:00
MacDue
a425b6f772 LibGfx: Make all fill_path() code member functions and move into .cpp
This makes all the code for fill_path() member functions of the painter,
and moves them into a new FillPathImplementation.cpp. This allows us
to avoid polluting Painter.h with implementation details, and makes
the edit, compile, retry loop much shorter.
2023-03-11 18:34:26 +00:00
MacDue
b1a72d66f6 LibGfx: Speed up fill_path() with per scanline clipping & fast fills
This improves fill_path() performance by adding an API to the painter
that allows painting an entire scanline rather than just a pixel.
With this paths can be clipped a scanline at a time rather than each
pixel, removing a fair amount of checks.

Along with optimized clipping, this can now use a fast_u32_fill() to
paint all but the subpixels of a scanline if a solid color with no
alpha channel is used (which is quite common in SVGs).

This reduces scrolling around on svg.html from 21% in set_pixel() and
19% in fill_path() to just 7.8% in fill_path (with set_pixel()
eliminated). Now fill_path() is far from the slowest code when
scrolling the page.
2023-03-11 18:34:26 +00:00
Kenneth Myhra
be958a14cf LibWeb: Use from_deprecated_fly_string() instead of from_utf8()
Use FlyString::from_deprecated_fly_string() in these instances instead
of FlyString::from_utf8(). As we convert to new FlyString/String we want
to be aware of these potential unnecessary allocations.
2023-03-11 18:32:33 +00:00
Linus Groh
41b8d81d49 LibWeb/HTML: Remove redundant namespace qualifiers from Window.{cpp,h} 2023-03-11 18:26:40 +00:00
Linus Groh
324dacbc5d LibWeb/HTML: Propagate OOM errors from Window::{local,session}_storage()
This requires a bit of error type conversion glue as HashMap::try_ensure
expects the callback to return ErrorOr<T> like the function itself does.
2023-03-11 18:26:40 +00:00
Linus Groh
4da68384e6 LibWeb/HTML: Make Window::m{location,navigator} lazily allocated
This now matches the other window-owned objects, which already do this:
m_crypto, m_performance, m_screen.
2023-03-11 17:53:50 +00:00
Linus Groh
22552382ff LibWeb/HTML: Use CreateMethodProperty for Window namespace properties
This makes sure the property attributes are correct (writable and
configurable), which they currently aren't for either CSS or
WebAssembly.
2023-03-11 17:32:07 +00:00
Linus Groh
be0dcd465f LibJS: Fix return type of Object::create_method_property()
This doesn't return a completion in the spec as it doesn't need to
propagate any errors. It's also unused right now, which is probably why
no one noticed.
2023-03-11 17:32:07 +00:00
Linus Groh
b6a69f5f03 LibWeb/HTML: Consolidate duplicate public/private sections in Window.h 2023-03-11 17:09:01 +00:00
Mathis Wiehl
dd81a975d7 LibWeb: Establish a stacking context for root element
Until now we were just creating a stacking context for the tree root,
which usually is the viewport element. This lead to weird painting
behaviour when negative z-index children of the html element that
established their own stacking context were drawn below the canvas
background.

Now we establish a stacking context for both, the root element and the
viewport.
2023-03-11 16:54:58 +00:00
Sam Atkins
08c1effc04 HackStudio: Use Syntax::Language instead of our own one
The one behavior difference here is that the statusbar used to display
"Unknown" for unknown file types, and "Markdown" for md, but we now
display "Plain Text" for all file types without syntax highlighters.
2023-03-11 13:22:57 +00:00
Sam Atkins
ffce6cc977 LibSyntax: Add Language-from-String/Path functions
These are taken from HackStudio, but slightly rearranged to be more
alphabetical, and returning an empty Optional instead of "Unknown".
2023-03-11 13:22:57 +00:00
Sam Atkins
8007c103dd LibSyntax: Move Language enum into its own files 2023-03-11 13:22:57 +00:00
Aliaksandr Kalenik
84e17fcbcc WebDriver: Fix crash in async execute script endpoint
Removal of dummy execution context in
9aca54091a caused a crash in
`execute_async_script` because of empty execution contexts stack
during `create_resolving_functions` call.
2023-03-11 13:11:51 +00:00
Andreas Kling
f3556f239e LibWeb: Don't touch flex items after they we've been frozen
When using the flex shrink factor, the flexible length resolution
algorithm was incorrectly ignoring the `frozen` flag on items and would
update the same items again, causing overconsumption of the remaining
free space on the flex line.
2023-03-11 11:52:19 +01:00
Andreas Kling
0808463a7d LibWeb: Use FlexItem::outer_hypothetical_main_size() in one more place
Better than doing the calculation manually.
2023-03-11 11:45:17 +01:00
Andreas Kling
f97754942c LibWeb: Collapse margin-left with space used by left-side floats
We had an issue where boxes with margin-left were shifted right by
left-side floats twice instead of just once.
2023-03-11 10:46:26 +01:00
Andreas Kling
1cf5737e9e LibWeb: Add fast_is<T>() for various types stood out in a profile 2023-03-11 10:46:26 +01:00
Andreas Kling
f6426cdcd4 LibWeb: Use static_cast in SVGGeometryBox::dom_node()
These are only ever constructed with a corresponding SVGGeometryElement,
so we know it's safe to static_cast here.
2023-03-11 10:46:26 +01:00
Mathis Wiehl
ab4cf7c57d LibWeb: Don't overflow flex containers on margin auto
In case flex items had `margin: auto` on the primary flex axis, we were
still also distributing remaining space according to `justify-content`
rules. This lead to duplicated spacing in various places and overflows.

It looks like this issue was observed previously but missidentified
because there was logic to ignore margins at the start and end which
would partially paper over the root cause. However this created other
bugs (like for example not having a margin at beginning and end ;-)) and
I can find nothing in the spec or other browser behaviour that indicates
that this is something that should be done.

Now we skip justify-content space distribution alltogether if it has
already been distributed to auto margins.
2023-03-11 10:46:21 +01:00
Lucas CHOLLET
a47d775be6 LibGfx/JPEG: Support RGB JPEGs
By default, JPEGs use YCbCr to encode colors however other encoding
exist. This patch adds the logic to determine which transformation is
needed and support for RGB encoded JPEGs :^).
2023-03-10 22:22:36 +01:00
Lucas CHOLLET
c60338e187 LibGfx/JPEG: Decode the App14 segment
This half-standardized application specific segment is used for color
transform information. It means that the decoder is know informed if the
image uses YCbCr, RGB, CMYK or even YCCK.
2023-03-10 22:22:36 +01:00
Lucas CHOLLET
00808c5eba LibGfx/JPEG: Use decimal instead of hexadecimal for APP markers 2023-03-10 22:22:36 +01:00
implicitfield
d4d1cab895 ThemeEditor: Support more color scheme-related roles 2023-03-10 22:03:49 +01:00
implicitfield
e9e4baee77 Everywhere: Support overriding the system color scheme 2023-03-10 22:03:49 +01:00
Ali Mohammad Pur
56b5b78d7b Shell: Error out on invalid `export' argument
Previously `export =` would crash the shell, make this an error instead.
2023-03-10 22:33:30 +03:30
Andrew Kaster
a5c47d0be3 LibAudio: Include missing AK/Stream.h in Loader.h
This fixes the FuzzQOILoader build.
2023-03-10 11:44:11 -07:00
Tom
52e45fb6fa LibWeb+Base: Fix row-height bug in Grid when there is a column gap
This fixes a bug in the CSS Grid when there is a column and/or row gap,
as previously it would take the index of the incorrect column when
finding the `AvailableSize`.

There is a mild complication in the GridFormattingContext as the
OccupationGrid does not take into account the gap columns and rows that
later appear in the `Vector<TemporaryTrack>` columns and rows. The
PositionedBoxes are kind of a connection between the two, and so it's
now more explicit whether you would like to refer to a column by its
position taking into the gap columns/rows or not.
2023-03-10 18:20:27 +01:00
Andreas Kling
ff7b949061 LibWeb: Make HTMLScript private members private once again
These were accidentally made public a while ago. Thankfully nobody
started poking into script element internals since then. :^)
2023-03-10 14:59:46 +01:00
Andreas Kling
e8f5085669 LibWeb: Implement Range.createContextualFragment() 2023-03-10 14:58:55 +01:00
Andreas Kling
fb6d6a985f LibWeb: Implement Element.setAttributeNode{,NS}() 2023-03-10 14:56:29 +01:00
Andreas Kling
8c5c78f1f1 LibWeb: Implement Document.createAttribute{,NS}() 2023-03-10 14:56:03 +01:00
Andreas Kling
109ed27423 LibWeb: Rewrite FFC "resolve flexible lengths" algorithm from draft spec
The draft CSS-FLEXBOX-1 spec had a more detailed description of this
algorithm, so let's use that as our basis for the implementation.

Test by Aliaksandr. :^)
2023-03-10 13:38:34 +01:00
Andreas Kling
0ef07383e5 LibWeb: Fix bogus min/max-height for box-sizing:border-box flex items
When resolving these constraints to CSS pixel sizes, we have to resolve
padding-top and padding-bottom against the flex container's *width*,
not its height.
2023-03-10 13:38:34 +01:00
Andreas Kling
24d5a9d7df LibWeb: Fix bogus percentage vertical padding with box-sizing:border-box
The padding-top and padding-bottom properties are relative to the
*width* of the containing block, not the height.

It's funny how we keep making this same mistake again and again. :^)
2023-03-10 13:38:34 +01:00
Andreas Kling
07f6ee9e73 LibWeb: Simplify FFC get_pixel_{width,height} internal helper API
These took an Optional<CSS::Size> for some reason, but that was not
necessary. Just take a CSS::Size.
2023-03-10 13:15:45 +01:00
Andreas Kling
6b19397452 LibWeb: Avoid unnecessary work for box-sizing: content-box flex items 2023-03-10 13:15:45 +01:00
Andreas Kling
64bda6de2a LibWeb: Use equals_ignoring_ascii_case() in infra helper 2023-03-10 13:15:44 +01:00
Andreas Kling
a504ac3e2a Everywhere: Rename equals_ignoring_case => equals_ignoring_ascii_case
Let's make it clear that these functions deal with ASCII case only.
2023-03-10 13:15:44 +01:00
kleines Filmröllchen
61bb9103c2 Base+Userland: Add support for QOA files everywhere
This adds MIME type sniffing,
`file` support,
LaunchServer support to open QOA in SoundPlayer,
and audio icons
2023-03-10 04:07:14 -07:00
kleines Filmröllchen
0b421a3764 LibAudio: Implement the Quite Okay Audio format
Brought to you by the inventor of QOI, QOA is a lossy audio codec that
is, as the name says, quite okay in compressing audio data reasonably
well without frequency transformation, mostly introducing some white
noise in the background. This implementation of QOA is fully compatible
with the qoa.h reference implementation as of 2023-02-25. Note that
there may be changes to the QOA format before a specification is
finalized, and there is currently no information on when that will
happen and which changes will be made.

This implementation of QOA can handle varying sample rate and varying
channel count files. The reference implementation does not produce these
files and cannot handle them, so their implementation is untested.

The QOA loader is capable of seeking in constant-bitrate streams.

QOA links:
https://phoboslab.org/log/2023/02/qoa-time-domain-audio-compression
https://github.com/phoboslab/qoa
2023-03-10 04:07:14 -07:00
kleines Filmröllchen
3c65c22728 LibAudio: Replace Result with ErrorOr
Since they are API compatible, this change is very simple.
2023-03-10 04:07:14 -07:00
Andreas Kling
806d32c88f LibWeb: Use shadow_root_internal() when building <input> UA shadow DOM 2023-03-09 21:54:59 +01:00
Andreas Kling
e6448f137e LibWeb: Avoid an unnecessary vector copy when generating flex items 2023-03-09 21:54:59 +01:00
Andreas Kling
8929c7b474 LibWeb: Remove FFC hack where we assign flex item box dimensions twice
This was necessary in the past, because IFC would set the height of its
containing block after inline layout.

Now that IFC can properly communicate the automatic size to its parent
formatting context, this hack is no longer necessary.
2023-03-09 21:54:59 +01:00
Andreas Kling
4bfdc4db17 LibWeb: Make CSS rule cache smarter about pseudo elements
Instead of putting every rule that matches a pseudo element in the
same bucket, let them go in the best ID/class/tag name bucket instead.
Then, add a flag to MatchingRule that says whether it contains a
pseudo element in the rightmost compound selector.

When deciding which selectors to run for an element, we can now simply
filter in/out pseudo element selectors as appropriate depending on what
we're trying to match.

This fixes an issue where pages using Font Awesome had 1700+ rules in the
pseudo-element rule cache. (This meant all those rules had to run
against every element twice or more while instantiating pseudo elements.)
2023-03-09 21:54:59 +01:00
Andreas Kling
2a607e9ebc LibWeb: Rename FFC::specified_axis_size() to inner_axis_size()
"Specified" means something else in CSS, so let's not use this
overloaded word here. These helpers return the inner main/cross size of
a given box, so let's say "inner" instead.
2023-03-09 21:54:59 +01:00