Commit Graph

1882 Commits

Author SHA1 Message Date
BenJilks
de4fe9fcfe LibWeb: Add writing-mode CSS property, and its values
Introduce the `writing-mode` property, as specified in
https://drafts.csswg.org/css-writing-modes/#block-flow

(cherry picked from commit c3f3e93b7e46e2f366fbc904852763af546d3913;
amended to fix conflict on `height:` in expectation)
2024-11-19 11:02:38 -05:00
stelar7
c39fa9a033 LibWeb: Parse the rotate css property
(cherry picked from commit 488436fb54347e69040cfed4f523926241a136a3)
2024-11-19 11:02:38 -05:00
Jelle Raaijmakers
93a8c61fe9 LibWeb: Parse and store filter property
This shares its implementation with `backdrop-filter`.

(cherry picked from commit 29974de852fb14eef78a18232bd36d5c8955a214;
amended to resolve conflict on `height:` in expectations file, and to
remove change to DisplayListPlayerSkia.cpp which serenity doesn't have;
also updated FilterPainting.{h,cpp} for changes since serenity does not
have LadybirdBrowser/ladybird#736 and LadybirdBrowser/ladybird#886)
2024-11-19 11:02:38 -05:00
Sam Atkins
f63a15665d LibWeb: Calculate hidden password text using code-point count
This means that an `<input type=password>` will show the correct number
of *s in it when non-ASCII characters are entered.

We also don't need to perform text-transform on these as that doesn't
affect the output length, so I've moved it earlier.

(cherry picked from commit c747b1c6b56156b5797fad0d8d95164f415c8b25;
amended to slightly adjust some BlockContainer and PaintableWithLines
widths, since serenity does not use harfbuzz for text shaping)
2024-11-14 23:38:34 -05:00
Simon König
e4903feab8 LibWeb: Don't crash on encountering display: list-item on pseudo element
On any `display: list-item` Node a CSS pseudo element (`::marker`) needs
to be created. This commit allows the ::maker pseudo element to be
nested within other pseudo elements (e. g. ::before or ::after).

This fixes this WPT test:
http://wpt.live/css/CSS2/generated-content/after-content-display-003.xht

(cherry picked from commit 15d2857a01b5bda90ace3d02cf9e1bc8ce279d38)
2024-11-13 10:17:34 -05:00
Magnus Johansson
099f907420 LibWeb: Fallback to auto when aspect ratio is degenerate as per spec
When aspect-ratio is degenerate (e.g. 0/1 or 1/0) we should
fallback to the same behaviour as `aspect-ratio: auto` according to spec
This commit explicitly handles this case and fixes five WPT test in
css/css-sizing/aspect-ratio (zero-or-infinity-[006-010])

(cherry picked from commit c6f77f4818a03411c14d9e60b743a7541a8280f6)
2024-11-12 07:14:25 -05:00
Andreas Kling
1600dcaf19 LibWeb: Ignore boxes wholly in the negative scrollable overflow region
This fixes an issue where https://hey.com/ was horizontally scrollable
even though it shouldn't be.

(cherry picked from commit 94721385ceb17e20428b94a946d39828bdd5b74e)
2024-11-11 19:54:09 -05:00
Timothy Flynn
dc60651607 LibWeb: Clean up HTMLInputElement-related includes
This mainly uses forward declarations as appropriate for input element
related files. This reduces the number of targets being built when we
change HTMLInputElement.h from 430 to 44.

(cherry picked from commit 57e4fb0caebb0074a23bef70d7558ce5e8a5f357)
2024-11-10 10:46:01 -05:00
Aliaksandr Kalenik
8d56f0ed15 LibWeb: Print FIXME instead of crashing in abspos SVG element layout
Currently we are crashing in `verify_cast<BlockContainer>(box)` on
attempt to create BFC for SVG box.

(cherry picked from commit fa907029ee6f202095011b84b109bc4a2b56c58b)
2024-11-09 16:08:01 -05:00
Aliaksandr Kalenik
df69fd9a66 LibWeb: Resolve floating box's paddings before width calculation
...because calculate_inner_width() assumes layout state has resolved
paddings that could be used to account for "box-sizing: border-box".

Fixes regression introduced in 5f74da6ae8ad470ad0ce325f570faa97292384ba

(cherry picked from commit d6a31d80c05db05c34cd56ca865658a5b82dbb69)
2024-11-09 16:08:01 -05:00
Andreas Kling
81f60e2077 LibWeb: Use LayoutState::UsedValues::containing_block_used_values() more
Use this cached pointer to the containing block's used values when
obviously possible. This avoids a hash lookup each time, and these
hash lookups do show up in profiles.

(cherry picked from commit bdb67d2bcb4ab6fa49292c3365facdeab1fd0e20)
2024-11-09 16:08:01 -05:00
Aliaksandr Kalenik
5d6ddc5a16 LibWeb: Remove unnecessary copying of UsedValues in BFC
(cherry picked from commit 4ba38c55d6b0f2ad49dd1c84e566412cb9ccc9ed)
2024-11-09 16:08:01 -05:00
Andreas Kling
438b1bddbc LibWeb: Implement vertical-align: middle correctly for atomic inlines
This makes inline icons pop into the right place on https://ahrefs.com/

(cherry picked from commit c22acc2551998e1e86970f89a452041dda8c3847)
2024-11-09 07:29:52 -05:00
Andreas Kling
c2a049e031 LibWeb: Derive SVG root's natural size from width/height attributes
We were incorrectly looking at the CSS computed values for width and
height to determine the natural size of <svg> root elements.
This meant that elements where the attribute and computed value were
different values would end up with incorrect natural size.

(cherry picked from commit 8eacfc8f10256f29fed0405a6bf1cb95e73b9bef)
2024-11-08 22:32:11 -05:00
Gingeh
b2d82319b7 LibWeb: Implement justify-*: left/right
(cherry picked from commit 4a3a9e6ec4891a6e38d175cca796770092e6b9a2)
2024-11-08 07:45:02 -05:00
Aliaksandr Kalenik
a1d89d5956 LibWeb: Fix wrong assumption that repeat() is always first track [GFC]
Fixes crashing in
https://wpt.live/css/css-grid/grid-definition/grid-auto-fit-columns-001.html

(cherry picked from commit ee41dbfec3c48dc58db45e413ff6b5eb11d2fd26)
2024-11-08 07:45:02 -05:00
Aliaksandr Kalenik
7ec8e933e2 LibWeb: Clamp growth limit after adding planned increase in GFC
Fixes implementation of the following line from the spec:
"However, limit the growth of any fit-content() tracks by their
fit-content() argument."

Now we correctly apply a limit to increased growth limit rather than to
the planned increase.

Change in "Tests/LibWeb/Layout/input/grid/fit-content-2.html" is a
progression and "Item as wide as the content." is actually as wide as a
content.

(cherry picked from commit 07aa25ce5095521437889079e511f6885684a762)
2024-11-08 07:45:02 -05:00
BenJilks
a9f5ae40e0 LibWeb: Use the correct dimension when computing the max grid size
When deciding if the grid containers min size should be limited by a
max size. Check for a max height or width depending on the dimension,
instead of just always checking for a max width.

(cherry picked from commit ef037b4152f96d88380005625b8d66761923b7ba)
2024-11-08 07:45:02 -05:00
Aliaksandr Kalenik
3048bcf599 LibWeb: Implement missing step in GFC fr size calculation
Implements:
"If the product of the hypothetical fr size and a flexible track’s flex
factor is less than the track’s base size, restart this algorithm
treating all such tracks as inflexible."

Fixes https://github.com/LadybirdBrowser/ladybird/issues/1211

(cherry picked from commit 7b2042571bf42d140bafb5e771c5bbadbcca2e9d)
2024-11-08 07:45:02 -05:00
Alec Murphy
57317484b1 LibWeb: Skip trim trailing whitespace if user is typing
This PR stops the cursor from disappearing while typing trailing spaces
in a text input box.

(cherry picked from commit b3a67ee088d5bd2fb8d76d3e6f9adeff2cb8a6b6)
2024-11-07 21:52:13 -05:00
sideshowbarker
ed9843b592 LibWeb: Fix handling of find-in-page with pseudo-element content
This change makes find-in-page ignore content that’s been added to the
document using CSS ::after or ::before pseudo-elements. Ignoring such
pseudo-element content for find-in-page matches the behavior in Chrome
and Safari (though not in Firefox).

Otherwise, without this change, find-in-page doesn’t ignore the
pseudo-element content, and we instead crash in
DOM::Range::common_ancestor_container after hitting an assert, due to
the start container and end container for the matched range not having a
common ancestor.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/514

(cherry picked from commit 0a55e36403416dbf2ec3c3ce4ede9d241eed20ef)
2024-11-07 20:29:07 -05:00
Andreas Kling
fbe99575e0 LibWeb: Resolve flex item % main size to 0 during min-content sizing
When the flex container is sized under a min-content constraint in the
main axis, any flex items with a percentage main size should collapse
to zero width, not take up their own intrinsic min-content size.

This is not in the spec, but matches how other browsers behave.

Fixes an issue where the cartoons on https://basecamp.com/ were way
too large. :^)

