Commit graph

593 commits

Author SHA1 Message Date
Sam Atkins
92a0d4c0af LibWeb: Split BackgroundStyleValue out of StyleValue.{h,cpp} 2023-03-25 16:56:04 +00:00
Sam Atkins
777d3e73f9 LibWeb: Split AngleStyleValue out of StyleValue.{h,cpp} 2023-03-25 16:56:04 +00:00
Sam Atkins
fcd4e68959 LibWeb: Use actual token representations when parsing CSS <urange>
nasty_hacks--; // :^)
2023-03-22 19:45:40 +01:00
implicitfield
a3d43b067a LibWeb: Parse CSS identifiers case-insensitively 2023-03-21 16:07:44 +00: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
Mathis Wiehl
3a45bba4e0 LibWeb: Load alternative font urls if others fail
We don't support all parts of the font formats we assume as "supported"
in the CSS parser. For example, if an open type font has a CFF table, we
reject loading it. This meant that until now, when such an
unsupported-supported font url was first in the list of urls, we
couldn't load it at all, even when we would support a later url.

To resolve that, try loading all font urls one after each other, in case
we are not able to load the higher priority one.

This also resolves a FIXME related to spec compliant url prioritization.
Our CSS parser already filters and prioritizes font src urls in
compliance with the spec. However, we still had to resort to brittle
file extension matching, because some websites don't set the `format`
and if the first url in a src list happened to be one we don't support,
the font could not be loaded at all. This now is unnecessary because we
can try and discard the urls instead.
2023-03-18 13:47:51 +01:00
Kenneth Myhra
be958a14cf LibWeb: Use from_deprecated_fly_string() instead of from_utf8()
Use FlyString::from_deprecated_fly_string() in these instances instead
of FlyString::from_utf8(). As we convert to new FlyString/String we want
to be aware of these potential unnecessary allocations.
2023-03-11 18:32:33 +00:00
Andreas Kling
a504ac3e2a Everywhere: Rename equals_ignoring_case => equals_ignoring_ascii_case
Let's make it clear that these functions deal with ASCII case only.
2023-03-10 13:15:44 +01:00
Luke Wilde
f7ff1fd985 LibWeb: Remove CSS::Parser::ParsingContext's default constructor
This relied on pulling the current realm from the main thread VM, which
requires an execution context to be on the VM's stack. This heavily
relied on the dummy execution context that is always on the stack, for
example, when parsing the UA style sheets where no JavaScript is
running.
2023-03-07 11:51:12 +00:00
Sam Atkins
ca30914fe9 LibWeb: Propagate errors from CSS Parser construction
This requires Parser to be movable, so we remove the `default`
destructors from Parser and TokenStream, and give them both move
constructors. Since TokenStream only holds a reference to its tokens,
(and it needs to, to avoid copying when given eg a function's contents,)
we add a manual move constructor for Parser which creates a new
TokenStream from the new Parser's tokens, and then manually copies the
old TokenStream's state.
2023-03-07 00:43:36 +01:00
Sam Atkins
235018046e LibWeb: Use free functions for parsing in @Supports 2023-03-07 00:43:36 +01:00
Sam Atkins
17618989a3 LibWeb: Propagate errors from CSS Tokenizer construction
Instead of constructing a Tokenizer and then calling parse() on it, we
now call `Tokenizer::tokenize(...)` directly. (Renamed from `parse()`
because this is a Tokenizer, not a Parser.)
2023-03-07 00:43:36 +01:00
Andreas Kling
359d6e7b0b Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
2023-03-06 23:46:35 +01:00
Andreas Kling
689ca370d4 Everywhere: Remove NonnullRefPtr.h includes 2023-03-06 23:46:35 +01:00
Andreas Kling
8a48246ed1 Everywhere: Stop using NonnullRefPtrVector
This class had slightly confusing semantics and the added weirdness
doesn't seem worth it just so we can say "." instead of "->" when
iterating over a vector of NNRPs.

This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
2023-03-06 23:46:35 +01:00
MacDue
3676f5085e LibWeb: Replace RefPtr with ValueComparingRefPtr in StyleValue
Like the name suggests this pointer type compares its pointees by value
rather than just by the pointer. This is needed for the defaulted
struct Properties equality operator.

This commit also contains a few changes to StyleValue such as replacing
the operator==()s with a .equals() again. This is done to avoid the new
reversed operator==()s ambiguity in C++20.
2023-02-20 10:50:20 +01:00
Sam Atkins
13d2111b74 LibWeb: Port Selector to new Strings
Also use `Infra::is_ascii_case_insensitive_match()` in some appropriate
places, after checking the specs.
2023-02-19 00:51:16 +01:00
Sam Atkins
c2f0b20d6b LibWeb: Port FontFace to new Strings 2023-02-19 00:51:16 +01:00
Sam Atkins
33e9c4e1b2 LibWeb: Port GeneralEnclosed to new Strings 2023-02-19 00:51:16 +01:00
Sam Atkins
2026ea557e LibWeb: Use is_ascii_case_insensitive_match() where the spec says to 2023-02-19 00:46:47 +01:00
Kenneth Myhra
64e4d3fd94 LibWeb: Make factory method of CSS::CSSSupportsRule fallible 2023-02-18 00:52:47 +01:00
Kenneth Myhra
5d9bc378c3 LibWeb: Make factory method of CSS::MediaList fallible 2023-02-18 00:52:47 +01:00
Kenneth Myhra
a49ea467ad LibWeb: Make factory method of CSS::CSSStyleSheet fallible 2023-02-18 00:52:47 +01:00
Kenneth Myhra
4f4a908e5f LibWeb: Make factory method of CSS::CSSStyleRule fallible 2023-02-18 00:52:47 +01:00
Kenneth Myhra
c950d1904a LibWeb: Make factory methods of CSS::CSSStyleDeclaration fallible 2023-02-18 00:52:47 +01:00
Kenneth Myhra
48872cd190 LibWeb: Make factory methods of CSS::CSSRuleList fallible 2023-02-18 00:52:47 +01:00
Kenneth Myhra
5601f439f9 LibWeb: Make factory method of CSS::CSSMediaRule fallible 2023-02-18 00:52:47 +01:00
Kenneth Myhra
d53d8cacec LibWeb: Make factory method of CSS::CSSImportRule fallible 2023-02-18 00:52:47 +01:00
Kenneth Myhra
ff8495de35 LibWeb: Make factory method of CSS::CSSFontFaceRule fallible 2023-02-18 00:52:47 +01:00
Sam Atkins
a381ce9519 LibWeb: Port CSS::Supports to new Strings 2023-02-15 12:48:26 -05:00
Sam Atkins
41c4cc95e4 LibWeb: Port CSS::Parser::Rule to new Strings
`Rule::to_deprecated_string()` and
`DeclarationOrAtRule::to_deprecated_string()` are not used anywhere, so
we can just delete them.
2023-02-15 12:48:26 -05:00
Sam Atkins
bee32b6cd2 LibWeb: Port CSS::Parser::Declaration to new Strings 2023-02-15 12:48:26 -05:00
Sam Atkins
a168cda4a7 LibWeb: Port CSS::Parser::ComponentValue to new Strings 2023-02-15 12:48:26 -05:00
Sam Atkins
05c1b09621 LibWeb: Port CSS::Parser::Function to new Strings 2023-02-15 12:48:26 -05:00
Sam Atkins
abc01cc9fe AK+Tests+LibWeb: Make URL::complete_url() take a StringView
All it does is pass this to `URLParser::parse()` which takes a
StringView, so we might as well take one here too.
2023-02-15 12:48:26 -05:00
Sam Atkins
8af65108e4 LibWeb: Construct CSS Tokenizer and Parser with a StringView encoding
This doesn't need to be a full (Deprecated)String, so let's not force it
to be.
2023-02-15 12:48:26 -05:00
Sam Atkins
476ec563bc LibWeb: Convert CSS Token::to_debug_string() to ::to_string() :^)
Using from_utf8_short_string() for all cases that are <= 3 bytes long.
Which is almost all of the static ones.
2023-02-13 14:35:40 +00:00
Aliaksandr Kalenik
ab99e95549 LibWeb: Parse font-stretch CSS property 2023-02-03 12:49:13 +00: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
martinfalisse
0448547553 LibWeb: Parse min and max-content
Parse min and max-content as well as use its values in the GridTrackSize
class.
2023-01-21 14:35:00 +01:00
martinfalisse
9d99bd8258 LibWeb: Use String class in certain CSS Grid classes
Converts the remaining instances of DeprecatedString to String in the
CSS Grid classes.
2023-01-21 14:35:00 +01: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
7d40e3eb0d LibWeb: Replace all px Length creation with Length::make_px(CSSPixels) 2023-01-05 17:42:31 +01:00
MacDue
d3588a9a2b LibWeb: Support calc() values in background-position 2022-12-11 22:09:24 +01: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
MacDue
28028be2fc LibWeb: Support repeating-radial-gradient()s 2022-12-03 09:06:51 -05:00