Commit Graph

156 Commits

Author SHA1 Message Date
Andreas Kling
254d040ff4 LibGfx: Move Gfx::Painter::ScalingMode => Gfx::ScalingMode
This will allow users to avoid including Painter.h
2024-06-05 15:37:05 +02:00
MacDue
517379ff80 LibWeb: Resolve basic-shape clip-paths
These will be ignored within SVGs (for now SVGs only support <clipPath>
elements), but will allow clipping standard HTML elements.
2024-05-26 07:55:50 +02:00
MacDue
6c9069fa5d LibWeb: Implement the SVG clip-rule attribute
This controls the fill rule used when rasterizing `<clipPath>` elements.
2024-05-14 23:01:18 +01:00
MacDue
03f957dc79 LibWeb: Add the clip-path property and resolve it for SVG elements 2024-03-29 21:59:56 +01:00
Shannon Booth
e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00
MacDue
4f78ddd6a2 LibWeb: Setup computed values for SVG geometry properties 2024-03-04 10:50:32 +01:00
Aliaksandr Kalenik
8d9e20cb03 LibWeb: Parse the CSS scrollbar-width property 2024-02-28 07:51:13 -05:00
Aliaksandr Kalenik
a0dc9584de LibWeb: Add "object-position" CSS property into ComputedValues 2024-02-27 16:53:13 +01:00
Aliaksandr Kalenik
677a00ed92 LibWeb: Add "object-fit" CSS property into ComputedValues 2024-02-27 16:53:13 +01:00
Shannon Booth
9ce8189f21 Everywhere: Use unqualified AK::URL
Now possible in LibWeb now that there is no longer a Web::URL.
2024-02-25 08:54:31 +01:00
MacDue
b10f58a1fe LibWeb: Support x and y attributes on nested SVGs
This allows positioning a child SVG relative to its parent SVG.

Note: These have been implemented as CSS properties as in SVG 2, these
are geometry properties that can be used in CSS (see
https://www.w3.org/TR/SVG/geometry.html), but there is not much browser
support for this. It is nicer to implement than the ad-hoc SVG
attribute parsing though, so I feel it may make sense to port the rest
of the attributes specified here (which should fix some issues with
viewport relative sizes).
2024-01-29 10:01:10 +00:00
Andreas Kling
ad7e6878fe LibWeb: Allocate CSS::ComputedValues objects on the heap
This makes them cheap to move around, since we can store them in a
NonnullOwnPtr instead of memcopying 2584(!) bytes.

Drastically reduces the chance of stack overflow while building the
layout tree for deeply nested DOMs (since tree building was putting
these things on the stack).

This change also exposed a completely unnecessary ComputedValues deep
copy in block layout.
2024-01-27 12:27:44 +01:00
Sam Atkins
391cfdc085 LibWeb: Parse the CSS transform-box property 2024-01-27 07:46:37 +01:00
Andreas Kling
bc3a16396e LibWeb: Move font list from NodeWithStyle to ComputedValues
Same here, no need for this to live in NodeWithStyle. Inheritance
behavior for free in ComputedValues.
2024-01-12 17:26:16 +01:00
Andreas Kling
c82d517447 LibWeb: Move line-height from NodeWithStyle to ComputedValues
There's no need for this to live in the NodeWithStyle anymore. By moving
it to ComputedValues we get all the right inheritance behavior for free.
2024-01-12 17:26:16 +01:00
Tobias Christiansen
6602b1ddb1 LibWeb: Rename "position" enum to "positioning"
The postitioning enum values are used by the position CSS property.
Unfortunately, the prior naming clashes with the CSS Values-4 type
named position, which will be implemented in a later commit.
2023-10-30 10:40:30 +00:00
Sam Atkins
642ad80960 LibWeb: Make CSS Transformation struct a proper class
Move it out of ComputedValues.h into its own files, and take the
transformation-to-matrix code from StackingContext.
2023-10-15 07:14:39 +02:00
Aliaksandr Kalenik
7803dcfcf9 LibWeb: Resolve backdrop filter length in apply_style()
Instead of resolving lengths used in the backdrop-filter during
painting, we can do that earlier in apply_style().

This change moves us a bit closer to the point when the stacking
context tree will be completely separated from the layout tree :)
2023-10-12 07:38:48 +02:00
MacDue
479451498b LibWeb: Implement mask-type CSS property
This property allows specifying if a mask is an alpha or luminance mask.

