Commit Graph

2051 Commits

Author SHA1 Message Date
Sergey Bugaev
7bce0e5d1a Tests: Fix TestDuration build with 32-bit time_t
There are a bunch of tests that check for time_t handling 64-bit values
properly. This makes sense, but also obviously doesn't work when time_t
is 32-bit, and causes compile-time errors. Compile these tests out in
that case.

Since there's no straightforward way to check sizeof(time_t) inside the
proprocessor, only do this when glibc's __TIMESIZE is defined.
2023-09-06 07:21:07 -06:00
Shannon Booth
f991e40d7f LibWeb: Support [Reflect] on IDL String attributes that may return null
This change allows IDL interfaces to be compiled using new AK String
which have a attribute in the interface that may return null.

Without this change we would run into a compile error from code such as
the following example:

```
auto retval = impl->deprecated_attribute(HTML::AttributeNames::ref);

if (!retval.has_value()) {
    return JS::js_null();
 }
 return JS::PrimitiveString::create(vm, retval.release_value());
```

As `deprecated_attribute` returns a `DeprecatedString` instead of an
`Optional<String>`. Fix that by using the non-deprecated attribute
implementation, and falling back to the empty string for where we cannot
return null.

Also add a test here to cover a regression I almost introduced here
which was not previously covered by our test suite.

Ideally, all of this should actually just be calling
Element::get_attribute_value, but I'm not entirely sure at this stage
what the behavioral change would be to test for here. Since this
implementation preserves the previous behavior, stick with it, and add a
FIXME for now.
2023-09-05 20:36:09 -04:00
Bastiaan van der Plaat
f1742ae1b9 LibWeb: Add DOMMatrix flipX and flipY 2023-09-05 20:30:36 +02:00
Bastiaan van der Plaat
fc380bf516 LibWeb: Add DOMMatrix skewX and skewY 2023-09-05 20:30:36 +02:00
Zaggy1024
98926b487c LibWeb: Perform rounding when dividing CSSPixels
This should allow us to produce results that more closely match old
layouts when divisions were done in floating-point.
2023-09-05 14:50:45 +02:00
Zaggy1024
bd85e1b30b LibWeb: Entirely and exactly distribute grids' extra space to tracks
Previously, the code assumed that in dividing up the space in the
affected tracks there would never be an overshoot. Instead, we can
check for each track how much extra space is left and never consume any
extra.

In the same way, we can ensure that all extra space is consumed by
distributing all remaining extra space starting from the first track.
Thus, if there is no growth limit, the space distribution should always
consume all the extra space.
2023-09-05 14:50:45 +02:00
Zaggy1024
eb7c2ee307 LibWeb: Limit affected size of grid tracks instead of only increase
The spec says that the sum of affected size + item-incurred increase
should reach the limit, rather than just the item-incurred increase.

This seems to improve layout on the testcase `row-span-2-with-gaps`.
The extra line of space at the bottom of the left div
(`div.grid-item.item-span-two`) is not present anymore, matching other
browsers' layout much more closely.
2023-09-05 14:50:45 +02:00
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
bf8aa33b68 LibWeb: Add tests for basic attr() behavior and fallback values 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
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
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
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
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
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
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
Bastiaan van der Plaat
b4ae719664 LibWeb: Add DOMPoint matrixTransform and DOMMatrix transformPoint 2023-09-01 20:58:13 +02:00
Andrew Kaster
1cd3826ad6 Userland+Tests: Don't use MAP_FILE when mmap-ing
MAP_FILE is not in POSIX, and is simply in most LibCs as a "default"
mode. Our own LibC defines it as 0, meaning "no flags". It is also not
defined in some OS's, such as Haiku. Let's be more portable and not use
the unnecessary flag.
2023-09-01 19:50:35 +02:00
Andreas Kling
ef9b6c25fa LibWeb: Consolidate consecutive inlines in a single anonymous flex item
Before this change, we were creating a new anonymous flex item for every
inline-level child of a flex container, even when we had a sequence of
inline-level children.

The fix here is to simply keep putting things in the last child of the
flex container, if that child is already an anonymous flex item.
2023-09-01 12:45:38 +02:00
Zaggy1024
50bb785306 Tests/LibWeb: Add a test for clipping text with CSS clip 2023-09-01 09:40:14 +02:00
Aliaksandr Kalenik
a482166087 LibWeb: Bring html element height calculation closer to the spec
Previously we always set the height of the HTML element equal to the
viewport height but now this will only happen in quirks mode as it is
intended. Otherwise the html element height will be computed as auto.
2023-08-31 21:43:58 +02:00
MacDue
720c27efbd LibWeb: Ensure transform of SVG <use> updates with x and y attributes
Rather than modify the transform of the parent (which could change
independently), this adds a new override element_transform() where
element specific tranfroms can be applied. This will always stay in
sync with the attributes.

A ref test comparing a .svg and .html version of the same file is
added as due to differences in attribute parsing order, the .svg version
was previously drawn incorrectly.

Fixes #20859
2023-08-31 11:10:30 +02:00
Karol Kosek
51fefb57fc LibCore: Check if a promise is already resolved in Promise::map() 2023-08-31 11:10:09 +02:00
Shannon Booth
cb4c279e90 AK: Percent encode URL fragments when parsed
This fixes URL fragments containing characters in the fragment encoding
set that were not being correctly percent encoded.
2023-08-31 11:02:18 +02:00
Shannon Booth
4eab37f391 LibWeb/Tests: Also include URL hash in test results
None of the existing tests contain a URL which has a fragment in them,
but this does verify that the URL parser does not actually find any!
Also, this should let us verify the correctness of URLs which actually
do contain fragments.
2023-08-31 11:02:18 +02:00
Shannon Booth
23e82114b4 AK: Do not consider port of 0 as a null port
This fixes an issue where if a port number of 0 was given for a non
special scheme the port number was being dropped.
2023-08-31 11:02:18 +02:00
MacDue
e8342a5b79 Tests/LibWeb: Add ref test for border-radius shrink of zero sized box 2023-08-30 20:36:27 +02:00
Aliaksandr Kalenik
0fb571c1c2 LibWeb: Add Length::resolved() overload for CSSPixels
Since we always pass the px value as an argument to resolved(), we can
pass it directly as CSSPixels instead of wrapping it in Length. This
approach allows us to avoid converting to a double, resulting in fewer
precision issues.
2023-08-30 20:09:15 +02:00
Andi Gallo
fab4d543f6 LibWeb: Set line height for table boxes generated during fixup 2023-08-30 07:57:56 +02:00
Andreas Kling
6d7a2f5cc9 LibWeb: Prune old paintable pointers from layout tree after relayout
When text paintables shift around in the tree due to line wrapping,
we may end up in a situation where some text node does not generate
a paintable (due to being all whitespace, for example), even though
in the previous layout pass, it *did* generate a paintable.

To prevent holding on to old paintables in such cases, we now do a
pass in LayoutState::commit() where we explicitly detach all old
paintables from the layout tree.
2023-08-29 17:05:16 +02:00
Aliaksandr Kalenik
2495302991 LibWeb: Reset auto_placement_cursor_x after adding new column in GFC
We need to start looking from the beginning of current row if adding
new implicit column track made enough space to accomodate spanning item

This fixes placement for spanning grid items when `grid-auto-flow` is
specified to `column`.
2023-08-29 12:35:21 +02:00
Zaggy1024
bb156f8133 LibAudio: Add a Serenity implementation of PlaybackStream
This implementation is very naive compared to the PulseAudio one.

Instead of using a callback implemented by the audio server connection
to push audio to the buffer, we have to poll on a timer to check when
we need to push the audio buffers. Implementing cross-process condition
variables into the audio queue class could allow us to avoid polling,
which may prove beneficial to CPU usage.

Audio timestamps will be accurate to the number of samples available,
but will count in increments of about 100ms and run ahead of the actual
audio being pushed to the device by the server.

Buffer underruns are completely ignored for now as well, since the
`AudioServer` has no way to know how many samples are actually written
in a single audio buffer.
2023-08-29 11:31:10 +02:00
ronak69
2caf68fd03 AK: Add binary and octal mode formatting for FixedPoint 2023-08-29 11:10:45 +02:00
ronak69
352480338e AK: Refactor FixedPoint's formatter
The main change is the simplification of the expression
`(10^precision * fraction) / 2^precision` to `5^precision * fraction`.

Those expressions overflow or not depends on the value of `precision`
and `fraction`. For the maximum value of `fraction`, the following table
shows for which value of `precision` overflow will occur.

            Old   New
    u32      08    10
    u64      15    20
    u128     30    39

As of now `u64` type is used to calculate the result of the expression.
Meaning that before, only FixedPoints with `precision` less than 15
could be accurately rendered (for every value of fraction) in decimal.
Now, this limit gets increased to 20.

