layout: script: Fix build.

This commit is contained in:
Emilio Cobos Álvarez 2018-06-23 20:00:26 +02:00
parent 750c223021
commit 895946bb18
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
23 changed files with 141 additions and 98 deletions

View file

@ -1417,7 +1417,7 @@ impl BlockFlow {
// Per CSS 2.1 § 16.3.1, text alignment propagates to all children in flow. // Per CSS 2.1 § 16.3.1, text alignment propagates to all children in flow.
// //
// TODO(#2265, pcwalton): Do this in the cascade instead. // TODO(#2265, pcwalton): Do this in the cascade instead.
let containing_block_text_align = self.fragment.style().get_inheritedtext().text_align; let containing_block_text_align = self.fragment.style().get_inherited_text().text_align;
kid.mut_base().flags.set_text_align(containing_block_text_align); kid.mut_base().flags.set_text_align(containing_block_text_align);
// Handle `text-indent` on behalf of any inline children that we have. This is // Handle `text-indent` on behalf of any inline children that we have. This is
@ -1425,7 +1425,7 @@ impl BlockFlow {
// we know. // we know.
if kid.is_inline_flow() { if kid.is_inline_flow() {
kid.as_mut_inline().first_line_indentation = kid.as_mut_inline().first_line_indentation =
self.fragment.style().get_inheritedtext().text_indent self.fragment.style().get_inherited_text().text_indent
.to_used_value(containing_block_size); .to_used_value(containing_block_size);
} }
} }
@ -2340,7 +2340,7 @@ pub trait ISizeAndMarginsComputer {
containing_block_inline_size), containing_block_inline_size),
MaybeAuto::from_style(position.inline_end, MaybeAuto::from_style(position.inline_end,
containing_block_inline_size), containing_block_inline_size),
style.get_inheritedtext().text_align, style.get_inherited_text().text_align,
available_inline_size) available_inline_size)
} }

View file