See: https://drafts.fxtf.org/css-masking/#the-mask-type
2023-10-09 07:28:18 +02:00
MacDue
dc58b5f418 LibWeb: Add CSS mask property and make it form a stacking context 2023-09-19 10:46:05 +02:00
Sam Atkins
dc7a52957e LibWeb: Parse and compute CSS quotes property 2023-09-17 15:45:52 -06:00
Sam Atkins
6476dea898 LibWeb: Implement the math-depth CSS property
This one is a bit fun because it can be `add(<integer>)` or `auto-add`,
but children have to inherit the computed value not the specified one.
We also have to compute it before computing the font-size, because of
`font-size: math` which will be implemented later.
2023-09-11 17:03:22 +01:00
Sam Atkins
6045143d39 LibWeb: Parse the math-shift and math-style CSS properties
Currently these have no effect, but they're simple, and `math-style`
influences `math-depth` which is coming next.
2023-09-11 17:03:22 +01:00
Sam Atkins
125d161b3f LibWeb: Move <display-foo> definitions into Enums.json
This eliminates a fair bit of boilerplate.
2023-09-11 17:03:22 +01:00
Zaggy1024
607a398917 LibWeb: Store computed CSS font size as CSSPixels
The value is originally set using a `CSSPixels` value converted to
double, then when it is used it is always converted back to a
`CSSPixels` again. Let's just store it as that instead.
2023-09-09 13:03:11 +02:00
Aliaksandr Kalenik
0f75d0611f LibWeb: Implement support for parsing CSS column-count property 2023-09-07 20:16:33 +02:00
Andreas Kling
703c2bb06e LibWeb: Add support for parsing grid-auto-flow CSS property
Co-Authored-By: Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
2023-08-20 15:36:18 +02:00
Andi Gallo
97512d0c76 LibWeb: Add table-layout CSS property 2023-08-09 08:33:02 +01:00
Sam Atkins
73fa58da34 LibWeb: Implement the CSS outline-offset property
This allows you to push the outline a certain distance away from the
border (or inside it, if the offset is negative).
2023-08-03 05:25:48 +02:00
Sam Atkins
fe7e797483 LibWeb: Implement the CSS outline property :^)
...along with `outline-color`, `outline-style`, and `outline-width`.

This re-uses the existing border-painting code, which seems to work well
enough!

This replaces the previous code for drawing focus-outlines, with generic
outline painting for any elements that want it. Focus outlines are now
instead supported by this code in Default.css:

```css
:focus-visible {
    outline: auto;
}
```
2023-08-03 05:25:48 +02:00
Tobias Christiansen
5fc6bff582 LibWeb: Add 'object-fit' property
This patch adds support for the 'object-fit' CSS property. :^)
2023-08-02 11:35:57 +01:00
Sam Atkins
5ee1b7db7c LibWeb: Convert BorderData::width to CSSPixels
The `clip_shrink` optimization in `paint_background()` now also
correctly uses DevicePixels, instead of reducing a DevicePixel rect by
a CSSPixels amount.
2023-07-30 22:18:26 +01:00
MacDue
30277f385c LibWeb: Add an initial implementation of SVG text-anchor
This only handles very simple <text> elements, but this is enough (with
the font-size changes) to improve the badges on the GitHub README a fair
bit.
2023-07-21 11:42:30 +02:00
Aliaksandr Kalenik
f060f89220 LibWeb: Add support for justify-items property in CSS parser 2023-07-15 05:50:51 +02:00
Aliaksandr Kalenik
fedbb39e9e LibWeb: Add support for justify-self property in CSS parser 2023-07-14 15:48:58 +02:00
Ali Mohammad Pur
06c6c40df9 LibWeb+LibJS: Move some code around to make CSS/Parser parse faster
This makes it possible to include fewer full definitions of things,
which makes the file about 30% faster to compile.
2023-07-11 09:38:37 +03:30
Andreas Kling
510dfbb7e6 LibWeb: Update anonymous wrappers when applying style changes
Anonymous wrapper boxes inherit style from their layout tree parent,
and since style data is per-layout-node, we have to manually sync them
from parent to anonymous children when something changes.

