Commit Graph

28059 Commits

Author SHA1 Message Date
Sam Atkins
07039af982 LibWeb: Implement attr() types :^)
Support the optional `<attr-type>` parameter to the `attr()` function,
which allows parsing the attribute's value as a variety of types,
instead of always as a string.
2023-09-05 14:27:23 +02:00
Sam Atkins
6f45df5ced LibWeb: Add more CSS Token factory methods
The way we currently deal with `attr()` means having to manufacture
Tokens, so we need a way to do that from StyleComputer.
2023-09-05 14:27:23 +02:00
Sam Atkins
9735f474a2 LibWeb: Extract attr() substitution into its own method
No functional changes.
2023-09-05 14:27:23 +02:00
Sam Atkins
7d10484660 LibWeb: Move UnresolvedStyleValue resolution into the CSS Parser
Resolving typed `attr()` functions is going to involve using more
internal Parser methods, so this is the simplest solution for that.
Also... resolving these is basically parsing them, so it makes more
sense for that process to live here.

This is just moving code, with minimal changes so it still works.
2023-09-05 14:27:23 +02:00
Sam Atkins
cab8b3e180 LibWeb: Move a FIXME comment where it belongs
`var()` is now handled in  `expand_variables()`, so let's have the FIXME
where it applies to the entire process.
2023-09-05 14:27:23 +02:00
Sam Atkins
733ad57f39 LibWeb: Expose Parser::Function name as FlyString const&
This saves us from having to re-convert the StringView back to a
FlyString again when resolving UnresolvedStyleValues.
2023-09-05 14:27:23 +02:00
Sam Atkins
e9b58ff096 LibWeb: Move check for CSS-wide keywords to ValueID.h
This feels like a better home for it. The new name better reflects the
spec phrasing.
2023-09-05 14:27:23 +02:00
Andreas Kling
e013306df8 LibWeb: Allow font-size: 0
Zero is a valid font-size value, and should result in no text being
visible. We now match the behavior of other engines.
2023-09-05 14:23:35 +02:00
Andreas Kling
6a32634440 LibGfx: Don't crash on Typeface::get_font() with size 0
If someone wants a zero-sized font, we can just give it to them instead
of making a fuss.
2023-09-05 14:23:35 +02:00
Andreas Kling
589a1e9325 LibWeb: Propagate font-size & line-height into generated table boxes
The final used values for these properties is stored in the layout node,
so we need to make sure they are propagated there as well when doing
table box fixup.
2023-09-05 14:23:35 +02:00
Cubic Love
8eb10b135d Maps: Add Application Icons
Add 16px and 32px application icons for Maps
2023-09-05 14:13:32 +02:00
Timothy Flynn
bc5b7aeffb Ladybird: Hide the WebDriver-to-WebContent IPC path from the help menu
This is never meant to be passed by a human, it is created and passed by
WebDriver only. Hide it from the --help menu to avoid confusion.
2023-09-05 06:51:16 -04:00
Timothy Flynn
b6835d2c40 LibJS: Stop propagating small OOM errors from Intl.RelativeTimeFormat 2023-09-05 08:08:09 +02:00
Timothy Flynn
b3694653a7 LibJS: Stop propagating small OOM errors from Intl.NumberFormat
Note this also does the same for Intl.PluralRules. The only OOM errors
propagated from Intl.PluralRules were from Intl.NumberFormat.
2023-09-05 08:08:09 +02:00
Timothy Flynn
30a812b77b LibJS: Stop propagating small OOM errors from Intl.MathematicalValue 2023-09-05 08:08:09 +02:00
Timothy Flynn
746ce6f9a1 LibJS: Stop propagating small OOM errors from Intl.Locale 2023-09-05 08:08:09 +02:00
Timothy Flynn
9e5055c298 LibJS: Stop propagating small OOM errors from Intl.ListFormat 2023-09-05 08:08:09 +02:00
Timothy Flynn
76b5974f08 LibJS: Stop propagating small OOM errors from the Intl namespace object 2023-09-05 08:08:09 +02:00
Timothy Flynn
20aaa2c236 LibJS: Stop propagating small OOM errors from Intl.DurationFormat 2023-09-05 08:08:09 +02:00
Timothy Flynn
b78cbf88db LibJS: Stop propagating small OOM errors from Intl.DateTimeFormat 2023-09-05 08:08:09 +02:00
Timothy Flynn
1708c1fdfe LibJS: Stop propagating small OOM errors from Intl.Collator 2023-09-05 08:08:09 +02:00
Timothy Flynn
b6ff25bd26 LibJS: Stop propagating small OOM errors from Intl abstract operations 2023-09-05 08:08:09 +02:00
Andreas Kling
c24d317d8f LibWeb: Remove some unnecessary static_casts to Layout::Box&
UBSAN flagged one of these as invalid, and since it's not even necessary
to cast here anymore, let's just not.
2023-09-04 18:22:59 +02:00
Andreas Kling
1434721247 LibWeb: Relax restrictions on LayoutState::get() input type
Instead of only letting NodeWithStyleAndBoxModelMetrics (and subclasses)
have used values in the layout state, we now allow any NodeWithStyle.
2023-09-04 18:22:59 +02:00
Andreas Kling
9577cd853a LibWeb: Use JS::MarkedVector while parsing CSS keyframe rules
We need to be sure they are marked in case the GC runs while we're
in the CSS parser.
2023-09-04 18:22:59 +02:00
Timothy Flynn
bb4eca2037 LibLocale: Remove compact currency patterns
These are no longer used by the Intl.NumberFormat implementation.
2023-09-04 18:22:28 +02:00
Timothy Flynn
ca0d926036 LibJS: Use decimal compact patterns for currency style sub-patterns
When formatting a currency style pattern with compact notation, we were
(trying to) doubly insert the currency symbol into the formatted string.
We would first look up the currency pattern in GetNumberFormatPattern
(for the en locale, this is "¤#,##0.00", which our generator transforms
to "{currency}{number}").

