Truly independent web browser
LibWeb: Make -webkit-box-* properties apply only to -webkit-box
sideshowbarker28a45c2c2fd3
diff --git a/Libraries/LibWeb/CSS/Enums.json b/Libraries/LibWeb/CSS/Enums.jsonindex 9dc8987f30d..639c9ee0049 100644--- a/Libraries/LibWeb/CSS/Enums.json+++ b/Libraries/LibWeb/CSS/Enums.json@@ -1315,10 +1315,23 @@"hidden","visible"],+ "webkit-box-align": [+ "stretch",+ "start",+ "end",+ "center",+ "baseline"+ ],"webkit-box-orient": ["horizontal","vertical"],+ "webkit-box-pack": [+ "start",+ "end",+ "center",+ "justify"+ ],"white-space": ["normal","pre",diff --git a/Libraries/LibWeb/CSS/Properties.json b/Libraries/LibWeb/CSS/Properties.jsonindex 82f5d766608..43394e7d672 100644--- a/Libraries/LibWeb/CSS/Properties.json+++ b/Libraries/LibWeb/CSS/Properties.json@@ -105,13 +105,35 @@"legacy-alias-for": "border-top-right-radius"},"-webkit-box-align": {- "legacy-alias-for": "align-items"+ "style-group": "AlignmentValues",+ "animation-type": "discrete",+ "inherited": false,+ "initial": "stretch",+ "requires-computation": "never",+ "valid-types": [+ "webkit-box-align"+ ]},"-webkit-box-flex": {- "legacy-alias-for": "flex-grow"+ "style-group": "AlignmentValues",+ "animation-type": "discrete",+ "inherited": false,+ "initial": "0",+ "requires-computation": "cascaded-value",+ "valid-types": [+ "number [-∞,∞]"+ ]},"-webkit-box-ordinal-group": {- "legacy-alias-for": "order"+ "style-group": "AlignmentValues",+ "affects-stacking-context": true,+ "animation-type": "discrete",+ "inherited": false,+ "initial": "1",+ "requires-computation": "cascaded-value",+ "valid-types": [+ "integer [1,∞]"+ ]},"-webkit-box-orient": {"style-group": "AlignmentValues",@@ -125,7 +147,14 @@]},"-webkit-box-pack": {- "legacy-alias-for": "justify-content"+ "style-group": "AlignmentValues",+ "animation-type": "discrete",+ "inherited": false,+ "initial": "start",+ "requires-computation": "never",+ "valid-types": [+ "webkit-box-pack"+ ]},"-webkit-box-shadow": {"legacy-alias-for": "box-shadow"diff --git a/Libraries/LibWeb/Rust/src/css/computed_value_types.rs b/Libraries/LibWeb/Rust/src/css/computed_value_types.rsindex 18ec62441f3..513f1095f56 100644--- a/Libraries/LibWeb/Rust/src/css/computed_value_types.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_value_types.rs@@ -79,12 +79,16 @@ pub struct ComputedGap {#[derive(Clone, PartialEq)]pub struct AlignmentValues {pub webkit_box_orient: u8,+ pub webkit_box_align: u8,+ pub webkit_box_pack: u8,pub flex_direction: u8,pub flex_wrap: u8,pub flex_basis: ComputedFlexBasis,pub flex_grow: f64,pub flex_shrink: f64,+ pub webkit_box_flex: f64,pub order: i32,+ pub webkit_box_ordinal_group: i32,pub align_content: u8,pub align_items: u8,pub align_self: u8,diff --git a/Libraries/LibWeb/Rust/src/css/computed_value_views.rs b/Libraries/LibWeb/Rust/src/css/computed_value_views.rsindex bf4db37025a..6d3b9d4c3fe 100644--- a/Libraries/LibWeb/Rust/src/css/computed_value_views.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_value_views.rs@@ -672,11 +672,15 @@ scalar_accessors! {}alignment: {webkit_box_orient: u8 => webkit_box_orient,+ webkit_box_align: u8 => webkit_box_align,+ webkit_box_pack: u8 => webkit_box_pack,flex_direction: u8 => flex_direction,flex_wrap: u8 => flex_wrap,flex_grow: f64 => flex_grow,flex_shrink: f64 => flex_shrink,order: i32 => order,+ webkit_box_ordinal_group: i32 => webkit_box_ordinal_group,+ webkit_box_flex: f64 => webkit_box_flex,align_items: u8 => align_items,align_self: u8 => align_self,align_items_is_last_baseline: bool => align_items_is_last_baseline,diff --git a/Libraries/LibWeb/Rust/src/css/computed_values.rs b/Libraries/LibWeb/Rust/src/css/computed_values.rsindex 32066062045..cf01afaba0d 100644--- a/Libraries/LibWeb/Rust/src/css/computed_values.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_values.rs@@ -5776,6 +5776,8 @@ impl AlignmentValues {Self {webkit_box_orient: crate::css::css_enums::webkit_box_orient::HORIZONTAL,+ webkit_box_align: crate::css::css_enums::webkit_box_align::STRETCH,+ webkit_box_pack: crate::css::css_enums::webkit_box_pack::START,flex_direction: flex_direction::ROW,flex_wrap: flex_wrap::NOWRAP,flex_basis: ComputedFlexBasis {@@ -5784,7 +5786,9 @@ impl AlignmentValues {},flex_grow: 0.0,flex_shrink: 1.0,+ webkit_box_flex: 0.0,order: 0,+ webkit_box_ordinal_group: 1,align_content: align_content::NORMAL,align_items: align_items::STRETCH,align_self: align_self::AUTO,@@ -6680,12 +6684,16 @@ fn alignment_overflow(data: &RetainedStyleValueData) -> u8 {pub(crate) fn rust_build_alignment_group(group_index: usize,webkit_box_orient: &RetainedStyleValueData,+ webkit_box_align: &RetainedStyleValueData,+ webkit_box_pack: &RetainedStyleValueData,flex_direction: &RetainedStyleValueData,flex_wrap: &RetainedStyleValueData,flex_basis: &RetainedStyleValueData,flex_grow: f64,flex_shrink: f64,+ webkit_box_flex: f64,order: i32,+ webkit_box_ordinal_group: i32,align_content: &RetainedStyleValueData,align_items: &RetainedStyleValueData,align_self: &RetainedStyleValueData,@@ -6711,12 +6719,16 @@ pub(crate) fn rust_build_alignment_group(};let built = AlignmentValues {webkit_box_orient: keyword_code(webkit_box_orient, crate::css::css_enums::keyword_to_webkit_box_orient)?,+ webkit_box_align: keyword_code(webkit_box_align, crate::css::css_enums::keyword_to_webkit_box_align)?,+ webkit_box_pack: keyword_code(webkit_box_pack, crate::css::css_enums::keyword_to_webkit_box_pack)?,flex_direction: keyword_code(flex_direction, crate::css::css_enums::keyword_to_flex_direction)?,flex_wrap: keyword_code(flex_wrap, crate::css::css_enums::keyword_to_flex_wrap)?,flex_basis: ComputedFlexBasis::from_data(flex_basis),flex_grow,flex_shrink,+ webkit_box_flex,order,+ webkit_box_ordinal_group,align_content: alignment_code(align_content, css_enums::keyword_to_align_content, true)?,align_items: alignment_code(align_items, css_enums::keyword_to_align_items, false)?,align_self: alignment_code(align_self, css_enums::keyword_to_align_self, false)?,diff --git a/Libraries/LibWeb/Rust/src/css/table_group_builder.rs b/Libraries/LibWeb/Rust/src/css/table_group_builder.rsindex 8dd8fd8b00a..2ffebba6a6f 100644--- a/Libraries/LibWeb/Rust/src/css/table_group_builder.rs+++ b/Libraries/LibWeb/Rust/src/css/table_group_builder.rs@@ -438,16 +438,26 @@ fn build_alignment_group(values: &LonghandSource, parent: GroupShares<'_>) -> *clet number = |property: u16| required_number(values.value(property).expect("the table holds the flex factor"));let flex_grow = number(property_id::FLEX_GROW);let flex_shrink = number(property_id::FLEX_SHRINK);+ let webkit_box_flex = number(property_id::_WEBKIT_BOX_FLEX);let order = required_integer(values.value(property_id::ORDER).expect("the table holds order"));+ let webkit_box_ordinal_group = required_integer(+ values+ .value(property_id::_WEBKIT_BOX_ORDINAL_GROUP)+ .expect("the table holds the ordinal group"),+ );rust_build_alignment_group(group_index::ALIGNMENT,values.handle(property_id::_WEBKIT_BOX_ORIENT),+ values.handle(property_id::_WEBKIT_BOX_ALIGN),+ values.handle(property_id::_WEBKIT_BOX_PACK),values.handle(property_id::FLEX_DIRECTION),values.handle(property_id::FLEX_WRAP),values.handle(property_id::FLEX_BASIS),flex_grow,flex_shrink,+ webkit_box_flex,order,+ webkit_box_ordinal_group,values.handle(property_id::ALIGN_CONTENT),values.handle(property_id::ALIGN_ITEMS),values.handle(property_id::ALIGN_SELF),diff --git a/Libraries/LibWeb/Rust/src/layout/box_alignment.rs b/Libraries/LibWeb/Rust/src/layout/box_alignment.rsindex a5e464c31ee..d933c66bc38 100644--- a/Libraries/LibWeb/Rust/src/layout/box_alignment.rs+++ b/Libraries/LibWeb/Rust/src/layout/box_alignment.rs@@ -193,6 +193,18 @@ impl SelfKeyword {(keyword, OverflowSafety::of(style.align_self_overflow()))}+ /// The alignment that the -webkit-box-align of a legacy webkit box styled `style` gives its items.+ pub(crate) fn webkit_box_align_of(style: ComputedValuesView<'_>) -> Self {+ match style.webkit_box_align() {+ webkit_box_align::STRETCH => Self::Stretch,+ webkit_box_align::START => Self::FlexStart,+ webkit_box_align::END => Self::FlexEnd,+ webkit_box_align::CENTER => Self::Center,+ webkit_box_align::BASELINE => Self::Baseline,+ _ => unreachable!("invalid -webkit-box-align value"),+ }+ }+pub(crate) fn align_items_of(style: ComputedValuesView<'_>) -> (Self, OverflowSafety) {let keyword = match style.align_items() {align_items::NORMAL => Self::Normal,@@ -287,6 +299,17 @@ pub(crate) enum ContentKeyword {}impl ContentKeyword {+ /// The distribution that the -webkit-box-pack of a legacy webkit box styled `style` gives its items.+ pub(crate) fn webkit_box_pack_of(style: ComputedValuesView<'_>) -> Self {+ match style.webkit_box_pack() {+ webkit_box_pack::START => Self::FlexStart,+ webkit_box_pack::END => Self::FlexEnd,+ webkit_box_pack::CENTER => Self::Center,+ webkit_box_pack::JUSTIFY => Self::SpaceBetween,+ _ => unreachable!("invalid -webkit-box-pack value"),+ }+ }+pub(crate) fn justify_content_of(style: ComputedValuesView<'_>) -> (Self, OverflowSafety) {let keyword = match style.justify_content() {justify_content::NORMAL => Self::Normal,diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rsindex 6ce1cbd12e9..0b236579b76 100644--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs@@ -381,7 +381,14 @@ impl<'pass> FlexContainerConstants<'pass> {flex_start_is_low: !is_direction_reverse,..AxisDirections::of(!main_axis_writing_mode_start_is_reverse, main_axis_line_left_is_low)};- let (justify_content, justify_content_safety) = ContentKeyword::justify_content_of(*style);+ // AD-HOC: A legacy webkit box distributes its items along the main axis as its -webkit-box-pack says, and+ // ignores justify-content, matching other engines. The compat spec makes -webkit-box-pack an alias of+ // justify-content, which it notes isn't web-compatible: https://github.com/whatwg/compat/issues/87+ let (justify_content, justify_content_safety) = if is_legacy_webkit_box {+ (ContentKeyword::webkit_box_pack_of(*style), OverflowSafety::Unsafe)+ } else {+ ContentKeyword::justify_content_of(*style)+ };let (align_content, align_content_safety) = ContentKeyword::align_content_of(*style);let (main_gap, cross_gap) = if is_row_layout {(style.column_gap(), style.row_gap())@@ -555,6 +562,17 @@ impl<'pass> FlexFormattingContext<'pass> {self.container.is_legacy_webkit_box}+ /// The order of an item styled `style` in order-modified document order.+ fn order_of_item(&self, style: StyleValues<'_>) -> i32 {+ // AD-HOC: The items of a legacy webkit box are ordered by their -webkit-box-ordinal-group, and order doesn't+ // apply, matching other engines.+ if self.is_legacy_webkit_box() {+ style.webkit_box_ordinal_group()+ } else {+ style.order()+ }+ }+fn used_flex_wrap(&self) -> u8 {self.container.used_flex_wrap}@@ -1116,12 +1134,14 @@ impl<'pass> FlexFormattingContext<'pass> {};let select_cross = |horizontal, vertical| select_main(vertical, horizontal);let preferred_cross_size = select_cross(style.width(), style.height());- // AD-HOC: Items in a legacy webkit box resolve their flex shrink factor from `-webkit-box-flex`, which we- // implement as an alias for `flex-grow`; `flex-shrink` does not apply, matching other engines.- let flex_shrink_factor = if self.is_legacy_webkit_box() {- style.flex_grow()+ // AD-HOC: Items in a legacy webkit box resolve both their flex grow and flex shrink factors from+ // -webkit-box-flex, and flex-grow and flex-shrink don't apply, matching other engines. A negative+ // -webkit-box-flex, which the property accepts, flexes the item as zero would.+ let (flex_grow_factor, flex_shrink_factor) = if self.is_legacy_webkit_box() {+ let factor = style.webkit_box_flex().max(0.0);+ (factor, factor)} else {- style.flex_shrink()+ (style.flex_grow(), style.flex_shrink())};// NB: A flex or grid button has no anonymous button content box, so it does not center its content.let uses_button_layout =@@ -1144,7 +1164,7 @@ impl<'pass> FlexFormattingContext<'pass> {max_cross_size: select_cross(style.max_width(), style.max_height()),flex_basis: style.flex_basis(),flex_basis_is_content: style.flex_basis_is_content(),- flex_grow_factor: style.flex_grow(),+ flex_grow_factor,flex_shrink_factor,is_replaced_box: facts.is_replaced_box(),is_table_wrapper,@@ -1184,7 +1204,7 @@ impl<'pass> FlexFormattingContext<'pass> {);let cells = self.keep_item_for_its_run(child);let (inputs, alignment_facts) = self.resolve_item_inputs(child);- let order = inputs.style.order();+ let order = self.order_of_item(inputs.style);items_have_different_orders |= *order_of_first_item.get_or_insert(order) != order;self.flex_items.push(FlexItem::new(child, alignment_facts, &inputs));self.items_to_fork.take();@@ -1201,11 +1221,8 @@ impl<'pass> FlexFormattingContext<'pass> {if items_have_different_orders {let mut order_modified_document_order: Vec<usize> = (first_new_item..self.flex_items.len()).collect();order_modified_document_order.sort_by(|&left, &right| {- self.flex_item_details[left]- .inputs- .style- .order()- .cmp(&self.flex_item_details[right].inputs.style.order())+ self.order_of_item(self.flex_item_details[left].inputs.style)+ .cmp(&self.order_of_item(self.flex_item_details[right].inputs.style))});fn reorder<T: Copy>(items: &mut Vec<T>, first_new_item: usize, order: &[usize]) {let reordered: Vec<T> = order.iter().map(|&index| items[index]).collect();@@ -2246,11 +2263,13 @@ impl<'pass> FlexFormattingContext<'pass> {/// The alignment along the cross axis of a box styled `style`.fn cross_alignment_of(&self, style: StyleValues<'_>) -> SelfAlignment {- // AD-HOC: The items of a legacy webkit box align as its -webkit-box-align, an alias of align-items, says,- // whatever their align-self and its safety are, matching other engines.+ // AD-HOC: The items of a legacy webkit box align as its -webkit-box-align says, whatever their align-self and+ // its safety are, and the box's align-items doesn't apply, matching other engines.let (keyword, safety) = if self.is_legacy_webkit_box() {- let (keyword, _) = SelfKeyword::align_items_of(*self.container.style);- (keyword, OverflowSafety::Unsafe)+ (+ SelfKeyword::webkit_box_align_of(*self.container.style),+ OverflowSafety::Unsafe,+ )} else {SelfKeyword::align_self_of(*style, Some(*self.container.style))};@@ -3516,7 +3535,10 @@ impl<'pass> FlexFormattingContext<'pass> {// of a flex container are the content edges of the flex container.let style = self.style(node);- let is_last_baseline = if style.align_self() == align_self::AUTO {+ // NB: The items of a legacy webkit box align as its -webkit-box-align says, which has no last baseline.+ let is_last_baseline = if self.is_legacy_webkit_box() {+ false+ } else if style.align_self() == align_self::AUTO {self.container.style.align_items_is_last_baseline()} else {style.align_self_is_last_baseline()@@ -3631,7 +3653,7 @@ impl<'pass> FlexFormattingContext<'pass> {main_size_property: crate::css::serialize::serialize_computed_size(main_size_property),main_min_size_property: crate::css::serialize::serialize_computed_size(main_min_size_property),main_max_size_property: crate::css::serialize::serialize_computed_size(main_max_size_property),- flex_grow: style.flex_grow(),+ flex_grow: self.flex_item_details[index].inputs.flex_grow_factor,flex_shrink: self.flex_item_details[index].inputs.flex_shrink_factor,});}diff --git a/Libraries/LibWeb/Rust/src/painting/paint_order.rs b/Libraries/LibWeb/Rust/src/painting/paint_order.rsindex d1f029ca06d..c369066d4cc 100644--- a/Libraries/LibWeb/Rust/src/painting/paint_order.rs+++ b/Libraries/LibWeb/Rust/src/painting/paint_order.rs@@ -7,17 +7,30 @@use crate::layout::LayoutNodeArena;use crate::layout::node_data::NodeSlotId;use crate::painting::node_painting;-use crate::painting::paint_read::PaintRead;+use crate::painting::paint_read::{PaintRead, PaintRow};use crate::painting::style_queries;use std::cmp::Ordering;pub(crate) fn order_for_painting(arena: &impl PaintRead, slot: NodeSlotId) -> i32 {// Absolutely positioned children of flex/grid containers have order: 0 for painting.// https://drafts.csswg.org/css-display-3/#order-modified-document-order- if style_queries::is_flex_or_grid_item(arena, slot) {- arena.node_style_if_live(slot).map_or(0, |style| style.order())+ if !style_queries::is_flex_or_grid_item(arena, slot) {+ return 0;+ }+ let Some(style) = arena.node_style_if_live(slot) else {+ return 0;+ };+ // AD-HOC: The items of a legacy webkit box are ordered by their -webkit-box-ordinal-group, and order doesn't+ // apply, matching other engines.+ let parent_is_legacy_webkit_box = arena+ .node(slot)+ .and_then(|row| arena.node_style_if_live(row.parent()))+ .is_some_and(|parent_style| parent_style.display().is_webkit_box_inside());+ // NB: The ordinal groups start at 1, so the initial one gives the key of a box that isn't an item, as order: 0 does.+ if parent_is_legacy_webkit_box {+ style.webkit_box_ordinal_group().saturating_sub(1)} else {- 0+ style.order()}}diff --git a/Tests/LibWeb/Text/expected/Layout/webkit-box-properties-apply-only-to-webkit-box.txt b/Tests/LibWeb/Text/expected/Layout/webkit-box-properties-apply-only-to-webkit-box.txtnew file mode 100644index 00000000000..45f538a76fe--- /dev/null+++ b/Tests/LibWeb/Text/expected/Layout/webkit-box-properties-apply-only-to-webkit-box.txt@@ -0,0 +1,17 @@+flex-with-box-align: 50x60 at 0,0+flex-with-box-pack: 50x60 at 0,0+flex-with-box-pack-and-justify-content: 50x60 at 125,0+flex-item-with-box-flex: 50x60 at 0,0+flex-item-with-box-ordinal-group: 50x60 at 0,0+box-with-box-align: 50x20 at 0,40+box-with-align-items: 50x60 at 0,0+box-with-box-pack: 50x60 at 250,0+box-with-box-pack-justify: 50x60 at 250,0+box-with-justify-content: 50x60 at 0,0+box-item-with-box-flex: 300x60 at 0,0+box-item-with-flex-grow: 50x60 at 0,0+box-item-with-negative-box-flex: 100x60 at 0,0+shrinking-box-item-with-negative-box-flex: 100x60 at 0,0+box-item-with-box-ordinal-group: 50x60 at 50,0+box-item-with-order: 50x60 at 0,0+box-item-with-both-orderings: 50x60 at 50,0diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt b/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txtindex d8db8abae45..631ea8e0b4c 100644--- a/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt+++ b/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt@@ -96,7 +96,11 @@ All properties associated with getComputedStyle(document.body):"word-break","word-spacing","writing-mode",+ "-webkit-box-align",+ "-webkit-box-flex",+ "-webkit-box-ordinal-group","-webkit-box-orient",+ "-webkit-box-pack","align-content","align-items","align-self",diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txtindex 07985483112..eb27e03afc6 100644--- a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt+++ b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt@@ -104,21 +104,21 @@ All supported properties and their default values exposed from CSSStylePropertie'WebkitBorderTopRightRadius': '0px''webkitBorderTopRightRadius': '0px''-webkit-border-top-right-radius': '0px'-'WebkitBoxAlign': 'normal'-'webkitBoxAlign': 'normal'-'-webkit-box-align': 'normal'+'WebkitBoxAlign': 'stretch'+'webkitBoxAlign': 'stretch'+'-webkit-box-align': 'stretch''WebkitBoxFlex': '0''webkitBoxFlex': '0''-webkit-box-flex': '0'-'WebkitBoxOrdinalGroup': '0'-'webkitBoxOrdinalGroup': '0'-'-webkit-box-ordinal-group': '0'+'WebkitBoxOrdinalGroup': '1'+'webkitBoxOrdinalGroup': '1'+'-webkit-box-ordinal-group': '1''WebkitBoxOrient': 'horizontal''webkitBoxOrient': 'horizontal''-webkit-box-orient': 'horizontal'-'WebkitBoxPack': 'normal'-'webkitBoxPack': 'normal'-'-webkit-box-pack': 'normal'+'WebkitBoxPack': 'start'+'webkitBoxPack': 'start'+'-webkit-box-pack': 'start''WebkitBoxShadow': 'none''webkitBoxShadow': 'none''-webkit-box-shadow': 'none'diff --git a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txtindex adc3e2429fe..4b74c760952 100644--- a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt+++ b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt@@ -94,7 +94,11 @@ widows: 2word-break: normalword-spacing: 0pxwriting-mode: horizontal-tb+-webkit-box-align: stretch+-webkit-box-flex: 0+-webkit-box-ordinal-group: 1-webkit-box-orient: horizontal+-webkit-box-pack: startalign-content: normalalign-items: normalalign-self: autodiff --git a/Tests/LibWeb/Text/expected/css/webkit-box-properties-are-not-aliases.txt b/Tests/LibWeb/Text/expected/css/webkit-box-properties-are-not-aliases.txtnew file mode 100644index 00000000000..5ea39e610cf--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/webkit-box-properties-are-not-aliases.txt@@ -0,0 +1,38 @@+-webkit-box-align: initial stretch+ stretch: specified stretch, computed stretch+ start: specified start, computed start+ end: specified end, computed end+ center: specified center, computed center+ baseline: specified baseline, computed baseline+ flex-start: invalid+ normal: invalid+-webkit-box-pack: initial start+ start: specified start, computed start+ end: specified end, computed end+ center: specified center, computed center+ justify: specified justify, computed justify+ space-between: invalid+ flex-end: invalid+ normal: invalid+-webkit-box-flex: initial 0+ 0: specified 0, computed 0+ 2.5: specified 2.5, computed 2.5+ -1: specified -1, computed -1+ 1px: invalid+ calc(1 + 1): specified calc(2), computed 2+-webkit-box-ordinal-group: initial 1+ 0: invalid+ 1: specified 1, computed 1+ 2: specified 2, computed 2+ -1: invalid+ 1.5: invalid+ calc(2): specified calc(2), computed 2+-webkit-box-align: end leaves align-items normal+align-items leaves -webkit-box-align stretch, cssText "align-items: center;"+-webkit-box-pack: end leaves justify-content normal+justify-content leaves -webkit-box-pack start, cssText "justify-content: center;"+-webkit-box-flex: 1 leaves flex-grow 0+flex-grow leaves -webkit-box-flex 0, cssText "flex-grow: 3;"+-webkit-box-ordinal-group: 2 leaves order 0+order leaves -webkit-box-ordinal-group 1, cssText "order: 3;"+-webkit-box-align is not inherited: stretchdiff --git a/Tests/LibWeb/Text/input/Layout/webkit-box-properties-apply-only-to-webkit-box.html b/Tests/LibWeb/Text/input/Layout/webkit-box-properties-apply-only-to-webkit-box.htmlnew file mode 100644index 00000000000..b5e07a03dd0--- /dev/null+++ b/Tests/LibWeb/Text/input/Layout/webkit-box-properties-apply-only-to-webkit-box.html@@ -0,0 +1,43 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ body { margin: 0; }+ .flex, .box { font: 20px/1 serif; }+ .flex { display: flex; width: 300px; height: 60px; }+ .box { display: -webkit-box; width: 300px; height: 60px; }+ .flex > div, .box > div { width: 50px; }+</style>+<!-- -webkit-box-align, -webkit-box-pack, -webkit-box-flex and -webkit-box-ordinal-group are properties of their own:+ They lay out a -webkit-box, but not a flex container. And align-items, justify-content, flex-grow and order lay out+ a flex container, but not a -webkit-box. -->+<div class="flex" style="-webkit-box-align: end"><div id="flex-with-box-align">a</div></div>+<div class="flex" style="-webkit-box-pack: end"><div id="flex-with-box-pack">a</div></div>+<div class="flex" style="-webkit-box-pack: end; justify-content: center"><div id="flex-with-box-pack-and-justify-content">a</div></div>+<div class="flex"><div id="flex-item-with-box-flex" style="-webkit-box-flex: 1">a</div></div>+<div class="flex"><div id="flex-item-with-box-ordinal-group" style="-webkit-box-ordinal-group: 2">a</div><div>b</div></div>+<div class="box" style="-webkit-box-align: end"><div id="box-with-box-align">a</div></div>+<div class="box" style="align-items: end"><div id="box-with-align-items">a</div></div>+<div class="box" style="-webkit-box-pack: end"><div id="box-with-box-pack">a</div></div>+<div class="box" style="-webkit-box-pack: justify"><div>a</div><div id="box-with-box-pack-justify">b</div></div>+<div class="box" style="justify-content: end"><div id="box-with-justify-content">a</div></div>+<div class="box"><div id="box-item-with-box-flex" style="-webkit-box-flex: 1">a</div></div>+<div class="box"><div id="box-item-with-flex-grow" style="flex-grow: 1">a</div></div>+<div class="box" style="width: 500px"><div id="box-item-with-negative-box-flex" style="width: 100px; -webkit-box-flex: -1">a</div><div style="width: 100px; -webkit-box-flex: 2">b</div></div>+<div class="box" style="width: 150px"><div id="shrinking-box-item-with-negative-box-flex" style="width: 100px; -webkit-box-flex: -1">a</div><div style="width: 100px; -webkit-box-flex: 1">b</div></div>+<div class="box"><div id="box-item-with-box-ordinal-group" style="-webkit-box-ordinal-group: 2">a</div><div>b</div></div>+<div class="box"><div id="box-item-with-order" style="order: 2">a</div><div>b</div></div>+<div class="box"><div id="box-item-with-both-orderings" style="-webkit-box-ordinal-group: 2; order: -1">a</div><div>b</div></div>+<script>+ function run(report) {+ for (const element of document.querySelectorAll("[id]:not(#out)")) {+ const rect = element.getBoundingClientRect();+ report(`${element.id}: ${rect.width}x${rect.height} at ${rect.left - element.parentElement.getBoundingClientRect().left},${rect.top - element.parentElement.getBoundingClientRect().top}`);+ }+ }+</script>+<script>+ if (window.asyncTest)+ asyncTest(done => addEventListener("load", () => { run(println); done(); }));+ else+ addEventListener("load", () => { run(line => console.log(line)); window.engineCompareDone = true; });+</script>diff --git a/Tests/LibWeb/Text/input/css/webkit-box-properties-are-not-aliases.html b/Tests/LibWeb/Text/input/css/webkit-box-properties-are-not-aliases.htmlnew file mode 100644index 00000000000..db4bf8d1ad9--- /dev/null+++ b/Tests/LibWeb/Text/input/css/webkit-box-properties-are-not-aliases.html@@ -0,0 +1,42 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<div id="target"></div>+<script>+ // -webkit-box-align, -webkit-box-pack, -webkit-box-flex and -webkit-box-ordinal-group are properties of their own, not+ // aliases of align-items, justify-content, flex-grow and order.+ function run(report) {+ const target = document.getElementById("target");+ const values = {+ "-webkit-box-align": ["stretch", "start", "end", "center", "baseline", "flex-start", "normal"],+ "-webkit-box-pack": ["start", "end", "center", "justify", "space-between", "flex-end", "normal"],+ "-webkit-box-flex": ["0", "2.5", "-1", "1px", "calc(1 + 1)"],+ "-webkit-box-ordinal-group": ["0", "1", "2", "-1", "1.5", "calc(2)"],+ };+ for (const [property, list] of Object.entries(values)) {+ report(`${property}: initial ${getComputedStyle(target).getPropertyValue(property)}`);+ for (const value of list) {+ target.style.cssText = "";+ target.style.setProperty(property, value);+ const specified = target.style.getPropertyValue(property);+ report(` ${value}: ${specified === "" ? "invalid" : `specified ${specified}, computed ${getComputedStyle(target).getPropertyValue(property)}`}`);+ }+ }+ const pairs = [["-webkit-box-align", "end", "align-items"], ["-webkit-box-pack", "end", "justify-content"],+ ["-webkit-box-flex", "1", "flex-grow"], ["-webkit-box-ordinal-group", "2", "order"]];+ for (const [property, value, modern] of pairs) {+ target.style.cssText = `${property}: ${value}`;+ report(`${property}: ${value} leaves ${modern} ${getComputedStyle(target).getPropertyValue(modern)}`);+ target.style.cssText = `${modern}: 3`;+ target.style.setProperty(modern, modern === "align-items" || modern === "justify-content" ? "center" : "3");+ report(`${modern} leaves ${property} ${getComputedStyle(target).getPropertyValue(property)}, cssText "${target.style.cssText}"`);+ }+ document.body.style.setProperty("-webkit-box-align", "end");+ report(`-webkit-box-align is not inherited: ${getComputedStyle(target).getPropertyValue("-webkit-box-align")}`);+ }+</script>+<script>+ if (window.test)+ test(() => run(println));+ else+ addEventListener("load", () => { run(line => console.log(line)); window.engineCompareDone = true; });+</script>