This refactor also fixes, broken decimal render for explicitly specified
precision width in format string, and broken hexadecimal render.
2023-08-29 11:10:45 +02:00
ronak69
4c6ea4a963 AK: Fix off-by-one error in round-to-even logic of FixedPoint
Because of the off-by-one error, the second bit of the fraction was
getting ignored in differentiating between fractions equal to 0.5 or
greater than 0.5. This resulted in numbers like 2.75 being considered
as having fraction equal to 0.5 and getting rounded incorrectly (to 2).
2023-08-29 11:10:45 +02:00
Marcus Nilsson
e2ca144cf9 Tests: Add tests for getaddrinfo() 2023-08-29 11:04:48 +02:00
Marcus Nilsson
db2f96e4ed Tests: Add tests for gethostbyname() 2023-08-29 11:04:48 +02:00
Marcus Nilsson
5c4b71ac67 Tests: Add tests for gethostbyname_r() 2023-08-29 11:04:48 +02:00
Andi Gallo
4a124333c8 LibWeb: Add back undistributable space when adjusting table width
If the table used width has to be adjusted because of a cell with
percentage width, add back the undistributable space due to border
spacing. This is consistent with the width distribution algorithm, which
sets aside the undistributable space and the behavior of other browsers.
2023-08-29 09:19:55 +02:00
Andreas Kling
2a86bd8c91 LibWeb: Fire the fail callback on SharedImageRequest when they fail
This fixes an issue where failed image loads would delay the document
load event forever.
2023-08-28 10:19:46 +02:00
Andi Gallo
8e0320626d LibWeb: Move line breaking test 2023-08-28 10:09:07 +02:00
Aliaksandr Kalenik
b66f65dc9e LibWeb: Define if identifier represent area or line during layout [GFC]
This fixes regression introduced in
c03e025a32 by assuming that it is
possible to determine whether identifier stands for line or area
during parsing.
2023-08-28 09:19:41 +02:00
Luke Wilde
af2886449a LibWeb: Implement PerformanceObserver 2023-08-27 23:27:44 +02:00
Aliaksandr Kalenik
e4dd4808c4 Tests/LibWeb: Split "grid/named-tracks.html" into smaller layout tests
The file grid/named-tracks.html contained multiple subtests. Splitting
them into individual files will make it simpler to identify where is
the issue.
2023-08-27 14:51:44 +02:00
Aliaksandr Kalenik
d3d67857b2 LibWeb: Use containing block width to measure fit-content width in GFC
When the grid layout gets to
`resolve_items_box_metrics(GridDimension::Column)`, we've already
determined the width of each column. However, the widths of the
individual grid items themselves haven't been set. Rather than using
`get_available_space_for_item()`, which returns an indefinite size if
an item's width/height hasn't been set, we should use the already
known track width as the available size to calculate the fit-content
width.
2023-08-27 05:11:55 +02:00
MacDue
360c0eb509 LibWeb: Remove implicit conversion from float and double to CSSPixels
In general it is not safe to convert any arbitrary floating-point value
to CSSPixels. CSSPixels has a resolution of 0.015625, which for small
values (e.g. scale factors between 0 and 1), can produce bad results
if converted to CSSPixels then scaled back up. In the worst case values
can underflow to zero and produce incorrect results.
2023-08-26 23:53:45 +02:00
Aliaksandr Kalenik
0060fe3095 LibWeb: Account for float intrusions in list marker x offset 2023-08-26 19:07:56 +02:00
Sam Atkins
240ec9aeed LibWeb: Treat invalid StyleValues that included var() as unset
This means StyleComputer::resolve_unresolved_style_value() always
returns a value, so we can change its return type.

However, it does still return an UnresolvedStyleValue sometimes, so we
can't remove those checks from the user code.
2023-08-26 15:33:45 +01:00
Sam Atkins
6b66e80fb8 LibWeb: Sort Ref/mainfest.json entries 2023-08-26 15:33:45 +01:00
Shannon Booth
f115e44066 LibWeb: Implement value attribute of RadioNodeList 2023-08-26 13:51:18 +02:00
Shannon Booth
fc4fd6cb02 LibWeb: Fix empty value attribute for 'file' input returning fakepath
It should be returning the empty string for this case.
2023-08-26 13:51:18 +02:00
Aliaksandr Kalenik
c03e025a32 LibWeb: Disambiguate GridTrackPlacement API
- Ambiguous `raw_value()` method is replaced with `line_number()` and
  `span()`.
- `line_name()` that before returned either line name or area name is
  replaced with `line_name()` and `area_name()`.
- `Position` type is replaced with `Line` and `Area` type so we don't
   have to guess while doing layout.

Affected test expectations:
- `template-lines-and-areas` - improvement over what we had before.
- `named-tracks` - rebaseline a giant test. will have to split it into
  smaller tests in the future.
2023-08-26 13:16:17 +02:00
Andi Gallo
29352f570a LibWeb: Fix table column constrainedness
Adjust implementation to reflect the CSS 2.1 definition of width.
2023-08-26 13:10:45 +02:00
Andrew Kaster
587cfa7739 LibWeb: Don't assert when calling navigation properties
The invariants for these property getters are supposed to be checked by
the has_entries_and_events_disabled AO, but we don't have all the
plumbing hooked up between Navigables and Navigation yet.

Add a test to make sure that these methods don't assert when calling
them on a fresh page.
2023-08-26 07:35:50 +01:00
Andreas Kling
da8692572a LibWeb: Support media queries with the resolution feature
The resolution is simply 1dppx * device pixel ratio.

This makes high resolution images show up on https://apple.com/
when running on a high-DPI display. :^)
2023-08-25 20:10:47 +02:00
Andreas Kling
b63e393cef LibWeb: Fix broken conversion of CSS <resolution> dpi/dpcm to dppx
Also add a basic test that documents how these media features currently
get serialized, even if they're not identical to other browsers yet.
2023-08-25 20:10:47 +02:00
Andreas Kling
b256e52586 AK: Make Formatter for NonnullOwnPtr<T> format the T
This mirrors the behavior of NonnullRefPtr<T>. If you want to format
the pointer address, call .ptr() on it.
2023-08-25 20:10:47 +02:00
Liav A
1c0aa51684 Kernel+Userland: Remove the {get,set}_thread_name syscalls
These syscalls are not necessary on their own, and they give the false
impression that a caller could set or get the thread name of any process
in the system, which is not true.

Therefore, move the functionality of these syscalls to be options in the
prctl syscall, which makes it abundantly clear that these operations
could only occur from a running thread in a process that sees other
threads in that process only.
2023-08-25 11:51:52 +02:00
Andreas Kling
13e2ca6b59 LibWeb: Parse src: local(...) in CSS @font-face rules
Note that we don't load the local font as specified, but at least we no
longer reject such src properties in the CSS parser.

This makes the custom fonts used on http://apple.com/ actually load. :^)
2023-08-25 11:51:28 +02:00
Timothy Flynn
5a2bf7fdd1 LibWeb: Set the correct end position of HTML attribute names
We were previously setting the end position of attribute names in self-
closing HTML tags to the end of the attribute value. To illustrate the
previous behavior, consider this tag and its attribute's start and end
positions (shown inclusively below):

    <meta charset="UTF-8" />
          ^ name start
                  ^ value start
                        ^ value end
                        ^ name end

Rather than setting the end position of the attribute name when we parse
the closing slash, ensure the end position is already set while we are
in the AttributeName state. We now have:

    <meta charset="UTF-8" />
          ^ name start
                ^ name end
                  ^ value start
                        ^ value end

The tokenizer unit test has been extended to test these positions.
2023-08-25 08:22:24 +02:00
Timothy Flynn
5b2bc90b50 LibWeb: Set consistent positions for the start and end of HTML tags
To illustrate the previous behavior, consider these tags and their start
and end positions (shown inclusively below):

    Start tag:    End tag:
    <span>        </span>
     ^ start       ^ start
         ^end           ^end

The start position of a tag is the first ASCII-alpha code point after
the opening brace. The start position of a close tag is the slash just
before the first ASCII-alpha code point. And the end position of both
is the closing brace. So the opening brace is not included in the
emitted tag, but the closing brace is. And the end tag including the
slash is an oddity that had to be worked around in its only use case
(syntax highlighting).

We now consistently exclude the braces from the emitted tag, and also
exclude the slash from the end tag, so that it does not need to be
accounted for in syntax highlighting. That is, we now have:

    Start tag:    End tag:
    <span>        </span>
     ^ start        ^ start
        ^end           ^end

The tokenizer unit test has been extended to test these positions.
2023-08-25 08:22:24 +02:00
Jonatan Klemets
04bc9b14d0 LibWeb: Use parse_non_negative_integer for colspan and rowspan parsing
`DeprecatedString::to_int` calls `StringUtils::convert_to_int`
internally. However, the integer parsing is not done in an HTML
spec-compliant way. For example, `colspan="2;"` is valid according to
the spec. But, with the current implementation, we will fail to parse
"2;", and instead fall back to using 1 as the colspan value.