This is not very elegant or efficient, so I've left a FIXME about
solving it in a nicer way.

This fixes horizontal dog alignment on https://waffles.dog/ :^)
2023-07-03 13:37:14 +02:00
Andreas Kling
8648355783 LibWeb: Modernize handling of the CSS flex-basis property
Instead of a custom struct, use an AK::Variant for flex-basis.
A flex-basis is either `content` or a CSS size value, so we don't need
anything custom for that.

By using a CSS size, we also avoid having to convert in and out of size
in various places, simplifying the code.

This finally gets rid of the "Unsupported main size for flex-basis"
debug spam. :^)
2023-06-21 20:20:59 +02:00
Andi Gallo
52956d355c LibWeb: Make border-collapse actually inherited
Move it to the inherited section of ComputedValues.
2023-06-16 17:21:15 +02:00
Andi Gallo
396f1a977c LibWeb: Add CSS support for border-spacing property 2023-06-16 13:57:31 +02:00
Sam Atkins
af51095fe2 LibWeb: Stop making ComputedValues::stroke_width() optional
This defaults to 1px and should always have some kind of value.
2023-06-16 07:03:57 +02:00
MacDue
377ff0ac26 LibWeb: Implement SVG fill-rule attribute
Previously, we did an evenodd fill for everything which while for most
SVGs works, it is not correct default (it should be nonzero), and broke
some SVGs. This fixes a few of the icons on https://shopify.com/.
2023-06-11 19:34:24 +02:00
Andi Gallo
940d9b98ae LibWeb: Add support for table caption
Adds layout support and the CSS caption-side property.
2023-06-10 07:09:11 +02:00
Sam Atkins
6fd3b39bef LibWeb: Parse aspect-ratio property
Parse it, store the result in the ComputedValues, and also expose it to
ResolvedCSSStyleDeclaration.
2023-06-09 20:37:51 +02:00
Aliaksandr Kalenik
3b3ade0b8d LibWeb: Use none as initial value for grid-template-column/rows
This fixes the issue that currently we use "auto" as initial value for
grid-template-column and grid-template-rows although spec says it
should be "none". This makes a lot of difference for these properties
because currently we represent "auto" as a list with one auto-sized
track which means initial value for grid-template-column defines one
"explicit" track while it should define none of them.

This change makes grid-auto-columns/rows be applied to the correct
tracks when initial values is used for grid-template-column/rows.
2023-06-07 14:13:07 +02:00
Andreas Kling
0c2fcffba3 LibWeb: Make text-shadow inherited in CSS::ComputedValues
CSS text-shadow is an inherited property, so we have to make sure it's
part of the inherited substructure in ComputedValues, otherwise it gets
incorrectly reset in children.
2023-06-07 06:29:59 +02:00
stelar7
a5f2024afa LibWeb: Resolve the transition-delay property 2023-06-03 05:59:19 +02:00
Simon Wanner
293ece2292 LibWeb: Support list-style-position
This moves the ::marker inside of <summary> actually inside. :^)
2023-06-03 05:54:49 +02:00
stelar7
421559d725 LibWeb: Change calc node representation from float to double 2023-05-31 10:56:32 +02:00
Sam Atkins
af68bf862f LibWeb: Resolve border[-color,-style,-width] properties 2023-05-27 20:55:00 +02:00