summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/Parser/Token.h
AgeCommit message (Collapse)Author
2023-03-22LibWeb: Store the original representation of CSS tokensSam Atkins
This is required for the `<urange>` type, and custom properties, to work correctly, as both need to know exactly what the original text was.
2023-02-15LibWeb: Remove unused includes for DeprecatedStringSam Atkins
Missed these before, oops.
2023-02-13LibWeb: Convert CSS Token::to_debug_string() to ::to_string() :^)Sam Atkins
Using from_utf8_short_string() for all cases that are <= 3 bytes long. Which is almost all of the static ones.
2023-02-13LibWeb: Convert CSS Token/ComponentValue::to_debug_string() to StringSam Atkins
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.
2023-02-13LibWeb: Convert CSS Token value to new FlyStringSam Atkins
2023-02-13LibWeb: Return StringViews from CSS Token bracket-string gettersSam Atkins
These don't need to be full Strings, so let's be lightweight.
2023-01-09AK+Everywhere: Rename FlyString to DeprecatedFlyStringTimothy Flynn
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.
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
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-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
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-11-02LibWeb: Add helper functions to create CSS parser tokensAndreas Kling
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.
2022-04-12LibWeb: Move Token and Tokenizer into Parser namespaceSam Atkins
2022-03-30LibWeb: Add basic support for the attr() CSS functionSimon Wanner
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>?)`
2022-03-22LibWeb: Remove separate Token::m_unit fieldSam Atkins
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
2022-03-22LibWeb: Use CSS::Number for Token numeric valuesSam Atkins
2022-03-22LibWeb: Use floats instead of doubles for CSS numbersSam Atkins
Using doubles isn't necessary, and they make things slightly bigger and slower, so let's use floats instead.
2022-03-21LibWeb: Use llround in CSS::Token::to_closest_integerHendiadyoin1
This should be equivalent, and much shorter than a clamp and static_cast
2022-03-21LibWeb: Use a u32 for a delim tokens valueHendiadyoin1
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.
2021-11-24LibWeb: Implement CSS::Token::to_string()Sam Atkins
This outputs valid CSS, as opposed to to_debug_string().
2021-11-19LibWeb: Convert CSS Token::m_value from StringBuilder to FlyStringSam Atkins
Again, this value does not change once we have finished creating the Token, so it can be more lightweight.
2021-11-19LibWeb: Convert CSS Token::m_unit from StringBuilder to FlyStringSam Atkins
This value doesn't change once it's assigned to the Token, so it can be more lightweight than a StringBuilder.
2021-11-19LibWeb: Break friendship between CSS Token and Parser :^(Sam Atkins
The Parser no longer needs to mess with Token's internals, since we have getter functions that are safer.
2021-11-19LibWeb: Return numeric values from Token value gettersSam Atkins
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.
2021-11-19LibWeb: Convert numeric tokens to numbers in CSS TokenizerSam Atkins
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.
2021-11-04LibWeb: Convert NumberType::Integer to i64 instead of i32networkException
2021-10-23LibWeb: Record position information in CSS TokensSam Atkins
This is a requirement to be able to use the Tokens for syntax highlighting.
2021-10-19LibWeb: Distinguish between integer and float in NumericStyleValueSam Atkins
We have this information when parsing, and some properties specifically only allow integers, so it makes sense to keep that around.
2021-09-03Everywhere: Use my shiny new serenityos.org email :^)Sam Atkins
2021-07-31LibWeb: Make CSS 'An+B' parsing spec-compliantSam Atkins
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.
2021-07-31LibWeb: Parse CSS selectors according to the specSam Atkins
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.
2021-07-31LibWeb: Get CSS @import rules working in new parserSam Atkins
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.
2021-07-22LibWeb: Implement ImageStyleValue parsingSam Atkins
Later we will want to make a distinction between URL and Image values, but this works for now.
2021-07-22LibWeb: Implement CSS color parsing from TokensSam Atkins
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.
2021-07-11LibWeb: Increase clarity with CSS token debug loggingSam Atkins
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.
2021-07-11LibWeb: Implement CSS::parse_css_value()Sam Atkins
A lot of this is not spec-compliant and copied from the old parser. In future PRs, we can revise it.
2021-07-11LibWeb: Give CSS Token and StyleComponentValueRule matching is() funcsSam Atkins
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.
2021-07-11LibWeb: Rename CSS::Token::TokenType -> TypeSam Atkins
2021-07-11LibWeb: Add convenience methods to CSS::Parser::TokenSam Atkins
Some of these will be removed later, when we move to using is() exclusively.
2021-04-29Everywhere: Use "the SerenityOS developers." in copyright headersLinus Groh
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).
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
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 *
2021-03-09LibWeb: Run clang-format on CSS/Parser/Token.hAndreas Kling
2021-03-09LibWeb: Add specification-based CSS tokenizerAndreas Kling
Original work by @stelar7 for #2628.