This patch changes the `HTMLTableCellElement::col_span` and
`HTMLTableCellElement::row_span` methods to use the
`Web::HTML::parse_non_negative_integer` function that will parse the
attribute value in an HTML spec-compliant way.
2023-08-24 22:26:53 +01:00
Jonatan Klemets
9812031a02 LibWeb: Implement spec-compliant integer parsing
We have code inside LibWeb that uses the
`AK::StringUtils::convert_to_uint`and `AK::StringUtils::convert_to_int`
methods for parsing integers. This works well for the most part, but
according to the spec, trailing characters are allowed and should be
ignored, but this is not how the `StringUtil` methods are implemented.

This patch adds two new methods named `parse_integer` and
`parse_non_negative_integer` inside the `Web::HTML` namespace that uses
`StringUtils` under the hood but adds a bit more logic to make it spec
compliant.
2023-08-24 22:26:53 +01:00
Aliaksandr Kalenik
6267037a74 Tests/LibWeb: Split grid/positions-and-spans.html into smaller tests
This giant grid test has been a source of problems while iterating on
GFC for a long time. Let's split it into smaller tests to make it
easier to identify issues without needing further reductions on the
test.
2023-08-24 20:18:00 +02:00
Aliaksandr Kalenik
c3f38c6cb8 Tests/LibWeb: Adjust "clip-abspos-children" ref-test to actually pass
Fixed the "clip-abspos-children" test which previously passed due to
black backgrounds on CI blending with the test's black borders.
2023-08-24 15:48:34 +02:00
Sam Atkins
82ccc49b52 LibWeb: Adjust ref-tests to reduce flakiness
These two ref-tests involve two boxes positioned in the same place, with
outlines. Outlines always have a border-radius, meaning that the corner
pixels are not 100% opaque. (It seems to be 254 instead of 255.) With
the test files painting two outlines, and the ref test only painting
one, slight changes in the background color of the page would make that
slight variation visible sometimes. So, let's avoid that inconsistency
by always painting one outline instead of two.
2023-08-24 13:46:28 +01:00
Andi Gallo
6175fcdaeb LibWeb: Add a table row to the layout tree for buttons
We were relying on the table fixup algorithm to insert the missing table
row, which fails to do so when we only have an image in the button.
While that might be a problem with the table fixup algorithm, we should
build a correct layout tree explicitly anyway.

Fixes crashes on GitHub.
2023-08-24 07:08:21 +02:00
Karol Kosek
e575ee4462 AK+Kernel: Unify Traits<T>::equals()'s argument order on different types
There was a small mishmash of argument order, as seen on the table:

                 | Traits<T>::equals(U, T) | Traits<T>::equals(T, U)
   ============= | ======================= | =======================
   uses equals() | HashMap                 | Vector, HashTable
defines equals() | *String[^1]             | ByteBuffer

[^1]: String, DeprecatedString, their Fly-type equivalents and KString.

This mostly meant that you couldn't use a StringView for finding a value
in Vector<String>.

I'm changing the order of arguments to make the trait type itself first
(`Traits<T>::equals(T, U)`), as I think it's more expected and makes us
more consistent with the rest of the functions that put the stored type
first (like StringUtils functions and binary_serach). I've also renamed
the variable name "other" in find functions to "entry" to give more
importance to the value.

With this change, each of the following lines will now compile
successfully:

    Vector<String>().contains_slow("WHF!"sv);
    HashTable<String>().contains("WHF!"sv);
    HashMap<ByteBuffer, int>().contains("WHF!"sv.bytes());
2023-08-23 20:21:09 +02:00
Aliaksandr Kalenik
d06d4eb388 LibWeb: Apply "clip" property in apply_clip_overflow_rect()
Fixes bug when "clip" property does not affect abspos children.
This change makes "clip" property to be applied together with
"overflow: hidden" in `apply_clip_overflow_rect()` that already
handles abspos children correctly.
2023-08-23 15:49:06 +02:00
Andi Gallo
b13fe9397d LibWeb: Support border attribute on the table element
Fixes #19938.
2023-08-23 15:40:41 +02:00
Bastiaan van der Plaat
c88f14902b LibWeb: Add DOMQuad and text tests 2023-08-23 12:11:21 +01:00
Tim Schumacher
dbc25f18ec LibCompress: Let BrotliDecompressionStream take a MaybeOwned 2023-08-23 12:03:37 +01:00
Tim Schumacher
8a853278d0 LibCompress: Port ZlibDecompressor to AK::Stream 2023-08-23 12:03:37 +01:00
Sam Atkins
7bc5949e35 LibWeb: Implement the :placeholder-shown pseudo-class
This matches if the element has a placeholder, and that placeholder is
currently visible. This applies to `<input>` and `<textarea>` elements,
but our `<textarea>` is very limited so does not support placeholders.
2023-08-23 05:30:59 +02:00
Sam Atkins
9f5b1e6614 LibWeb: Implement the :read-only and :read-write pseudo-classes 2023-08-23 05:30:59 +02:00
Sam Atkins
3af8b491b4 LibWeb: Implement :any-link and :local-link pseudo-class selectors
`:any-link` matches links, whether they have been visited or not.

`:local-link` matches links to the current URL.
2023-08-23 05:30:59 +02:00
Timothy Flynn
7536648498 LibLocale+LibJS+ClockSettings: Make date time format APIs infallible
These APIs only perform small allocations, and are only used by LibJS
and the time zone settings widget. Callers which could only have failed
from these APIs are also made to be infallible here.
2023-08-23 05:29:21 +02:00
Timothy Flynn
cd526813e6 LibLocale+LibJS: Make locale data APIs infallible
These APIs only perform small allocations, and are only used by LibJS.
Callers which could only have failed from these APIs are also made to
be infallible here.
2023-08-23 05:29:21 +02:00
MacDue
a98201f889 LibGfx: Nudge points away from the start point in radial gradients
Avoids a division by zero, and an incorrect pixel in some repeating
radial gradient cases.

(Ref tests updated)
2023-08-23 05:27:19 +02:00
Andi Gallo
bab1d09d92 LibWeb: Derive baseline from rightmost descendant
Make the existing algorithm recursive, accounting for boxes which
contain line boxes indirectly. Fixes some button alignment issues on
Wikipedia.
2023-08-23 05:24:55 +02:00
MacDue
f3a6fe256f Tests/LibWeb: Add a ref test for many wacky SVG radialGradients
Believe it or not, these are all correct (± a pixel), there meant to
look like that!
2023-08-22 20:25:57 +02:00
MacDue
4ad0ac465e Tests/LibWeb: Update reference for svg-gradient-spreadMethod.html 2023-08-22 20:25:57 +02:00
Andreas Kling
0b83717ea2 AK: Make SourceGenerator::fork() infallible 2023-08-22 13:08:24 +02:00
Andrew Kaster
b3bd232a5e LibWeb: Implement StructuredSerialize for BigIntObject and Symbol 2023-08-22 13:08:08 +02:00
Andi Gallo
685ef4ec82 LibWeb: Stop collecting lookahead items on forced break
This avoids a crash since such items don't have a node nor CSS
properties. Fixes crashes on Wikipedia pages which contain preformatted
code.
2023-08-22 11:33:45 +02:00
Aliaksandr Kalenik
cca779e7f6 LibWeb: Treat grid items with z-index != auto as positioned elements 2023-08-22 11:33:24 +02:00
Aliaksandr Kalenik
95a8dec373 LibWeb: Treat grid item as it creates stacking context during painting
Grid specification https://www.w3.org/TR/css-grid-2/#z-order defines
special painting order for grid items which should be the same as for
defined for inline-blocks in CSS2.
2023-08-22 11:33:24 +02:00
Andi Gallo
3d7e788981 LibWeb: Improve the line breaking algorithm
Check the width of the next token after white space to decide line
breaks. The next width can also be the total width of multiple tokens.
This better follows the CSS Text specification and matches behavior of
other browsers.

Fixes #20388.
2023-08-21 19:31:00 +02:00
Andreas Kling
0103940cee LibWeb: Resolve viewport-relative <img sizes> values
We still don't know how to resolve font-relative lengths in <img sizes>
since we don't always have font size information available at this stage
in the pipeline, but we can at least handle viewport-relative lengths.