@ -1095,7 +1095,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
kid_flow.as_block() kid_flow.as_block()
.fragment .fragment
.style() .style()
.get_inheritedtable() .get_inherited_table()
.caption_side == side { .caption_side == side {
table_wrapper_flow.add_new_child(kid_flow); table_wrapper_flow.add_new_child(kid_flow);
} }
@ -1256,7 +1256,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
// Determine if the table cell should be hidden. Per CSS 2.1 § 17.6.1.1, this will be true // Determine if the table cell should be hidden. Per CSS 2.1 § 17.6.1.1, this will be true
// if the cell has any in-flow elements (even empty ones!) and has `empty-cells` set to // if the cell has any in-flow elements (even empty ones!) and has `empty-cells` set to
// `hide`. // `hide`.
let hide = node.style(self.style_context()).get_inheritedtable().empty_cells == EmptyCells::Hide && let hide = node.style(self.style_context()).get_inherited_table().empty_cells == EmptyCells::Hide &&
node.children().all(|kid| { node.children().all(|kid| {
let position = kid.style(self.style_context()).get_box().position; let position = kid.style(self.style_context()).get_box().position;
!kid.is_content() || !kid.is_content() ||
@ -1871,7 +1871,7 @@ fn bidi_control_chars(style: &ServoArc<ComputedValues>) -> Option<(&'static str,
use style::computed_values::unicode_bidi::T::*; use style::computed_values::unicode_bidi::T::*;
let unicode_bidi = style.get_text().unicode_bidi; let unicode_bidi = style.get_text().unicode_bidi;
let direction = style.get_inheritedbox().direction; let direction = style.get_inherited_box().direction;
// See the table in http://dev.w3.org/csswg/css-writing-modes/#unicode-bidi // See the table in http://dev.w3.org/csswg/css-writing-modes/#unicode-bidi
match (unicode_bidi, direction) { match (unicode_bidi, direction) {

View file

@ -1013,7 +1013,7 @@ impl FragmentDisplayListBuilding for Fragment {
id: webrender_image.key.unwrap(), id: webrender_image.key.unwrap(),
stretch_size: placement.tile_size.to_layout(), stretch_size: placement.tile_size.to_layout(),
tile_spacing: placement.tile_spacing.to_layout(), tile_spacing: placement.tile_spacing.to_layout(),
image_rendering: style.get_inheritedbox().image_rendering.to_layout(), image_rendering: style.get_inherited_box().image_rendering.to_layout(),
}))); })));
}); });
} }
@ -1581,7 +1581,7 @@ impl FragmentDisplayListBuilding for Fragment {
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
clip: Rect<Au>, clip: Rect<Au>,
) { ) {
if self.style().get_inheritedbox().visibility != Visibility::Visible { if self.style().get_inherited_box().visibility != Visibility::Visible {
return; return;
} }
@ -1744,7 +1744,7 @@ impl FragmentDisplayListBuilding for Fragment {
state, state,
&text_fragment, &text_fragment,
stacking_relative_content_box, stacking_relative_content_box,
&self.style.get_inheritedtext().text_shadow.0, &self.style.get_inherited_text().text_shadow.0,
clip, clip,
); );
@ -1765,7 +1765,7 @@ impl FragmentDisplayListBuilding for Fragment {
state, state,
&text_fragment, &text_fragment,
stacking_relative_content_box, stacking_relative_content_box,
&self.style.get_inheritedtext().text_shadow.0, &self.style.get_inherited_text().text_shadow.0,
clip, clip,
); );
@ -1837,7 +1837,7 @@ impl FragmentDisplayListBuilding for Fragment {
stretch_size: stacking_relative_content_box.size.to_layout(), stretch_size: stacking_relative_content_box.size.to_layout(),
tile_spacing: LayoutSize::zero(), tile_spacing: LayoutSize::zero(),
image_rendering: self.style image_rendering: self.style
.get_inheritedbox() .get_inherited_box()
.image_rendering .image_rendering
.to_layout(), .to_layout(),
}))); })));
@ -2005,7 +2005,7 @@ impl FragmentDisplayListBuilding for Fragment {
} }
// Create display items for text decorations. // Create display items for text decorations.
let text_decorations = self.style().get_inheritedtext().text_decorations_in_effect; let text_decorations = self.style().get_inherited_text().text_decorations_in_effect;
let logical_stacking_relative_content_box = LogicalRect::from_physical( let logical_stacking_relative_content_box = LogicalRect::from_physical(
self.style.writing_mode, self.style.writing_mode,
@ -3048,8 +3048,8 @@ impl ComputedValuesCursorUtility for ComputedValues {
#[inline] #[inline]
fn get_cursor(&self, default_cursor: CursorKind) -> Option<CursorKind> { fn get_cursor(&self, default_cursor: CursorKind) -> Option<CursorKind> {
match ( match (
self.get_inheritedui().pointer_events, self.get_inherited_ui().pointer_events,
&self.get_inheritedui().cursor, &self.get_inherited_ui().cursor,
) { ) {
(PointerEvents::None, _) => None, (PointerEvents::None, _) => None,
( (

View file

@ -561,7 +561,7 @@ impl FlexFlow {
.explicit_block_size(parent_container_size) .explicit_block_size(parent_container_size)
.map(|x| max(x - box_border, Au(0))); .map(|x| max(x - box_border, Au(0)));
let containing_block_text_align = let containing_block_text_align =
self.block_flow.fragment.style().get_inheritedtext().text_align; self.block_flow.fragment.style().get_inherited_text().text_align;
while let Some(mut line) = self.get_flex_line(inline_size) { while let Some(mut line) = self.get_flex_line(inline_size) {
let items = &mut self.items[line.range.clone()]; let items = &mut self.items[line.range.clone()];

View file

@ -818,7 +818,7 @@ impl Fragment {
SpecificFragmentInfo::TableCell => { SpecificFragmentInfo::TableCell => {
let base_quantities = QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_PADDING | let base_quantities = QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_PADDING |
QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED; QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED;
if self.style.get_inheritedtable().border_collapse == if self.style.get_inherited_table().border_collapse ==
BorderCollapse::Separate { BorderCollapse::Separate {
base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER
} else { } else {
@ -828,7 +828,7 @@ impl Fragment {
SpecificFragmentInfo::TableWrapper => { SpecificFragmentInfo::TableWrapper => {
let base_quantities = QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_MARGINS | let base_quantities = QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_MARGINS |
QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED; QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED;
if self.style.get_inheritedtable().border_collapse == if self.style.get_inherited_table().border_collapse ==
BorderCollapse::Separate { BorderCollapse::Separate {
base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER
} else { } else {
@ -838,7 +838,7 @@ impl Fragment {
SpecificFragmentInfo::TableRow => { SpecificFragmentInfo::TableRow => {
let base_quantities = let base_quantities =
QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED; QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED;
if self.style.get_inheritedtable().border_collapse == if self.style.get_inherited_table().border_collapse ==
BorderCollapse::Separate { BorderCollapse::Separate {
base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER
} else { } else {
@ -1272,7 +1272,7 @@ impl Fragment {
pub fn compute_border_and_padding(&mut self, pub fn compute_border_and_padding(&mut self,
containing_block_inline_size: Au) { containing_block_inline_size: Au) {
// Compute border. // Compute border.
let border = match self.style.get_inheritedtable().border_collapse { let border = match self.style.get_inherited_table().border_collapse {
BorderCollapse::Separate => self.border_width(), BorderCollapse::Separate => self.border_width(),
BorderCollapse::Collapse => LogicalMargin::zero(self.style.writing_mode), BorderCollapse::Collapse => LogicalMargin::zero(self.style.writing_mode),
}; };
@ -1377,7 +1377,7 @@ impl Fragment {
} }
pub fn white_space(&self) -> WhiteSpace { pub fn white_space(&self) -> WhiteSpace {
self.style().get_inheritedtext().white_space self.style().get_inherited_text().white_space
} }
pub fn color(&self) -> Color { pub fn color(&self) -> Color {
@ -1625,12 +1625,12 @@ impl Fragment {
let mut flags = SplitOptions::empty(); let mut flags = SplitOptions::empty();
if starts_line { if starts_line {
flags.insert(SplitOptions::STARTS_LINE); flags.insert(SplitOptions::STARTS_LINE);
if self.style().get_inheritedtext().overflow_wrap == OverflowWrap::BreakWord { if self.style().get_inherited_text().overflow_wrap == OverflowWrap::BreakWord {
flags.insert(SplitOptions::RETRY_AT_CHARACTER_BOUNDARIES) flags.insert(SplitOptions::RETRY_AT_CHARACTER_BOUNDARIES)
} }
} }
match self.style().get_inheritedtext().word_break { match self.style().get_inherited_text().word_break {
WordBreak::Normal | WordBreak::KeepAll => { WordBreak::Normal | WordBreak::KeepAll => {
// Break at normal word boundaries. keep-all forbids soft wrap opportunities. // Break at normal word boundaries. keep-all forbids soft wrap opportunities.
let natural_word_breaking_strategy = let natural_word_breaking_strategy =

View file

@ -934,7 +934,7 @@ impl InlineFlow {
if fragments.fragments.is_empty() { if fragments.fragments.is_empty() {
return return
} }
let text_justify = fragments.fragments[0].style().get_inheritedtext().text_justify; let text_justify = fragments.fragments[0].style().get_inherited_text().text_justify;
// Translate `left` and `right` to logical directions. // Translate `left` and `right` to logical directions.
let is_ltr = fragments.fragments[0].style().writing_mode.is_bidi_ltr(); let is_ltr = fragments.fragments[0].style().writing_mode.is_bidi_ltr();
@ -1341,7 +1341,7 @@ impl Flow for InlineFlow {
let mut intrinsic_sizes_for_nonbroken_run = IntrinsicISizesContribution::new(); let mut intrinsic_sizes_for_nonbroken_run = IntrinsicISizesContribution::new();
for fragment in &mut self.fragments.fragments { for fragment in &mut self.fragments.fragments {
let intrinsic_sizes_for_fragment = fragment.compute_intrinsic_inline_sizes().finish(); let intrinsic_sizes_for_fragment = fragment.compute_intrinsic_inline_sizes().finish();
match fragment.style.get_inheritedtext().white_space { match fragment.style.get_inherited_text().white_space {
WhiteSpace::Nowrap => { WhiteSpace::Nowrap => {
intrinsic_sizes_for_nonbroken_run.union_nonbreaking_inline( intrinsic_sizes_for_nonbroken_run.union_nonbreaking_inline(
&intrinsic_sizes_for_fragment) &intrinsic_sizes_for_fragment)

View file

@ -959,7 +959,7 @@ fn inner_text_collection_steps<N: LayoutNode>(node: N,
}; };
// Step 2. // Step 2.
if style.get_inheritedbox().visibility != Visibility::Visible { if style.get_inherited_box().visibility != Visibility::Visible {
continue; continue;
} }

View file

@ -191,8 +191,8 @@ impl TableFlow {
/// Returns the effective spacing per cell, taking the value of `border-collapse` into account. /// Returns the effective spacing per cell, taking the value of `border-collapse` into account.
pub fn spacing(&self) -> border_spacing::T { pub fn spacing(&self) -> border_spacing::T {
let style = self.block_flow.fragment.style(); let style = self.block_flow.fragment.style();
match style.get_inheritedtable().border_collapse { match style.get_inherited_table().border_collapse {
border_collapse::T::Separate => style.get_inheritedtable().border_spacing, border_collapse::T::Separate => style.get_inherited_table().border_spacing,
border_collapse::T::Collapse => border_spacing::T::zero(), border_collapse::T::Collapse => border_spacing::T::zero(),
} }
} }
@ -298,7 +298,7 @@ impl Flow for TableFlow {
let collapsing_borders = self.block_flow let collapsing_borders = self.block_flow
.fragment .fragment
.style .style
.get_inheritedtable() .get_inherited_table()
.border_collapse == border_collapse::T::Collapse; .border_collapse == border_collapse::T::Collapse;
let table_inline_collapsed_borders = if collapsing_borders { let table_inline_collapsed_borders = if collapsing_borders {
Some(TableInlineCollapsedBorders { Some(TableInlineCollapsedBorders {
@ -522,7 +522,7 @@ impl Flow for TableFlow {
let border_painting_mode = match self.block_flow let border_painting_mode = match self.block_flow
.fragment .fragment
.style .style
.get_inheritedtable() .get_inherited_table()
.border_collapse { .border_collapse {
border_collapse::T::Separate => BorderPaintingMode::Separate, border_collapse::T::Separate => BorderPaintingMode::Separate,
border_collapse::T::Collapse => BorderPaintingMode::Hidden, border_collapse::T::Collapse => BorderPaintingMode::Hidden,
@ -771,12 +771,12 @@ pub trait TableLikeFlow {
impl TableLikeFlow for BlockFlow { impl TableLikeFlow for BlockFlow {
fn assign_block_size_for_table_like_flow(&mut self, block_direction_spacing: Au, fn assign_block_size_for_table_like_flow(&mut self, block_direction_spacing: Au,
layout_context: &LayoutContext) { layout_context: &LayoutContext) {
debug_assert!(self.fragment.style.get_inheritedtable().border_collapse == debug_assert!(self.fragment.style.get_inherited_table().border_collapse ==
border_collapse::T::Separate || block_direction_spacing == Au(0)); border_collapse::T::Separate || block_direction_spacing == Au(0));
fn border_spacing_for_row(fragment: &Fragment, row: &TableRowFlow, fn border_spacing_for_row(fragment: &Fragment, row: &TableRowFlow,
block_direction_spacing: Au) -> Au { block_direction_spacing: Au) -> Au {
match fragment.style.get_inheritedtable().border_collapse { match fragment.style.get_inherited_table().border_collapse {
border_collapse::T::Separate => block_direction_spacing, border_collapse::T::Separate => block_direction_spacing,
border_collapse::T::Collapse => { border_collapse::T::Collapse => {
row.collapsed_border_spacing.block_start row.collapsed_border_spacing.block_start
@ -1204,13 +1204,13 @@ impl<'table> TableCellStyleInfo<'table> {
use style::computed_values::visibility::T as Visibility; use style::computed_values::visibility::T as Visibility;
if !self.cell.visible || self.cell.block_flow.fragment.style() if !self.cell.visible || self.cell.block_flow.fragment.style()
.get_inheritedbox().visibility != Visibility::Visible { .get_inherited_box().visibility != Visibility::Visible {
return return
} }
let border_painting_mode = match self.cell.block_flow let border_painting_mode = match self.cell.block_flow
.fragment .fragment
.style .style
.get_inheritedtable() .get_inherited_table()
.border_collapse { .border_collapse {
border_collapse::T::Separate => BorderPaintingMode::Separate, border_collapse::T::Separate => BorderPaintingMode::Separate,
border_collapse::T::Collapse => BorderPaintingMode::Collapse(&self.cell.collapsed_borders), border_collapse::T::Collapse => BorderPaintingMode::Collapse(&self.cell.collapsed_borders),

View file

@ -353,7 +353,7 @@ impl Flow for TableRowFlow {
let collapsing_borders = self.block_flow let collapsing_borders = self.block_flow
.fragment .fragment
.style() .style()
.get_inheritedtable() .get_inherited_table()
.border_collapse == BorderCollapse::Collapse; .border_collapse == BorderCollapse::Collapse;
let row_style = &*self.block_flow.fragment.style; let row_style = &*self.block_flow.fragment.style;
self.preliminary_collapsed_borders.reset( self.preliminary_collapsed_borders.reset(
@ -500,7 +500,7 @@ impl Flow for TableRowFlow {
// Set up border collapse info. // Set up border collapse info.
let border_collapse_info = let border_collapse_info =
match self.block_flow.fragment.style().get_inheritedtable().border_collapse { match self.block_flow.fragment.style().get_inherited_table().border_collapse {
BorderCollapse::Collapse => { BorderCollapse::Collapse => {
Some(BorderCollapseInfoForChildTableCell { Some(BorderCollapseInfoForChildTableCell {
collapsed_borders_for_row: &self.final_collapsed_borders, collapsed_borders_for_row: &self.final_collapsed_borders,

View file

@ -130,7 +130,7 @@ impl Flow for TableRowGroupFlow {
let (inline_start_content_edge, inline_end_content_edge) = (Au(0), Au(0)); let (inline_start_content_edge, inline_end_content_edge) = (Au(0), Au(0));
let content_inline_size = containing_block_inline_size; let content_inline_size = containing_block_inline_size;
let border_collapse = self.block_flow.fragment.style.get_inheritedtable().border_collapse; let border_collapse = self.block_flow.fragment.style.get_inherited_table().border_collapse;
let inline_size_computer = InternalTable; let inline_size_computer = InternalTable;
inline_size_computer.compute_used_inline_size(&mut self.block_flow, inline_size_computer.compute_used_inline_size(&mut self.block_flow,
shared_context, shared_context,

View file

@ -170,7 +170,7 @@ impl TextRunScanner {
{ {
let in_fragment = self.clump.front().unwrap(); let in_fragment = self.clump.front().unwrap();
let font_style = in_fragment.style().clone_font(); let font_style = in_fragment.style().clone_font();
let inherited_text_style = in_fragment.style().get_inheritedtext(); let inherited_text_style = in_fragment.style().get_inherited_text();
font_group = font_context.font_group(font_style); font_group = font_context.font_group(font_style);
compression = match in_fragment.white_space() { compression = match in_fragment.white_space() {
WhiteSpace::Normal | WhiteSpace::Normal |
@ -477,7 +477,7 @@ pub fn font_metrics_for_style(mut font_context: &mut LayoutFontContext, style: :
/// Returns the line block-size needed by the given computed style and font size. /// Returns the line block-size needed by the given computed style and font size.
pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) -> Au { pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) -> Au {
let font_size = style.get_font().font_size.size(); let font_size = style.get_font().font_size.size();
match style.get_inheritedtext().line_height { match style.get_inherited_text().line_height {
LineHeight::Normal => Au::from(metrics.line_gap), LineHeight::Normal => Au::from(metrics.line_gap),
LineHeight::Number(l) => font_size.scale_by(l.0), LineHeight::Number(l) => font_size.scale_by(l.0),
LineHeight::Length(l) => Au::from(l) LineHeight::Length(l) => Au::from(l)

View file

@ -979,7 +979,7 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> {
// //
// If you implement other values for this property, you will almost certainly // If you implement other values for this property, you will almost certainly
// want to update this check. // want to update this check.
!self.style(context).get_inheritedtext().white_space.preserve_newlines() !self.style(context).get_inherited_text().white_space.preserve_newlines()
} }
} }

View file

@ -128,7 +128,7 @@ use style::context::{QuirksMode, RegisteredSpeculativePainter, RegisteredSpecula
use style::context::{SharedStyleContext, StyleSystemOptions, ThreadLocalStyleContextCreationInfo}; use style::context::{SharedStyleContext, StyleSystemOptions, ThreadLocalStyleContextCreationInfo};
use style::dom::{ShowSubtree, ShowSubtreeDataAndPrimaryValues, TElement, TNode}; use style::dom::{ShowSubtree, ShowSubtreeDataAndPrimaryValues, TElement, TNode};
use style::driver; use style::driver;
use style::error_reporting::{NullReporter, RustLogReporter}; use style::error_reporting::RustLogReporter;
use style::invalidation::element::restyle_hints::RestyleHint; use style::invalidation::element::restyle_hints::RestyleHint;
use style::logical_geometry::LogicalPoint; use style::logical_geometry::LogicalPoint;
use style::media_queries::{Device, MediaList, MediaType}; use style::media_queries::{Device, MediaList, MediaType};
@ -1754,7 +1754,7 @@ fn get_ua_stylesheets() -> Result<UserAgentStylesheets, &'static str> {
MediaList::empty(), MediaList::empty(),
shared_lock.clone(), shared_lock.clone(),
None, None,
&NullReporter, None,
QuirksMode::NoQuirks, QuirksMode::NoQuirks,
)))) ))))
} }
@ -1782,7 +1782,7 @@ fn get_ua_stylesheets() -> Result<UserAgentStylesheets, &'static str> {
MediaList::empty(), MediaList::empty(),
shared_lock.clone(), shared_lock.clone(),
None, None,
&RustLogReporter, Some(&RustLogReporter),
QuirksMode::NoQuirks, QuirksMode::NoQuirks,
))) )))
); );

View file

@ -42,7 +42,8 @@ impl CSS {
&url, &url,
Some(CssRuleType::Style), Some(CssRuleType::Style),
ParsingMode::DEFAULT, ParsingMode::DEFAULT,
QuirksMode::NoQuirks QuirksMode::NoQuirks,
None,
); );
decl.eval(&context) decl.eval(&context)
} }
@ -58,7 +59,8 @@ impl CSS {
&url, &url,
Some(CssRuleType::Style), Some(CssRuleType::Style),
ParsingMode::DEFAULT, ParsingMode::DEFAULT,
QuirksMode::NoQuirks QuirksMode::NoQuirks,
None,
); );
cond.eval(&context) cond.eval(&context)
} else { } else {

View file

@ -75,15 +75,15 @@ impl CSSMediaRule {
let window = global.as_window(); let window = global.as_window();
let url = window.get_url(); let url = window.get_url();
let quirks_mode = window.Document().quirks_mode(); let quirks_mode = window.Document().quirks_mode();
let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media), let context = ParserContext::new_for_cssom(
ParsingMode::DEFAULT, &url,
quirks_mode); Some(CssRuleType::Media),
ParsingMode::DEFAULT,
let new_medialist = StyleMediaList::parse( quirks_mode,
&context,
&mut input,
window.css_error_reporter(), window.css_error_reporter(),
); );
let new_medialist = StyleMediaList::parse(&context, &mut input);
let mut guard = self.cssconditionrule.shared_lock().write(); let mut guard = self.cssconditionrule.shared_lock().write();
// Clone an Arc because we cant borrow `guard` twice at the same time. // Clone an Arc because we cant borrow `guard` twice at the same time.

View file

@ -181,6 +181,19 @@ macro_rules! css_properties(
); );
); );
fn remove_property(
decls: &mut PropertyDeclarationBlock,
id: &PropertyId,
) -> bool {
let first_declaration = decls.first_declaration_to_remove(id);
let first_declaration = match first_declaration {
Some(i) => i,
None => return false,
};
decls.remove_property(id, first_declaration);
true
}
impl CSSStyleDeclaration { impl CSSStyleDeclaration {
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new_inherited(owner: CSSStyleOwner, pub fn new_inherited(owner: CSSStyleOwner,
@ -253,7 +266,7 @@ impl CSSStyleDeclaration {
self.owner.mutate_associated_block(|pdb, changed| { self.owner.mutate_associated_block(|pdb, changed| {
if value.is_empty() { if value.is_empty() {
// Step 3 // Step 3
*changed = pdb.remove_property(&id, |_| {}); *changed = remove_property(pdb, &id);
return Ok(()); return Ok(());
} }
@ -365,7 +378,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
let mut string = String::new(); let mut string = String::new();
self.owner.mutate_associated_block(|pdb, changed| { self.owner.mutate_associated_block(|pdb, changed| {
pdb.property_value_to_css(&id, &mut string).unwrap(); pdb.property_value_to_css(&id, &mut string).unwrap();
*changed = pdb.remove_property(&id, |_| {}); *changed = remove_property(pdb, &id);
}); });
// Step 6 // Step 6

View file

@ -63,9 +63,13 @@ impl CSSSupportsRule {
let win = global.as_window(); let win = global.as_window();
let url = win.Document().url(); let url = win.Document().url();
let quirks_mode = win.Document().quirks_mode(); let quirks_mode = win.Document().quirks_mode();
let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Supports), let context = ParserContext::new_for_cssom(
ParsingMode::DEFAULT, &url,
quirks_mode); Some(CssRuleType::Supports),
ParsingMode::DEFAULT,
quirks_mode,
None,
);
let enabled = cond.eval(&context); let enabled = cond.eval(&context);
let mut guard = self.cssconditionrule.shared_lock().write(); let mut guard = self.cssconditionrule.shared_lock().write();
let rule = self.supportsrule.write_with(&mut guard); let rule = self.supportsrule.write_with(&mut guard);

View file

@ -127,6 +127,7 @@ use std::cell::{Cell, Ref, RefMut};
use std::collections::{HashMap, HashSet, VecDeque}; use std::collections::{HashMap, HashSet, VecDeque};
use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::default::Default; use std::default::Default;
use std::fmt;
use std::mem; use std::mem;
use std::ptr::NonNull; use std::ptr::NonNull;
use std::rc::Rc; use std::rc::Rc;
@ -213,6 +214,12 @@ struct StyleSheetInDocument {
owner: Dom<Element>, owner: Dom<Element>,
} }
impl fmt::Debug for StyleSheetInDocument {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
self.sheet.fmt(formatter)
}
}
impl PartialEq for StyleSheetInDocument { impl PartialEq for StyleSheetInDocument {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
Arc::ptr_eq(&self.sheet, &other.sheet) Arc::ptr_eq(&self.sheet, &other.sheet)

View file

@ -770,10 +770,13 @@ pub fn parse_a_sizes_attribute(input: DOMString, width: Option<u32>) -> Vec<Size
} }
let mut input = ParserInput::new(&trimmed); let mut input = ParserInput::new(&trimmed);
let url = ServoUrl::parse("about:blank").unwrap(); let url = ServoUrl::parse("about:blank").unwrap();
let context = ParserContext::new_for_cssom(&url, let context = ParserContext::new_for_cssom(
None, &url,
ParsingMode::empty(), None,
QuirksMode::NoQuirks); ParsingMode::empty(),
QuirksMode::NoQuirks,
None,
);
let mut parser = Parser::new(&mut input); let mut parser = Parser::new(&mut input);
let length = parser.try(|i| Length::parse_non_negative(&context, i)); let length = parser.try(|i| Length::parse_non_negative(&context, i));
match length { match length {

View file

@ -277,6 +277,7 @@ impl HTMLLinkElement {
let mut input = ParserInput::new(&mq_str); let mut input = ParserInput::new(&mq_str);
let mut css_parser = CssParser::new(&mut input); let mut css_parser = CssParser::new(&mut input);
let doc_url = document.url(); let doc_url = document.url();
let window = document.window();
// FIXME(emilio): This looks somewhat fishy, since we use the context // FIXME(emilio): This looks somewhat fishy, since we use the context
// only to parse the media query list, CssRuleType::Media doesn't make // only to parse the media query list, CssRuleType::Media doesn't make
// much sense. // much sense.
@ -285,13 +286,9 @@ impl HTMLLinkElement {
Some(CssRuleType::Media), Some(CssRuleType::Media),
ParsingMode::DEFAULT, ParsingMode::DEFAULT,
document.quirks_mode(), document.quirks_mode(),
);
let window = document.window();
let media = MediaList::parse(
&context,
&mut css_parser,
window.css_error_reporter(), window.css_error_reporter(),
); );
let media = MediaList::parse(&context, &mut css_parser);
let im_attribute = element.get_attribute(&ns!(), &local_name!("integrity")); let im_attribute = element.get_attribute(&ns!(), &local_name!("integrity"));
let integrity_val = im_attribute.r().map(|a| a.value()); let integrity_val = im_attribute.r().map(|a| a.value());

View file

@ -84,25 +84,32 @@ impl HTMLStyleElement {
let data = node.GetTextContent().expect("Element.textContent must be a string"); let data = node.GetTextContent().expect("Element.textContent must be a string");
let url = window.get_url(); let url = window.get_url();
let context = CssParserContext::new_for_cssom(&url, let css_error_reporter = window.css_error_reporter();
Some(CssRuleType::Media), let context = CssParserContext::new_for_cssom(
ParsingMode::DEFAULT, &url,
doc.quirks_mode()); Some(CssRuleType::Media),
ParsingMode::DEFAULT,
doc.quirks_mode(),
css_error_reporter,
);
let shared_lock = node.owner_doc().style_shared_lock().clone(); let shared_lock = node.owner_doc().style_shared_lock().clone();
let mut input = ParserInput::new(&mq_str); let mut input = ParserInput::new(&mq_str);
let css_error_reporter = window.css_error_reporter();
let mq = Arc::new(shared_lock.wrap(MediaList::parse( let mq = Arc::new(shared_lock.wrap(MediaList::parse(
&context, &context,
&mut CssParser::new(&mut input), &mut CssParser::new(&mut input),
css_error_reporter), )));
));
let loader = StylesheetLoader::for_element(self.upcast()); let loader = StylesheetLoader::for_element(self.upcast());
let sheet = Stylesheet::from_str(&data, window.get_url(), let sheet = Stylesheet::from_str(
Origin::Author, mq, &data,
shared_lock, Some(&loader), window.get_url(),
css_error_reporter, Origin::Author,
doc.quirks_mode(), mq,
self.line_number as u32); shared_lock,
Some(&loader),
css_error_reporter,
doc.quirks_mode(),
self.line_number as u32,
);
let sheet = Arc::new(sheet); let sheet = Arc::new(sheet);

View file

@ -77,14 +77,14 @@ impl MediaListMethods for MediaList {
let window = global.as_window(); let window = global.as_window();
let url = window.get_url(); let url = window.get_url();
let quirks_mode = window.Document().quirks_mode(); let quirks_mode = window.Document().quirks_mode();
let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media), let context = ParserContext::new_for_cssom(
ParsingMode::DEFAULT, &url,
quirks_mode); Some(CssRuleType::Media),
*media_queries = StyleMediaList::parse( ParsingMode::DEFAULT,
&context, quirks_mode,
&mut parser,
window.css_error_reporter(), window.css_error_reporter(),
); );
*media_queries = StyleMediaList::parse(&context, &mut parser);
} }
// https://drafts.csswg.org/cssom/#dom-medialist-length // https://drafts.csswg.org/cssom/#dom-medialist-length
@ -117,9 +117,13 @@ impl MediaListMethods for MediaList {
let win = global.as_window(); let win = global.as_window();
let url = win.get_url(); let url = win.get_url();
let quirks_mode = win.Document().quirks_mode(); let quirks_mode = win.Document().quirks_mode();
let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media), let context = ParserContext::new_for_cssom(
ParsingMode::DEFAULT, &url,
quirks_mode); Some(CssRuleType::Media),
ParsingMode::DEFAULT,
quirks_mode,
win.css_error_reporter(),
);
let m = MediaQuery::parse(&context, &mut parser); let m = MediaQuery::parse(&context, &mut parser);
// Step 2 // Step 2
if let Err(_) = m { if let Err(_) = m {
@ -146,9 +150,13 @@ impl MediaListMethods for MediaList {
let win = global.as_window(); let win = global.as_window();
let url = win.get_url(); let url = win.get_url();
let quirks_mode = win.Document().quirks_mode(); let quirks_mode = win.Document().quirks_mode();
let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media), let context = ParserContext::new_for_cssom(
ParsingMode::DEFAULT, &url,
quirks_mode); Some(CssRuleType::Media),
ParsingMode::DEFAULT,
quirks_mode,
win.css_error_reporter(),
);
let m = MediaQuery::parse(&context, &mut parser); let m = MediaQuery::parse(&context, &mut parser);
// Step 2 // Step 2
if let Err(_) = m { if let Err(_) = m {

View file

@ -100,6 +100,7 @@ use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{Sender, channel}; use std::sync::mpsc::{Sender, channel};
use std::sync::mpsc::TryRecvError::{Disconnected, Empty}; use std::sync::mpsc::TryRecvError::{Disconnected, Empty};
use style::error_reporting::ParseErrorReporter;
use style::media_queries; use style::media_queries;
use style::parser::ParserContext as CssParserContext; use style::parser::ParserContext as CssParserContext;
use style::properties::{ComputedValues, PropertyId}; use style::properties::{ComputedValues, PropertyId};
@ -389,8 +390,8 @@ impl Window {
&self.bluetooth_extra_permission_data &self.bluetooth_extra_permission_data
} }
pub fn css_error_reporter(&self) -> &CSSErrorReporter { pub fn css_error_reporter(&self) -> Option<&ParseErrorReporter> {
&self.error_reporter Some(&self.error_reporter)
} }
/// Sets a new list of scroll offsets. /// Sets a new list of scroll offsets.
@ -1017,14 +1018,15 @@ impl WindowMethods for Window {
let mut parser = Parser::new(&mut input); let mut parser = Parser::new(&mut input);
let url = self.get_url(); let url = self.get_url();
let quirks_mode = self.Document().quirks_mode(); let quirks_mode = self.Document().quirks_mode();
let context = CssParserContext::new_for_cssom(&url, Some(CssRuleType::Media), let context = CssParserContext::new_for_cssom(
ParsingMode::DEFAULT, &url,
quirks_mode); Some(CssRuleType::Media),
let media_query_list = media_queries::MediaList::parse( ParsingMode::DEFAULT,
&context, quirks_mode,
&mut parser,
self.css_error_reporter(), self.css_error_reporter(),
); );
let media_query_list =
media_queries::MediaList::parse(&context, &mut parser);
let document = self.Document(); let document = self.Document();
let mql = MediaQueryList::new(&document, media_query_list); let mql = MediaQueryList::new(&document, media_query_list);
self.media_query_lists.push(&*mql); self.media_query_lists.push(&*mql);