LibWeb: Parse and propagate touch-action CSS property

Co-authored-by: Sam Atkins <sam@ladybird.org>
This commit is contained in:
Mark Langen 2025-03-16 18:44:49 -07:00 committed by Sam Atkins
commit 6cbb5d2785
Notes: github-actions[bot] 2025-05-06 11:23:01 +00:00
21 changed files with 364 additions and 19 deletions

View file

@ -1580,6 +1580,54 @@ Isolation ComputedProperties::isolation() const
return keyword_to_isolation(value.to_keyword()).release_value();
}
TouchActionData ComputedProperties::touch_action() const
{
auto const& touch_action = property(PropertyID::TouchAction);
if (touch_action.is_keyword()) {
switch (touch_action.to_keyword()) {
case Keyword::Auto:
return TouchActionData {};
case Keyword::None:
return TouchActionData::none();
case Keyword::Manipulation:
return TouchActionData { .allow_other = false };
default:
VERIFY_NOT_REACHED();
}
}
if (touch_action.is_value_list()) {
TouchActionData touch_action_data = TouchActionData::none();
for (auto const& value : touch_action.as_value_list().values()) {
switch (value->as_keyword().keyword()) {
case Keyword::PanX:
touch_action_data.allow_right = true;
touch_action_data.allow_left = true;
break;
case Keyword::PanLeft:
touch_action_data.allow_left = true;
break;
case Keyword::PanRight:
touch_action_data.allow_right = true;
break;
case Keyword::PanY:
touch_action_data.allow_up = true;
touch_action_data.allow_down = true;
break;
case Keyword::PanUp:
touch_action_data.allow_up = true;
break;
case Keyword::PanDown:
touch_action_data.allow_down = true;
break;
default:
VERIFY_NOT_REACHED();
}
}
return touch_action_data;
}
return TouchActionData {};
}
Containment ComputedProperties::contain() const
{
Containment containment = {};