This fixes an issue on many websites where low-resolution images were
loaded (appropriate for a small viewport) even when the viewport is big.
2023-08-21 13:56:18 +02:00
Sam Atkins
b8e694c0f2 LibWeb: Implement the :dir() selector pseudo-class 2023-08-21 13:51:56 +02:00
Shannon Booth
7690f76f92 LibWeb/Tests: Move unresolvable % width on inline-block to layout test
Removing the last test fomr Base/res/html/tests :^)
2023-08-21 13:51:12 +02:00
Shannon Booth
ed03dd0f99 LibWeb/Tests: Port two DOM cloneNode() test cases to text tests 2023-08-21 13:51:12 +02:00
Shannon Booth
a5fb0b4243 LibWeb/Tests: Port height:auto abspos flex container test to layout test
This test was written before we had layout test functionality.
2023-08-21 13:51:12 +02:00
Shannon Booth
6cee028ecc LibWeb/Tests: Port HTMLCollection [[SameObject]] test to a text test
This test was written before we had the facility to write text tests -
port this test to a text test so that we test against it in CI.
2023-08-21 13:51:12 +02:00
Ali Mohammad Pur
5f013e5374 Meta: Generate bigint values for v128 constants in Wasm tests 2023-08-21 13:39:32 +03:30
Ali Mohammad Pur
2462064fcd LibWasm+LibWeb: Parse and validate all Wasm SIMD instructions 2023-08-21 13:39:32 +03:30
Ali Mohammad Pur
4f0f1c7c72 AK: Add support for Little/BigEndian<UFixedBigInteger<M>> 2023-08-21 13:39:32 +03:30
Sam Atkins
0d021a63c7 LibUnicode: Generate data for bidirectional character types
This will let us examine code points to determine the rtl/ltr direction
of a piece of text.
2023-08-20 16:21:35 -04:00
MacDue
8cef2f7be8 Tests/LibWeb: Add ref test for SVG gradients with various spreadMethods
Note: The final three gradients in this test are currently incorrectly
rendered.
2023-08-20 20:04:10 +02:00
Andreas Kling
27ddfa84fa LibWeb: Accept height: {min,max,fit}-content
And treat them as "auto" for now, per CSS-SIZING-3, with a FIXME about
supporting more layout directions.

This fixes an issue on MDN where `height: max-content` was not
overriding height from non-CSS presentational hints.
2023-08-20 19:37:50 +02:00
Andreas Kling
90e95d38d7 LibWeb: Make align-items: normal behave like stretch on flex items
CSS-ALIGN-3 tells us that `normal` behavior inside flex containers is
simply to behave as `stretch` so this patch makes them behave the same
inside FFC.

Furthermore, we change the `align-items` initial value to `normal`,
matching other engines.
2023-08-20 19:37:50 +02:00
Andi Gallo
769f11f9ae LibWeb: Implement table missing cells fixup
Fixes #19936.
2023-08-20 18:38:15 +02:00
Aliaksandr Kalenik
37f5253ec9 LibWeb/Layout: Add support for grid-auto-flow in GFC 2023-08-20 15:36:18 +02:00
Shannon Booth
9cf5b67162 LibWeb: Return a HTMLFormControlsCollection from HTMLFormElement element
Instead of a HTMLCollection
2023-08-20 11:04:03 +02:00
0GreenClover0
f6c3ec3742 LibWeb: Add Base::apply_presentational_hints call to <symbol> element 2023-08-20 05:03:27 +02:00
Andreas Kling
1e0ea45fe5 LibWeb: Make sure that SVG use and symbol elements get paintables
I'm about to make StackingContext traverse the paintable tree instead of
actually traversing the layout tree, and it turns out we were not
creating paintables for these SVG elements.

Also switch them to Layout::Box instead of the default InlineNode to
make the trees look a bit less weird. Ultimately, we should do something
specialized for these subtrees, but for now this'll do.
2023-08-20 05:02:59 +02:00
Andreas Kling
c01c4b41e2 LibWeb: Add ViewportPaintable to represent viewports in the paint tree
This patch just adds the new root paintable and updates the tests
expectations. The next patch will move painting logic from the layout
viewport to the paint viewport.
2023-08-20 05:02:59 +02:00
Andrew Kaster
4c26b0b047 Tests: Convert WebDriver patch to a git patch and clean up assumptions
Instead of assuming that the WebDriver binary is in PATH or the two
most common build directories for our scripts, add a command line
argument to the script to pass a WebDriver binary.
2023-08-20 03:20:54 +02:00
Andrew Kaster
326e8a0a33 LibWeb: Only update /etc/hosts for WPT if required lines are not present 2023-08-19 17:49:04 -06:00
Andrew Kaster
8e605fb0f9 Meta+LibWeb: Make WPT run script runnable anywhere, remove apt installs
We should be documenting required pacakges elsewhere and installing them
in the setup step of CI.

This also fixes a problem where the run script would fail if you already
had a cloned wpt directory.
2023-08-19 23:50:29 +02:00
Hendiadyoin1
b342b4dfb8 LibWeb: Fix a rounding issue on CSSPixels multiplication
Co-Authored-By: ronak69 <ronak69@danwin1210.de>
2023-08-18 17:58:44 +02:00
Daniel Bertalan
c63fe0e1f1 Tests/LibELF: Test loading libraries with dynamic TLS
The setup is a bit peculiar: both the definition and the use site of
these TLS variables have to be in a shared library, otherwise the linker
might relax the global-dynamic access mode to something that doesn't
require a `__tls_get_addr` call.
2023-08-18 16:20:13 +02:00
Poseydon42
d160ff2f8d LibGLSL: Add tests for GLSL parser 2023-08-18 15:29:48 +02:00
Andi Gallo
65854c3411 LibWeb: Set table wrapper width from the table box
Fixes #20385 and some Wikipedia pages, for example:
https://en.wikipedia.org/wiki/2022%E2%80%9323_UEFA_Champions_League_knockout_phase
2023-08-18 12:52:29 +02:00
MacDue
3a42ef4118 Tests/LibWeb: Add ref test for CSS gradients
This has to cheat and use a screenshot but thanks to the "Take Full
Screenshot" feature of Ladybird, it is very easy to update this test.

The steps are documented in the test.
2023-08-18 05:26:04 +02:00
Aliaksandr Kalenik
37bd216c52 LibWeb: Ignore % max-width if box is sized under max-content constraint
When a box is sized under max-content constraint, any percentage value
set for max-width should be considered as if it were infinite. In other
words, it should have no effect on restricting the box's width.
2023-08-18 05:08:52 +02:00
martinfalisse
70919dbed7 LibWeb: Fix parsing bug for SVG attributes
This doesn't seem to actually have fixed any bugs, as having
FillOpacity instead of StrokeOpacity in the call to parse_css_value
doesn't seem to have actually been causing bugs. But, I still think it's
worthwhile correcting.

The reason that it wasn't causing bugs is that having FillOpacity
instead of StrokeOpacity in the call to parse_css_value means that when
parsing the value is compared to the acceptable values for that property
(for example the value can only be a percentage, or a number, etc.). In
this case both FillOpacity and StrokeOpacity seem to accept the same
values.
2023-08-17 17:48:34 +02:00
martinfalisse
f2047a5c32 LibWeb: Size SVG G container according to children
The SVG G container should have the same size as its children. This
fixes a bug when there was an opacity value on the G element, as in
StackingContext it would try and get a bitmap of the element which would
be empty due to it having no size.
2023-08-17 17:48:34 +02:00
Andreas Kling
f34cc0b8e3 LibWeb: Null check fonts after parsing them in CRC2D.font assignment
Fixes an issue where setting CRC2D.font to an unparseable value would
assert due to a null dereference.
2023-08-17 10:07:38 +02:00
Andi Gallo
d5f54956ba LibWeb: Use the auto table width formula if it cannot be resolved
If the width is a percentage but the parent isn't resolved yet, take the
same path as for auto width.
2023-08-17 04:13:46 +02:00
Ali Mohammad Pur
4d27257c45 LibRegex: Treat backwards jumps to IP 0 as normal backwards jumps too
This shows up in something like /\d+|x/, where the `+` ends up jumping
to the start of its own alternative.
2023-08-16 22:20:24 +03:30
Sam Atkins
12a2750d1e LibWeb: Support multiple values in :lang() selector
Parse them, and also don't give up completely if the first language
listed doesn't match an element.
2023-08-16 18:05:26 +02:00
Sam Atkins
631a988a57 LibWeb: Allow any valid <color> in CSS gradients
We now keep the color value as a StyleValue up until we go to paint the
gradient, which makes `currentColor` work, along with any other color
values that can't be immediately converted into a `Gfx::Color` while
parsing.
2023-08-16 14:51:12 +02:00
Andreas Kling
1c47695bae LibWeb: Invalidate layout-transformed text on DOM text node change
This fixes an issue where programmatically changing the value of an
input element wasn't reflected visually.
2023-08-16 12:16:05 +02:00
Andreas Kling
e2740bd19d LibWeb: Don't overwrite existing text content when flushing HTML parser
If we run an inline script from the HTML parser, it may append a text
node to the current insertion point.

If there was text content immediately following the script element,
we would previously overwrite the script-inserted text content, due to
an oversight in the way we select an appropriate insertion point

This patch fixes the issue by only inserting parser content into
existing text nodes if they are empty.
2023-08-16 12:16:05 +02:00
Nicolas Ramz
0986533c11 Meta+Tests: Add a fuzzer and a test for the ILBM decoder 2023-08-15 18:36:11 +01:00
Andreas Kling
dea91afba7 LibWeb: Make HTMLElement.offset{Left,Top} work on inline elements
Before this change, we were returning (0, 0) for inline elements, due to
a bogus paintable type check in box_type_agnostic_position().
2023-08-15 16:37:11 +02:00
Andreas Kling
25a3d0d643 LibWeb: Resolve relative offsets *once* after layout
Instead of applying relative offsets (like position:relative insets)
during painting and hit testing, we now do a pass at the end of layout
and assign the final resolved offsets to paintables.

