Commit graph

78 commits

Author SHA1 Message Date
Aliaksandr Kalenik
6e0601a63e LibWeb/CSS: Implement parsing of grid-auto-columns and grid-auto-rows 2023-05-22 06:05:19 +02:00
MacDue
00cda96e2d LibWeb: Implement SVG opacity properties
This implements the stop-opacity, fill-opacity, and stroke-opacity
properties (in CSS). This replaces the existing more ad-hoc
fill-opacity attribute handling.
2023-05-20 08:52:19 +02:00
Sam Atkins
0679b4e0b9 LibWeb: Wrap font metrics into a struct
Rather than passing an increasingly-unwieldy number of font parameters
individually to every function that resolves lengths, let's wrap them
up.

This is frustratingly close to being `Gfx::FontPixelMetrics`, but bitmap
fonts cause issues: We choose the closest font to what the CSS
requests, but that might have a wildly different size than what the
page expects, so we have to fudge the numbers.

No behaviour changes.
2023-04-29 16:23:50 +02:00
MacDue
297d8eebcd LibWeb: Add stop-color as a CSS property
(This is to set the color of a stop for an SVG gradient)
2023-04-28 09:42:28 +02:00
Sam Atkins
0c14103025 LibWeb: Move PercentageOr and subclasses into PercentageOr.{h,cpp}
This solves an awkward dependency cycle, where CalculatedStyleValue
needs the definition of Percentage, but including that would also pull
in PercentageOr, which in turn needs CalculatedStyleValue.

Many places that previously included StyleValue.h no longer need to. :^)
2023-03-30 21:29:50 +02:00
Sam Atkins
7d08d5ad6f LibWeb: Remove now-unused includes from StyleValue.cpp
And add them to all the places that relied on getting them transitively.
2023-03-25 16:56:04 +00:00
MacDue
87b8a36e56 LibWeb: Parse and plumb the accent-color CSS property 2023-03-23 08:27:51 +00:00
Simon Wanner
554c4af90f LibWeb: Add support for the lh and rlh length units
Resolving these units is somewhat tricky because of their interaction
with both font-size and line-height, but this implementation seems to
work as tested in http://wpt.live/css/css-values/lh-unit-001.html and
http://wpt.live/css/css-values/lh-unit-002.html
2023-03-18 20:14:52 +01:00
Andreas Kling
f11899f885 LibWeb+LibIDL: Fix (or paper over) various const-correctness issues
There's definitely stuff to iterate on here, but this takes care of
making the libraries compile with stricter RP and NNRP.
2023-02-21 00:54:04 +01:00
martinfalisse
9bc001f410 LibWeb: Parse grid-area CSS property 2023-01-21 14:35:00 +01:00
martinfalisse
a6548c4d80 LibWeb: Parse grid-template-areas CSS property 2023-01-21 14:35:00 +01:00
Sam Atkins
5d8e3f5122 LibWeb: Convert Layout::Node to new pixel units 2023-01-05 17:42:31 +01:00
martinfalisse
64c353f11c LibWeb: Parse border-collapse property for HTML table 2023-01-03 20:02:47 +01:00
Karol Kosek
e338a0656d LibWeb: Remove unused StyleProperties::length_or_fallback function 2022-12-10 11:46:12 +00:00
Daniel Bertalan
4296425bd8 Everywhere: Remove redundant inequality comparison operators
C++20 can automatically synthesize `operator!=` from `operator==`, so
there is no point in writing such functions by hand if all they do is
call through to `operator==`.

This fixes a compile error with compilers that implement P2468 (Clang
16 currently). This paper restores the C++17 behavior that if both
`T::operator==(U)` and `T::operator!=(U)` exist, `U == T` won't be
rewritten in reverse to call `T::operator==(U)`. Removing `!=` operators
makes the rewriting possible again.
See https://reviews.llvm.org/D134529#3853062
2022-11-06 10:25:08 -07:00
martinfalisse
b2b677e984 LibWeb: Refactor GridTrackSize classes
Refactor various classes in the GridTrackSize file for the incoming
named_tracks feature.

Previously the ExplicitTrackSizing had mixed responsiblities with the
newly-named GridRepeat class. This made it so it was not possible to
have multiple repeats within a single 'GridTrackSizeList' definition.

The MetaGridTrackSize class had both the responsibilities of being a
container for minmax values as well as for simple GridSizes. By uniting
the different possible values (repeat, minmax, default) into the
ExplicitGridTrack class are able to be more expressive as to the
different grid size modalities.

