diff --git a/components/layout/block.rs b/components/layout/block.rs index 003f1fb2e02..351b0dba9d9 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -1417,7 +1417,7 @@ impl BlockFlow { // Per CSS 2.1 § 16.3.1, text alignment propagates to all children in flow. // // 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); // Handle `text-indent` on behalf of any inline children that we have. This is @@ -1425,7 +1425,7 @@ impl BlockFlow { // we know. if kid.is_inline_flow() { 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); } } @@ -2340,7 +2340,7 @@ pub trait ISizeAndMarginsComputer { containing_block_inline_size), MaybeAuto::from_style(position.inline_end, containing_block_inline_size), - style.get_inheritedtext().text_align, + style.get_inherited_text().text_align, available_inline_size) } diff --git a/components/layout/construct.rs b/components/layout/construct.rs index efa3ccd176a..063b1ee710f 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -1095,7 +1095,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> kid_flow.as_block() .fragment .style() - .get_inheritedtable() + .get_inherited_table() .caption_side == side { 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 // if the cell has any in-flow elements (even empty ones!) and has `empty-cells` set to // `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| { let position = kid.style(self.style_context()).get_box().position; !kid.is_content() || @@ -1871,7 +1871,7 @@ fn bidi_control_chars(style: &ServoArc) -> Option<(&'static str, use style::computed_values::unicode_bidi::T::*; 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 match (unicode_bidi, direction) { diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs index 16a1fc85770..d8467958038 100644 --- a/components/layout/display_list/builder.rs +++ b/components/layout/display_list/builder.rs @@ -1013,7 +1013,7 @@ impl FragmentDisplayListBuilding for Fragment { id: webrender_image.key.unwrap(), stretch_size: placement.tile_size.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, clip: Rect, ) { - if self.style().get_inheritedbox().visibility != Visibility::Visible { + if self.style().get_inherited_box().visibility != Visibility::Visible { return; } @@ -1744,7 +1744,7 @@ impl FragmentDisplayListBuilding for Fragment { state, &text_fragment, stacking_relative_content_box, - &self.style.get_inheritedtext().text_shadow.0, + &self.style.get_inherited_text().text_shadow.0, clip, ); @@ -1765,7 +1765,7 @@ impl FragmentDisplayListBuilding for Fragment { state, &text_fragment, stacking_relative_content_box, - &self.style.get_inheritedtext().text_shadow.0, + &self.style.get_inherited_text().text_shadow.0, clip, ); @@ -1837,7 +1837,7 @@ impl FragmentDisplayListBuilding for Fragment { stretch_size: stacking_relative_content_box.size.to_layout(), tile_spacing: LayoutSize::zero(), image_rendering: self.style - .get_inheritedbox() + .get_inherited_box() .image_rendering .to_layout(), }))); @@ -2005,7 +2005,7 @@ impl FragmentDisplayListBuilding for Fragment { } // 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( self.style.writing_mode, @@ -3048,8 +3048,8 @@ impl ComputedValuesCursorUtility for ComputedValues { #[inline] fn get_cursor(&self, default_cursor: CursorKind) -> Option { match ( - self.get_inheritedui().pointer_events, - &self.get_inheritedui().cursor, + self.get_inherited_ui().pointer_events, + &self.get_inherited_ui().cursor, ) { (PointerEvents::None, _) => None, ( diff --git a/components/layout/flex.rs b/components/layout/flex.rs index 42ed7910b8d..2864c922874 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -561,7 +561,7 @@ impl FlexFlow { .explicit_block_size(parent_container_size) .map(|x| max(x - box_border, Au(0))); 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) { let items = &mut self.items[line.range.clone()]; diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 38ea9d03b93..b7b3ac07d64 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -818,7 +818,7 @@ impl Fragment { SpecificFragmentInfo::TableCell => { let base_quantities = QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_PADDING | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED; - if self.style.get_inheritedtable().border_collapse == + if self.style.get_inherited_table().border_collapse == BorderCollapse::Separate { base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER } else { @@ -828,7 +828,7 @@ impl Fragment { SpecificFragmentInfo::TableWrapper => { let base_quantities = QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_MARGINS | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED; - if self.style.get_inheritedtable().border_collapse == + if self.style.get_inherited_table().border_collapse == BorderCollapse::Separate { base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER } else { @@ -838,7 +838,7 @@ impl Fragment { SpecificFragmentInfo::TableRow => { let base_quantities = QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED; - if self.style.get_inheritedtable().border_collapse == + if self.style.get_inherited_table().border_collapse == BorderCollapse::Separate { base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER } else { @@ -1272,7 +1272,7 @@ impl Fragment { pub fn compute_border_and_padding(&mut self, containing_block_inline_size: Au) { // 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::Collapse => LogicalMargin::zero(self.style.writing_mode), }; @@ -1377,7 +1377,7 @@ impl Fragment { } pub fn white_space(&self) -> WhiteSpace { - self.style().get_inheritedtext().white_space + self.style().get_inherited_text().white_space } pub fn color(&self) -> Color { @@ -1625,12 +1625,12 @@ impl Fragment { let mut flags = SplitOptions::empty(); if 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) } } - match self.style().get_inheritedtext().word_break { + match self.style().get_inherited_text().word_break { WordBreak::Normal | WordBreak::KeepAll => { // Break at normal word boundaries. keep-all forbids soft wrap opportunities. let natural_word_breaking_strategy = diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 83961219e37..58d6a498457 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -934,7 +934,7 @@ impl InlineFlow { if fragments.fragments.is_empty() { 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. 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(); for fragment in &mut self.fragments.fragments { 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 => { intrinsic_sizes_for_nonbroken_run.union_nonbreaking_inline( &intrinsic_sizes_for_fragment) diff --git a/components/layout/query.rs b/components/layout/query.rs index b52d415939f..408e220dfe4 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -959,7 +959,7 @@ fn inner_text_collection_steps(node: N, }; // Step 2. - if style.get_inheritedbox().visibility != Visibility::Visible { + if style.get_inherited_box().visibility != Visibility::Visible { continue; } diff --git a/components/layout/table.rs b/components/layout/table.rs index a258a570692..658a39d8e21 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -191,8 +191,8 @@ impl TableFlow { /// Returns the effective spacing per cell, taking the value of `border-collapse` into account. pub fn spacing(&self) -> border_spacing::T { let style = self.block_flow.fragment.style(); - match style.get_inheritedtable().border_collapse { - border_collapse::T::Separate => style.get_inheritedtable().border_spacing, + match style.get_inherited_table().border_collapse { + border_collapse::T::Separate => style.get_inherited_table().border_spacing, border_collapse::T::Collapse => border_spacing::T::zero(), } } @@ -298,7 +298,7 @@ impl Flow for TableFlow { let collapsing_borders = self.block_flow .fragment .style - .get_inheritedtable() + .get_inherited_table() .border_collapse == border_collapse::T::Collapse; let table_inline_collapsed_borders = if collapsing_borders { Some(TableInlineCollapsedBorders { @@ -522,7 +522,7 @@ impl Flow for TableFlow { let border_painting_mode = match self.block_flow .fragment .style - .get_inheritedtable() + .get_inherited_table() .border_collapse { border_collapse::T::Separate => BorderPaintingMode::Separate, border_collapse::T::Collapse => BorderPaintingMode::Hidden, @@ -771,12 +771,12 @@ pub trait TableLikeFlow { impl TableLikeFlow for BlockFlow { fn assign_block_size_for_table_like_flow(&mut self, block_direction_spacing: Au, 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)); fn border_spacing_for_row(fragment: &Fragment, row: &TableRowFlow, 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::Collapse => { row.collapsed_border_spacing.block_start @@ -1204,13 +1204,13 @@ impl<'table> TableCellStyleInfo<'table> { use style::computed_values::visibility::T as Visibility; if !self.cell.visible || self.cell.block_flow.fragment.style() - .get_inheritedbox().visibility != Visibility::Visible { + .get_inherited_box().visibility != Visibility::Visible { return } let border_painting_mode = match self.cell.block_flow .fragment .style - .get_inheritedtable() + .get_inherited_table() .border_collapse { border_collapse::T::Separate => BorderPaintingMode::Separate, border_collapse::T::Collapse => BorderPaintingMode::Collapse(&self.cell.collapsed_borders), diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 933d3be632e..ffecce5d6c7 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -353,7 +353,7 @@ impl Flow for TableRowFlow { let collapsing_borders = self.block_flow .fragment .style() - .get_inheritedtable() + .get_inherited_table() .border_collapse == BorderCollapse::Collapse; let row_style = &*self.block_flow.fragment.style; self.preliminary_collapsed_borders.reset( @@ -500,7 +500,7 @@ impl Flow for TableRowFlow { // Set up 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 => { Some(BorderCollapseInfoForChildTableCell { collapsed_borders_for_row: &self.final_collapsed_borders, diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index 85bccb18ade..cac1657bd43 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -130,7 +130,7 @@ impl Flow for TableRowGroupFlow { let (inline_start_content_edge, inline_end_content_edge) = (Au(0), Au(0)); 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; inline_size_computer.compute_used_inline_size(&mut self.block_flow, shared_context, diff --git a/components/layout/text.rs b/components/layout/text.rs index 15fecd3f7d1..ac93eaed03f 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -170,7 +170,7 @@ impl TextRunScanner { { let in_fragment = self.clump.front().unwrap(); 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); compression = match in_fragment.white_space() { 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. pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) -> Au { 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::Number(l) => font_size.scale_by(l.0), LineHeight::Length(l) => Au::from(l) diff --git a/components/layout_thread/dom_wrapper.rs b/components/layout_thread/dom_wrapper.rs index 309ddaf7e93..89a21ec64d5 100644 --- a/components/layout_thread/dom_wrapper.rs +++ b/components/layout_thread/dom_wrapper.rs @@ -979,7 +979,7 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { // // If you implement other values for this property, you will almost certainly // want to update this check. - !self.style(context).get_inheritedtext().white_space.preserve_newlines() + !self.style(context).get_inherited_text().white_space.preserve_newlines() } } diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index f0383e871fa..3c39b95a28b 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -128,7 +128,7 @@ use style::context::{QuirksMode, RegisteredSpeculativePainter, RegisteredSpecula use style::context::{SharedStyleContext, StyleSystemOptions, ThreadLocalStyleContextCreationInfo}; use style::dom::{ShowSubtree, ShowSubtreeDataAndPrimaryValues, TElement, TNode}; use style::driver; -use style::error_reporting::{NullReporter, RustLogReporter}; +use style::error_reporting::RustLogReporter; use style::invalidation::element::restyle_hints::RestyleHint; use style::logical_geometry::LogicalPoint; use style::media_queries::{Device, MediaList, MediaType}; @@ -1754,7 +1754,7 @@ fn get_ua_stylesheets() -> Result { MediaList::empty(), shared_lock.clone(), None, - &NullReporter, + None, QuirksMode::NoQuirks, )))) } @@ -1782,7 +1782,7 @@ fn get_ua_stylesheets() -> Result { MediaList::empty(), shared_lock.clone(), None, - &RustLogReporter, + Some(&RustLogReporter), QuirksMode::NoQuirks, ))) ); diff --git a/components/script/dom/css.rs b/components/script/dom/css.rs index 4b67f516e83..d642b44a19f 100644 --- a/components/script/dom/css.rs +++ b/components/script/dom/css.rs @@ -42,7 +42,8 @@ impl CSS { &url, Some(CssRuleType::Style), ParsingMode::DEFAULT, - QuirksMode::NoQuirks + QuirksMode::NoQuirks, + None, ); decl.eval(&context) } @@ -58,7 +59,8 @@ impl CSS { &url, Some(CssRuleType::Style), ParsingMode::DEFAULT, - QuirksMode::NoQuirks + QuirksMode::NoQuirks, + None, ); cond.eval(&context) } else { diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs index 0ecdf71a314..23f3c46a251 100644 --- a/components/script/dom/cssmediarule.rs +++ b/components/script/dom/cssmediarule.rs @@ -75,15 +75,15 @@ impl CSSMediaRule { let window = global.as_window(); let url = window.get_url(); let quirks_mode = window.Document().quirks_mode(); - let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media), - ParsingMode::DEFAULT, - quirks_mode); - - let new_medialist = StyleMediaList::parse( - &context, - &mut input, + let context = ParserContext::new_for_cssom( + &url, + Some(CssRuleType::Media), + ParsingMode::DEFAULT, + quirks_mode, window.css_error_reporter(), ); + + let new_medialist = StyleMediaList::parse(&context, &mut input); let mut guard = self.cssconditionrule.shared_lock().write(); // Clone an Arc because we can’t borrow `guard` twice at the same time. diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index e3a4a20d380..9f6c97dbc7d 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -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 { #[allow(unrooted_must_root)] pub fn new_inherited(owner: CSSStyleOwner, @@ -253,7 +266,7 @@ impl CSSStyleDeclaration { self.owner.mutate_associated_block(|pdb, changed| { if value.is_empty() { // Step 3 - *changed = pdb.remove_property(&id, |_| {}); + *changed = remove_property(pdb, &id); return Ok(()); } @@ -365,7 +378,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration { let mut string = String::new(); self.owner.mutate_associated_block(|pdb, changed| { pdb.property_value_to_css(&id, &mut string).unwrap(); - *changed = pdb.remove_property(&id, |_| {}); + *changed = remove_property(pdb, &id); }); // Step 6 diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs index 68d02aa241a..a96cd706b86 100644 --- a/components/script/dom/csssupportsrule.rs +++ b/components/script/dom/csssupportsrule.rs @@ -63,9 +63,13 @@ impl CSSSupportsRule { let win = global.as_window(); let url = win.Document().url(); let quirks_mode = win.Document().quirks_mode(); - let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Supports), - ParsingMode::DEFAULT, - quirks_mode); + let context = ParserContext::new_for_cssom( + &url, + Some(CssRuleType::Supports), + ParsingMode::DEFAULT, + quirks_mode, + None, + ); let enabled = cond.eval(&context); let mut guard = self.cssconditionrule.shared_lock().write(); let rule = self.supportsrule.write_with(&mut guard); diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 9e048161633..26c59bdb8ec 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -127,6 +127,7 @@ use std::cell::{Cell, Ref, RefMut}; use std::collections::{HashMap, HashSet, VecDeque}; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::default::Default; +use std::fmt; use std::mem; use std::ptr::NonNull; use std::rc::Rc; @@ -213,6 +214,12 @@ struct StyleSheetInDocument { owner: Dom, } +impl fmt::Debug for StyleSheetInDocument { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + self.sheet.fmt(formatter) + } +} + impl PartialEq for StyleSheetInDocument { fn eq(&self, other: &Self) -> bool { Arc::ptr_eq(&self.sheet, &other.sheet) diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 8206af23e3e..61acecda71d 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -770,10 +770,13 @@ pub fn parse_a_sizes_attribute(input: DOMString, width: Option) -> Vec &CSSErrorReporter { - &self.error_reporter + pub fn css_error_reporter(&self) -> Option<&ParseErrorReporter> { + Some(&self.error_reporter) } /// Sets a new list of scroll offsets. @@ -1017,14 +1018,15 @@ impl WindowMethods for Window { let mut parser = Parser::new(&mut input); let url = self.get_url(); let quirks_mode = self.Document().quirks_mode(); - let context = CssParserContext::new_for_cssom(&url, Some(CssRuleType::Media), - ParsingMode::DEFAULT, - quirks_mode); - let media_query_list = media_queries::MediaList::parse( - &context, - &mut parser, + let context = CssParserContext::new_for_cssom( + &url, + Some(CssRuleType::Media), + ParsingMode::DEFAULT, + quirks_mode, self.css_error_reporter(), ); + let media_query_list = + media_queries::MediaList::parse(&context, &mut parser); let document = self.Document(); let mql = MediaQueryList::new(&document, media_query_list); self.media_query_lists.push(&*mql);