(cherry picked from commit 59ed823724331d6457e81f8674aef392ca4dc174)
2024-11-04 21:46:05 -05:00
BenJilks
84617a7202 LibWeb: Add support for flex-wrap: wrap-reverse
Reverse the order of flex lines, when the `flex-wrap` property is set to
`wrap-reverse`. This will also swap the cross-start and cross-end
directions.

(cherry picked from commit 46649fbe1b015a7f4bfad4e059ecaf3c513f3a26)
2024-11-04 21:46:05 -05:00
BenJilks
91d454e252 LibWeb: Only reverse each line of a reverse flex-direction
When a flex container with a reverse `flex-direction` is wrapped. Only
each line should be reversed, not all items.

(cherry picked from commit e2c1fe7255c84ad1ee172765ef9f107949117098)
2024-11-04 21:46:05 -05:00
Andreas Kling
213f86d781 LibWeb: Adjust flex item intrinsic contributions through aspect ratio
When determining the intrinsic cross size contribution of a flex item
with a preferred aspect ratio, we have to account for any min/max
constraints in the main axis.

(cherry picked from commit bde2d3dc7b359cd4f56ad9975c44d22e43ef82fe)
2024-11-04 21:46:05 -05:00
Jelle Raaijmakers
94a64acb2e LibWeb: Account for intrinsic width or height in flex base size
In calculating the base size of a flex item, we have a piece of ad-hoc
code that deals with an item that does have an instrinsic aspect ratio,
but not a cross size to resolve that ratio against. In determining the
actual flex item size however, we also take into account the minimum
content width and height, which assumes the box' intrinsic width or
height when available. This would break having an image as a flex item,
which gets stretched to its maximum size within the flex container
instead of the flex item being shrunk to the instrinsic size of the
image.

