mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Do not use synthetic display-inside values.
This matches the new servo layout engine too, and thus removes some #[cfg] gunk. Just use `flow` since it doesn't simplify the layout code as much. Differential Revision: https://phabricator.services.mozilla.com/D45973
This commit is contained in:
parent
0dfbd38532
commit
2b499e4850
2 changed files with 16 additions and 40 deletions
|
@ -12,8 +12,6 @@ use crate::properties::longhands::float::computed_value::T as Float;
|
|||
use crate::properties::longhands::overflow_x::computed_value::T as Overflow;
|
||||
use crate::properties::longhands::position::computed_value::T as Position;
|
||||
use crate::properties::{self, ComputedValues, StyleBuilder};
|
||||
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
|
||||
use crate::values::specified::box_::DisplayInside;
|
||||
use app_units::Au;
|
||||
|
||||
/// A struct that implements all the adjustment methods.
|
||||
|
@ -207,7 +205,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
self.style.pseudo.map_or(false, |p| p.is_marker()) &&
|
||||
self.style.get_parent_list().clone_list_style_position() ==
|
||||
ListStylePosition::Outside &&
|
||||
layout_parent_style.get_box().clone_display().inside() != DisplayInside::Inline
|
||||
!layout_parent_style.get_box().clone_display().is_inline_flow()
|
||||
);
|
||||
|
||||
if !blockify {
|
||||
|
|
|
@ -61,12 +61,9 @@ pub enum DisplayInside {
|
|||
None = 0,
|
||||
#[cfg(any(feature = "servo-layout-2020", feature = "gecko"))]
|
||||
Contents,
|
||||
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
|
||||
Block,
|
||||
Flow,
|
||||
FlowRoot,
|
||||
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
|
||||
Inline,
|
||||
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
|
||||
Flex,
|
||||
#[cfg(feature = "gecko")]
|
||||
Grid,
|
||||
|
@ -114,7 +111,6 @@ pub enum DisplayInside {
|
|||
MozGroupbox,
|
||||
#[cfg(feature = "gecko")]
|
||||
MozPopup,
|
||||
Flow, // only used for parsing, not computed value
|
||||
}
|
||||
|
||||
#[allow(missing_docs)]
|
||||
|
@ -147,14 +143,8 @@ impl Display {
|
|||
pub const None: Self = Self::new(DisplayOutside::None, DisplayInside::None);
|
||||
#[cfg(any(feature = "servo-layout-2020", feature = "gecko"))]
|
||||
pub const Contents: Self = Self::new(DisplayOutside::None, DisplayInside::Contents);
|
||||
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
|
||||
pub const Inline: Self = Self::new(DisplayOutside::Inline, DisplayInside::Inline);
|
||||
#[cfg(any(feature = "servo-layout-2020"))]
|
||||
pub const Inline: Self = Self::new(DisplayOutside::Inline, DisplayInside::Flow);
|
||||
pub const InlineBlock: Self = Self::new(DisplayOutside::Inline, DisplayInside::FlowRoot);
|
||||
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
|
||||
pub const Block: Self = Self::new(DisplayOutside::Block, DisplayInside::Block);
|
||||
#[cfg(any(feature = "servo-layout-2020"))]
|
||||
pub const Block: Self = Self::new(DisplayOutside::Block, DisplayInside::Flow);
|
||||
#[cfg(feature = "gecko")]
|
||||
pub const FlowRoot: Self = Self::new(DisplayOutside::Block, DisplayInside::FlowRoot);
|
||||
|
@ -171,7 +161,7 @@ impl Display {
|
|||
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
|
||||
pub const InlineTable: Self = Self::new(DisplayOutside::Inline, DisplayInside::Table);
|
||||
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
|
||||
pub const TableCaption: Self = Self::new(DisplayOutside::TableCaption, DisplayInside::Block);
|
||||
pub const TableCaption: Self = Self::new(DisplayOutside::TableCaption, DisplayInside::Flow);
|
||||
#[cfg(feature = "gecko")]
|
||||
pub const Ruby: Self = Self::new(DisplayOutside::Inline, DisplayInside::Ruby);
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -256,18 +246,8 @@ impl Display {
|
|||
}
|
||||
|
||||
/// Make a display enum value from <display-outside> and <display-inside> values.
|
||||
/// We store `flow` as a synthetic `block` or `inline` inside-value to simplify
|
||||
/// our layout code.
|
||||
#[inline]
|
||||
fn from3(outside: DisplayOutside, inside: DisplayInside, list_item: bool) -> Self {
|
||||
let inside = match inside {
|
||||
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
|
||||
DisplayInside::Flow => match outside {
|
||||
DisplayOutside::Inline => DisplayInside::Inline,
|
||||
_ => DisplayInside::Block,
|
||||
},
|
||||
_ => inside,
|
||||
};
|
||||
let v = Self::new(outside, inside);
|
||||
if !list_item {
|
||||
return v;
|
||||
|
@ -290,6 +270,13 @@ impl Display {
|
|||
.unwrap()
|
||||
}
|
||||
|
||||
/// Whether this is `display: inline` (or `inline list-item`).
|
||||
#[inline]
|
||||
pub fn is_inline_flow(&self) -> bool {
|
||||
self.outside() == DisplayOutside::Inline &&
|
||||
self.inside() == DisplayInside::Flow
|
||||
}
|
||||
|
||||
/// Returns whether this `display` value is some kind of list-item.
|
||||
#[inline]
|
||||
pub const fn is_list_item(&self) -> bool {
|
||||
|
@ -381,9 +368,8 @@ impl Display {
|
|||
match self.outside() {
|
||||
DisplayOutside::Inline => {
|
||||
let inside = match self.inside() {
|
||||
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
|
||||
DisplayInside::Inline | DisplayInside::FlowRoot => DisplayInside::Block,
|
||||
#[cfg(feature = "servo-layout-2020")]
|
||||
// `inline-block` blockifies to `block` rather than
|
||||
// `flow-root`, for legacy reasons.
|
||||
DisplayInside::FlowRoot => DisplayInside::Flow,
|
||||
inside => inside,
|
||||
};
|
||||
|
@ -407,7 +393,9 @@ impl Display {
|
|||
match self.outside() {
|
||||
DisplayOutside::Block => {
|
||||
let inside = match self.inside() {
|
||||
DisplayInside::Block => DisplayInside::FlowRoot,
|
||||
// `display: block` inlinifies to `display: inline-block`,
|
||||
// rather than `inline`, for legacy reasons.
|
||||
DisplayInside::Flow => DisplayInside::FlowRoot,
|
||||
inside => inside,
|
||||
};
|
||||
Display::from3(DisplayOutside::Inline, inside, self.is_list_item())
|
||||
|
@ -443,18 +431,8 @@ impl ToCss for Display {
|
|||
where
|
||||
W: fmt::Write,
|
||||
{
|
||||
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
|
||||
debug_assert_ne!(
|
||||
self.inside(),
|
||||
DisplayInside::Flow,
|
||||
"`flow` fears in `display` computed value"
|
||||
);
|
||||
let outside = self.outside();
|
||||
let inside = match self.inside() {
|
||||
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
|
||||
DisplayInside::Block | DisplayInside::Inline => DisplayInside::Flow,
|
||||
inside => inside,
|
||||
};
|
||||
let inside = self.inside();
|
||||
match *self {
|
||||
Display::Block | Display::Inline => outside.to_css(dest),
|
||||
Display::InlineBlock => dest.write_str("inline-block"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue