mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +00:00
LibWeb/CSS: Replace Parser "current property" with a stack of contexts
`current_property_id()` is insufficient to determine if a quirk is allowed. For example, unitless lengths are allowed in certain properties, but NOT if they are inside a calc() or other function. It's also incorrect when we are parsing a longhand inside a shorthand. So instead, replace that with a stack of value-parsing contexts. For now, this is either properties or CSS functions, but in future can be expanded to include media features and other places. This lets us disallow quirks inside functions, like we're supposed to. It also lays the groundwork for being able to more easily determine what type a percentage inside a calculation should become, as this is based on the same stack of contexts.
This commit is contained in:
parent
619df0bc2c
commit
bc00ef8314
Notes:
github-actions[bot]
2025-01-13 11:00:39 +00:00
Author: https://github.com/AtkinsSJ
Commit: bc00ef8314
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3198
4 changed files with 196 additions and 76 deletions
|
@ -443,6 +443,18 @@ private:
|
|||
Vector<Token> m_tokens;
|
||||
TokenStream<Token> m_token_stream;
|
||||
|
||||
struct FunctionContext {
|
||||
StringView name;
|
||||
};
|
||||
using ValueParsingContext = Variant<PropertyID, FunctionContext>;
|
||||
Vector<ValueParsingContext> m_value_context;
|
||||
auto push_temporary_value_parsing_context(ValueParsingContext&& context)
|
||||
{
|
||||
m_value_context.append(context);
|
||||
return ScopeGuard { [&] { m_value_context.take_last(); } };
|
||||
}
|
||||
bool context_allows_quirky_length() const;
|
||||
|
||||
enum class ContextType {
|
||||
Unknown,
|
||||
Style,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue