mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
2020: define DisplayInside and DisplayOutside enums separately from Stylo
This commit is contained in:
parent
8f89f59329
commit
22f5e07765
4 changed files with 36 additions and 22 deletions
|
@ -210,7 +210,6 @@ where
|
|||
self.handle_block_level_element(style.clone(), inside, contents, box_slot)
|
||||
}
|
||||
},
|
||||
DisplayOutside::None => panic!(":("),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -352,7 +351,6 @@ where
|
|||
inline_box.last_fragment = true;
|
||||
Arc::new(InlineLevelBox::InlineBox(inline_box))
|
||||
},
|
||||
DisplayInside::None | DisplayInside::Contents => panic!(":("),
|
||||
},
|
||||
};
|
||||
self.current_inline_level_boxes().push(box_.clone());
|
||||
|
|
|
@ -122,7 +122,6 @@ impl InlineFormattingContext {
|
|||
inline: match outside {
|
||||
DisplayOutside::Inline => ifc.inline_position,
|
||||
DisplayOutside::Block => Length::zero(),
|
||||
DisplayOutside::None => unreachable!(":("),
|
||||
},
|
||||
block: ifc.line_boxes.next_line_block_position,
|
||||
},
|
||||
|
|
|
@ -38,11 +38,10 @@ use crate::flow::{BlockFormattingContext, FlowChildren};
|
|||
use crate::geom::flow_relative::Vec2;
|
||||
use crate::positioned::AbsolutelyPositionedFragment;
|
||||
use crate::replaced::ReplacedContent;
|
||||
use crate::style_ext::{ComputedValuesExt, Direction, Position, WritingMode};
|
||||
use crate::style_ext::{ComputedValuesExt, Direction, DisplayInside, Position, WritingMode};
|
||||
use servo_arc::Arc;
|
||||
use std::convert::TryInto;
|
||||
use style::context::SharedStyleContext;
|
||||
use style::values::specified::box_::DisplayInside;
|
||||
|
||||
/// https://drafts.csswg.org/css-display/#independent-formatting-context
|
||||
#[derive(Debug)]
|
||||
|
@ -74,7 +73,6 @@ impl IndependentFormattingContext {
|
|||
non_replaced,
|
||||
))
|
||||
},
|
||||
DisplayInside::None | DisplayInside::Contents => panic!(":("),
|
||||
},
|
||||
Err(replaced) => IndependentFormattingContext::Replaced(replaced),
|
||||
}
|
||||
|
|
|
@ -4,14 +4,12 @@
|
|||
|
||||
use crate::geom::{flow_relative, physical};
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{
|
||||
Display as PackedDisplay, Length, LengthPercentage, LengthPercentageOrAuto, Size,
|
||||
};
|
||||
use style::values::computed::{Length, LengthPercentage, LengthPercentageOrAuto, Size};
|
||||
use style::values::specified::box_ as stylo;
|
||||
|
||||
pub use style::computed_values::direction::T as Direction;
|
||||
pub use style::computed_values::position::T as Position;
|
||||
pub use style::computed_values::writing_mode::T as WritingMode;
|
||||
pub use style::values::specified::box_::{DisplayInside, DisplayOutside};
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
pub(crate) enum Display {
|
||||
|
@ -31,6 +29,18 @@ pub(crate) enum DisplayGeneratingBox {
|
|||
// https://drafts.csswg.org/css-display-3/#layout-specific-display
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
pub(crate) enum DisplayOutside {
|
||||
Block,
|
||||
Inline,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
pub(crate) enum DisplayInside {
|
||||
Flow,
|
||||
FlowRoot,
|
||||
}
|
||||
|
||||
pub(crate) trait ComputedValuesExt {
|
||||
fn writing_mode(&self) -> (WritingMode, Direction);
|
||||
fn box_offsets(&self) -> flow_relative::Sides<LengthPercentageOrAuto>;
|
||||
|
@ -105,18 +115,27 @@ impl ComputedValuesExt for ComputedValues {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<PackedDisplay> for Display {
|
||||
fn from(packed_display: PackedDisplay) -> Self {
|
||||
if packed_display == PackedDisplay::None {
|
||||
return Self::None;
|
||||
}
|
||||
if packed_display == PackedDisplay::Contents {
|
||||
return Self::Contents;
|
||||
}
|
||||
Self::GeneratingBox(DisplayGeneratingBox::OutsideInside {
|
||||
outside: packed_display.outside(),
|
||||
inside: packed_display.inside(),
|
||||
// list_item: packed_display.is_list_item(),
|
||||
impl From<stylo::Display> for Display {
|
||||
fn from(packed: stylo::Display) -> Self {
|
||||
let inside = match packed.inside() {
|
||||
stylo::DisplayInside::Flow => DisplayInside::Flow,
|
||||
stylo::DisplayInside::FlowRoot => DisplayInside::FlowRoot,
|
||||
|
||||
// These should not be values of DisplayInside, but oh well
|
||||
stylo::DisplayInside::None => return Display::None,
|
||||
stylo::DisplayInside::Contents => return Display::Contents,
|
||||
};
|
||||
let outside = match packed.outside() {
|
||||
stylo::DisplayOutside::Block => DisplayOutside::Block,
|
||||
stylo::DisplayOutside::Inline => DisplayOutside::Inline,
|
||||
|
||||
// This should not be a value of DisplayInside, but oh well
|
||||
stylo::DisplayOutside::None => return Display::None,
|
||||
};
|
||||
Display::GeneratingBox(DisplayGeneratingBox::OutsideInside {
|
||||
outside,
|
||||
inside,
|
||||
// list_item: packed.is_list_item(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue