Skip to content

Truly independent web browser

LibWeb: Accept flip-x and flip-y try tactics

Andreas Klinga892b431a66e
diff --git a/Libraries/LibWeb/CSS/Enums.json b/Libraries/LibWeb/CSS/Enums.json
index aae17020a1f..3cd7d861883 100644
--- a/Libraries/LibWeb/CSS/Enums.json
+++ b/Libraries/LibWeb/CSS/Enums.json
@@ -1218,7 +1218,9 @@
"try-tactic": [
"flip-block",
"flip-inline",
- "flip-start"
+ "flip-start",
+ "flip-x",
+ "flip-y"
],
"unicode-bidi": [
"bidi-override",
diff --git a/Libraries/LibWeb/CSS/Keywords.json b/Libraries/LibWeb/CSS/Keywords.json
index ea7cbf19c08..470515ca3db 100644
--- a/Libraries/LibWeb/CSS/Keywords.json
+++ b/Libraries/LibWeb/CSS/Keywords.json
@@ -249,6 +249,8 @@
"flip-block",
"flip-inline",
"flip-start",
+ "flip-x",
+ "flip-y",
"flow",
"flow-root",
"forwards",
diff --git a/Libraries/LibWeb/Rust/src/css/computed_value_types.rs b/Libraries/LibWeb/Rust/src/css/computed_value_types.rs
index cb85f4c31ee..170399dcd48 100644
--- a/Libraries/LibWeb/Rust/src/css/computed_value_types.rs
+++ b/Libraries/LibWeb/Rust/src/css/computed_value_types.rs
@@ -825,7 +825,7 @@ pub struct RetainedPositionAreaList {
#[repr(C)]
pub struct ComputedPositionTryFallback {
pub name: crate::css::retained_fly_string::RetainedUtf16FlyString,
- pub tactics: [u8; 3],
+ pub tactics: [u8; 5],
pub tactic_count: usize,
pub has_position_area: bool,
pub position_area: RetainedPositionAreaList,
diff --git a/Libraries/LibWeb/Rust/src/css/parser/value_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/value_parser.rs
index e4a5ffed808..6f31ff9d73b 100644
--- a/Libraries/LibWeb/Rust/src/css/parser/value_parser.rs
+++ b/Libraries/LibWeb/Rust/src/css/parser/value_parser.rs
@@ -2583,7 +2583,11 @@ fn parse_position_try_fallbacks_property(context: &ParseContext, values: &[Compo
if let Some(keyword) = value.ident().and_then(keyword_from_ascii_case_insensitive)
&& matches!(
keyword,
- keyword::FLIP_BLOCK | keyword::FLIP_INLINE | keyword::FLIP_START
+ keyword::FLIP_BLOCK
+ | keyword::FLIP_INLINE
+ | keyword::FLIP_START
+ | keyword::FLIP_X
+ | keyword::FLIP_Y
)
{
if dashed_ident.is_some() {
diff --git a/Libraries/LibWeb/Rust/src/css/table_group_builder.rs b/Libraries/LibWeb/Rust/src/css/table_group_builder.rs
index de7c4534483..d6fbfee2ebf 100644
--- a/Libraries/LibWeb/Rust/src/css/table_group_builder.rs
+++ b/Libraries/LibWeb/Rust/src/css/table_group_builder.rs
@@ -2653,7 +2653,7 @@ fn build_anchor_group(
let mut append_fallback = |data: &StyleValueData| {
let mut fallback = ComputedPositionTryFallback {
name: RetainedUtf16FlyString::none(),
- tactics: [0; 3],
+ tactics: [0; 5],
tactic_count: 0,
has_position_area: false,
position_area: RetainedPositionAreaList::from_vec(Vec::new()),
@@ -2663,8 +2663,8 @@ fn build_anchor_group(
fallback.name = custom_ident.to_fly_string();
} else if let Some(tactic) = keyword_of(data).and_then(crate::css::css_enums::keyword_to_try_tactic) {
assert!(
- fallback.tactic_count < 3,
- "a try tactic list holds at most three tactics"
+ fallback.tactic_count < 5,
+ "a try tactic list holds at most five tactics"
);
fallback.tactics[fallback.tactic_count] = tactic;
fallback.tactic_count += 1;
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/parsing/position-try-fallbacks-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/parsing/position-try-fallbacks-computed.txt
index 589753c485e..518bb12850c 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/parsing/position-try-fallbacks-computed.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/parsing/position-try-fallbacks-computed.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 24 tests
-20 Pass
-4 Fail
+24 Pass
Pass Property position-try-fallbacks value 'none'
Pass Property position-try-fallbacks value 'flip-block'
Pass Property position-try-fallbacks value 'flip-inline'
@@ -22,9 +21,9 @@ Pass Property position-try-fallbacks value '--foo, left, --bar'
Pass Property position-try-fallbacks value '--foo, flip-start, left'
Pass Property position-try-fallbacks value '--foo flip-start, left'
Pass Property position-try-fallbacks value 'left, --bar flip-start'
-Fail Property position-try-fallbacks value 'flip-y'
-Fail Property position-try-fallbacks value 'flip-x'
-Fail Property position-try-fallbacks value 'flip-y, flip-x'
-Fail Property position-try-fallbacks value 'flip-start flip-x flip-y'
+Pass Property position-try-fallbacks value 'flip-y'
+Pass Property position-try-fallbacks value 'flip-x'
+Pass Property position-try-fallbacks value 'flip-y, flip-x'
+Pass Property position-try-fallbacks value 'flip-start flip-x flip-y'
Pass Property position-try-fallbacks has initial value none
Pass Property position-try-fallbacks does not inherit
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/parsing/position-try-fallbacks-parsing.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/parsing/position-try-fallbacks-parsing.txt
index 8a7a35bfc02..e0bde370c24 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/parsing/position-try-fallbacks-parsing.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/parsing/position-try-fallbacks-parsing.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 57 tests
-45 Pass
-12 Fail
+57 Pass
Pass e.style['position-try-fallbacks'] = "initial" should set the property value
Pass e.style['position-try-fallbacks'] = "inherit" should set the property value
Pass e.style['position-try-fallbacks'] = "unset" should set the property value
@@ -31,18 +30,18 @@ Pass e.style['position-try-fallbacks'] = "--foo, left, --bar" should set the pro
Pass e.style['position-try-fallbacks'] = "--foo, flip-start, left" should set the property value
Pass e.style['position-try-fallbacks'] = "--foo flip-start, left" should set the property value
Pass e.style['position-try-fallbacks'] = "left, --bar flip-start" should set the property value
-Fail e.style['position-try-fallbacks'] = "flip-x" should set the property value
-Fail e.style['position-try-fallbacks'] = "flip-x " should set the property value
-Fail e.style['position-try-fallbacks'] = "flip-start, flip-x" should set the property value
-Fail e.style['position-try-fallbacks'] = "flip-start flip-y, flip-x" should set the property value
-Fail e.style['position-try-fallbacks'] = "flip-start flip-y flip-x" should set the property value
-Fail e.style['position-try-fallbacks'] = "flip-x, --foo" should set the property value
-Fail e.style['position-try-fallbacks'] = "--bar, flip-x flip-start" should set the property value
-Fail e.style['position-try-fallbacks'] = "--bar flip-x" should set the property value
-Fail e.style['position-try-fallbacks'] = "--bar flip-y flip-x" should set the property value
-Fail e.style['position-try-fallbacks'] = "flip-y --foo" should set the property value
-Fail e.style['position-try-fallbacks'] = "flip-y flip-start --foo" should set the property value
-Fail e.style['position-try-fallbacks'] = "flip-start flip-inline flip-y flip-block flip-x" should set the property value
+Pass e.style['position-try-fallbacks'] = "flip-x" should set the property value
+Pass e.style['position-try-fallbacks'] = "flip-x " should set the property value
+Pass e.style['position-try-fallbacks'] = "flip-start, flip-x" should set the property value
+Pass e.style['position-try-fallbacks'] = "flip-start flip-y, flip-x" should set the property value
+Pass e.style['position-try-fallbacks'] = "flip-start flip-y flip-x" should set the property value
+Pass e.style['position-try-fallbacks'] = "flip-x, --foo" should set the property value
+Pass e.style['position-try-fallbacks'] = "--bar, flip-x flip-start" should set the property value
+Pass e.style['position-try-fallbacks'] = "--bar flip-x" should set the property value
+Pass e.style['position-try-fallbacks'] = "--bar flip-y flip-x" should set the property value
+Pass e.style['position-try-fallbacks'] = "flip-y --foo" should set the property value
+Pass e.style['position-try-fallbacks'] = "flip-y flip-start --foo" should set the property value
+Pass e.style['position-try-fallbacks'] = "flip-start flip-inline flip-y flip-block flip-x" should set the property value
Pass e.style['position-try-fallbacks'] = "none, flip-start" should not set the property value
Pass e.style['position-try-fallbacks'] = "flip-block flip-block" should not set the property value
Pass e.style['position-try-fallbacks'] = "flip-block flip-inline flip-inline" should not set the property value