Commit Graph

109 Commits

Author SHA1 Message Date
Andi Gallo
6c2712764d LibWeb: Add table-column-group to layout tree dump 2023-06-10 11:17:21 +02:00
Andreas Kling
caa491b72a LibWeb: Measure the overflow for all scroll containers
Instead of just measuring the layout viewport, we now measure overflow
in every box that is a scroll container.

This has the side effect of no longer creating paintables for layout
boxes that didn't participate in layout. (For example, empty/anonymous
boxes that were ignored by flex itemization.)

Such boxes are now marked as "(not painted)" in the layout tree dumps,
as they have no paintable to dump geometry from.
2023-06-01 13:33:35 +02:00
Andreas Kling
571c05bb47 LibWeb: Include scrollable overflow in paint tree dumps 2023-06-01 13:33:35 +02:00
Aliaksandr Kalenik
0bef3085dd LibWeb: Output names of inner table boxes in layout dump
Since there are no table-specific boxes anymore it would be nice to
output their types additionally in layout dump so we can tell table
boxes from "regular" boxes.
2023-05-29 21:36:17 +02:00
Ali Mohammad Pur
e90752cc21 LibWeb: Add preliminary support for CSS animations
This partially implements CSS-Animations-1 (though there are references
to CSS-Animations-2).
Current limitations:
- Multi-selector keyframes are not supported.
- Most animation properties are ignored.
- Timing functions are not applied.
- Non-absolute values are not interpolated unless the target is also of
  the same non-absolute type (e.g. 10% -> 25%, but not 10% -> 20px).
- The JavaScript interface is left as an exercise for the next poor soul
  looking at this code.

With those said, this commit implements:
- Interpolation for most common types
- Proper keyframe resolution (including the synthetic from-keyframe
  containing the initial state)
- Properly driven animations, and proper style invalidation

Co-Authored-By: Andreas Kling <kling@serenityos.org>
2023-05-29 05:35:41 +02:00
Andreas Kling
4fc5e06837 LibWeb: Include weight and slope in CSSFontFaceRule debug dumps 2023-05-24 20:58:46 +02:00
Andreas Kling
94a26e2715 LibWeb: Include SVG-as-image isolated contexts in layout/DOM tree dumps
This allows us to see the inside of SVG-as-image in layout tests. :^)
2023-05-21 07:44:29 +02:00
Andreas Kling
968db96101 LibWeb: Show formatting context roots in layout tree dumps
This patch does three things:

- Factors out the code that determines whether a box will create a new
  formatting context for its children (and which type of context)

- Uses that code to mark all formatting context roots in layout tree
  dumps. This makes it much easier to follow along with layout since
  you can now see exactly where control is transferred to a new
  formatting context.

- Rebaselines all existing layout tests, since the output format has
  changed slightly.
2023-05-03 13:14:36 +02:00
Linus Groh
36d35c9c82 LibWeb: Rename remaining paint_box variables to paintable_box
These don't match the type name, which is confusing.
2023-04-20 20:43:30 +02:00
Linus Groh
a75915f055 LibWeb/Layout: Rename BlockContainer::paint{_box => able_with_lines}()
It returns a PaintableBox (a PaintableWithLines, to be specific), not a
'PaintBox'. paintable_box() without the cast is already available
through BlockContainer's Box base class, we don't need to shadow it.
2023-04-20 20:43:30 +02:00
Linus Groh
754e458d0a LibWeb/Layout: Rename Box::{paint => paintable}_box()
It returns a PaintableBox, not a 'PaintBox'.
2023-04-20 20:43:30 +02:00
Luke Wilde
a744ae79ff LibWeb: Implement the :defined pseudo class
This selects an element if it is either a built-in element, or an
upgraded custom element.
2023-04-06 11:36:56 +02:00
Simon Wanner
c8ebacb1c9 LibWeb: Support the :scope pseudo class 2023-03-21 10:45:19 +01:00
Srikavin Ramkumar
c3d6709a9e LibWeb: Implement selector matching for :indeterminate pseudo-class 2023-03-20 10:15:58 +00:00
Andreas Kling
72d817d4ea LibWeb+Browser+Ladybird: Add menu action to dump paint tree 2023-03-18 20:23:35 +01:00
Andreas Kling
6960a1bb45 LibWeb: Stop polluting layout tree dumps with TextNode memory addresses
I've never actually used this for anything, and it's pretty noisy.
2023-03-12 18:10:32 +01:00
Andreas Kling
9eb8025463 LibWeb: Always include shadow roots in DOM debug dumps 2023-03-09 21:54:59 +01:00
Linus Groh
09d40bfbb2 Everywhere: Use _{short_,}string to create Strings from literals 2023-02-25 20:51:49 +01:00
Sam Atkins
c2f0b20d6b LibWeb: Port FontFace to new Strings 2023-02-19 00:51:16 +01:00
Sam Atkins
fc3540c4b1 LibWeb: Port CSS::UnicodeRange to new Strings 2023-02-15 12:48:26 -05:00
Aliaksandr Kalenik
45e85d20b6 LibWeb: Output display type inline-table in layout dump 2023-01-17 10:18:33 +01:00
MacDue
e2db717bf5 LibWeb: Fix ignored .to_string() errors in Web::dump_sheet() 2023-01-12 23:29:57 +00:00
Timothy Flynn
f3db548a3d AK+Everywhere: Rename FlyString to DeprecatedFlyString
DeprecatedFlyString relies heavily on DeprecatedString's StringImpl, so
let's rename it to A) match the name of DeprecatedString, B) write a new
FlyString class that is tied to String.
2023-01-09 23:00:24 +00:00
martinfalisse
ce0f41b9fb LibWeb+WebContent: Use new String class in CSS::StyleValue
Converts uses of DeprecatedString to String in StyleValue, and patches
surrounding files that depend on these functions.
2023-01-09 11:09:31 +01:00
Sam Atkins
ab49dbf137 LibWeb: Convert Paintable coordinates to new pixel units
This fixes a few sizing issues too. The page size is now correct in most
cases! \o/

We get to remove some of the `to_type<>()` shenanigans, though it
reappears in some other places.
2022-12-14 16:47:57 +00:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Timothy Flynn
fddbc2e378 LibWeb: Ensure the number of pseudo elements stays up-to-date
The ::placeholder pseudo element was added in commit 1fbad9c, but the
total number of pseudo elements was not updated. Instead of this manual
bookkeeping, add a dummy value at the end of the enumeration for the
count.
2022-12-01 11:18:11 -05:00
Luke Wilde
1fbad9caaf LibWeb: Recognise the ::placeholder pseudo element
This doesn't give it any functionality.
2022-11-07 14:10:41 +01:00
Andreas Kling
5fbe245406 LibWeb: Don't include object addresses in layout tree dumps
I've used this feature less than 3 times, and it's trivial to hack back
in if/when needed. Let's stop cluttering the layout tree dumps.
2022-11-03 18:52:53 +01:00
Andreas Kling
9abe3b0db5 LibWeb: Unbreak layout tree dumps after layout tree GC changes
Layout::Node::class_name() no longer includes the `Web::Layout::` prefix
and thus we don't need to be substringing them in dumps.
2022-10-20 16:06:26 +02:00
Andreas Kling
13834cfdff LibWeb: Use Layout::Node::display() everywhere 2022-10-06 16:25:26 +02:00
Andreas Kling
1dd4e2dc87 LibWeb: Cache lowercased names in SimpleSelector
When matching selectors in HTML documents, we know that all the elements
have lowercase local names already (the parser makes sure of this.)

Style sheets still need to remember the original name strings, in case
we want to match against non-HTML content like XML/SVG. To make the
common HTML case faster, we now cache a lowercase version of the name
with each type/class/id SimpleSelector.

