mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 00:29:15 +00:00
LibWeb/CSS: Support overlay
keyword as alias to auto
in overflow
We don't yet have a system for "legacy value aliases", but until we have a lot of them we can handle them manually. We also have to do this in two places because parse_css_value_for_property() doesn't call any property-specific parsing code.
This commit is contained in:
parent
128b66e30d
commit
db75405881
Notes:
github-actions[bot]
2025-07-21 09:05:57 +00:00
Author: https://github.com/AtkinsSJ
Commit: db75405881
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5484
4 changed files with 56 additions and 2 deletions
|
@ -673,6 +673,17 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_css_value
|
||||||
if (auto parsed_value = parse_overflow_value(tokens); parsed_value && !tokens.has_next_token())
|
if (auto parsed_value = parse_overflow_value(tokens); parsed_value && !tokens.has_next_token())
|
||||||
return parsed_value.release_nonnull();
|
return parsed_value.release_nonnull();
|
||||||
return ParseError::SyntaxError;
|
return ParseError::SyntaxError;
|
||||||
|
case PropertyID::OverflowX:
|
||||||
|
case PropertyID::OverflowY:
|
||||||
|
if (auto parsed_value = parse_css_value_for_property(property_id, tokens); parsed_value && !tokens.has_next_token()) {
|
||||||
|
// https://drafts.csswg.org/css-overflow-3/#valdef-overflow-overlay
|
||||||
|
// User agents must also support the overlay keyword as a legacy value alias of auto.
|
||||||
|
// FIXME: Figure out a generic way of supporting legacy value aliases.
|
||||||
|
if (parsed_value->to_keyword() == Keyword::Overlay)
|
||||||
|
return CSSKeywordValue::create(Keyword::Auto);
|
||||||
|
return parsed_value.release_nonnull();
|
||||||
|
}
|
||||||
|
return ParseError::SyntaxError;
|
||||||
case PropertyID::PlaceContent:
|
case PropertyID::PlaceContent:
|
||||||
if (auto parsed_value = parse_place_content_value(tokens); parsed_value && !tokens.has_next_token())
|
if (auto parsed_value = parse_place_content_value(tokens); parsed_value && !tokens.has_next_token())
|
||||||
return parsed_value.release_nonnull();
|
return parsed_value.release_nonnull();
|
||||||
|
@ -3600,11 +3611,24 @@ RefPtr<CSSStyleValue const> Parser::parse_opacity_value(PropertyID property_id,
|
||||||
|
|
||||||
RefPtr<CSSStyleValue const> Parser::parse_overflow_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<CSSStyleValue const> Parser::parse_overflow_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
|
// https://drafts.csswg.org/css-overflow-3/#valdef-overflow-overlay
|
||||||
|
// User agents must also support the overlay keyword as a legacy value alias of auto.
|
||||||
|
// FIXME: Figure out a generic way of supporting legacy value aliases.
|
||||||
|
// FIXME: Even better, make parsing the longhands go through their proper parsing routine.
|
||||||
|
auto parse_an_overflow_longhand_value = [this](PropertyID property, auto& tokens) -> RefPtr<CSSStyleValue const> {
|
||||||
|
auto maybe_value = parse_css_value_for_property(property, tokens);
|
||||||
|
if (!maybe_value)
|
||||||
|
return nullptr;
|
||||||
|
if (maybe_value->to_keyword() == Keyword::Overlay)
|
||||||
|
return CSSKeywordValue::create(Keyword::Auto);
|
||||||
|
return maybe_value.release_nonnull();
|
||||||
|
};
|
||||||
|
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
auto maybe_x_value = parse_css_value_for_property(PropertyID::OverflowX, tokens);
|
auto maybe_x_value = parse_an_overflow_longhand_value(PropertyID::OverflowX, tokens);
|
||||||
if (!maybe_x_value)
|
if (!maybe_x_value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
auto maybe_y_value = parse_css_value_for_property(PropertyID::OverflowY, tokens);
|
auto maybe_y_value = parse_an_overflow_longhand_value(PropertyID::OverflowY, tokens);
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
if (maybe_y_value) {
|
if (maybe_y_value) {
|
||||||
return ShorthandStyleValue::create(PropertyID::Overflow,
|
return ShorthandStyleValue::create(PropertyID::Overflow,
|
||||||
|
|
|
@ -2644,6 +2644,9 @@
|
||||||
"initial": "visible",
|
"initial": "visible",
|
||||||
"valid-types": [
|
"valid-types": [
|
||||||
"overflow"
|
"overflow"
|
||||||
|
],
|
||||||
|
"valid-identifiers": [
|
||||||
|
"overlay"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"overflow-y": {
|
"overflow-y": {
|
||||||
|
@ -2652,6 +2655,9 @@
|
||||||
"initial": "visible",
|
"initial": "visible",
|
||||||
"valid-types": [
|
"valid-types": [
|
||||||
"overflow"
|
"overflow"
|
||||||
|
],
|
||||||
|
"valid-identifiers": [
|
||||||
|
"overlay"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"padding": {
|
"padding": {
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<style>
|
||||||
|
div {
|
||||||
|
width: 15em;
|
||||||
|
height: 10em;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div>
|
||||||
|
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||||
|
</div>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/8063">
|
||||||
|
<link rel="match" href="../../../../expected/wpt-import/css/css-overflow/overflow-overlay-ref.html">
|
||||||
|
<style>
|
||||||
|
div {
|
||||||
|
width: 15em;
|
||||||
|
height: 10em;
|
||||||
|
overflow: overlay;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div>
|
||||||
|
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||||
|
</div>
|
Loading…
Add table
Add a link
Reference in a new issue