Commit Graph

5702 Commits

Author SHA1 Message Date
Matthew Olsson
e5ff777b48 LibWeb: Capture stack values by copy in async lambdas in Stream AOs 2023-05-27 13:55:14 +02:00
Matthew Olsson
42fb847cc8 LibWeb: Use u64 for ReadableByteStream offsets instead of u32
These are specified in the IDL as "unsigned long long", which translates
to u64.
2023-05-27 13:55:14 +02:00
Andreas Kling
e30709fca9 LibWeb: Don't throw away the layout tree on viewport resize
We'll throw it out automatically if some media query changes changes its
evaluation state in response to the resize, and that should be enough.
2023-05-27 11:43:56 +02:00
Andreas Kling
78d6e2db8c LibWeb: Don't invalidate style when attribute set to identical value
This was a fairly common source of unnecessary style invalidations.
2023-05-27 11:43:56 +02:00
Andreas Kling
8ba7bd1b67 LibWeb: Accept fit-content as a value for min-width and max-width
This starts working immediately in BFC thanks to calculate_inner_width
being used for width constraints. :^)
2023-05-27 05:47:54 +02:00
Andreas Kling
1bb4e5c428 LibWeb: Support fit-content width for block-level boxes 2023-05-27 05:47:54 +02:00
Andreas Kling
a277c393b9 LibWeb: Support grid items with fit-content width :^) 2023-05-27 05:47:54 +02:00
Andreas Kling
299775345d LibWeb: Allow calculating intrinsic sizes of non-FC-roots
In order to support intrinsic size keywords (such as fit-content), we
need to be able to calculate the intrinsic sizes of any element, not
just those that form their own formatting context.

When a non-FC-root element is passed to calculate_some_intrinsic_size(),
we now create a synthetic BFC to handle sizing of them.
2023-05-27 05:47:54 +02:00
Andreas Kling
09eb3ef405 LibWeb: Add fit-content as a valid size value for CSS width 2023-05-27 05:47:54 +02:00
Aliaksandr Kalenik
ab5b89eb95 LibWeb: Add basic parsing of grid shorthand CSS property
Introduces incomplete parsing of grid shorthand property. Only
<grid-template> part of syntax is supported for now but it is enough
to significantly improve rendering of websites that use this shorthand
to define grid :)
2023-05-27 05:47:14 +02:00
Andi Gallo
1e526af430 LibWeb: Fix width calculation for floating replaced elements
The path for floating, replaced elements must not fall through to the
path taken for floating, non-replaced elements. The former works like
inline replaced elements, while the latter uses a completely different
algorithm which doesn't account for intrinsic ratio. Falling through
overrides the correct value computed by the former.

Fixes #19061.
2023-05-26 21:20:56 +02:00
Aliaksandr Kalenik
7cc20f4cb5 LibWeb: Reset margin collapsing state only if box indeed add clearance
This fixes the issue when margin collapsing state was always reset if
a box has clear property not equal to none even if it does not actually
introduce clearance.
2023-05-26 18:11:35 +02:00
Sam Atkins
b0a43404b9 LibWeb: Avoid nullptr dereference when parsing grid sizes 2023-05-26 17:53:11 +02:00
Cameron Youell
0afdde0eef LibWeb: Consume sign in SVG::parse_elliptical_arg_argument
This was crashing on google.com with the linux chrome user agent,
interestingly it seems like this behavior may have been accidental as
only two of the three `parse_number()` were changed in f7dbcb6
2023-05-26 14:54:00 +02:00
Andi Gallo
5cec517153 LibWeb: Get reference height from closest non-anonymous ancestor
Ignore anonymous block boxes when resolving percentage weights that
would refer to them, per the CSS 2 visual formatting model
specification. This fixes the case when we create an anonymous block
between an image which uses a percentage height relative to a parent
which specifies a definite height.