This makes tag type checks O(1) instead of O(n).
2022-09-15 16:16:56 +02:00
Andreas Kling
99ecc216d7 LibWeb: Show iframe URLs in layout tree dumps 2022-08-05 12:46:40 +02:00
MacDue
b5febe538c LibWeb: Parse the -webkit-progress-bar/value pseudo elements
These will be needed for styling progress bars, sadly this can
only be done with these non-standard selectors. These are, hovever,
in use on real sites such as https://rpcs3.net/compatibility.
2022-07-23 01:45:49 +02:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
Andreas Kling
f4f850aaf2 LibWeb: Support CSSRule.type
We already had the CSSRule::Type enum, but the values were not aligned
with the CSSOM spec. This patch takes care of that, and then exposes
the type of a CSSRule to JavaScript via the "type" attribute.
2022-04-11 21:10:08 +02:00
Sam Atkins
12b8570ce3 LibWeb: Understand the format() part of a @font-face's src
This is used to skip downloading fonts in formats that we don't support.
Currently we only support TTF as far as I am aware.

The parts of a `src` are in a fixed order, unusually, which makes the
parsing more nesty instead of loopy.
2022-04-07 21:20:14 +02:00
Sam Atkins
dbbd6d3508 LibWeb: Parse @font-face unicode-range descriptor 2022-04-07 21:20:14 +02:00
Sam Atkins
804b8c85e8 LibWeb: Implement initial CSSFontFaceRule and FontFace classes
For now, this is the bare minimum that's needed: font-family and src.
2022-03-28 22:25:25 +02:00
Andreas Kling
618273b48d LibWeb: Include children-are-inline state in layout tree dumps
Sometimes it's really helpful to know if a box considers its children to
be inline or not.
2022-03-26 00:15:25 +01:00
Andreas Kling
195ef5e26f LibWeb: Bring CSS line-height implementation closer to spec
We now distribute the line-height evenly between the space above and
below inline-level boxes. This noticeably improves our baseline
alignment in many cases.

Note that the "vertical-align: <length>" case is quite awkward, as the
extra height added by the offset baseline must count towards the line
box height.

There's a lot of room for improvement here, but this makes the buckets
container on Acid3 show up in the right place, with the right size.
2022-03-24 22:52:44 +01:00
Sam Atkins
31b24c2b29 LibWeb: Remove now-unused null values from Selector enums
Now that we use a Variant for the SimpleSelector's data, we don't need
to instantiate empty structs or variables for the types that aren't
used, and so we can remove `PseudoElement::None`,
`PsuedoClass::Type::None` and `Attribute::MatchType::None`.

Also, we now always initialize a SimpleSelector with a type, so
`SimpleSelector::Type::Invalid` can go too.
2022-03-22 15:47:36 +01:00
Sam Atkins
c0db19f63c LibWeb: Use a Variant for SimpleSelector's contents
This reduces SimpleSelector's size from 112 bytes to 80 bytes. :^)
2022-03-22 15:47:36 +01:00
Sam Atkins
d60b3be29a LibWeb: Implement the :focus-within selector
This matches if it has focus, or any nodes inside it do.
2022-03-20 17:35:31 +00:00
Andreas Kling
bdd42c9b0e LibWeb: Add basic support for :lang() CSS selector
This doesn't have parsing support for multiple languages in the same
selector. Support for language subcodes is not great either. But it
does do the basics.
2022-03-20 13:36:45 +01:00
Andreas Kling
3f55271c8e LibWeb: Don't crash when dumping layout tree pre-layout
If we haven't run layout yet, there aren't any paintables attached to
the tree, so we have to null check them.
2022-03-19 12:42:10 +01:00
Sam Atkins
5b0187477b LibWeb: Implement :nth-[last-]child(n of foo) syntax
In Selectors level 4, `:nth-child()` and `:nth-last-child()` can both
optionally take a selector-list argument. This selector-list acts as a
filter, so that only elements matching the list are counted. For
example, this means that the following are equivalent:

```css
:nth-child(2n+1 of p) {}
p:nth-of-type(2n+1) {}
```
2022-03-18 11:34:02 +01:00
Sam Atkins
993653317c LibWeb: Implement the :where() selector
This is identical to :is() except for specificity, so we can use the
same code paths. :^)
2022-03-18 11:34:02 +01:00
Sam Atkins
c148ed50bb LibWeb: Implement the :is() selector
This lets us finally get rid of a FIXME in the default style sheet. :^)
2022-03-18 11:34:02 +01:00