Age | Commit message (Collapse) | Author |
|
This is required for the `<urange>` type, and custom properties, to work
correctly, as both need to know exactly what the original text was.
|
|
Missed these before, oops.
|
|
Using from_utf8_short_string() for all cases that are <= 3 bytes long.
Which is almost all of the static ones.
|
|
These are only used for debugging, so I've decided that logging the
ErrorOr<String> itself is fine instead of trying to handle that error
more gracefully in those cases. If you're getting OOM trying to debug
log things, you have bigger problems.
|
|
|
|
These don't need to be full Strings, so let's be lightweight.
|
|
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.
|
|
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.
|
|
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 :^)
|
|
These will be used when resolving calc() values in StyleComputer.
It's indeed strange that calc() resolves to tokens, but it's how the
engine currently handles those things. There is room for improvement.
|
|
|
|
CSS Values and Units Module Level 5 defines attr as:
`attr(<q-name> <attr-type>?, <declaration-value>?)`
This implementation does not contain support for the type argument,
effectively supporting `attr(<q-name>, <declaration-value>?)`
|
|
Dimension tokens don't make use of the m_value string for anything else,
so we can sneak the unit string in there.
- Token goes from 72 to 64 bytes
- StyleComponentValueRule goes from 80 to 72 bytes
|
|
|
|
Using doubles isn't necessary, and they make things slightly bigger and
slower, so let's use floats instead.
|
|
This should be equivalent, and much shorter than a clamp and static_cast
|
|
The spec says:
> <delim-token> has a value composed of a single code point.
So using StringView is a bit overkill.
This also allows us to use switch statements in the future.
|
|
This outputs valid CSS, as opposed to to_debug_string().
|
|
Again, this value does not change once we have finished creating the
Token, so it can be more lightweight.
|
|
This value doesn't change once it's assigned to the Token, so it can be
more lightweight than a StringBuilder.
|
|
The Parser no longer needs to mess with Token's internals, since we have
getter functions that are safer.
|
|
This saves user code from having to parse the numbers, as we already did
that while Tokenizing. :^)
As a bonus, we now round extremely large integers to the closest
available value, like the spec tells us to.
|
|
The spec wants us to produce numeric values as the Tokenizer sees them,
rather than waiting until the parse stage. This is a first step towards
that.
|
|
|
|
This is a requirement to be able to use the Tokens for syntax
highlighting.
|
|
We have this information when parsing, and some properties specifically
only allow integers, so it makes sense to keep that around.
|
|
|
|
Parsing this pattern from CSS tokens turns out to be slightly crazy, but
thankfully well documented in the spec.
The spec lists the cases in order of simple -> complicated, but this
would cause problems in code, since `<n-dimension> <signed-.integer>`
would never by reached, as `<n-dimension>` comes before. Instead, I
have grouped them by their first token.
Also renamed the NthChildPattern class to ANPlusBPattern, to match spec
terminology.
|
|
The spec does not directly tell us how to parse selectors, so there are
likely some bugs here, but I've used the spec language where possible.
This is very much based on the previous selector parsing code.
Any parse error inside a selector makes the entire SelectorList
invalid, so nothing is returned.
|
|
Also added css-import.html, which tests the 3 syntax variations on
`@import` statements. Note that the optional media-query parameter to
`@import` is not handled yet.
|
|
Later we will want to make a distinction between URL and Image values,
but this works for now.
|
|
This was broken when we switched away from using StringStyleValues.
While I was at it, I have implemented hsl/a() and the percentage
syntax for rgb/a().
As a bonus, added `colors.html` as a test page for the various CSS
color syntaxes, since nothing was testing rgb() or rgba() before.
Much of the parsing code in LibGFX/Color.h seems to be centered
around CSS color values, but this is not used by the new Parser.
(And can't be used, because it requires a String value and we have
a list of Tokens of some kind instead.) Maybe that should be removed
from there when the new CSS parser is operational.
|
|
Had to adjust some places that were using Token.to_string() for
non-debug-logging purposes. Changed its name to to_debug_string()
to make the usage clearer.
|
|
A lot of this is not spec-compliant and copied from the old parser.
In future PRs, we can revise it.
|
|
The end goal here is to make the two classes mostly interchangeable, as
the CSS spec requires that the various parser algorithms can take a
stream of either class, and we want to have that functionality without
needing to duplicate all of the code.
|
|
|
|
Some of these will be removed later, when we move to using is()
exclusively.
|
|
We had some inconsistencies before:
- Sometimes "The", sometimes "the"
- Sometimes trailing ".", sometimes no trailing "."
I picked the most common one (lowecase "the", trailing ".") and applied
it to all copyright headers.
By using the exact same string everywhere we can ensure nothing gets
missed during a global search (and replace), and that these
inconsistencies are not spread any further (as copyright headers are
commonly copied to new files).
|
|
SPDX License Identifiers are a more compact / standardized
way of representing file license information.
See: https://spdx.dev/resources/use/#identifiers
This was done with the `ambr` search and replace tool.
ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
|
|
|
|
Original work by @stelar7 for #2628.
|