Fixes #19052.
2023-05-26 14:53:53 +02:00
PrestonLTaylor
5d3b7a5ecc LibWeb: Return DOMException instead of crashing when setting attributes 2023-05-26 05:23:09 +02:00
Andreas Kling
624f43c12b LibWeb: Do the CORS cross-origin workaround to find MIME type for images
This makes cross-origin image loads actually see the MIME type the
server tells us. :^)
2023-05-25 12:53:41 -07:00
Andreas Kling
aeffa0d988 LibWeb: Make Fetch::Infrastructure::HeaderList::is_empty() public 2023-05-25 12:53:41 -07:00
Andreas Kling
475bac89e1 LibWeb: Don't crash on unimplemented CSS display type
If some page throws "display: ruby-text" or some such at us, let's just
complain and carry on.
2023-05-25 16:49:34 +02:00
Andreas Kling
9c8da4374d LibWeb: Try failed font lookups again without weight and slope
If CSS requests a font that we have loaded, but we didn't associate it
with a specific weight and/or slope, let's still use it if it matches
the family name.

This is a hack until we implement proper CSS font selection.
2023-05-25 16:49:34 +02:00
Sam Atkins
f6fae315e3 LibWeb: Add CustomIdentStyleValue, along with parsing for it
This corresponds to the `<custom-ident>` type in CSS grammar.
2023-05-25 15:31:20 +01:00
0GreenClover0
b4c6cddd96 LibWeb: Handle invalid UTF-8 in Fetch's Body#text() 2023-05-25 06:03:40 -07:00
Andreas Kling
7d24c13d8b LibWeb: Make input element placeholders look better
We now create a flex container inside the input element's UA shadow tree
and add the placeholder and non-placeholder text as flex items (wrapped
in elements whose style we can manipulate).

