Skip to content

Commit 4465d07

Browse files
mrobinsonnicoburns
andauthored
Switch to Gecko's representation of alignment styles (#53)
- Cherry-picked ddb7af7 from upstream - Remove alignment style adjustment function (which should be implemented in layout anyway - implemented in servo#32686) - Switch column-gap to being behind the flexbox flag rather than the multi-column layout flag Signed-off-by: Martin Robinson <[email protected]> Co-authored-by: Nico Burns <[email protected]>
1 parent 4a8401a commit 4465d07

File tree

7 files changed

+84
-250
lines changed

7 files changed

+84
-250
lines changed

style/properties/longhands/position.mako.rs

Lines changed: 61 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -75,127 +75,59 @@ ${helpers.single_keyword(
7575
affects="layout",
7676
)}
7777

78-
% if engine in "servo":
79-
// FIXME: Update Servo to support the same Syntax as Gecko.
80-
${helpers.single_keyword(
81-
"justify-content",
82-
"start flex-start stretch end flex-end center space-between space-around space-evenly",
83-
engines="servo",
84-
servo_pref="layout.flexbox.enabled",
85-
extra_prefixes="webkit",
86-
spec="https://drafts.csswg.org/css-align/#propdef-justify-content",
87-
animation_value_type="discrete",
88-
servo_restyle_damage = "reflow",
89-
affects="layout",
90-
)}
91-
% endif
92-
% if engine == "gecko":
93-
${helpers.predefined_type(
94-
"justify-content",
95-
"JustifyContent",
96-
"specified::JustifyContent(specified::ContentDistribution::normal())",
97-
engines="gecko",
98-
spec="https://drafts.csswg.org/css-align/#propdef-justify-content",
99-
extra_prefixes="webkit",
100-
animation_value_type="discrete",
101-
servo_restyle_damage="reflow",
102-
affects="layout",
103-
)}
104-
105-
${helpers.predefined_type(
106-
"justify-tracks",
107-
"JustifyTracks",
108-
"specified::JustifyTracks::default()",
109-
engines="gecko",
110-
gecko_pref="layout.css.grid-template-masonry-value.enabled",
111-
animation_value_type="discrete",
112-
servo_restyle_damage="reflow",
113-
spec="https://github.com/w3c/csswg-drafts/issues/4650",
114-
affects="layout",
115-
)}
116-
% endif
117-
118-
% if engine == "servo":
119-
// FIXME: Update Servo to support the same Syntax as Gecko.
120-
${helpers.single_keyword(
121-
"align-content",
122-
"stretch start flex-start end flex-end center space-between space-around space-evenly",
123-
engines="servo",
124-
servo_pref="layout.flexbox.enabled",
125-
extra_prefixes="webkit",
126-
spec="https://drafts.csswg.org/css-align/#propdef-align-content",
127-
animation_value_type="discrete",
128-
servo_restyle_damage="reflow",
129-
affects="layout",
130-
)}
78+
${helpers.predefined_type(
79+
"justify-content",
80+
"JustifyContent",
81+
"specified::JustifyContent(specified::ContentDistribution::normal())",
82+
engines="gecko servo",
83+
spec="https://drafts.csswg.org/css-align/#propdef-justify-content",
84+
extra_prefixes="webkit",
85+
animation_value_type="discrete",
86+
servo_restyle_damage="reflow",
87+
affects="layout",
88+
)}
13189

132-
${helpers.single_keyword(
133-
"align-items",
134-
"stretch flex-start flex-end center baseline",
135-
engines="servo",
136-
servo_pref="layout.flexbox.enabled",
137-
extra_prefixes="webkit",
138-
spec="https://drafts.csswg.org/css-flexbox/#align-items-property",
139-
animation_value_type="discrete",
140-
servo_restyle_damage="reflow",
141-
affects="layout",
142-
)}
143-
% endif
144-
% if engine == "gecko":
145-
${helpers.predefined_type(
146-
"align-content",
147-
"AlignContent",
148-
"specified::AlignContent(specified::ContentDistribution::normal())",
149-
engines="gecko",
150-
spec="https://drafts.csswg.org/css-align/#propdef-align-content",
151-
extra_prefixes="webkit",
152-
animation_value_type="discrete",
153-
servo_restyle_damage="reflow",
154-
affects="layout",
155-
)}
90+
${helpers.predefined_type(
91+
"align-content",
92+
"AlignContent",
93+
"specified::AlignContent(specified::ContentDistribution::normal())",
94+
engines="gecko servo",
95+
spec="https://drafts.csswg.org/css-align/#propdef-align-content",
96+
extra_prefixes="webkit",
97+
animation_value_type="discrete",
98+
servo_restyle_damage="reflow",
99+
affects="layout",
100+
)}
156101

157-
${helpers.predefined_type(
158-
"align-tracks",
159-
"AlignTracks",
160-
"specified::AlignTracks::default()",
161-
engines="gecko",
162-
gecko_pref="layout.css.grid-template-masonry-value.enabled",
163-
animation_value_type="discrete",
164-
servo_restyle_damage="reflow",
165-
spec="https://github.com/w3c/csswg-drafts/issues/4650",
166-
affects="layout",
167-
)}
102+
${helpers.predefined_type(
103+
"align-items",
104+
"AlignItems",
105+
"specified::AlignItems::normal()",
106+
engines="gecko servo",
107+
spec="https://drafts.csswg.org/css-align/#propdef-align-items",
108+
extra_prefixes="webkit",
109+
animation_value_type="discrete",
110+
servo_restyle_damage="reflow",
111+
affects="layout",
112+
)}
168113

169-
${helpers.predefined_type(
170-
"align-items",
171-
"AlignItems",
172-
"specified::AlignItems::normal()",
173-
engines="gecko",
174-
spec="https://drafts.csswg.org/css-align/#propdef-align-items",
175-
extra_prefixes="webkit",
176-
animation_value_type="discrete",
177-
servo_restyle_damage="reflow",
178-
affects="layout",
179-
)}
114+
${helpers.predefined_type(
115+
"justify-items",
116+
"JustifyItems",
117+
"computed::JustifyItems::legacy()",
118+
engines="gecko servo",
119+
spec="https://drafts.csswg.org/css-align/#propdef-justify-items",
120+
animation_value_type="discrete",
121+
affects="layout",
122+
)}
180123

181-
${helpers.predefined_type(
182-
"justify-items",
183-
"JustifyItems",
184-
"computed::JustifyItems::legacy()",
185-
engines="gecko",
186-
spec="https://drafts.csswg.org/css-align/#propdef-justify-items",
187-
animation_value_type="discrete",
188-
affects="layout",
189-
)}
190-
% endif
191124

192125
// Flex item properties
193126
${helpers.predefined_type(
194127
"flex-grow",
195128
"NonNegativeNumber",
196129
"From::from(0.0)",
197130
engines="gecko servo",
198-
servo_pref="layout.flexbox.enabled",
199131
spec="https://drafts.csswg.org/css-flexbox/#flex-grow-property",
200132
extra_prefixes="webkit",
201133
animation_value_type="NonNegativeNumber",
@@ -217,42 +149,26 @@ ${helpers.predefined_type(
217149
)}
218150

219151
// https://drafts.csswg.org/css-align/#align-self-property
220-
% if engine == "servo":
221-
// FIXME: Update Servo to support the same syntax as Gecko.
222-
${helpers.single_keyword(
223-
"align-self",
224-
"auto stretch flex-start flex-end center baseline",
225-
engines="servo",
226-
servo_pref="layout.flexbox.enabled",
227-
extra_prefixes="webkit",
228-
spec="https://drafts.csswg.org/css-flexbox/#propdef-align-self",
229-
animation_value_type="discrete",
230-
servo_restyle_damage = "reflow",
231-
affects="layout",
232-
)}
233-
% endif
234-
% if engine == "gecko":
235-
${helpers.predefined_type(
236-
"align-self",
237-
"AlignSelf",
238-
"specified::AlignSelf(specified::SelfAlignment::auto())",
239-
engines="gecko",
240-
spec="https://drafts.csswg.org/css-align/#align-self-property",
241-
extra_prefixes="webkit",
242-
animation_value_type="discrete",
243-
affects="layout",
244-
)}
152+
${helpers.predefined_type(
153+
"align-self",
154+
"AlignSelf",
155+
"specified::AlignSelf(specified::SelfAlignment::auto())",
156+
engines="gecko servo",
157+
spec="https://drafts.csswg.org/css-align/#align-self-property",
158+
extra_prefixes="webkit",
159+
animation_value_type="discrete",
160+
affects="layout",
161+
)}
245162

246-
${helpers.predefined_type(
247-
"justify-self",
248-
"JustifySelf",
249-
"specified::JustifySelf(specified::SelfAlignment::auto())",
250-
engines="gecko",
251-
spec="https://drafts.csswg.org/css-align/#justify-self-property",
252-
animation_value_type="discrete",
253-
affects="layout",
254-
)}
255-
% endif
163+
${helpers.predefined_type(
164+
"justify-self",
165+
"JustifySelf",
166+
"specified::JustifySelf(specified::SelfAlignment::auto())",
167+
engines="gecko servo",
168+
spec="https://drafts.csswg.org/css-align/#justify-self-property",
169+
animation_value_type="discrete",
170+
affects="layout",
171+
)}
256172

257173
// https://drafts.csswg.org/css-flexbox/#propdef-order
258174
${helpers.predefined_type(

style/properties/shorthands/position.mako.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@
716716

717717
<%helpers:shorthand
718718
name="place-content"
719-
engines="gecko"
719+
engines="gecko servo"
720720
sub_properties="align-content justify-content"
721721
spec="https://drafts.csswg.org/css-align/#propdef-place-content"
722722
>
@@ -771,7 +771,7 @@
771771

772772
<%helpers:shorthand
773773
name="place-self"
774-
engines="gecko"
774+
engines="gecko servo"
775775
sub_properties="align-self justify-self"
776776
spec="https://drafts.csswg.org/css-align/#place-self-property"
777777
>
@@ -812,7 +812,7 @@
812812

813813
<%helpers:shorthand
814814
name="place-items"
815-
engines="gecko"
815+
engines="gecko servo"
816816
sub_properties="align-items justify-items"
817817
spec="https://drafts.csswg.org/css-align/#place-items-property"
818818
>

style/style_adjuster.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -402,29 +402,6 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
402402
}
403403
}
404404

405-
/// This implements an out-of-date spec. The new spec moves the handling of
406-
/// this to layout, which Gecko implements but Servo doesn't.
407-
///
408-
/// See https://github.com/servo/servo/issues/15229
409-
#[cfg(feature = "servo")]
410-
fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValues) {
411-
use crate::computed_values::align_items::T as AlignItems;
412-
use crate::computed_values::align_self::T as AlignSelf;
413-
414-
if self.style.get_position().clone_align_self() == AlignSelf::Auto &&
415-
!self.style.is_absolutely_positioned()
416-
{
417-
let self_align = match layout_parent_style.get_position().clone_align_items() {
418-
AlignItems::Stretch => AlignSelf::Stretch,
419-
AlignItems::Baseline => AlignSelf::Baseline,
420-
AlignItems::FlexStart => AlignSelf::FlexStart,
421-
AlignItems::FlexEnd => AlignSelf::FlexEnd,
422-
AlignItems::Center => AlignSelf::Center,
423-
};
424-
self.style.mutate_position().set_align_self(self_align);
425-
}
426-
}
427-
428405
/// The initial value of border-*-width may be changed at computed value
429406
/// time.
430407
///
@@ -990,10 +967,6 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
990967
self.adjust_for_table_text_align();
991968
self.adjust_for_justify_items();
992969
}
993-
#[cfg(feature = "servo")]
994-
{
995-
self.adjust_for_alignment(layout_parent_style);
996-
}
997970
self.adjust_for_border_width();
998971
#[cfg(feature = "gecko")]
999972
self.adjust_for_column_rule_width();

style/values/computed/align.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ use crate::values::computed::{Context, ToComputedValue};
1010
use crate::values::specified;
1111

1212
pub use super::specified::{
13-
AlignContent, AlignItems, AlignTracks, ContentDistribution, JustifyContent, JustifyTracks,
14-
SelfAlignment,
13+
AlignContent, AlignItems, ContentDistribution, JustifyContent, SelfAlignment,
1514
};
1615
pub use super::specified::{AlignSelf, JustifySelf};
1716

style/values/computed/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@ use std::cmp;
3636
use std::f32;
3737
use std::ops::{Add, Sub};
3838

39-
#[cfg(feature = "gecko")]
4039
pub use self::align::{
41-
AlignContent, AlignItems, AlignTracks, JustifyContent, JustifyItems, JustifyTracks,
42-
SelfAlignment,
40+
AlignContent, AlignItems, JustifyContent, JustifyItems, SelfAlignment,
4341
};
44-
#[cfg(feature = "gecko")]
4542
pub use self::align::{AlignSelf, JustifySelf};
4643
pub use self::angle::Angle;
4744
pub use self::animation::{
@@ -121,7 +118,6 @@ pub use super::specified::ViewportVariant;
121118
pub use super::specified::{BorderStyle, TextDecorationLine};
122119
pub use app_units::Au;
123120

124-
#[cfg(feature = "gecko")]
125121
pub mod align;
126122
pub mod angle;
127123
pub mod animation;

0 commit comments

Comments
 (0)