Fix this by only stretching flex items that do not have an instrinsic
width nor height set.

(cherry picked from commit 7a783d3a89aec0caaa63a483c855fe921b6d0984)
2024-11-04 21:46:05 -05:00
Jelle Raaijmakers
7c9cafc8f9 LibWeb: Update two spec URIs
No functional changes.

(cherry picked from commit d82f8a4b16097ad2b5d0d61787c8f72c0f43830f)
2024-11-04 21:46:05 -05:00
Jelle Raaijmakers
97e91ab12d LibWeb: Remove unused includes
No functional changes.

(cherry picked from commit 89d21335a127dc385d91aeedac36e78aa662ee83)
2024-11-04 21:46:05 -05:00
Tim Ledbetter
610873368a LibWeb: Don't crash when converting small CSS::Ratio to CSSPixelFraction
Previously, a crash would occur in the if `CSSPixelFraction` was given a
denominator value less than the resolution of `CSSPixels` (1/64).

We now divide both parts of the ratio by the denominator in this case.

(cherry picked from commit 2c5d626b2125ffea49e06735e2f93279d0dfa0e1)
2024-11-02 07:50:34 -04:00
matjojo
86e1e4618b LibWeb: Save float-intrusion for marker before list elements layout
... to prevent that left-floating elements inside the list element
push the list marker into the (non-floating) content of the list
element.