This fixes the visual glitch where the placeholder would appear below
the bounding box of the input element. It also allows us to align the
text vertically inside the input element (like we're supposed to).

In order to achieve this, I had to make two small architectural changes
to layout tree building:

- Elements can now report that they represent a given pseudo element.
  This allows us to instantiate the ::placeholder pseudo element as an
  actual DOM element inside the input element's UA shadow tree.

- We no longer create a separate layout node for the shadow root itself.
  Instead, children of the shadow root are treated as if they were
  children of the DOM element itself for the purpose of layout tree
  building.
2023-05-25 14:42:24 +02:00
Andreas Kling
6fb661e781 LibWeb: Make HTMLDivElement not "final"
This is to prepare for making some custom internal divs inside the input
element UA shadow tree.
2023-05-25 14:42:24 +02:00
Sam Atkins
c0e61f92c0 LibWeb: Remove now-unused parse_css_value(ComponentValue) method
:^)
2023-05-25 06:36:10 +02:00
Sam Atkins
7e8ed996c9 LibWeb: Use new StyleValue parsing for transform-origin 2023-05-25 06:36:10 +02:00
Sam Atkins
f759a16087 LibWeb: Use new StyleValue parsing for text-decoration 2023-05-25 06:36:10 +02:00
Sam Atkins
a473f6074d LibWeb: Use new StyleValue parsing for text-decoration-line 2023-05-25 06:36:10 +02:00
Sam Atkins
a7a61c4cd9 LibWeb: Use new StyleValue parsing for overflow 2023-05-25 06:36:10 +02:00
Sam Atkins
2da15f987f LibWeb: Use new StyleValue parsing for list-style 2023-05-25 06:36:10 +02:00
Sam Atkins
7386ed7cfb LibWeb: Use new StyleValue parsing for content 2023-05-25 06:36:10 +02:00
Sam Atkins
c8626f2294 LibWeb: Use new StyleValue parsing for font and font-family 2023-05-25 06:36:10 +02:00
Sam Atkins
100adffdfb LibWeb: Use new StyleValue parsing for flex-flow 2023-05-25 06:36:10 +02:00
Sam Atkins
5d8b01ad04 LibWeb: Use new StyleValue parsing for border and its sided versions 2023-05-25 06:36:10 +02:00
Sam Atkins
91c9d10a78 LibWeb: Use new StyleValue parsing for flex
To make this work, we also add `none` as a valid identifier for `flex`.
(This is correct, we just didn't need it before.)
2023-05-25 06:36:10 +02:00
Sam Atkins
021fd15434 LibWeb: Use new StyleValue parsing for background-size 2023-05-25 06:36:10 +02:00
Sam Atkins
8e34bdc123 LibWeb: Use new StyleValue parsing for background-repeat 2023-05-25 06:36:10 +02:00
Sam Atkins
a0ec05ef81 LibWeb: Use new StyleValue parsing for background-position[-x,-y] 2023-05-25 06:36:10 +02:00
Sam Atkins
b0fe07cba3 LibWeb: Use new StyleValue parsing for background 2023-05-25 06:36:10 +02:00
Sam Atkins
d90ad19201 LibWeb: Use new StyleValue parsing for "simple" properties
That is, properties that don't have a bespoke parsing function.
2023-05-25 06:36:10 +02:00
Sam Atkins
bcacc2357e LibWeb: Implement smarter CSS StyleValue parsing
We know what types and identifiers a property can accept, so we can use
that information to only parse things that can be accepted. This solves
some awkward ambiguity problems that we have now or will face in the
future, including:

- Is `0` a number or a length with no unit?
- Is `3.5` a number or a ratio?
- Is `bottom` an identifier, or a custom-ident?

Two CSS Parser methods are introduced here:

`parse_css_value_for_property()` attempts to parse a StyleValue that the
property can accept, skipping any types that it doesn't want.

`parse_css_value_for_properties()` does the same, but takes multiple
PropertyIDs and additionally returns which one the parsed StyleValue is
for. This is intended for parsing shorthands, so you can give it a list
of longhands you haven't yet parsed.

Subsequent commits will actually use these new methods.
2023-05-25 06:36:10 +02:00
Sam Atkins
da4b2d9ca3 LibWeb: Cache initial property values when parsing background
Previously we were looking these up once per background layer. Let's not
do that. :^)
2023-05-25 06:36:10 +02:00
Sam Atkins
aad2f0963f LibWeb: Teach the CSS parser about extra color keywords
All of these identifiers can be treated as a color, so let's make sure
the parser understands that.
2023-05-25 06:36:10 +02:00
Sam Atkins
465ecf37c2 LibWeb: Make property_id_from_string() return Optional 2023-05-25 06:36:10 +02:00
Sam Atkins
03613dc14d LibWeb: Make value_id_from_string() return Optional 2023-05-25 06:36:10 +02:00
Sam Atkins
6f3e48db57 LibWeb: Fill in some missing property data and bodge extra types
We don't yet have generic parsing support for `<filter-value-list>` or
`<paint>`, so listing them here confuses the new StyleValue parsing code
I'm working on. For now, let's skip `<filter-value-list>` since it's
only used in one pkace which manually parses it, and list the parts of
`<paint>` instead which are taken from here:
https://www.w3.org/TR/SVG2/painting.html#SpecifyingPaint
2023-05-25 06:36:10 +02:00
Sam Atkins
5533413061 LibWeb: Remove "Invalid" StyleValue type
We never actually use this, we always initialize StyleValues with a
proper type.
2023-05-25 06:36:10 +02:00
kleines Filmröllchen
fc5cab5c21 Everywhere: Use MonotonicTime instead of Duration
This is easily identifiable by anyone who uses Duration::now_monotonic,
and any downstream users of that data.
2023-05-24 23:18:07 +02:00
kleines Filmröllchen
effcd080ca Userland: Remove remaining users of Duration::now_realtime()
This is a clear sign that they want to use a UnixDateTime instead.

This also adds support for placing durations and date times into SQL
databases via their millisecond offset to UTC.
2023-05-24 23:18:07 +02:00
kleines Filmröllchen
213025f210 AK: Rename Time to Duration
That's what this class really is; in fact that's what the first line of
the comment says it is.

This commit does not rename the main files, since those will contain
other time-related classes in a little bit.
2023-05-24 23:18:07 +02:00