Auto merge of #24871 - servo:2020-ci, r=nox,SimonSapin

Run WPT with Layout 2020 on CI

… and gate PRs on the result.
This commit is contained in:
bors-servo 2019-11-27 06:02:23 -05:00 committed by GitHub
commit 83bb96740d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 363 additions and 225 deletions

View file

@ -8,7 +8,7 @@ use crate::style_ext::{Display, DisplayGeneratingBox, DisplayInside, DisplayOuts
use crate::wrapper::GetRawData; use crate::wrapper::GetRawData;
use atomic_refcell::{AtomicRefCell, AtomicRefMut}; use atomic_refcell::{AtomicRefCell, AtomicRefMut};
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode}; use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
use servo_arc::Arc; use servo_arc::Arc as ServoArc;
use std::convert::TryInto; use std::convert::TryInto;
use std::marker::PhantomData as marker; use std::marker::PhantomData as marker;
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
@ -30,7 +30,7 @@ pub(super) enum Contents<Node> {
/// <https://drafts.csswg.org/css2/conform.html#replaced-element> /// <https://drafts.csswg.org/css2/conform.html#replaced-element>
Replaced(ReplacedContent), Replaced(ReplacedContent),
/// Content of a `::before` or `::after` pseudo-element this is being generated. /// Content of a `::before` or `::after` pseudo-element that is being generated.
/// <https://drafts.csswg.org/css2/generate.html#content> /// <https://drafts.csswg.org/css2/generate.html#content>
OfPseudoElement(Vec<PseudoElementContentItem>), OfPseudoElement(Vec<PseudoElementContentItem>),
} }
@ -49,12 +49,12 @@ pub(super) trait TraversalHandler<'dom, Node>
where where
Node: 'dom, Node: 'dom,
{ {
fn handle_text(&mut self, text: String, parent_style: &Arc<ComputedValues>); fn handle_text(&mut self, text: String, parent_style: &ServoArc<ComputedValues>);
/// Or pseudo-element /// Or pseudo-element
fn handle_element( fn handle_element(
&mut self, &mut self,
style: &Arc<ComputedValues>, style: &ServoArc<ComputedValues>,
display: DisplayGeneratingBox, display: DisplayGeneratingBox,
contents: Contents<Node>, contents: Contents<Node>,
box_slot: BoxSlot<'dom>, box_slot: BoxSlot<'dom>,
@ -144,7 +144,7 @@ fn traverse_pseudo_element<'dom, Node>(
} }
fn traverse_pseudo_element_contents<'dom, Node>( fn traverse_pseudo_element_contents<'dom, Node>(
pseudo_element_style: &Arc<ComputedValues>, pseudo_element_style: &ServoArc<ComputedValues>,
context: &SharedStyleContext, context: &SharedStyleContext,
handler: &mut impl TraversalHandler<'dom, Node>, handler: &mut impl TraversalHandler<'dom, Node>,
items: Vec<PseudoElementContentItem>, items: Vec<PseudoElementContentItem>,
@ -213,7 +213,7 @@ where
{ {
pub(crate) fn traverse( pub(crate) fn traverse(
self, self,
inherited_style: &Arc<ComputedValues>, inherited_style: &ServoArc<ComputedValues>,
context: &SharedStyleContext, context: &SharedStyleContext,
handler: &mut impl TraversalHandler<'dom, Node>, handler: &mut impl TraversalHandler<'dom, Node>,
) { ) {
@ -230,7 +230,7 @@ fn pseudo_element_style<'dom, Node>(
_which: WhichPseudoElement, _which: WhichPseudoElement,
_element: Node, _element: Node,
_context: &SharedStyleContext, _context: &SharedStyleContext,
) -> Option<Arc<ComputedValues>> ) -> Option<ServoArc<ComputedValues>>
where where
Node: NodeExt<'dom>, Node: NodeExt<'dom>,
{ {
@ -253,12 +253,12 @@ where
} }
pub struct BoxSlot<'dom> { pub struct BoxSlot<'dom> {
slot: Option<Arc<AtomicRefCell<Option<LayoutBox>>>>, slot: Option<ServoArc<AtomicRefCell<Option<LayoutBox>>>>,
marker: marker<&'dom ()>, marker: marker<&'dom ()>,
} }
impl BoxSlot<'_> { impl BoxSlot<'_> {
pub(crate) fn new(slot: Arc<AtomicRefCell<Option<LayoutBox>>>) -> Self { pub(crate) fn new(slot: ServoArc<AtomicRefCell<Option<LayoutBox>>>) -> Self {
*slot.borrow_mut() = None; *slot.borrow_mut() = None;
let slot = Some(slot); let slot = Some(slot);
Self { slot, marker } Self { slot, marker }
@ -284,13 +284,13 @@ impl Drop for BoxSlot<'_> {
} }
} }
pub trait NodeExt<'dom>: 'dom + Copy + LayoutNode + Send + Sync { pub(crate) trait NodeExt<'dom>: 'dom + Copy + LayoutNode + Send + Sync {
fn is_element(self) -> bool; fn is_element(self) -> bool;
fn as_text(self) -> Option<String>; fn as_text(self) -> Option<String>;
fn first_child(self) -> Option<Self>; fn first_child(self) -> Option<Self>;
fn next_sibling(self) -> Option<Self>; fn next_sibling(self) -> Option<Self>;
fn parent_node(self) -> Option<Self>; fn parent_node(self) -> Option<Self>;
fn style(self, context: &SharedStyleContext) -> Arc<ComputedValues>; fn style(self, context: &SharedStyleContext) -> ServoArc<ComputedValues>;
fn layout_data_mut(&self) -> AtomicRefMut<LayoutDataForElement>; fn layout_data_mut(&self) -> AtomicRefMut<LayoutDataForElement>;
fn element_box_slot(&self) -> BoxSlot<'dom>; fn element_box_slot(&self) -> BoxSlot<'dom>;
@ -327,7 +327,7 @@ where
TNode::parent_node(&self) TNode::parent_node(&self)
} }
fn style(self, context: &SharedStyleContext) -> Arc<ComputedValues> { fn style(self, context: &SharedStyleContext) -> ServoArc<ComputedValues> {
self.to_threadsafe().style(context) self.to_threadsafe().style(context)
} }

View file

@ -7,9 +7,9 @@ use crate::element_data::LayoutBox;
use crate::flow::float::FloatBox; use crate::flow::float::FloatBox;
use crate::flow::inline::{InlineBox, InlineFormattingContext, InlineLevelBox, TextRun}; use crate::flow::inline::{InlineBox, InlineFormattingContext, InlineLevelBox, TextRun};
use crate::flow::{BlockContainer, BlockFormattingContext, BlockLevelBox}; use crate::flow::{BlockContainer, BlockFormattingContext, BlockLevelBox};
use crate::formatting_contexts::IndependentFormattingContext;
use crate::positioned::AbsolutelyPositionedBox; use crate::positioned::AbsolutelyPositionedBox;
use crate::style_ext::{DisplayGeneratingBox, DisplayInside, DisplayOutside}; use crate::style_ext::{DisplayGeneratingBox, DisplayInside, DisplayOutside};
use crate::{take, IndependentFormattingContext};
use rayon::iter::{IntoParallelIterator, ParallelIterator}; use rayon::iter::{IntoParallelIterator, ParallelIterator};
use rayon_croissant::ParallelIteratorExt; use rayon_croissant::ParallelIteratorExt;
use servo_arc::Arc; use servo_arc::Arc;
@ -380,7 +380,7 @@ where
// The fragmented boxes before the block level element // The fragmented boxes before the block level element
// are obviously not the last fragment. // are obviously not the last fragment.
last_fragment: false, last_fragment: false,
children: take(&mut ongoing.children), children: std::mem::take(&mut ongoing.children),
}; };
ongoing.first_fragment = false; ongoing.first_fragment = false;
fragmented fragmented
@ -450,11 +450,10 @@ where
AbsolutelyPositionedBox { AbsolutelyPositionedBox {
contents: IndependentFormattingContext::construct( contents: IndependentFormattingContext::construct(
unimplemented!(), unimplemented!(),
&style, style,
display_inside, display_inside,
contents, contents,
), ),
style,
}, },
)); ));
self.current_inline_level_boxes().push(box_.clone()); self.current_inline_level_boxes().push(box_.clone());
@ -482,11 +481,10 @@ where
let box_ = Arc::new(InlineLevelBox::OutOfFlowFloatBox(FloatBox { let box_ = Arc::new(InlineLevelBox::OutOfFlowFloatBox(FloatBox {
contents: IndependentFormattingContext::construct( contents: IndependentFormattingContext::construct(
self.context, self.context,
&style, style,
display_inside, display_inside,
contents, contents,
), ),
style,
})); }));
self.current_inline_level_boxes().push(box_.clone()); self.current_inline_level_boxes().push(box_.clone());
box_slot.set(LayoutBox::InlineLevel(box_)) box_slot.set(LayoutBox::InlineLevel(box_))
@ -517,7 +515,7 @@ where
let box_ = IntermediateBlockLevelBox::SameFormattingContextBlock { let box_ = IntermediateBlockLevelBox::SameFormattingContextBlock {
style: anonymous_style.clone(), style: anonymous_style.clone(),
contents: IntermediateBlockContainer::InlineFormattingContext(take( contents: IntermediateBlockContainer::InlineFormattingContext(std::mem::take(
&mut self.ongoing_inline_formatting_context, &mut self.ongoing_inline_formatting_context,
)), )),
}; };
@ -562,12 +560,12 @@ where
} => { } => {
let contents = IndependentFormattingContext::construct( let contents = IndependentFormattingContext::construct(
context, context,
&style, style,
display_inside, display_inside,
contents, contents,
); );
( (
Arc::new(BlockLevelBox::Independent { style, contents }), Arc::new(BlockLevelBox::Independent(contents)),
ContainsFloats::No, ContainsFloats::No,
) )
}, },
@ -580,11 +578,10 @@ where
AbsolutelyPositionedBox { AbsolutelyPositionedBox {
contents: IndependentFormattingContext::construct( contents: IndependentFormattingContext::construct(
context, context,
&style, style,
display_inside, display_inside,
contents, contents,
), ),
style: style,
}, },
)); ));
(block_level_box, ContainsFloats::No) (block_level_box, ContainsFloats::No)
@ -596,14 +593,12 @@ where
} => { } => {
let contents = IndependentFormattingContext::construct( let contents = IndependentFormattingContext::construct(
context, context,
&style, style,
display_inside, display_inside,
contents, contents,
); );
let block_level_box = Arc::new(BlockLevelBox::OutOfFlowFloatBox(FloatBox { let block_level_box =
contents, Arc::new(BlockLevelBox::OutOfFlowFloatBox(FloatBox { contents }));
style,
}));
(block_level_box, ContainsFloats::Yes) (block_level_box, ContainsFloats::Yes)
}, },
} }