(cherry picked from commit b7e505365c768b70ce830fbe3a6eac93b2364cd8)
2024-11-01 13:11:30 -04:00
Tim Ledbetter
7d472b5bc7 LibWeb: Cache text blocks used by find in page
The first step of the find in page algorithm is to walk the layout tree
of each document on the page and construct a list of strings against
which to search for matches.

Previously, this was being done for each new query, even when the
page content hadn't been updated. The output of this process is now
cached in the viewport node of the associated document. This ensures
that this process is no longer repeated unnceessarily.

(cherry picked from commit 156c1083e9de23a93075ec9e3c55cd5f93c48896)
2024-11-01 09:38:01 -04:00
Nico Weber
6f09a68baf LibWeb: Parse stroke-{linejoin,miterlimit} attributes
Similar to LadybirdBrowser/ladybird#1714.

We don't implement the linejoin values `miter-clip` and `arcs`, because
according to the SVG 2 spec:

> The values miter-clip and arcs of the stroke-linejoin property are at
> risk. There are no known browser implementations. See issue Github
> issue w3c/svgwg#592.

Nothing uses this yet. The next step is to change
SVGPathPaintable::paint() to read `graphics_element.stroke_linejoin()`
and `graphics_element.stroke_miterlimit()` when painting.

(cherry picked from commit 421cf8d9bf276cff61acdc32dc55d978d37fb671;
amended to resolve conflict on `height:` in
getComputedStyle-print-all.txt)
2024-10-29 21:42:09 -04:00
Kostya Farber
0b90c18afb LibWeb: Parse the word-break css property
(cherry picked from commit 44b1c4f2b59563cf29f6af81bb86645f2fa89155)
2024-10-27 20:06:44 -04:00
Kostya Farber
797697e0f2 LibWeb: Add letter-spacing css property to Node
(cherry picked from commit 537cbf55c36c14247d027f0495d595eb357dd84d)
2024-10-27 18:30:52 -04:00
Kostya Farber
22af58eb7a LibWeb: Apply the word-spacing css property to Node
This will let us start to begin applying this during
text shaping.

(cherry picked from commit da42c19cb66656e3b2531c29542b4bb27b21ec94)
2024-10-27 18:06:39 -04:00
Andreas Kling
0ed1c4fcab LibWeb: Don't crash when encountering border-spacing: calc(...)
This allows us to progress further on this WPT test:
https://wpt.live/quirks/unitless-length/quirks.html

...although it still crashes before finishing.

(cherry picked from commit 5e240f997caa8b62275d3c5d18a1cf1885349971)
2024-10-26 23:26:45 -04:00
Sam Atkins
f8a66c346e LibWeb/CSS: Parse and propagate font-feature-settings property
(cherry picked from commit 95c17dfab51fefdd5ca364652e8571827d9693b1)
2024-10-26 09:29:16 -04:00
Sam Atkins
7b35ed0c66 LibWeb/CSS: Parse and propagate font-variation-settings property
(cherry picked from commit 55812aaed20ce8f7aeea233a47bcab73b60edd5e;
amended to include AK/QuickSort.h in Parser.cpp to fix a compile
error, and to update height: in getComputedStyle-print-all.txt)
2024-10-26 09:29:16 -04:00
Kostya Farber
8718238254 LibWeb/CSS: Parse the tab-size property
(cherry picked from commit 68a28ff33abe29376cea009e24c406d3a23d4890;
amended to update `height:` line in getComputedStyle-print-all.txt)
2024-10-25 21:11:16 -04:00
Tim Ledbetter
5dc046bb7a LibWeb/SVG: Implement SVGImageElement
This element allows images to be embedded within SVGs.

