Skip to content

Commit bb62b4e

Browse files
authored
Add support for -webkit-fill-available sizing keyword (#243)
This keyword is de-facto required for web compatibility, Firefox is also enabling it (https://bugzil.la/1988938). Servo will just alias it to `stretch`. Signed-off-by: Oriol Brufau <[email protected]>
1 parent c4caa30 commit bb62b4e

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

style/values/generics/length.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ pub enum GenericSize<LengthPercent> {
164164
#[cfg(feature = "gecko")]
165165
#[animation(error)]
166166
MozAvailable,
167-
#[cfg(feature = "gecko")]
168167
#[animation(error)]
169168
WebkitFillAvailable,
170169
#[animation(error)]
@@ -182,14 +181,12 @@ where
182181
{
183182
fn collect_completion_keywords(f: style_traits::KeywordsCollectFn) {
184183
LengthPercent::collect_completion_keywords(f);
185-
f(&["auto", "stretch", "fit-content"]);
184+
f(&["auto", "stretch", "fit-content", "max-content", "min-content"]);
186185
if cfg!(feature = "gecko") {
187-
f(&[
188-
"max-content",
189-
"min-content",
190-
"-moz-available",
191-
"-webkit-fill-available",
192-
]);
186+
f(&["-moz-available"]);
187+
}
188+
if static_prefs::pref!("layout.css.webkit-fill-available.enabled") {
189+
f(&["-webkit-fill-available"]);
193190
}
194191
if static_prefs::pref!("layout.css.anchor-positioning.enabled") {
195192
f(&["anchor-size"]);
@@ -242,7 +239,6 @@ pub enum GenericMaxSize<LengthPercent> {
242239
#[cfg(feature = "gecko")]
243240
#[animation(error)]
244241
MozAvailable,
245-
#[cfg(feature = "gecko")]
246242
#[animation(error)]
247243
WebkitFillAvailable,
248244
#[animation(error)]
@@ -260,14 +256,12 @@ where
260256
{
261257
fn collect_completion_keywords(f: style_traits::KeywordsCollectFn) {
262258
LP::collect_completion_keywords(f);
263-
f(&["none", "stretch", "fit-content"]);
259+
f(&["none", "stretch", "fit-content", "max-content", "min-content"]);
264260
if cfg!(feature = "gecko") {
265-
f(&[
266-
"max-content",
267-
"min-content",
268-
"-moz-available",
269-
"-webkit-fill-available",
270-
]);
261+
f(&["-moz-available"]);
262+
}
263+
if static_prefs::pref!("layout.css.webkit-fill-available.enabled") {
264+
f(&["-webkit-fill-available"]);
271265
}
272266
if static_prefs::pref!("layout.css.anchor-positioning.enabled") {
273267
f(&["anchor-size"]);

style/values/specified/length.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,7 +2056,6 @@ macro_rules! parse_size_non_length {
20562056
"fit-content" | "-moz-fit-content" => $size::FitContent,
20572057
#[cfg(feature = "gecko")]
20582058
"-moz-available" => $size::MozAvailable,
2059-
#[cfg(feature = "gecko")]
20602059
"-webkit-fill-available" if is_webkit_fill_available_keyword_enabled() => $size::WebkitFillAvailable,
20612060
"stretch" if is_stretch_enabled() => $size::Stretch,
20622061
$auto_or_none => $size::$auto_or_none_ident,
@@ -2068,7 +2067,6 @@ macro_rules! parse_size_non_length {
20682067
}};
20692068
}
20702069

2071-
#[cfg(feature = "gecko")]
20722070
fn is_webkit_fill_available_keyword_enabled() -> bool {
20732071
static_prefs::pref!("layout.css.webkit-fill-available.enabled")
20742072
}

stylo_static_prefs/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ macro_rules! pref {
3636
("layout.css.marker.restricted") => {
3737
true
3838
};
39+
("layout.css.webkit-fill-available.enabled") => {
40+
true
41+
};
3942
($string:literal) => {
4043
false
4144
};

0 commit comments

Comments
 (0)