This makes painting and hit testing easier since they don't have to
think about relative offsets, and it also fixes a bug where offsets were
not applied to text fragments inside inline-flow elements that were
themselves position:relative.
2023-08-15 16:37:11 +02:00
MacDue
4e49aee545 Tests/LibWeb: Add opacity-stacking.html test to manifest.json
(Also explicitly set the background color)
2023-08-14 23:52:53 +02:00
MacDue
9006c7aece LibWeb: Add ref test for opacity (stacking context) paint order
Now that we can test this, let's add a test, as mentioned in:
https://github.com/SerenityOS/serenity/pull/20559#issuecomment-1677126697

(I confirmed this test failed before #20559)
2023-08-14 22:42:25 +02:00
Hendiadyoin1
394529b7d0 AK: Fix formatting of negative whole fixed point numbers
Instead of `-2` we were printing `-2.1`

Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
2023-08-14 14:20:45 -06:00
Hendiadyoin1
daacc5c6c2 AK: Rename AK::FixedPoint::round to rint and fix a rounding error
`rint` is a more accurate name for the roudning mode as the fixme above
stated
2023-08-14 14:20:45 -06:00
Hendiadyoin1
05c959e40b AK: Change standard casting method of FixedPoint to truncation
This matches what floats do.

Also fix typo `trunk`->`trunc`
2023-08-14 14:20:45 -06:00
Hendiadyoin1
e609ac74a3 AK: Fix FixedPoint multiplication rounding and overflow behaviour
We now preform the multiplication in a widened type which makes it
overflow-safe and use the correct bit for rounding direction detection.
2023-08-14 14:20:45 -06:00
Shannon Booth
099a069b86 LibWeb: Fix typo in query of link element search params
Regressed in 21fe86d235
2023-08-14 16:26:34 +02:00
Andi Gallo
a18500c78c LibWeb: Paint separate borders for inline tables 2023-08-14 15:12:19 +02:00
Andi Gallo
bc8c2b2bc2 LibWeb: Use cell width instead available width to compute height
Overall available width should only affect later stages of the table
layout algorithm and have no impact on cell measures.
2023-08-14 13:14:24 +02:00
Shannon Booth
576f8e8fa8 LibWeb: Fix crash parsing an invalid pseudo compound selector
Reduced from a crash on: https://github.com/SerenityOS/serenity/pulls

Fixes #20568
2023-08-14 11:43:57 +01:00
Aliaksandr Kalenik
0d66a80a0f headless-browser: Add ref tests support
The ref tests runner takes screenshots of both the input page and the
expected page, then compares them. Ref testing allows us to catch
painting bugs, which cannot be detected with the layout and text tests
we already have.

With ref tests, we'll likely want to reuse the same expectation page
for multiple inputs. Therefore, there's a `manifest.json` file that
describes the relationship between inputs and expected outputs.
2023-08-14 07:28:22 +02:00
Shannon Booth
9d60f23abc AK: Port URL::m_fragment from DeprecatedString to String 2023-08-13 15:03:53 -06:00
Shannon Booth
21fe86d235 AK: Port URL::m_query from DeprecatedString to String 2023-08-13 15:03:53 -06:00
Andreas Kling
72c9f56c66 LibJS: Make Heap::allocate<T>() infallible
Stop worrying about tiny OOMs. Work towards #20449.

While going through these, I also changed the function signature in many
places where returning ThrowCompletionOr<T> is no longer necessary.
2023-08-13 15:38:42 +02:00
Andi Gallo
b6f9f4c28c LibWeb: Fix handling of max-content containing block for floating box
Fixes layout of page toolbar on Wikipedia.
2023-08-13 14:43:41 +02:00
kleines Filmröllchen
001ea22917 AK+LibCore: Make output buffered stream seekable
Just like with input buffered streams, we don't currently have a use
case for output buffered streams which aren't seekable, since the main
application are files.
2023-08-12 12:25:26 -06:00
Valtteri Koskivuori
077a8058c3 LibIMAP+Mail: Implement RFC2047 message header encoding
This enables us to display email subject fields with non-ASCII
characters in Mail :^)
2023-08-12 11:45:52 -06:00
Aliaksandr Kalenik
e25b1f76e1 LibWeb: Forbid usage of indefinite width in calculate_min{max}_height
Changing `calculate_min_content_heigh()` and
`calculate_min_content_heigh()` to accept width as `CSSPixels`, instead
of `AvailableSize` that might be indefinite, makes it more explicit
that width is supposed to be known by the time height is measured.

This change has a bit of collateral damage which is rows height
calculation regression in `table/inline-table-width` that worked before
by accident.
2023-08-12 16:26:08 +02:00
Andi Gallo
89305f1481 LibWeb: Copy button style properties for generated table and cell 2023-08-12 13:36:37 +02:00
Jonah
0b2da4f8c6 LibWeb: Add the default user agent MathML stylesheet
We now apply MathML's default user agent style sheet along with other
default styles. This sheet is not mixed in with the other styles in
CSS/Default.css because it is a namespaced stylesheet and so has to
be its own sheet.
2023-08-12 07:59:23 +01:00
Aliaksandr Kalenik
9101c8d079 LibWeb: Use available space to resolve table container width
Using avilable space directly while resolving table container width
allows to avoid assigning it to table wrapper box content width which
sometimes involves infinite (saturated) values.

Also this allows to get rid of set_max_content_width() which is a hack
that allows to bypass set_content_width() to assign infinite
(saturated) width to a box.

Closes https://github.com/SerenityOS/serenity/issues/19521
2023-08-11 19:36:19 +02:00
Andi Gallo
a426263dee LibWeb: Remove 3 decimal places rounding hack in Length::percentage_of
CSSPixels uses fixed point now.
2023-08-11 11:00:27 +01:00
Andi Gallo
b34b80104f LibWeb: Fix buttons with TextNode label
Fixes #20472.
2023-08-11 10:02:27 +02:00
Andreas Kling
9e22f01eba LibWeb: Stub out SVGMaskElement
Just enough that we stop creating layout nodes for mask elements, which
was making some SVG content look very wrong. :^)
2023-08-10 11:36:17 +02:00
Andi Gallo
34cd7f4c22 LibWeb: Verify that table cells have a paintable when collecting them
Replicate the more conservative way it's done for other nodes, for
which we verify whether they have a paintable before doing
painting-related operations with it.

Fixes crash on https://www.haiku-os.org/.
2023-08-10 05:14:40 +02:00
Aliaksandr Kalenik
5003b1a421 LibWeb: Use automatic width to resolve min/max-width for inline boxes 2023-08-10 05:10:44 +02:00
Aliaksandr Kalenik
b34b0a1cd3 LibWeb: Use root content width as automatic width if children inline
Returning greatest_child_width() from automatic_content_width() in BFC
if root box children are inline and there are min/max-width that caused
width to be changed after IFC layout while content_width should be
always set to correct value by layout_inline_children() regardless of
layout mode.
2023-08-10 05:10:44 +02:00
Liav A
d8b514873f Kernel: Use FixedStringBuffer for fixed-length strings in syscalls
Using the kernel stack is preferable, especially when the examined
strings should be limited to a reasonable length.

This is a small improvement, because if we don't actually move these
strings then we don't need to own heap allocations for them during the
syscall handler function scope.

In addition to that, some kernel strings are known to be limited, like
the hostname string, for these strings we also can use FixedStringBuffer
to store and copy to and from these buffers, without using any heap
allocations at all.
2023-08-09 21:06:54 -06:00
Timothy Flynn
7003c6ffdb LibJS: Remove the isBytecodeInterpreterEnabled built-in 2023-08-09 20:47:44 +01:00
Tom
d7a3b65a44 LibWeb: Vertically align HTML Button content 2023-08-09 18:34:17 +02:00
Aliaksandr Kalenik
6354f950fd LibWeb: Support "order" property for items in GridFormattingContext
Closes https://github.com/SerenityOS/serenity/issues/20434
2023-08-09 18:01:36 +02:00
Aliaksandr Kalenik
bf4e2f3e9c LibWeb: Add hit testing API in internals object
Introduces `internals.hitTest(x, y)` that is going to allow us write
tests for hit testing :)
2023-08-09 17:26:44 +02:00
Andreas Kling
97ebfd9f0f LibJS: Make Value::to_string_without_side_effects() infallible
Work towards #20449.
2023-08-09 17:09:16 +02:00
Andreas Kling
09547ec975 LibJS: Make PrimitiveString::deprecated_string() infallible
Work towards #20449.
2023-08-09 17:09:16 +02:00
Andi Gallo
ada05ab4e4 LibWeb: Implement fixed table layout 2023-08-09 08:33:02 +01:00
Sam Atkins
1858f06881 LibWeb: Add namespaces to Universal and TagName selectors 2023-08-08 20:49:45 +01:00
Timothy Flynn
c20df34b79 LibJS: Remove bytecode option from the test262 runner
This scripts have been updated to not use this option.
2023-08-08 13:30:45 +02:00
Andreas Kling
2eaa528a0e LibJS: Rip out the AST interpreter :^)
This has been superseded by the bytecode VM, which is both faster
and more capable.
2023-08-08 13:07:13 +02:00
Andreas Kling
e2c8d5859e LibJS: Remove ability to disable bytecode VM 2023-08-08 13:07:13 +02:00
Andreas Kling
9a709e03a3 test262-runner: Remove ability to run with AST interpreter
I'm leaving the --use-bytecode CLI option here as a no-op for now, until
we get all the scripts updated. But the program always runs in bytecode
mode now.
2023-08-08 13:07:13 +02:00
Andreas Kling
efe3eb8f4c test-js: Remove ability to run with AST interpreter 2023-08-08 13:07:13 +02:00
Aliaksandr Kalenik
568c486610 LibWeb: Support positioning of abspos boxes inside grid container
- Out-of-flow items should not affect grid layout
- "The static position of an absolutely-positioned child of a grid
  container is determined as if it were the sole grid item in a grid
  area whose edges coincide with the content edges of the grid
  container."