The GridTrackSizeList will be useful as compared to a
Vector<ExplicitGridTrack> since this way can keep track of the declared
line names. These same line names are able to be declared within the
values of a repeat function, hence the presence of a GridTrackSizeList
inside the GridRepeat class.
2022-11-01 11:19:41 +01:00
Luke Wilde
5e2b41175c LibWeb: Return empty Optional<StyleProperty> for shorthand properties
This is a stopgap until we implement shorthand -> longhand conversion.
2022-10-28 16:17:08 +01:00
martinfalisse
f7af190de0 LibWeb: Add parent classes for managing GridTrackSizes
Add classes ExplicitTrackSizing and MetaGridTrackSize which will allow
for managing properties like auto-fill and minmax.

In the following CSS example there are 3 classes that will be used:
grid-template-column: repeat(auto-fill, minmax(50px, 1fr) 75px);

ExplicitTrackSizing - will contain the entire value. e.g.
repeat(auto-fill, minmax(50px, 1fr) 75px)

With a flag if it's a repeat, as well as references to the
MetaGridTrackSizes which is the next step down.

MetaGridTrackSize:
Contain the individual grid track sizes. Here there are two:
minmax(50px, 1fr) as well as 75px.

This way can keep track if it's a minmax function or not, and the
references to both GridTrackSizes in the case it is, or in just the one
if it is not.

GridTrackSize:
Is the most basic element, in this case there are three in total; two of
which are held by the first MetaGridTrackSize, and the third is held by
the second MetaGridTrackSize.
Examples: 50px, 1fr and 75px.
2022-10-15 16:04:01 +02:00
Andreas Kling
f8a2c0586a LibWeb: Parse the CSS align-content property 2022-10-14 19:50:15 +02:00
Andreas Kling
844321d89f LibWeb: Teach CSS::StyleProperties to create CSS::Size values
You can now use StyleProperties::size_value(CSS::PropertyID) to extract
a CSS::Size for a given property.
2022-09-25 17:51:43 +02:00
MacDue
ec4de1e07d LibWeb: Plumb style/computed values for backdrop-filter 2022-09-16 10:50:48 +01:00
martinfalisse
44d08b81b7 LibWeb: Parse grid-column-start and related CSS properties
Parse grid-column-start, end, and the equivalent for rows.
2022-08-25 13:47:48 +02:00
martinfalisse
92a00648b1 LibWeb: Parse grid-template-columns and grid-template-rows
Add functionality to begin parsing grid-template-columns and
grid-template-rows. There are still things to be added, like parsing
functions, but I would say a couple of the major points are already
adressed like length, percentage, and flexible-length.
2022-08-25 13:47:48 +02:00
Tom
8163ee1500 LibWeb: Use rect value in CSS clip property
When a rect value is passed to the clip property via CSS, keep it in
ComputedValues so that at a later stage can make use of it.
2022-08-07 22:40:11 +02:00
MacDue
d7d34d88e5 LibWeb: Implement appearance CSS property
This includes the "compat" values even though they are not strictly
necessary.
2022-07-23 01:45:49 +02:00
Andreas Kling
2f0657739b LibWeb: Honor align-self over align-items when non-auto on flex item 2022-07-12 02:46:21 +02:00
Sam Atkins
7c91fda088 LibWeb: Allow multiple text-decoration-lines
The spec grammar for `text-decoration-line` is:

`none | [ underline || overline || line-through || blink ]`

Which means that it's either `none`, or any combination of the other
values. This patch makes that parse for `text-decoration-line` and
`text-decoration`, stores the results as a Vector, and adjusts
`paint_text_decoration()` to run as a loop over all the values that are
provided.

As noted, storing a Vector of values is a bit wasteful, as they could be
stored as flags in a single `u8`. But I was getting too confused trying
to do that in a nice way.
2022-04-14 21:54:10 +02:00
Sam Atkins
e941f07931 LibWeb: Make StyleProperties::property() always return a value
By the time that property() gets called, we've already given every
single property a value, so we can just return it. This simplifies a
lot of places that were manually handling a lack of value
unnecessarily.
2022-04-14 14:54:06 +02:00
Sam Atkins
4d42885327 LibWeb: Return Optional from StyleProperties::box_sizing()
This function was written as if it returned `Optional<CSS::BoxSizing>`
but actually returned a plain `CSS::BoxSizing`, meaning if the property
was not set or was invalid, it would return whichever enum value was
first. This wasn't visible because we don't yet pay any attention to
the `box-sizing` property.
2022-04-14 14:54:06 +02:00
Simon Wanner
206d6ece55 LibGfx: Move other font-related files to LibGfx/Font/ 2022-04-09 23:48:18 +02:00
Enver Balalic
58398b1e12 LibWeb: Implement the flex order CSS property
Adds support for the flex order property and a test page for it
on the browser welcome page.
2022-04-02 18:40:32 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Sam Atkins
03daa4653f LibWeb: Parse and compute text-shadow property 2022-03-24 18:08:34 +01:00
Sam Atkins
1094654adc LbWeb: Rename BoxShadowFoo => ShadowFoo
The `text-shadow` property is almost identical to `box-shadow`:
> Values are interpreted as for box-shadow [CSS-BACKGROUNDS-3].
> (But note that the inset keyword are not allowed.)

