Bug 1906995 - Enable grid styles for servo. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D216128
This commit is contained in:
Nico Burns 2024-07-16 10:02:32 +00:00
Родитель a3c57b39dd
Коммит 1e75e8a3fc
3 изменённых файлов: 28 добавлений и 18 удалений

Просмотреть файл

@ -344,7 +344,8 @@ ${helpers.predefined_type(
"grid-%s-%s" % (kind, range),
"GridLine",
"Default::default()",
engines="gecko",
engines="gecko servo",
servo_pref="layout.grid.enabled",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-grid/#propdef-grid-%s-%s" % (kind, range),
affects="layout",
@ -355,7 +356,8 @@ ${helpers.predefined_type(
"grid-auto-%ss" % kind,
"ImplicitGridTracks",
"Default::default()",
engines="gecko",
engines="gecko servo",
servo_pref="layout.grid.enabled",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-%ss" % kind,
affects="layout",
@ -365,7 +367,8 @@ ${helpers.predefined_type(
"grid-template-%ss" % kind,
"GridTemplateComponent",
"specified::GenericGridTemplateComponent::None",
engines="gecko",
engines="gecko servo",
servo_pref="layout.grid.enabled",
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-%ss" % kind,
animation_value_type="ComputedValue",
affects="layout",
@ -388,7 +391,8 @@ ${helpers.predefined_type(
"grid-auto-flow",
"GridAutoFlow",
"computed::GridAutoFlow::ROW",
engines="gecko",
engines="gecko servo",
servo_pref="layout.grid.enabled",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-flow",
affects="layout",
@ -398,7 +402,8 @@ ${helpers.predefined_type(
"grid-template-areas",
"GridTemplateAreas",
"computed::GridTemplateAreas::none()",
engines="gecko",
engines="gecko servo",
servo_pref="layout.grid.enabled",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-areas",
affects="layout",

Просмотреть файл

@ -165,7 +165,8 @@
<%helpers:shorthand
name="grid-${kind}"
sub_properties="grid-${kind}-start grid-${kind}-end"
engines="gecko",
engines="gecko servo",
servo_pref="layout.grid.enabled",
spec="https://drafts.csswg.org/css-grid/#propdef-grid-${kind}"
>
use crate::values::specified::GridLine;
@ -219,7 +220,8 @@
<%helpers:shorthand
name="grid-area"
engines="gecko"
engines="gecko servo"
servo_pref="layout.grid.enabled",
sub_properties="grid-row-start grid-row-end grid-column-start grid-column-end"
spec="https://drafts.csswg.org/css-grid/#propdef-grid-area"
>
@ -314,7 +316,8 @@
<%helpers:shorthand
name="grid-template"
engines="gecko"
engines="gecko servo"
servo_pref="layout.grid.enabled",
sub_properties="grid-template-rows grid-template-columns grid-template-areas"
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template"
>
@ -555,7 +558,8 @@
<%helpers:shorthand
name="grid"
engines="gecko"
engines="gecko servo"
servo_pref="layout.grid.enabled",
sub_properties="grid-template-rows grid-template-columns grid-template-areas
grid-auto-rows grid-auto-columns grid-auto-flow"
spec="https://drafts.csswg.org/css-grid/#propdef-grid"

Просмотреть файл

@ -23,6 +23,10 @@ use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss};
fn flexbox_enabled() -> bool {
true
}
#[cfg(not(feature = "servo"))]
fn grid_enabled() -> bool {
true
}
#[cfg(feature = "servo")]
fn flexbox_enabled() -> bool {
@ -31,6 +35,10 @@ fn flexbox_enabled() -> bool {
.as_bool()
.unwrap_or(false)
}
#[cfg(feature = "servo")]
fn grid_enabled() -> bool {
style_config::get_bool("layout.grid.enabled")
}
/// Defines an elements display type, which consists of
/// the two basic qualities of how an element generates boxes
@ -57,7 +65,6 @@ pub enum DisplayInside {
Flow,
FlowRoot,
Flex,
#[cfg(feature = "gecko")]
Grid,
Table,
TableRowGroup,
@ -152,10 +159,8 @@ impl Display {
Self(((DisplayOutside::Block as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Flex as u16);
pub const InlineFlex: Self =
Self(((DisplayOutside::Inline as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Flex as u16);
#[cfg(feature = "gecko")]
pub const Grid: Self =
Self(((DisplayOutside::Block as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Grid as u16);
#[cfg(feature = "gecko")]
pub const InlineGrid: Self =
Self(((DisplayOutside::Inline as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Grid as u16);
pub const Table: Self =
@ -326,7 +331,6 @@ impl Display {
pub fn is_item_container(&self) -> bool {
match self.inside() {
DisplayInside::Flex => true,
#[cfg(feature = "gecko")]
DisplayInside::Grid => true,
_ => false,
}
@ -423,8 +427,7 @@ impl DisplayKeyword {
"inline-table" => Full(Display::InlineTable),
"-webkit-flex" if flexbox_enabled() => Full(Display::Flex),
"inline-flex" | "-webkit-inline-flex" if flexbox_enabled() => Full(Display::InlineFlex),
#[cfg(feature = "gecko")]
"inline-grid" => Full(Display::InlineGrid),
"inline-grid" if grid_enabled() => Full(Display::InlineGrid),
"table-caption" => Full(Display::TableCaption),
"table-row-group" => Full(Display::TableRowGroup),
"table-header-group" => Full(Display::TableHeaderGroup),
@ -459,8 +462,7 @@ impl DisplayKeyword {
"flex" if flexbox_enabled() => Inside(DisplayInside::Flex),
"flow-root" => Inside(DisplayInside::FlowRoot),
"table" => Inside(DisplayInside::Table),
#[cfg(feature = "gecko")]
"grid" => Inside(DisplayInside::Grid),
"grid" if grid_enabled() => Inside(DisplayInside::Grid),
#[cfg(feature = "gecko")]
"ruby" => Inside(DisplayInside::Ruby),
})
@ -481,7 +483,6 @@ impl ToCss for Display {
Display::WebkitInlineBox => dest.write_str("-webkit-inline-box"),
Display::TableCaption => dest.write_str("table-caption"),
_ => match (outside, inside) {
#[cfg(feature = "gecko")]
(DisplayOutside::Inline, DisplayInside::Grid) => dest.write_str("inline-grid"),
(DisplayOutside::Inline, DisplayInside::Flex) => dest.write_str("inline-flex"),
(DisplayOutside::Inline, DisplayInside::Table) => dest.write_str("inline-table"),