2023-08-08 11:31:35 +02:00
Andreas Kling
18c54d8d40 LibJS: Make Cell::initialize() return void
Stop worrying about tiny OOMs.

Work towards #20405
2023-08-08 07:39:11 +02:00
Lucas CHOLLET
fde26c53f0 AK: Remove the API to explicitly construct short strings
Now that ""_string is infallible, the only benefit of explicitly
constructing a short string is the ability to do it at compile-time. But
we never do that, so let's simplify the API and remove this
implementation detail from it.
2023-08-08 07:37:21 +02:00
Lucas CHOLLET
3f35ffb648 Userland: Prefer _string over _short_string
As `_string` can't fail anymore (since 3434412), there are no real
benefits to use the short variant in most cases.
2023-08-08 07:37:21 +02:00
Timothy Flynn
3ea4c56d04 LibSQL: Remove Core::EventReceiver parent from SQL::Relation
This relationship was only used to provide a name, factory methods, and
parent-child relationships for the relations.
2023-08-07 14:38:38 -04:00
Timothy Flynn
5ad78cab8d LibSQL: Remove Core::EventReceiver parent from SQL::Index
This relationship was only used to provide factory methods for the index
(and its BTree child).
2023-08-07 14:38:38 -04:00
Timothy Flynn
1b40bf9783 LibSQL: Remove unused HashIndex and related classes
The features provided by these classes should be used eventually, but so
far we've been maintaining these classes for over 2 years without any
actual use. We can restore them when it comes time to actually use them.
2023-08-07 14:38:38 -04:00
Timothy Flynn
1151ba333a LibSQL+SQLServer: Remove Core::EventReceiver parent from SQL::Database
This relationship was only used to provide factory methods for the
database.
2023-08-07 14:38:38 -04:00
Timothy Flynn
4a04438e43 LibSQL: Remove Core::EventReceiver parent from SQL::Heap
This relationship was only used to provide a name and factory methods
for the heap.
2023-08-07 14:38:38 -04:00
Zaggy1024
50c73d02f0 LibAudio: Add a test for creating and destructing a PlaybackStream
This will ensure that we don't leak any memory while playing back
audio.

There is an expectation value in the test that is only set to true when
PulseAudio is present for the moment. When any new implementation is
added for other libraries/platforms, we should hopefully get a CI
failure due to unexpected success in creating the `PlaybackStream`.

To ensure that we clean up our PulseAudio connection whenever audio
output is not needed, add `PulseAudioContext::weak_instance()` to allow
us to check whether an instance exists without creating one.
2023-08-07 10:40:34 -06:00
Andreas Kling
25eee91811 AK: Make "foo"_fly_string infallible
Stop worrying about tiny OOMs.

Work towards #20405.
2023-08-07 16:03:27 +02:00
Andreas Kling
34344120f2 AK: Make "foo"_string infallible
Stop worrying about tiny OOMs.

Work towards #20405.
2023-08-07 16:03:27 +02:00
Aliaksandr Kalenik
dc08e9138c LibWeb/Tests: Add basic test for Element::scroll(x, y) 2023-08-07 05:23:31 +02:00
Andreas Kling
ddbe6bd7b4 Userland: Rename Core::Object to Core::EventReceiver
This is a more precise description of what this class actually does.
2023-08-06 20:39:51 +02:00
Andreas Kling
ec24d7555a LibWeb: Add a simple internals objects only available during testing
This object is available as `window.internals` (or just `internals`) and
is only accessible while running in "test mode".

This first version only has one API: gc(), which triggers a garbage
collection immediately.

In the future, we can add more APIs here to help us test parts of the
engine that are hard or impossible to reach via public web APIs.
2023-08-06 15:26:34 +02:00
Shannon Booth
faf9d08371 AK: Fix IPv6 serialization on multiple '0' parts ending in a '0' part
This could happen if a sequence of '0' parts was followed by a longer
sequence of '0' parts at the end of the host. The first sequence was
being used for the compress, and not the second.

For example, [1:1:0:0:1:0:0:0] was being serialized as: [1:1::1:0:0:0]
instead of [1:1:0:0:1::].

Fix this by checking at the end of the loop if we are in the middle of a
sequence of '0' parts that is longer than the current longest.
2023-08-06 10:53:32 +02:00
Aliaksandr Kalenik
da2cd73bcf LibWeb: Add place-self css property support 2023-08-06 08:26:36 +02:00
Hendiadyoin1
6c341ca985 LibWeb: Implement rounding for PixelUnits 2023-08-05 20:03:09 +02:00
Hendiadyoin1
71f56d8697 LibWeb: Saturate result in PixelUnits::operator/ 2023-08-05 20:03:09 +02:00
Hendiadyoin1
f9fc0505fb LibWeb: Add propper rounding to PixelUnits::operator*
Also moves related constants into the class to make them accessible for
tests.
2023-08-05 20:03:09 +02:00
Hendiadyoin1
af161a8b83 AK+LibWeb: Round to int in clamp_to_int instead of truncating
This caused inaccuracies in float->CssPixel conversions
2023-08-05 20:03:09 +02:00
Ali Mohammad Pur
e689422564 LibRegex: Keep track of instruction positions for backwards tree jumps 2023-08-05 16:40:04 +02:00
Andreas Kling
64c06c345e LibWeb: Parse :host() selector
We were already parsing non-function-syntax :host, so let's also do
the :host(...) variant. Note that we don't have matching for these yet.

This fixes many issues on sites generated by Wix, as they often have
selector lists that include some :host() selector, and we'd reject the
entire rule after failing to parse it.
2023-08-05 13:23:12 +02:00
Andreas Kling
6f0a93b5df Tests/LibWeb: Rebaseline a block-and-inlines layout test
This test was created before layout test dumps included the paint tree.
2023-08-05 12:09:34 +02:00
Andreas Kling
41e7c5766e LibWeb: Support more kinds of indefinite widths on flex column items
This stuff is pretty hairy since the specifications don't give any
guidance on which widths to use when calculating the intrinsic height of
flex items in a column layout.

However, our old behavior of "treat anything indefinite as fit-content"
was definitely not good enough, so this patch improves the situation by
considering values like `min-content`, `max-content` and `fit-content`
separately from `auto`, and making the whole flex layout pipeline aware
of them (in the cross axis context).
2023-08-05 10:58:12 +02:00
Andi Gallo
7b0b501418 LibWeb: Improve adjustment of automatic table width with percentages
Use the max-width of percentage cells instead of min-width as the
reference to be used to compute the total table width. The specification
only suggests that the UA should try to satisfy percentage constraints
and this behavior is more consistent with other browsers.
2023-08-05 10:32:48 +02:00
Aliaksandr Kalenik
d32bf4cd41 LibWeb: Set min-width for inline child boxes after inside layout
min-width for boxes with inline children can only be applied after
inside layout is done and width of box content is known.
2023-08-05 09:25:24 +02:00
Zaggy1024
fe672989a9 LibCore: Add a class for thread-safe promises
Since the existing Promise class is designed with deferred tasks on the
main thread only, we need a new class that will ensure we can handle
promises that are resolved/rejected off the main thread.

This new class ensures that the callbacks are only called on the same
thread that the promise is fulfilled from. If the callbacks are not set
before the thread tries to fulfill the promise, it will spin until they
are so that they will run on that thread.
2023-08-04 13:49:36 -06:00
Aliaksandr Kalenik
79cbbfc67f LibWeb: Fix infinite spinning while distributing extra space in GFC
Fixes infinite spinning in the cases when CSSPixels does not have
enough precision to represent increase per track which happens when
very small extra_space got divided by affected tracks number.
2023-08-04 19:00:02 +02:00
Andi Gallo
3e70c1b6a3 LibWeb: Improve precision when computing size of replaced elements
Change associativity in computing of replaced element size to improve
precision of division.