So, let's use the same data structures and parsing code for both. :^)
2022-03-24 18:08:34 +01:00
Andreas Kling
5118a4c1e7 LibWeb: Parse CSS "font-variant" as part of "font"
This allows us to parse CSS "font" values that contain e.g "small-caps"
or "normal", as used on Acid3.
2022-03-23 14:54:21 +01:00
Simon Wanner
145efbe07a LibWeb: Apply the CSS transform-origin property
We don't have transform-box yet, so this applies to the border-box
for now.

This also makes us pass a couple Web Platform Tests as well :^)
For example:
https://wpt.live/css/css-transforms/css3-transform-scale-002.html
2022-03-22 02:06:21 +01:00
Andreas Kling
df8ef03957 LibWeb: Pick up the CSS "visibility" property an honor it when painting 2022-03-21 15:42:57 +01:00
Lenny Maiorani
c37820b898 Libraries: Use default constructors/destructors in LibWeb
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-17 17:23:49 +00:00
sin-ack
0679eadd62 LibWeb: Add support for the text-justify property
This commit adds the text-justify property as defined in:
https://drafts.csswg.org/css-text/#propdef-text-justify
2022-03-12 21:51:38 +01:00
Andreas Kling
1cdbd377e7 LibWeb: Add vertical-align to ComputedValues 2022-02-26 01:35:06 +01:00
Sam Atkins
1de0ca3286 LibWeb: Compute value for content property 2022-02-25 19:35:34 +01:00
Andreas Kling
141b01d3e3 LibWeb: Turn StyleProperties::m_property_values into an Array
After style computation, every StyleProperties has a value for every
PropertyID. Given this, it's simpler, faster and less memory-heavy to
use an Array instead of a HashMap. :^)
2022-02-19 14:45:59 +01:00
Maciej
3e1c1c0b16 LibWeb: Add support for CSS image-rendering property
Currently only "auto" and "pixelated" values are supported.
2022-02-19 11:38:46 +01:00
Sam Atkins
5b2482a939 LibWeb: Use Optional instead of undefined-lengths for widths/heights 2022-02-18 19:04:37 +01:00
Sam Atkins
10c6c77b5c LibWeb: Render multiple box-shadows
Because why not? :^)
2022-02-08 17:45:51 +01:00
Tobias Christiansen
69aac6ecd7 LibWeb: Add new property 'text-decoration-style'
This patch makes the property 'text-decoration-style' known throughout
all the places in LibWeb that care.
2022-01-23 15:48:27 +03:30
Sam Atkins
dc681913e8 LibWeb: Convert width/height and min-/max- versions to LengthPercentage
A lot of this is quite ugly, but it should only be so until I remove
Length::Type::Percentage entirely. (Which should happen later in this
PR, otherwise, yell at me!) For now, a lot of things have to be
resolved twice, first from a LengthPercentage to a Length, and then
from a Length to a pixel one.
2022-01-20 00:04:10 +01:00
Sam Atkins
69878cde3e LibWeb: Remove unused StyleProperties::background_repeat() 2022-01-20 00:04:10 +01:00
Sam Atkins
1e53768f1b LibWeb: Combine background-repeat-x/y pseudo-properties
While right now this doesn't save much complexity, it will do once we
care about multiple background layers per node. Then, having a single
repeat value per layer will simplify things.

It also means we can remove the pseudo-property concept entirely! :^)
2021-11-10 14:38:49 +01:00
Andreas Kling
84b15cc7b1 LibWeb: Remove StyleProperties::set_property(PropertyID, StringView)
This API has no more clients (and the last client that I just removed
wasn't even using it right) so let's get rid of it.
2021-10-28 12:53:31 +02:00