(cherry picked from commit 03bbc2b111b211f472bfbc0f04c10f03e28dbbdf)
2024-10-21 12:01:12 -04:00
Sam Atkins
ee3710f681 LibWeb/CSS: Parse and propagate the font-language-override property
(cherry picked from commit 1d8867d9ae9de1312fe6624bf9040dde12bfa9df;
amended to fix `height:` line in getComputedStyle-print-all.txt)
2024-10-21 09:36:47 -04:00
Sam Atkins
e47c20c994 LibWeb/CSS: Rename CalculatedStyleValue -> CSSMathValue
This matches the name in the CSS Typed OM spec. There's quite a lot
still to do to make it match the spec behavior, but this is the first
step.

(cherry picked from commit 76daba3069de4c184c6b2317d0c89b50f81a8c00)
2024-10-20 22:24:57 -04:00
Nico Weber
052f35da64 LibWeb: Add stroke-linecap attribute and plumb it to SVGGraphicsElement
SVGGraphicsElement then goes ahead and does nothing with it for now.

(cherry picked from commit cc0cfd044b3a04c021f8810f7e96d98a05f7146a;
amended to fix minor conflict in getComputedStyle-print-all.txt)
2024-10-14 22:34:19 -04:00
Samuel Fry
6bed0011e1 LibWeb: Support parsing column-span
(cherry picked from commit 23b4367c9c8c074e72d52ac8633e5d02302053ca)
2024-10-11 10:12:44 -04:00
Samuel Fry
40d4b58deb LibWeb: Support parsing column-width
(cherry picked from commit c113d3fae9aec35a6314a06466fbb6bfbe2a4de3)
2024-10-11 10:12:44 -04:00
Khaled Lakehal
cc4ba18bed LibWeb/CSS: Add support for unicode-bidi property
(cherry picked from commit 77761e123d61ff792efe78a06ca863925a1f5f98)
2024-10-11 09:27:42 -04:00
Sam Atkins
0a3b33e6f6 LibWeb: Rename "identifier" and "ValueID" to "Keyword" where correct
For a long time, we've used two terms, inconsistently:
- "Identifier" is a spec term, but refers to a sequence of alphanumeric
  characters, which may or may not be a keyword. (Keywords are a
  subset of all identifiers.)
- "ValueID" is entirely non-spec, and is directly called a "keyword" in
  the CSS specs.

So to avoid confusion as much as possible, let's align with the spec
terminology. I've attempted to change variable names as well, but
obviously we use Keywords in a lot of places in LibWeb and so I may
have missed some.

One exception is that I've not renamed "valid-identifiers" in
Properties.json... I'd like to combine that and the "valid-types" array
together eventually, so there's no benefit to doing an extra rename
now.

(cherry picked from commit 6a74b0164423d63904cf5a5b594772b595f57600;
very minorly amended to fix conflict in GenerateCSSKeyword.cpp caused
by #22870, and in libweb_generators.cmake due to us not having
https://github.com/LadybirdBrowser/ladybird/pull/741)
2024-10-10 10:08:59 -04:00
Sam Atkins
63e3442b15 LibWeb: Rename IdentifierStyleValue -> CSSKeywordValue
This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue

(cherry picked from commit 9559f0f123fcd1c2fddba625d4bdc4806bb8bd68)
2024-10-10 10:08:59 -04:00
Sam Atkins
a4981ae745 LibWeb: Rename StyleValue -> CSSStyleValue
This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue

No behaviour changes.

(cherry picked from commit 0e3487b9ab455a7648185995363bb3b487551d40)
2024-10-10 10:08:59 -04:00
Aliaksandr Kalenik
81f2405c8b LibWeb: Fix OOB access in "text-overflow: ellipsis" clip
Fixes out of bound access to glyph run when `last_glyph_index` is 0.

Fixes crashing on https://github.com/LadybirdBrowser/ladybird/pulls

(cherry picked from commit fa605ef22577d92bbfc3f4a809bb1b4072bb0048)
2024-10-10 09:46:20 -04:00