Fixes vertically squashed image from Mozilla splash page MDN example.
2023-08-04 13:36:29 +02:00
Andi Gallo
e9ad8d5e4f LibWeb: Use i64 for intermediate value in CSSPixels multiplication
Reduce the chance of overflow due to fixed point denominator being
squared when multiplying the raw values, before adjusting the final
value back.
2023-08-04 13:36:29 +02:00
Aliaksandr Kalenik
0019b901a0 LibWeb: Remove hardcoded span = 2 while sizing spanning items in GFC 2023-08-04 12:41:11 +02:00
Aliaksandr Kalenik
1e953f2acc LibWeb: Reset planned_increase while distributing space to "fr" tracks
Fixes bug when planned_increase is not reset after adding it to
base_size.
2023-08-03 17:05:57 +02:00
Andreas Kling
4011a107a4 LibWeb: Propagate overflow modes from <html> or <body> to viewport
This patch implements "Overflow Viewport Propagation" from CSS-OVERFLOW.
It fixes an issue where many websites were not scrollable because they
had `overflow: scroll` on the body element and we didn't propagate it.
2023-08-03 13:21:26 +02:00
Andreas Kling
09eed8eea2 LibWeb+headless-browser: Include paint tree in layout test output
This will give us a more comprehensive look at what actually gets
rendered in the end, and also allows us to catch more behavior changes.
2023-08-03 13:21:26 +02:00
Karol Kosek
142d498f14 LibWeb: Include anonymous boxes with no lines into computing BFC height
Pseudo-elements like ::before and ::after were discarded when their
content property was an empty string (ignoring whitespace), because they
are anonymous containers with no lines.

Our previous way around it was to add an empty line box (see b062a0fb7c)
however it didn't actually work for cases described in the previous
commit.

This makes avatars and cover arts square on last.fm and "fixes" the test
css-pseudo-element-should-not-be-affected-by-presentational-hints.html.
Unfortunately, this also regresses on block-and-inline/clearfix.html,
but that hopefully will be handled in subsequent commit.
2023-08-02 17:35:54 +02:00
Aliaksandr Kalenik
1f28fdacf0 LibWeb: Set max-width for inline child boxes after inside layout
max-width for boxes with inline children can only be applied after
inside layout is done and width of box content is known.

Fixes https://github.com/SerenityOS/serenity/issues/20235
2023-08-02 05:27:56 +02:00
Andreas Kling
15440b156f LibWeb: Ignore flex container size constraints during intrinsic sizing
Properties like min-width, max-width, etc, should be ignored while we're
trying to determine the intrinsic size of a flex container.

This fixes an infinite recursion when using an intrinsic size keyword as
the max-width of a flex column container.

Note that this behavior is marked as AD-HOC in code comments because
specs don't tell us how to achieve intrinsic sizing.

We can now load product pages on the Twinings site, such as
https://twinings.co.uk/products/earl-grey-100-tea-bags :^)
2023-08-01 20:15:20 +02:00
Aliaksandr Kalenik
338fa8261e LibWeb: Use item minimum contribution while sizing "fr" track in GFC
Fixes the issue that before "automatic minimum size" were used to size
flexible tracks even though specification says is should be "minimum
contribution"
2023-08-01 16:25:10 +02:00
Tom
e61fdd1dc6 LibWeb: Use viewbox attribute in SVG symbol element
Previously when a viewBox was passed to a SVG symbol element it would
not be taken into account when drawing the SVG.
2023-08-01 14:40:51 +02:00
stelar7
9f73fc87a8 LibWeb: Add tests for calc function nodes 2023-08-01 14:39:31 +02:00
Karol Kosek
eb41f0144b AK: Decode data URLs to separate class (and parse like every other URL)
Parsing 'data:' URLs took it's own route. It never set standard URL
fields like path, query or fragment (except for scheme) and instead
gave us separate methods called `data_payload()`, `data_mime_type()`,
and `data_payload_is_base64()`.

Because parsing 'data:' didn't use standard fields, running the
following JS code:

    new URL('#a', 'data:text/plain,hello').toString()

not only cleared the path as URLParser doesn't check for data from
data_payload() function (making the result be 'data:#a'), but it also
crashes the program because we forbid having an empty MIME type when we
serialize to string.

With this change, 'data:' URLs will be parsed like every other URLs.
To decode the 'data:' URL contents, one needs to call process_data_url()
on a URL, which will return a struct containing MIME type with already
decoded data! :^)
2023-08-01 14:19:05 +02:00
Karol Kosek
58017a0581 AK: Clear buffer after leaving CannotBeABaseUrlPath in URLParser
By not clearing the buffer, we were leaking the path part of a URL into
the query for URLs without an authority component (no '//host').

This could be seen most noticeably in mailto: URLs with header fields
set, as the query part of `mailto:user@example.com?subject=test` was
parsed to `user@example.comsubject=test`.

data: URLs didn't have this problem, because we have a special case for
parsing them.
2023-08-01 10:10:07 +02:00
Andreas Kling
28fdc7af05 LibWeb: Detach stale layout nodes from DOM during layout tree build
When toggling `display: none` on an element, it can go from having a
layout subtree to not having one. In the `none` case, we were previously
leaving stale layout nodes hanging off DOM nodes in the subtree.

These layout nodes could be queried for outdated information and
probably other things that we shouldn't allow.

Fix this by having TreeBuilder prune any old layout nodes hanging off
nodes in a subtree after its subtree root doesn't produce a layout node.
2023-08-01 09:19:41 +02:00
Andi Gallo
62f15f94d2 LibWeb: Better handling of floating boxes from inline formatting context
Handle the clear property for floating boxes and add tracking for
vertical clearence within an inline formatting context.
2023-08-01 07:38:19 +02:00
Lucas CHOLLET
00240cb0b3 LibGfx/JPEGXL: Fix property 8
The first implementation of this property was just plain wrong. Looks
like this property isn't used a lot as I found the issue by reviewing
the code and not because of a specific image.

The test image is a 32x32 mosaic of alternating black and yellow pixels,
it was generated using this code:

Bitdepth 8
RCT 1
Width 32
Height 32

if W-WW-NW+NWW > -300
 - Set -1000
 - Set 900
2023-08-01 05:35:01 +02:00
Shannon Booth
aa7ca80d7c AK: Fix missing step step for serialization of IPv6 hosts
This was resulting in the incorrect host serialization of:

http://[0:1:0:1:0:1:0:1] to [::1:0:1:0:1:0:1]

and:

http://[1:0:1:0:1:0:1:0] to [1::1:0:1:0:1:0]
2023-07-31 14:48:24 +02:00
Shannon Booth
4fdd4dd979 AK: Add missing default port definitions for FTP scheme URLs
This is defined in the spec, but was missing in our table. Fix this, and
add a spec comment for what is missing. Also begin a basic text based
test for URL, so we can get some coverage of LibWeb's usage of URL too.
2023-07-31 14:48:24 +02:00
Andreas Kling
9937fcc5e1 LibWeb: Don't assume opacity values are CSS numbers
...since they can also be percentages. Better to resolve them to a pair
of absolute values, and then compare those. :^)

Regressed in 921aee8c66.
2023-07-31 09:16:18 +02:00
Ali Mohammad Pur
4e69eb89e8 LibRegex: Generate a search tree when patterns would benefit from it
This takes the previous alternation optimisation and applies it to all
the alternation blocks instead of just the few instructions at the
start.
By generating a trie of instructions, all logically equivalent
instructions will be consolidated into a single node, allowing the
engine to avoid checking the same thing multiple times.
For instance, given the pattern /abc|ac|ab/, this optimisation would
generate the following tree:
    - a
    | - b
    | | - c
    | | | - <accept>
    | | - <accept>
    | - c
    | | - <accept>
which will attempt to match 'a' or 'b' only once, and would also limit
the number of backtrackings performed in case alternatives fails to
match.

This optimisation is currently gated behind a simple cost model that
estimates the number of instructions generated, which is pessimistic for
small patterns, though the change in performance in such patterns is not
particularly large.
2023-07-31 05:31:33 +02:00
Shannon Booth
8751be09f9 AK: Serialize URL hosts with 'concept-host-serializer'
In order to follow spec text to achieve this, we need to change the
underlying representation of a host in AK::URL to deserialized format.
Before this, we were parsing the host and then immediately serializing
it again.

Making that change resulted in a whole bunch of fallout.

After this change, callers can access the serialized data through
this concept-host-serializer. The functional end result of this
change is that IPv6 hosts are now correctly serialized to be
surrounded with '[' and ']'.
2023-07-31 05:18:51 +02:00
Sam Atkins
6038e36250 LibWeb: Add and use the "snap a length as a border width" algorithm
Previously, we always rounded border-widths up when converting them to
device pixels. However, the spec asks us to follow a specific algorithm
to "snap" these values, so that the computed value is snapped.