View file

@ -2,13 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::IndependentFormattingContext; use crate::formatting_contexts::IndependentFormattingContext;
use servo_arc::Arc; use servo_arc::Arc;
use style::properties::ComputedValues; use style::properties::ComputedValues;
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct FloatBox { pub(crate) struct FloatBox {
pub style: Arc<ComputedValues>,
pub contents: IndependentFormattingContext, pub contents: IndependentFormattingContext,
} }

View file

@ -4,7 +4,7 @@
use crate::context::LayoutContext; use crate::context::LayoutContext;
use crate::flow::float::FloatBox; use crate::flow::float::FloatBox;
use crate::flow::FlowChildren; use crate::flow::FlowLayout;
use crate::fragments::{ use crate::fragments::{
AnonymousFragment, BoxFragment, CollapsedBlockMargins, Fragment, TextFragment, AnonymousFragment, BoxFragment, CollapsedBlockMargins, Fragment, TextFragment,
}; };
@ -12,7 +12,7 @@ use crate::geom::flow_relative::{Rect, Sides, Vec2};
use crate::positioned::{AbsolutelyPositionedBox, AbsolutelyPositionedFragment}; use crate::positioned::{AbsolutelyPositionedBox, AbsolutelyPositionedFragment};
use crate::replaced::ReplacedContent; use crate::replaced::ReplacedContent;
use crate::style_ext::{ComputedValuesExt, Display, DisplayGeneratingBox, DisplayOutside}; use crate::style_ext::{ComputedValuesExt, Display, DisplayGeneratingBox, DisplayOutside};
use crate::{relative_adjustement, take, ContainingBlock}; use crate::{relative_adjustement, ContainingBlock};
use servo_arc::Arc; use servo_arc::Arc;
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::values::computed::Length; use style::values::computed::Length;
@ -88,7 +88,7 @@ impl InlineFormattingContext {
containing_block: &ContainingBlock, containing_block: &ContainingBlock,
tree_rank: usize, tree_rank: usize,
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>, absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
) -> FlowChildren { ) -> FlowLayout {
let mut ifc = InlineFormattingContextState { let mut ifc = InlineFormattingContextState {
containing_block, containing_block,
partial_inline_boxes_stack: Vec::new(), partial_inline_boxes_stack: Vec::new(),
@ -118,7 +118,7 @@ impl InlineFormattingContext {
}, },
InlineLevelBox::OutOfFlowAbsolutelyPositionedBox(box_) => { InlineLevelBox::OutOfFlowAbsolutelyPositionedBox(box_) => {
let initial_start_corner = let initial_start_corner =
match Display::from(box_.style.get_box().original_display) { match Display::from(box_.contents.style.get_box().original_display) {
Display::GeneratingBox(DisplayGeneratingBox::OutsideInside { Display::GeneratingBox(DisplayGeneratingBox::OutsideInside {
outside, outside,
inside: _, inside: _,
@ -156,9 +156,9 @@ impl InlineFormattingContext {
} else { } else {
ifc.line_boxes ifc.line_boxes
.finish_line(&mut ifc.current_nesting_level, containing_block); .finish_line(&mut ifc.current_nesting_level, containing_block);
return FlowChildren { return FlowLayout {
fragments: ifc.line_boxes.boxes, fragments: ifc.line_boxes.boxes,
block_size: ifc.line_boxes.next_line_block_position, content_block_size: ifc.line_boxes.next_line_block_position,
collapsible_margins_in_children: CollapsedBlockMargins::zero(), collapsible_margins_in_children: CollapsedBlockMargins::zero(),
}; };
} }
@ -185,7 +185,7 @@ impl LinesBoxes {
}; };
self.next_line_block_position += size.block; self.next_line_block_position += size.block;
self.boxes.push(Fragment::Anonymous(AnonymousFragment { self.boxes.push(Fragment::Anonymous(AnonymousFragment {
children: take(&mut top_nesting_level.fragments_so_far), children: std::mem::take(&mut top_nesting_level.fragments_so_far),
rect: Rect { start_corner, size }, rect: Rect { start_corner, size },
mode: containing_block.mode, mode: containing_block.mode,
})) }))
@ -250,7 +250,7 @@ impl<'box_tree> PartialInlineBoxFragment<'box_tree> {
) { ) {
let mut fragment = BoxFragment { let mut fragment = BoxFragment {
style: self.style.clone(), style: self.style.clone(),
children: take(&mut nesting_level.fragments_so_far), children: std::mem::take(&mut nesting_level.fragments_so_far),
content_rect: Rect { content_rect: Rect {
size: Vec2 { size: Vec2 {
inline: *inline_position - self.start_corner.inline, inline: *inline_position - self.start_corner.inline,

View file

@ -7,15 +7,16 @@
use crate::context::LayoutContext; use crate::context::LayoutContext;
use crate::flow::float::{FloatBox, FloatContext}; use crate::flow::float::{FloatBox, FloatContext};
use crate::flow::inline::InlineFormattingContext; use crate::flow::inline::InlineFormattingContext;
use crate::formatting_contexts::{IndependentFormattingContext, IndependentLayout};
use crate::fragments::{ use crate::fragments::{
AnonymousFragment, BoxFragment, CollapsedBlockMargins, CollapsedMargin, Fragment, AnonymousFragment, BoxFragment, CollapsedBlockMargins, CollapsedMargin, Fragment,
}; };
use crate::geom::flow_relative::{Rect, Vec2}; use crate::geom::flow_relative::{Rect, Sides, Vec2};
use crate::positioned::{ use crate::positioned::{
adjust_static_positions, AbsolutelyPositionedBox, AbsolutelyPositionedFragment, adjust_static_positions, AbsolutelyPositionedBox, AbsolutelyPositionedFragment,
}; };
use crate::style_ext::{ComputedValuesExt, Position}; use crate::style_ext::{ComputedValuesExt, Position};
use crate::{relative_adjustement, ContainingBlock, IndependentFormattingContext}; use crate::{relative_adjustement, ContainingBlock};
use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator}; use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};
use rayon_croissant::ParallelIteratorExt; use rayon_croissant::ParallelIteratorExt;
use servo_arc::Arc; use servo_arc::Arc;
@ -50,15 +51,12 @@ pub(crate) enum BlockLevelBox {
}, },
OutOfFlowAbsolutelyPositionedBox(AbsolutelyPositionedBox), OutOfFlowAbsolutelyPositionedBox(AbsolutelyPositionedBox),
OutOfFlowFloatBox(FloatBox), OutOfFlowFloatBox(FloatBox),
Independent { Independent(IndependentFormattingContext),
style: Arc<ComputedValues>,
contents: IndependentFormattingContext,
},
} }
pub(super) struct FlowChildren { struct FlowLayout {
pub fragments: Vec<Fragment>, pub fragments: Vec<Fragment>,
pub block_size: Length, pub content_block_size: Length,
pub collapsible_margins_in_children: CollapsedBlockMargins, pub collapsible_margins_in_children: CollapsedBlockMargins,
} }
@ -72,7 +70,7 @@ impl BlockFormattingContext {
containing_block: &ContainingBlock, containing_block: &ContainingBlock,
tree_rank: usize, tree_rank: usize,
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>, absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
) -> FlowChildren { ) -> IndependentLayout {
let mut float_context; let mut float_context;
let float_context = if self.contains_floats { let float_context = if self.contains_floats {
float_context = FloatContext::new(); float_context = FloatContext::new();
@ -80,7 +78,7 @@ impl BlockFormattingContext {
} else { } else {
None None
}; };
let mut flow_children = self.contents.layout( let flow_layout = self.contents.layout(
layout_context, layout_context,
containing_block, containing_block,
tree_rank, tree_rank,
@ -88,12 +86,16 @@ impl BlockFormattingContext {
float_context, float_context,
CollapsibleWithParentStartMargin(false), CollapsibleWithParentStartMargin(false),
); );
flow_children.block_size += flow_children.collapsible_margins_in_children.end.solve(); assert!(
flow_children !flow_layout
.collapsible_margins_in_children .collapsible_margins_in_children
.collapsed_through = false; .collapsed_through
flow_children.collapsible_margins_in_children.end = CollapsedMargin::zero(); );
flow_children IndependentLayout {
fragments: flow_layout.fragments,
content_block_size: flow_layout.content_block_size +
flow_layout.collapsible_margins_in_children.end.solve(),
}
} }
} }
@ -106,7 +108,7 @@ impl BlockContainer {
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>, absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
float_context: Option<&mut FloatContext>, float_context: Option<&mut FloatContext>,
collapsible_with_parent_start_margin: CollapsibleWithParentStartMargin, collapsible_with_parent_start_margin: CollapsibleWithParentStartMargin,
) -> FlowChildren { ) -> FlowLayout {
match self { match self {
BlockContainer::BlockLevelBoxes(child_boxes) => layout_block_level_children( BlockContainer::BlockLevelBoxes(child_boxes) => layout_block_level_children(
layout_context, layout_context,
@ -135,7 +137,7 @@ fn layout_block_level_children<'a>(
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>, absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
float_context: Option<&mut FloatContext>, float_context: Option<&mut FloatContext>,
collapsible_with_parent_start_margin: CollapsibleWithParentStartMargin, collapsible_with_parent_start_margin: CollapsibleWithParentStartMargin,
) -> FlowChildren { ) -> FlowLayout {
fn place_block_level_fragment(fragment: &mut Fragment, placement_state: &mut PlacementState) { fn place_block_level_fragment(fragment: &mut Fragment, placement_state: &mut PlacementState) {
match fragment { match fragment {
Fragment::Box(fragment) => { Fragment::Box(fragment) => {
@ -251,9 +253,9 @@ fn layout_block_level_children<'a>(
tree_rank, tree_rank,
); );
FlowChildren { FlowLayout {
fragments, fragments,
block_size: placement_state.current_block_direction_position, content_block_size: placement_state.current_block_direction_position,
collapsible_margins_in_children: CollapsedBlockMargins { collapsible_margins_in_children: CollapsedBlockMargins {
collapsed_through: placement_state collapsed_through: placement_state
.next_in_flow_margin_collapses_with_parent_start_margin, .next_in_flow_margin_collapses_with_parent_start_margin,
@ -292,19 +294,29 @@ impl BlockLevelBox {
}, },
)) ))
}, },
BlockLevelBox::Independent { style, contents } => match contents.as_replaced() { BlockLevelBox::Independent(contents) => match contents.as_replaced() {
Ok(replaced) => { Ok(replaced) => {
// FIXME // FIXME
match *replaced {} match *replaced {}
}, },
Err(contents) => Fragment::Box(layout_in_flow_non_replaced_block_level( Err(non_replaced) => Fragment::Box(layout_in_flow_non_replaced_block_level(
layout_context, layout_context,
containing_block, containing_block,
absolutely_positioned_fragments, absolutely_positioned_fragments,
style, &contents.style,
BlockLevelKind::EstablishesAnIndependentFormattingContext, BlockLevelKind::EstablishesAnIndependentFormattingContext,
|containing_block, nested_abspos, _| { |containing_block, nested_abspos, _| {
contents.layout(layout_context, containing_block, tree_rank, nested_abspos) let independent_layout = non_replaced.layout(
layout_context,
containing_block,
tree_rank,
nested_abspos,
);
FlowLayout {
fragments: independent_layout.fragments,
content_block_size: independent_layout.content_block_size,
collapsible_margins_in_children: CollapsedBlockMargins::zero(),
}
}, },
)), )),
}, },
@ -338,7 +350,7 @@ fn layout_in_flow_non_replaced_block_level<'a>(
&ContainingBlock, &ContainingBlock,
&mut Vec<AbsolutelyPositionedFragment<'a>>, &mut Vec<AbsolutelyPositionedFragment<'a>>,
CollapsibleWithParentStartMargin, CollapsibleWithParentStartMargin,
) -> FlowChildren, ) -> FlowLayout,
) -> BoxFragment { ) -> BoxFragment {
let cbis = containing_block.inline_size; let cbis = containing_block.inline_size;
let padding = style.padding().percentages_relative_to(cbis); let padding = style.padding().percentages_relative_to(cbis);
@ -397,7 +409,7 @@ fn layout_in_flow_non_replaced_block_level<'a>(
LengthOrAuto::Auto, LengthOrAuto::Auto,
); );
let mut nested_abspos = vec![]; let mut nested_abspos = vec![];
let mut flow_children = layout_contents( let mut flow_layout = layout_contents(
&containing_block_for_children, &containing_block_for_children,
if style.get_box().position == Position::Relative { if style.get_box().position == Position::Relative {
&mut nested_abspos &mut nested_abspos
@ -409,15 +421,15 @@ fn layout_in_flow_non_replaced_block_level<'a>(
if this_start_margin_can_collapse_with_children.0 { if this_start_margin_can_collapse_with_children.0 {
block_margins_collapsed_with_children block_margins_collapsed_with_children
.start .start
.adjoin_assign(&flow_children.collapsible_margins_in_children.start); .adjoin_assign(&flow_layout.collapsible_margins_in_children.start);
if flow_children if flow_layout
.collapsible_margins_in_children .collapsible_margins_in_children
.collapsed_through .collapsed_through
{ {
block_margins_collapsed_with_children block_margins_collapsed_with_children
.start .start
.adjoin_assign(&std::mem::replace( .adjoin_assign(&std::mem::replace(
&mut flow_children.collapsible_margins_in_children.end, &mut flow_layout.collapsible_margins_in_children.end,
CollapsedMargin::zero(), CollapsedMargin::zero(),
)); ));
} }
@ -425,18 +437,18 @@ fn layout_in_flow_non_replaced_block_level<'a>(
if this_end_margin_can_collapse_with_children { if this_end_margin_can_collapse_with_children {
block_margins_collapsed_with_children block_margins_collapsed_with_children
.end .end
.adjoin_assign(&flow_children.collapsible_margins_in_children.end); .adjoin_assign(&flow_layout.collapsible_margins_in_children.end);
} else { } else {
flow_children.block_size += flow_children.collapsible_margins_in_children.end.solve(); flow_layout.content_block_size += flow_layout.collapsible_margins_in_children.end.solve();
} }
block_margins_collapsed_with_children.collapsed_through = block_margins_collapsed_with_children.collapsed_through =
this_start_margin_can_collapse_with_children.0 && this_start_margin_can_collapse_with_children.0 &&
this_end_margin_can_collapse_with_children && this_end_margin_can_collapse_with_children &&
flow_children flow_layout
.collapsible_margins_in_children .collapsible_margins_in_children
.collapsed_through; .collapsed_through;
let relative_adjustement = relative_adjustement(style, inline_size, block_size); let relative_adjustement = relative_adjustement(style, inline_size, block_size);
let block_size = block_size.auto_is(|| flow_children.block_size); let block_size = block_size.auto_is(|| flow_layout.content_block_size);
let content_rect = Rect { let content_rect = Rect {
start_corner: Vec2 { start_corner: Vec2 {
block: pb.block_start + relative_adjustement.block, block: pb.block_start + relative_adjustement.block,
@ -451,7 +463,7 @@ fn layout_in_flow_non_replaced_block_level<'a>(
AbsolutelyPositionedFragment::in_positioned_containing_block( AbsolutelyPositionedFragment::in_positioned_containing_block(
layout_context, layout_context,
&nested_abspos, &nested_abspos,
&mut flow_children.fragments, &mut flow_layout.fragments,
&content_rect.size, &content_rect.size,
&padding, &padding,
containing_block_for_children.mode, containing_block_for_children.mode,
@ -459,7 +471,7 @@ fn layout_in_flow_non_replaced_block_level<'a>(
} }
BoxFragment { BoxFragment {
style: style.clone(), style: style.clone(),
children: flow_children.fragments, children: flow_layout.fragments,
content_rect, content_rect,
padding, padding,
border, border,

View file

@ -8,6 +8,7 @@ use crate::dom_traversal::{Contents, NodeExt};
use crate::flow::construct::ContainsFloats; use crate::flow::construct::ContainsFloats;
use crate::flow::float::FloatBox; use crate::flow::float::FloatBox;
use crate::flow::{BlockContainer, BlockFormattingContext, BlockLevelBox}; use crate::flow::{BlockContainer, BlockFormattingContext, BlockLevelBox};
use crate::formatting_contexts::IndependentFormattingContext;
use crate::fragments::Fragment; use crate::fragments::Fragment;
use crate::geom; use crate::geom;
use crate::geom::flow_relative::Vec2; use crate::geom::flow_relative::Vec2;
@ -16,8 +17,9 @@ use crate::replaced::ReplacedContent;
use crate::style_ext::{ use crate::style_ext::{
Direction, Display, DisplayGeneratingBox, DisplayInside, DisplayOutside, WritingMode, Direction, Display, DisplayGeneratingBox, DisplayInside, DisplayOutside, WritingMode,
}; };
use crate::{ContainingBlock, DefiniteContainingBlock, IndependentFormattingContext}; use crate::{ContainingBlock, DefiniteContainingBlock};
use rayon::iter::{IntoParallelRefIterator, ParallelExtend, ParallelIterator}; use rayon::iter::{IntoParallelRefIterator, ParallelExtend, ParallelIterator};
use script_layout_interface::wrapper_traits::LayoutNode;
use servo_arc::Arc; use servo_arc::Arc;
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::properties::ComputedValues; use style::properties::ComputedValues;
@ -29,10 +31,10 @@ pub struct BoxTreeRoot(BlockFormattingContext);
pub struct FragmentTreeRoot(Vec<Fragment>); pub struct FragmentTreeRoot(Vec<Fragment>);
impl BoxTreeRoot { impl BoxTreeRoot {
pub fn construct<'dom>( pub fn construct<'dom, Node>(context: &SharedStyleContext<'_>, root_element: Node) -> Self
context: &SharedStyleContext<'_>, where
root_element: impl NodeExt<'dom>, Node: 'dom + Copy + LayoutNode + Send + Sync,
) -> Self { {
let (contains_floats, boxes) = construct_for_root_element(&context, root_element); let (contains_floats, boxes) = construct_for_root_element(&context, root_element);
Self(BlockFormattingContext { Self(BlockFormattingContext {
contains_floats: contains_floats == ContainsFloats::Yes, contains_floats: contains_floats == ContainsFloats::Yes,
@ -69,31 +71,32 @@ fn construct_for_root_element<'dom>(
} }
} }
let position = box_style.position;
let float = box_style.float;
let contents = IndependentFormattingContext::construct( let contents = IndependentFormattingContext::construct(
context, context,
&style, style,
display_inside, display_inside,
Contents::OfElement(root_element), Contents::OfElement(root_element),
); );
if box_style.position.is_absolutely_positioned() { if position.is_absolutely_positioned() {
( (
ContainsFloats::No, ContainsFloats::No,
vec![Arc::new(BlockLevelBox::OutOfFlowAbsolutelyPositionedBox( vec![Arc::new(BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(
AbsolutelyPositionedBox { style, contents }, AbsolutelyPositionedBox { contents },
))], ))],
) )
} else if box_style.float.is_floating() { } else if float.is_floating() {
( (
ContainsFloats::Yes, ContainsFloats::Yes,
vec![Arc::new(BlockLevelBox::OutOfFlowFloatBox(FloatBox { vec![Arc::new(BlockLevelBox::OutOfFlowFloatBox(FloatBox {
contents, contents,
style,
}))], }))],
) )
} else { } else {
( (
ContainsFloats::No, ContainsFloats::No,
vec![Arc::new(BlockLevelBox::Independent { style, contents })], vec![Arc::new(BlockLevelBox::Independent(contents))],
) )
} }
} }
@ -118,7 +121,7 @@ impl BoxTreeRoot {
}; };
let dummy_tree_rank = 0; let dummy_tree_rank = 0;
let mut absolutely_positioned_fragments = vec![]; let mut absolutely_positioned_fragments = vec![];
let mut flow_children = self.0.layout( let mut independent_layout = self.0.layout(
layout_context, layout_context,
&initial_containing_block, &initial_containing_block,
dummy_tree_rank, dummy_tree_rank,
@ -129,12 +132,12 @@ impl BoxTreeRoot {
size: initial_containing_block_size, size: initial_containing_block_size,
mode: initial_containing_block.mode, mode: initial_containing_block.mode,
}; };
flow_children.fragments.par_extend( independent_layout.fragments.par_extend(
absolutely_positioned_fragments absolutely_positioned_fragments
.par_iter() .par_iter()
.map(|a| a.layout(layout_context, &initial_containing_block)), .map(|a| a.layout(layout_context, &initial_containing_block)),
); );
FragmentTreeRoot(flow_children.fragments) FragmentTreeRoot(independent_layout.fragments)
} }
} }

View file

@ -0,0 +1,114 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::context::LayoutContext;
use crate::dom_traversal::{Contents, NodeExt};
use crate::flow::BlockFormattingContext;
use crate::fragments::Fragment;
use crate::geom::flow_relative::Vec2;
use crate::positioned::AbsolutelyPositionedFragment;
use crate::replaced::ReplacedContent;
use crate::style_ext::{ComputedValuesExt, Direction, DisplayInside, Position, WritingMode};
use crate::ContainingBlock;
use servo_arc::Arc;
use std::convert::TryInto;
use style::context::SharedStyleContext;
use style::properties::ComputedValues;
use style::values::computed::Length;
/// https://drafts.csswg.org/css-display/#independent-formatting-context
#[derive(Debug)]
pub(crate) struct IndependentFormattingContext {
pub style: Arc<ComputedValues>,
contents: IndependentFormattingContextContents,
}
pub(crate) struct IndependentLayout {
pub fragments: Vec<Fragment>,
pub content_block_size: Length,
}
// Private so that code outside of this module cannot match variants.
// It should got through methods instead.
#[derive(Debug)]
enum IndependentFormattingContextContents {
Flow(BlockFormattingContext),
// Not called FC in specs, but behaves close enough
Replaced(ReplacedContent),
// Other layout modes go here
}
pub(crate) struct NonReplacedIFC<'a>(NonReplacedIFCKind<'a>);
enum NonReplacedIFCKind<'a> {
Flow(&'a BlockFormattingContext),
}
impl IndependentFormattingContext {
pub fn construct<'dom, 'style>(
context: &SharedStyleContext<'style>,
style: Arc<ComputedValues>,
display_inside: DisplayInside,
contents: Contents<impl NodeExt<'dom>>,
) -> Self {
use self::IndependentFormattingContextContents as Contents;
let contents = match contents.try_into() {
Ok(non_replaced) => match display_inside {
DisplayInside::Flow | DisplayInside::FlowRoot => Contents::Flow(
BlockFormattingContext::construct(context, &style, non_replaced),
),
},
Err(replaced) => Contents::Replaced(replaced),
};
Self { style, contents }
}
pub fn as_replaced(&self) -> Result<&ReplacedContent, NonReplacedIFC> {
use self::IndependentFormattingContextContents as Contents;
use self::NonReplacedIFC as NR;
use self::NonReplacedIFCKind as Kind;
match &self.contents {
Contents::Replaced(r) => Ok(r),
Contents::Flow(f) => Err(NR(Kind::Flow(f))),
}
}
pub fn layout<'a>(
&'a self,
layout_context: &LayoutContext,
containing_block: &ContainingBlock,
tree_rank: usize,
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
) -> IndependentLayout {
match self.as_replaced() {
Ok(replaced) => match *replaced {},
Err(ifc) => ifc.layout(
layout_context,
containing_block,
tree_rank,
absolutely_positioned_fragments,
),
}
}
}
impl<'a> NonReplacedIFC<'a> {
pub fn layout(
&self,
layout_context: &LayoutContext,
containing_block: &ContainingBlock,
tree_rank: usize,
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
) -> IndependentLayout {
match &self.0 {
NonReplacedIFCKind::Flow(bfc) => bfc.layout(
layout_context,
containing_block,
tree_rank,
absolutely_positioned_fragments,
),
}
}
}

View file

@ -12,16 +12,13 @@
#[macro_use] #[macro_use]
extern crate serde; extern crate serde;
use style::properties::ComputedValues;
use style::values::computed::{Length, LengthOrAuto};
use style::Zero;
pub mod context; pub mod context;
pub mod data; pub mod data;
pub mod display_list; pub mod display_list;
mod dom_traversal; mod dom_traversal;
mod element_data; mod element_data;
mod flow; mod flow;
mod formatting_contexts;
mod fragments; mod fragments;
mod geom; mod geom;
mod opaque_node; mod opaque_node;
@ -36,94 +33,16 @@ pub use flow::{BoxTreeRoot, FragmentTreeRoot};
use crate::context::LayoutContext; use crate::context::LayoutContext;
use crate::dom_traversal::{Contents, NodeExt}; use crate::dom_traversal::{Contents, NodeExt};
use crate::flow::{BlockFormattingContext, FlowChildren}; use crate::flow::BlockFormattingContext;
use crate::geom::flow_relative::Vec2; use crate::geom::flow_relative::Vec2;
use crate::positioned::AbsolutelyPositionedFragment; use crate::positioned::AbsolutelyPositionedFragment;
use crate::replaced::ReplacedContent; use crate::replaced::ReplacedContent;
use crate::style_ext::{ComputedValuesExt, Direction, DisplayInside, Position, WritingMode}; use crate::style_ext::{ComputedValuesExt, Direction, DisplayInside, Position, WritingMode};
use servo_arc::Arc; use servo_arc::Arc;
use std::convert::TryInto; use std::convert::TryInto;
use style::context::SharedStyleContext; use style::properties::ComputedValues;
use style::values::computed::{Length, LengthOrAuto};
/// https://drafts.csswg.org/css-display/#independent-formatting-context use style::Zero;
#[derive(Debug)]
enum IndependentFormattingContext {
Flow(BlockFormattingContext),
// Not called FC in specs, but behaves close enough
Replaced(ReplacedContent),
// Other layout modes go here
}
enum NonReplacedIFC<'a> {
Flow(&'a BlockFormattingContext),
}
impl IndependentFormattingContext {
fn construct<'dom, 'style>(
context: &SharedStyleContext<'style>,
style: &Arc<ComputedValues>,
display_inside: DisplayInside,
contents: Contents<impl NodeExt<'dom>>,
) -> Self {
match contents.try_into() {
Ok(non_replaced) => match display_inside {
DisplayInside::Flow | DisplayInside::FlowRoot => {
IndependentFormattingContext::Flow(BlockFormattingContext::construct(
context,
style,
non_replaced,
))
},
},
Err(replaced) => IndependentFormattingContext::Replaced(replaced),
}
}
fn as_replaced(&self) -> Result<&ReplacedContent, NonReplacedIFC> {
match self {
IndependentFormattingContext::Replaced(r) => Ok(r),
IndependentFormattingContext::Flow(f) => Err(NonReplacedIFC::Flow(f)),
}
}
fn layout<'a>(
&'a self,
layout_context: &LayoutContext,
containing_block: &ContainingBlock,
tree_rank: usize,
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
) -> FlowChildren {
match self.as_replaced() {
Ok(replaced) => match *replaced {},
Err(ifc) => ifc.layout(
layout_context,
containing_block,
tree_rank,
absolutely_positioned_fragments,
),
}
}
}
impl<'a> NonReplacedIFC<'a> {
fn layout(
&self,
layout_context: &LayoutContext,
containing_block: &ContainingBlock,
tree_rank: usize,
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
) -> FlowChildren {
match self {
NonReplacedIFC::Flow(bfc) => bfc.layout(
layout_context,
containing_block,
tree_rank,
absolutely_positioned_fragments,
),
}
}
}
struct ContainingBlock { struct ContainingBlock {
inline_size: Length, inline_size: Length,
@ -162,12 +81,3 @@ fn relative_adjustement(
block: adjust(box_offsets.block_start, box_offsets.block_end), block: adjust(box_offsets.block_start, box_offsets.block_end),
} }
} }
// FIXME: use std::mem::take when its stable.
// https://github.com/rust-lang/rust/issues/61129
fn take<T>(x: &mut T) -> T
where
T: Default,
{
std::mem::replace(x, Default::default())
}

View file

@ -3,10 +3,11 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::context::LayoutContext; use crate::context::LayoutContext;
use crate::formatting_contexts::IndependentFormattingContext;
use crate::fragments::{AnonymousFragment, BoxFragment, CollapsedBlockMargins, Fragment}; use crate::fragments::{AnonymousFragment, BoxFragment, CollapsedBlockMargins, Fragment};
use crate::geom::flow_relative::{Rect, Sides, Vec2}; use crate::geom::flow_relative::{Rect, Sides, Vec2};
use crate::style_ext::{ComputedValuesExt, Direction, WritingMode}; use crate::style_ext::{ComputedValuesExt, Direction, WritingMode};
use crate::{ContainingBlock, DefiniteContainingBlock, IndependentFormattingContext}; use crate::{ContainingBlock, DefiniteContainingBlock};
use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use servo_arc::Arc; use servo_arc::Arc;
use style::properties::ComputedValues; use style::properties::ComputedValues;
@ -15,7 +16,6 @@ use style::Zero;
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct AbsolutelyPositionedBox { pub(crate) struct AbsolutelyPositionedBox {
pub style: Arc<ComputedValues>,
pub contents: IndependentFormattingContext, pub contents: IndependentFormattingContext,
} }
@ -49,7 +49,7 @@ impl AbsolutelyPositionedBox {
initial_start_corner: Vec2<Length>, initial_start_corner: Vec2<Length>,
tree_rank: usize, tree_rank: usize,
) -> AbsolutelyPositionedFragment { ) -> AbsolutelyPositionedFragment {
let style = &self.style; let style = &self.contents.style;
let box_offsets = style.box_offsets(); let box_offsets = style.box_offsets();
let box_size = style.box_size(); let box_size = style.box_size();
@ -130,7 +130,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
layout_context: &LayoutContext, layout_context: &LayoutContext,
containing_block: &DefiniteContainingBlock, containing_block: &DefiniteContainingBlock,
) -> Fragment { ) -> Fragment {
let style = &self.absolutely_positioned_box.style; let style = &self.absolutely_positioned_box.contents.style;
let cbis = containing_block.size.inline; let cbis = containing_block.size.inline;
let cbbs = containing_block.size.block; let cbbs = containing_block.size.block;
@ -274,7 +274,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
); );
let dummy_tree_rank = 0; let dummy_tree_rank = 0;
let mut absolutely_positioned_fragments = vec![]; let mut absolutely_positioned_fragments = vec![];
let mut flow_children = self.absolutely_positioned_box.contents.layout( let mut independent_layout = self.absolutely_positioned_box.contents.layout(
layout_context, layout_context,
&containing_block_for_children, &containing_block_for_children,
dummy_tree_rank, dummy_tree_rank,
@ -286,7 +286,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
Anchor::End(end) => cbbs - end - pb.inline_end - margin.inline_end - inline_size, Anchor::End(end) => cbbs - end - pb.inline_end - margin.inline_end - inline_size,
}; };
let block_size = block_size.auto_is(|| flow_children.block_size); let block_size = block_size.auto_is(|| independent_layout.content_block_size);
let block_start = match block_anchor { let block_start = match block_anchor {
Anchor::Start(start) => start + pb.block_start + margin.block_start, Anchor::Start(start) => start + pb.block_start + margin.block_start,
Anchor::End(end) => cbbs - end - pb.block_end - margin.block_end - block_size, Anchor::End(end) => cbbs - end - pb.block_end - margin.block_end - block_size,
@ -306,7 +306,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
AbsolutelyPositionedFragment::in_positioned_containing_block( AbsolutelyPositionedFragment::in_positioned_containing_block(
layout_context, layout_context,
&absolutely_positioned_fragments, &absolutely_positioned_fragments,
&mut flow_children.fragments, &mut independent_layout.fragments,
&content_rect.size, &content_rect.size,
&padding, &padding,
containing_block_for_children.mode, containing_block_for_children.mode,
@ -314,7 +314,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
Fragment::Box(BoxFragment { Fragment::Box(BoxFragment {
style: style.clone(), style: style.clone(),
children: flow_children.fragments, children: independent_layout.fragments,
content_rect, content_rect,
padding, padding,
border, border,

View file

@ -1091,7 +1091,7 @@ impl LayoutThread {
let rayon_pool = rayon_pool.as_ref().unwrap(); let rayon_pool = rayon_pool.as_ref().unwrap();
let box_tree = if token.should_traverse() { let box_tree = if token.should_traverse() {
driver::traverse_dom(&traversal, token, None); driver::traverse_dom(&traversal, token, Some(rayon_pool));
let shared = DomTraversal::<ServoLayoutElement>::shared_context(&traversal); let shared = DomTraversal::<ServoLayoutElement>::shared_context(&traversal);
let root_node = document.root_element().unwrap().as_node(); let root_node = document.root_element().unwrap().as_node();

View file

@ -1260,12 +1260,12 @@ impl LonghandId {
LonghandId::Stroke | LonghandId::Stroke |
LonghandId::CaretColor | LonghandId::CaretColor |
% endif % endif
% if engine in ["gecko", "servo-2013"]:
LonghandId::BackgroundColor | LonghandId::BackgroundColor |
LonghandId::BorderTopColor | LonghandId::BorderTopColor |
LonghandId::BorderRightColor | LonghandId::BorderRightColor |
LonghandId::BorderBottomColor | LonghandId::BorderBottomColor |
LonghandId::BorderLeftColor | LonghandId::BorderLeftColor |
% if engine in ["gecko", "servo-2013"]:
LonghandId::OutlineColor | LonghandId::OutlineColor |
% endif % endif
LonghandId::Color LonghandId::Color
@ -1315,14 +1315,12 @@ impl LonghandId {
LonghandId::MozScriptLevel | LonghandId::MozScriptLevel |
% endif % endif
% if engine in ["gecko", "servo-2013"]:
// Needed to compute the first available font, in order to // Needed to compute the first available font, in order to
// compute font-relative units correctly. // compute font-relative units correctly.
LonghandId::FontSize | LonghandId::FontSize |
LonghandId::FontWeight | LonghandId::FontWeight |
LonghandId::FontStretch | LonghandId::FontStretch |
LonghandId::FontStyle | LonghandId::FontStyle |
% endif
LonghandId::FontFamily | LonghandId::FontFamily |
// Needed to properly compute the writing mode, to resolve logical // Needed to properly compute the writing mode, to resolve logical

View file

@ -26,7 +26,9 @@ pub struct RuleCacheConditions {
impl RuleCacheConditions { impl RuleCacheConditions {
/// Sets the style as depending in the font-size value. /// Sets the style as depending in the font-size value.
pub fn set_font_size_dependency(&mut self, font_size: NonNegativeLength) { pub fn set_font_size_dependency(&mut self, font_size: NonNegativeLength) {
debug_assert!(self.font_size.map_or(true, |f| f == font_size)); if let Some(f) = &self.font_size {
debug_assert_eq!(*f, font_size);
}
self.font_size = Some(font_size); self.font_size = Some(font_size);
} }

View file

@ -50,6 +50,7 @@ def tasks(task_for):
android_arm32_release, android_arm32_release,
android_x86_wpt, android_x86_wpt,
linux_wpt, linux_wpt,
linux_wpt_layout_2020,
linux_release, linux_release,
macos_wpt, macos_wpt,
] ]
@ -72,6 +73,7 @@ def tasks(task_for):
"try-magicleap": [magicleap_dev], "try-magicleap": [magicleap_dev],
"try-arm": [windows_arm64], "try-arm": [windows_arm64],
"try-wpt": [linux_wpt], "try-wpt": [linux_wpt],
"try-wpt-2020": [linux_wpt_layout_2020],
"try-wpt-mac": [macos_wpt], "try-wpt-mac": [macos_wpt],
"try-wpt-android": [android_x86_wpt], "try-wpt-android": [android_x86_wpt],
"try-android": [ "try-android": [
@ -555,26 +557,6 @@ def linux_release():
.find_or_create("build.linux_x64_release" + CONFIG.task_id()) .find_or_create("build.linux_x64_release" + CONFIG.task_id())
) )
def linux_wpt():
release_build_task = (
linux_build_task("Release build, with debug assertions")
.with_treeherder("Linux x64", "Release+A")
.with_script("""
./mach build --release --with-debug-assertions -p servo
./etc/ci/lockfile_changed.sh
tar -czf /target.tar.gz \
target/release/servo \
target/release/build/osmesa-src-*/output \
target/release/build/osmesa-src-*/out/lib/gallium
""")
.with_artifacts("/target.tar.gz")
.find_or_create("build.linux_x64_release_w_assertions" + CONFIG.task_id())
)
def linux_run_task(name):
return linux_task(name).with_dockerfile(dockerfile_path("run")).with_repo_bundle()
wpt_chunks("Linux x64", linux_run_task, release_build_task, repo_dir="/repo",
total_chunks=4, processes=12)
def macos_nightly(): def macos_nightly():
return ( return (
@ -661,16 +643,73 @@ def macos_wpt():
) )
def linux_wpt():
linux_wpt_common(total_chunks=4, layout_2020=False)
def linux_wpt_layout_2020():
linux_wpt_common(total_chunks=1, layout_2020=True)
def linux_wpt_common(total_chunks, layout_2020):
if layout_2020:
name_prefix = "Layout 2020 "
build_args = "--with-layout-2020"
index_key_suffix = "_2020"
else:
name_prefix = ""
build_args = ""
index_key_suffix = ""
release_build_task = (
linux_build_task(name_prefix + "Release build, with debug assertions")
.with_treeherder("Linux x64", "Release+A")
.with_script("""
time ./mach rustc -V
time ./mach fetch
./mach build --release --with-debug-assertions %s -p servo
./etc/ci/lockfile_changed.sh
tar -czf /target.tar.gz \
target/release/servo \
target/release/build/osmesa-src-*/output \
target/release/build/osmesa-src-*/out/lib/gallium
sccache --show-stats
""" % build_args)
.with_artifacts("/target.tar.gz")
.find_or_create("build.linux_x64%s_release_w_assertions.%s" % (
index_key_suffix,
CONFIG.task_id(),
))
)
def linux_run_task(name):
return linux_task(name).with_dockerfile(dockerfile_path("run")).with_repo_bundle()
wpt_chunks("Linux x64", linux_run_task, release_build_task, repo_dir="/repo",
processes=12, total_chunks=total_chunks, layout_2020=layout_2020)
def wpt_chunks(platform, make_chunk_task, build_task, total_chunks, processes, def wpt_chunks(platform, make_chunk_task, build_task, total_chunks, processes,
repo_dir, chunks="all"): repo_dir, chunks="all", layout_2020=False):
if layout_2020:
start = 1 # Skip the "extra" WPT testing, a.k.a. chunk 0
name_prefix = "Layout 2020 "
job_id_prefix = "2020-"
args = "--layout-2020"
else:
start = 0
name_prefix = ""
job_id_prefix = ""
args = ""
if chunks == "all": if chunks == "all":
chunks = range(total_chunks + 1) chunks = range(start, total_chunks + 1)
for this_chunk in chunks: for this_chunk in chunks:
task = ( task = (
make_chunk_task("WPT chunk {:0{width}} / {}".format( make_chunk_task("{}WPT chunk {:0{width}} / {}".format(
this_chunk, total_chunks, width=len(str(total_chunks)), name_prefix,
this_chunk,
total_chunks,
width=len(str(total_chunks)),
)) ))
.with_treeherder(platform, "WPT-%s" % this_chunk) .with_treeherder(platform, "%sWPT-%s" % (job_id_prefix, this_chunk))
.with_curl_artifact_script(build_task, "target.tar.gz") .with_curl_artifact_script(build_task, "target.tar.gz")
.with_script("tar -xzf target.tar.gz") .with_script("tar -xzf target.tar.gz")
.with_index_and_artifacts_expire_in(log_artifacts_expire_in) .with_index_and_artifacts_expire_in(log_artifacts_expire_in)
@ -679,6 +718,7 @@ def wpt_chunks(platform, make_chunk_task, build_task, total_chunks, processes,
TOTAL_CHUNKS=str(total_chunks), TOTAL_CHUNKS=str(total_chunks),
THIS_CHUNK=str(this_chunk), THIS_CHUNK=str(this_chunk),
PROCESSES=str(processes), PROCESSES=str(processes),
WPT_ARGS=args,
GST_DEBUG="3", GST_DEBUG="3",
) )
) )
@ -722,6 +762,7 @@ def wpt_chunks(platform, make_chunk_task, build_task, total_chunks, processes,
task.with_script(""" task.with_script("""
./mach test-wpt \ ./mach test-wpt \
--release \ --release \
$WPT_ARGS \
--processes $PROCESSES \ --processes $PROCESSES \
--total-chunks "$TOTAL_CHUNKS" \ --total-chunks "$TOTAL_CHUNKS" \
--this-chunk "$THIS_CHUNK" \ --this-chunk "$THIS_CHUNK" \
@ -742,8 +783,12 @@ def wpt_chunks(platform, make_chunk_task, build_task, total_chunks, processes,
for word in script.split() for word in script.split()
if word.endswith(".log") if word.endswith(".log")
]) ])
platform_id = platform.replace(" ", "_").lower() task.find_or_create("%s_%swpt_%s.%s" % (
task.find_or_create("%s_wpt_%s.%s" % (platform_id, this_chunk, CONFIG.task_id())) platform.replace(" ", "_").lower(),
job_id_prefix.replace("-", "_"),
this_chunk,
CONFIG.task_id(),
))
def daily_tasks_setup(): def daily_tasks_setup():

View file

@ -321,6 +321,7 @@ class CommandBase(object):
self.config.setdefault("build", {}) self.config.setdefault("build", {})
self.config["build"].setdefault("android", False) self.config["build"].setdefault("android", False)
self.config["build"].setdefault("mode", "") self.config["build"].setdefault("mode", "")
self.config["build"].setdefault("debug-assertions", False)
self.config["build"].setdefault("debug-mozjs", False) self.config["build"].setdefault("debug-mozjs", False)
self.config["build"].setdefault("ccache", "") self.config["build"].setdefault("ccache", "")
self.config["build"].setdefault("rustflags", "") self.config["build"].setdefault("rustflags", "")
@ -933,7 +934,7 @@ install them, let us know by filing a bug!")
features.append("webgl-backtrace") features.append("webgl-backtrace")
if self.config["build"]["dom-backtrace"]: if self.config["build"]["dom-backtrace"]:
features.append("dom-backtrace") features.append("dom-backtrace")
if with_debug_assertions: if with_debug_assertions or self.config["build"]["debug-assertions"]:
env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -C debug_assertions" env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -C debug_assertions"
assert "--features" not in cargo_args assert "--features" not in cargo_args

View file

@ -29,6 +29,9 @@ rustc-with-gold = true
# Set "android = true" or use `mach build --android` to build the Android app. # Set "android = true" or use `mach build --android` to build the Android app.
android = false android = false
# Enable `debug_assert!` macros in release mode
debug-assertions = false
# Set "debug-mozjs" or use `mach build --debug-mozjs` to build a debug spidermonkey. # Set "debug-mozjs" or use `mach build --debug-mozjs` to build a debug spidermonkey.
debug-mozjs = false debug-mozjs = false

View file

@ -1,2 +0,0 @@
[anonymous-boxes-inheritance-001.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[block-in-inline-001.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[block-in-inline-002.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[block-in-inline-007.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[block-in-inline-relpos-001.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[block-in-inline-relpos-002.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[box-generation-001.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[box-generation-002.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[containing-block-008.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[containing-block-010.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[containing-block-019.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[containing-block-020.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[containing-block-021.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[containing-block-022.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[containing-block-029.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[display-006.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[display-007.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[display-008.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[display-009.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[display-010.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[display-011.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[display-012.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[display-013.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[display-014.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[display-015.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[display-change-001.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[insert-inline-in-blocks-n-inlines-begin-001.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[insert-inline-in-blocks-n-inlines-end-001.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[insert-inline-in-blocks-n-inlines-middle-001.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[root-box-002.xht]
expected: FAIL