When we hit the "{number}" field, NumberFormat will do a second lookup
for the compact pattern to use for the number being formatted. By using
the currency compact patterns, we receive a second pattern that also has
the currency symbol (for the en locale, if formatting the number 1000,
this is "¤0K", which our generator transforms to
"{currency}{number}{compactIdentifier:0}". This second lookup is not
supposed to have currency symbols (or any other symbols), thus we hit a
VERIFY_NOT_REACHED().

Instead, we are meant to use the decimal compact pattern, and allow the
currency symbol to be handled by only the outer currency pattern.
2023-09-04 18:22:28 +02:00
Zaggy1024
e3f693ca7c LibWeb: Resolve replaced element size constraints using aspect ratios
Some replaced elements can have intrinsic aspect ratios but no
intrinsic size. In these cases, the tentative sizes are undefined, and
can therefore sometimes be zero. However, when resolving the size
constraints, we are already guaranteed to have an intrinsic aspect
ratio, so let's use that instead to calculate the resolved sizes.
2023-09-04 12:40:17 +02:00
Zaggy1024
051f357110 LibWeb: Treat replaced size constraint resolutions as mutually exclusive
Previously, we would run through all the constraints in the spec one by
one, but if we check and resolve each constraint in the order they are
defined in the spec, only the first four will ever match.

This leads me to believe that these constraints are meant to be
mutually exclusive instead, meaning that we must check the most
specific constraints first and return upon the first resolution that
matches.
2023-09-04 12:40:17 +02:00
Zaggy1024
34c5043cbe LibWeb: Use CSSPixelFraction to represent aspect ratios
This allows us to retain perfect precision for aspect ratios derived
from either the intrinsic sizes of replaced elements, or the
`aspect-ratio` CSS property.
2023-09-04 12:40:17 +02:00
Ali Mohammad Pur
4fb209d25f LibWasm: Explicitly place the paddings in the WASI API types
This makes it so we don't rely on e.g. u64 to have an 8-byte alignment,
fixing breakage on i686 systems.
2023-09-04 13:32:36 +03:30
Andreas Kling
b52cbf673d LibJS: Avoid DeprecatedString allocation in Token::double_value()
Instead of allocating a DeprecatedString just so we can call strtoull()
on it, we now collect the relevant token characters in a vector and add
a null terminator manually.

2% speed-up on Kraken/imaging-darkroom.js :^)
2023-09-03 18:59:00 +02:00
Andreas Kling
008b9f4c9f LibJS: Add fast-path for Value::to_numeric() on number values
We can skip a whole bunch of checks in this case and just return the
value itself.

2% speed-up on Kraken/imaging-darkroom.js :^)
2023-09-03 18:59:00 +02:00
Aliaksandr Kalenik
5951a93f51 LibWeb: Remove GC allocations in FetchAlgorithms constructor
We should not GC allocate in the constructors of GC-allocated objects
because a new allocation might trigger garbage collection, which in
turn might access not fully initialized objects.
2023-09-03 18:52:31 +02:00
Bastiaan van der Plaat
f9f9c38de3 Maps: Add new basic maps application and map widget 2023-09-03 18:10:58 +02:00
Andreas Kling
50d72f0d8c LibWeb: Handle case where abspos flex child position depends on height
There's a particularly awkward case where the static position of an
abspos child of a flex container is dependent on its height. This can
happen when `align-items: center` is in effect, as we have to adjust
the abspos child's Y position by half of its height.

This patch solves the issue by reordering operations in the abspos
height resolution algorithm, to make sure that height is resolved
before the static position is calculated.
2023-09-03 15:44:47 +02:00
Andreas Kling
f77256fcba LibWeb: Use should_height_treat_as_auto() consistently in abspos layout 2023-09-03 15:44:47 +02:00
Bastiaan van der Plaat
5cd35b633a LibWeb: Add DOMMatrix translate 2023-09-03 15:05:41 +02:00
Bastiaan van der Plaat
61c063f7b3 LibWeb: Add DOMMatrix multiply 2023-09-03 15:05:41 +02:00
Bastiaan van der Plaat
ff1bcc694d LibWeb: Add DOMMatrix and DOMMatrixReadOnly fromMatrix 2023-09-03 15:05:41 +02:00
MacDue
bbf66ea055 LibGfx: Remove maximum size limit for decoded images
It is unlikely this is needed anymore, and as pointed out things should
now safely return OOM if the bitmap is too large to allocate.

Also, no recently added decoders respected this limit anyway.

Fixes #20872
2023-09-03 14:36:54 +02:00
Alexander Bosu-Kellett
13d1c37ea0 LibCore: Recognize .xht as an HTML document
This allows opening the WPT .xht files directly with ladybird.
2023-09-03 12:33:34 +02:00
Aliaksandr Kalenik
ed0dc2ff72 LibWeb: Use flex layout for button content alignment
Using flex layout inside button solves the issue with wrongly calculated
height when it has: pseudo element and whitespaces inside.

Also using flex instead of a table layout allows for the same vertical
alignment but with fewer layout nodes: a flex container and anonymous
wrapper for content instead of a table wrapper, table, row, and cell.
2023-09-03 12:33:10 +02:00
Andrew Kaster
6e8f1549a3 AK+LibCore: Don't use unsupported features on Android 2023-09-03 11:38:51 +02:00
Daniel Bertalan
725584881a LibC: Set (U)LONG_WIDTH correctly for 64-bit
All supported targets use an LP64 ABI, where both `long` and `long long`
are 64 bits wide. We set `LONG_WIDTH` to 32, which caused an error when
compiling gnulib's `vasnprintf` routine.

We might consider using built-in macros to avoid such issues in the
future.
2023-09-03 09:18:22 +02:00
Andreas Kling
e2dcd97c88 LibWeb: Stub out HTMLDialogElement APIs
This makes https://null.com/ load instead of throwing a React internal
error and showing a black background.
2023-09-03 07:51:11 +02:00
René Hickersberger
f2bd3904da LibC: Implement memccpy 2023-09-03 06:21:40 +02:00
René Hickersberger
ad560cff0f LibC: Implement vdprintf and dprintf
These functions work just like `vfprintf` and `fprintf`, except that
they take a file descriptor as their first argument instead of a FILE*.
2023-09-03 06:21:40 +02:00
Zaggy1024
daf3d4c6ef LibWeb: Don't send audio time updates until audio is playing
We would start the timer to send playback time updates to the element
before playback had started, so in cases where the `HTMLMediaElement`
(incorrectly) creates both an `AudioTrack` and `VideoTrack`, it will
not cause the seek bar to flicker between the current video position
and zero.
2023-09-02 19:36:09 -04:00
Shannon Booth
a53459192f LibWeb: Add Optional<String> overload for Element::set_attribute
Which for now will just call the DeprecatedString version of this
function. This is intended to be used in porting code over to using the
new String equivalent with the end goal of removing the DeprecatedString
version of this function.

This allows us to port a whole heap of IDL interfaces from
DeprecatedString to String.
2023-09-02 19:23:41 +01:00