The difference from before, is that widths of between 0 and 1 device
pixels are rounded up to 1, and and values larger than 1 are rounded
down.
2023-07-30 22:18:26 +01:00
Jonah
60e35f2a97 LibWeb: Rough implementation of CSS namespace rule
This provides a rough implementation of the CSS @namespace rule.
Currently we just support default namespaces, namespace prefixes
are still to come.
2023-07-30 20:27:19 +01:00
Sam Atkins
06eb4a7557 LibWeb: Match math function values to properties in correct order
If a math function resolves to `<length>` or `<percentage>`, then it
will by definition also resolve to `<length-percentage>`. (Same for any
other basic types.) Since we were checking `<length-percentage>` first
and then bailing if no given properties could accept that, math
functions would always fail to match a property that just accepts a non
`-percentage` type.
2023-07-30 14:18:13 +02:00
Shannon Booth
dd373eacbc LibDiff+patch: Support multiple patches in a single patch file
Multiple patches may be concatenated in the same patch file, such as git
commits which are changing multiple files at the same time. To handle
this, parse each patch in order in the patch file, and apply each patch
sequentially.

To determine whether we are at the end of a patch (and not just parsing
another hunk) the parser will look for a leading '@@ ' after every hunk.
If that is found, there is another hunk. Otherwise, we must be at the
end of this patch.
2023-07-30 07:47:22 +01:00
Shannon Booth
f893e0820f patch: Support creation of a file
Previously patch would always expect the file that it was patching to
exist (even it were empty). If we know that the patch is creating a file
from nothing (i.e has a start line of '0'), then we treat a file that
doesn't exist as if it has no content lines.
2023-07-30 07:47:22 +01:00
Shannon Booth
81df0278b1 patch+LibDiff: Implement 'strip' of filenames when parsing patch
Implement the patch '-p' / '--strip' option, which strips the given
number of leading components from filenames parsed in the patch header.
If not given this option defaults to the basename of that path.
2023-07-29 17:09:09 -06:00
Shannon Booth
87e2b8e343 patch/Tests: Add some initial tests for patch utility 2023-07-29 17:09:09 -06:00
Andreas Kling
8f29bdb62c LibWeb: Implement the CSS revert keyword
This is a universal value like `initial` and `inherit` and works by
reverting the current value to whatever we had at the start of the
current cascade origin.

The implementation is somewhat inefficient as we make a copy of all
current values at the start of each origin. I'm sure we can come up with
a way to make this faster eventually.
2023-07-29 19:16:08 +02:00
Andreas Kling
13d5d47b56 LibWeb: Implement the CSS all property
This sets all longhand values to one of initial, inherit, unset or
revert. Note that revert is not supported yet, but will be soon.
2023-07-29 19:16:08 +02:00
Kenneth Myhra
66c0e78c7d Tests/LibWeb: Add standard built-in objects test for structuredClone() 2023-07-29 17:24:39 +02:00
Shannon Booth
bf7af25a82 AK: Allow testing Empty instances for equality
This also makes it possible to compare `Variant<Empty, Ts...>`
objects if operator== exists for all Ts
2023-07-28 20:47:48 +03:30
Christophe Naud-Dulude
4f9f21e8fe LibWeb: Only derive baseline from children with a non-empty line box
If none of the box children have a baseline set, the bottom margin
edge of the box is used as the baseline.
2023-07-28 17:02:33 +02:00
kleines Filmröllchen
a0705202ea Kernel/Ext2: Write superblock backups
We don't ever read them out, but this should make fsck a lot less mad.
2023-07-28 14:51:07 +02:00
Andi Gallo
6a17a30e2e LibWeb: Handle overlapping floating box and left margin
Allow the left margin of a box which creates a block formatting context
to overlap with left floating boxes which are siblings in the document
tree.

Fixes #20233 and the comment layout on https://lobste.rs.
2023-07-28 12:44:09 +02:00
Aliaksandr Kalenik
0e8a0a8191 LibWeb: Add support for "display: contents"
This change makes tree builder omit elements with "display: contents"
from the layout tree during construction. Their child elements are
instead directly appended to the parent element in layout tree.
2023-07-28 05:29:43 +02:00
Timothy Flynn
456211932f LibUnicode: Perform code point case conversion lookups in constant time
Similar to commit 0652cc4, we now generate 2-stage lookup tables for
case conversion information. Only about 1500 code points are actually
cased. This means that case information is rather highly compressible,
as the blocks we break the code points into will generally all have no
casing information at all.

In total, this change:

    * Does not change the size of libunicode.so (which is nice because,
      generally, the 2-stage lookup tables are expected to trade a bit
      of size for performance).

    * Reduces the runtime of the new benchmark test case added here from
      1.383s to 1.127s (about an 18.5% improvement).
2023-07-28 05:28:50 +02:00
Christophe Naud-Dulude
11b844ce20 LibWeb: Add support for align-items and align-self in CSS grid 2023-07-27 19:54:17 +02:00
Zaggy1024
66c9696687 LibGfx: Add initial ISO BMFF parsing and a utility to print file info
Currently, the `isobmff` utility will only print the media file type
info from the FileTypeBox (major brand and compatible brands), as well
as the names and sizes of top-level boxes.
2023-07-27 12:02:37 +01:00
Andi Gallo
3b75b9ef1c LibWeb: Avoid division by zero when computing table measures
For malformed tables which only have cells with span greater than 1, the
content sizes for row and column aren't initialized to non-zero values.
Avoid undefined behavior in such cases, which sometimes show up on
Wikipedia.
2023-07-27 08:01:36 +02:00
Lucas CHOLLET
fa379b6e86 Tests/LibGfx: Use a JPEG XL image with a RCT transformation
This image is exactly the same as the previous one, excepted the RCT
transformation. It has been generated with:

Width 64
Height 64
RCT 29
Upsample 2
Bitdepth 10

if N > 300
  - NE -6
  - W 6
2023-07-26 08:44:17 +02:00
Andi Gallo
8f7b269bf1 LibWeb: Convert divisor to double in TableFormattingContext
Improves precision of height and width distribution.
2023-07-26 08:38:03 +02:00
Andi Gallo
b12820c967 LibWeb: Handle float clearing specified on line break elements 2023-07-26 08:37:16 +02:00
Timothy Flynn
0652cc48c0 LibUnicode: Perform code point property lookups in constant time
We currently produce a single table for all categories of code point
properties (GeneralCategory, Script, etc.). Each row contains a field
indicating the range of code points to which that property applies. At
runtime, we then do a binary search through that table to decide if a
code point has a property.

This changes our approach to generate a 2-stage lookup table for each of
those categories. There is an in-depth explanation of these tables above
the new `create_code_point_tables` method. The end effect is that code
point property lookup is reduced from a binary search to constant-time
array lookups.

In total, this change:

    * Increases the size of libunicode.so from 2.7 MB to 2.9 MB.

    * Reduces the runtime of the new benchmark test case added here from
      3.576s to 1.020s (a 3.5x speedup).

    * In a profile of resizing a TextEditor window with a 3MB file open,
      the runtime of checking if a code point has a word break property
      reduces from ~81% to ~56%.
2023-07-26 08:36:20 +02:00
Timothy Flynn
c950f88611 LibUnicode: Stop generating Block property data
We started generating this data in commit 0505e03, but it was unused.
It's still not used, so let's remove it, rather than bloating the size
of libunicode.so with unused data. If we need it in the future, it's
trivial to add back.

Note we *have* always used the block name data from that commit, and
that is still present here.
2023-07-26 08:36:20 +02:00
PaddiM8
6de701b5c3 LibWeb: Handle auto margins with flex and justify-content
Auto margins used together with justify-content would previously
result in children being positioned outside their parent. This was
solved by letting auto margins take precedence when they are used,
which was already implemented to some extent before, but not
fully.
2023-07-26 08:35:23 +02:00
PaddiM8
a26f2f0aab LibWeb: Handle flex reverse togther with justify-content
Containers with both flex reverse and justify content would
sometimes place children outside the container. This happened
because it assumed any reversed container would have items
aligned to the right, which isn't true when using eg. `flex-end`.

Both `justify-content: start` and `justify-content: end` are now
also independent of the reverseness.
2023-07-26 08:35:23 +02:00
Aliaksandr Kalenik
152ce88984 LibWeb: Avoid leaking infinite remaining_free_space in FFC calculation
After switching to fixed-point arithmetic in CSSPixels, it no longer
supports representing infinite values, which was previously the case
for remaining_free_space in FFC. Using Optional that is not empty only
when value is finite to store remaining_free_space ensures that
infinity is avoided in layout calculations.
2023-07-26 05:17:56 +02:00
Andreas Kling
a653b60e49 LibWeb: Implement basic support for window[number]
This fixes an assertion on https://amazon.com/ since WindowProxy
would advertise "0" as an own property key, but then act like it was
a bogus property when actually queried for it directly.
2023-07-25 15:45:44 +02:00