aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-06-23 14:43:07 -0400
committerGitHub <noreply@github.com>2018-06-23 14:43:07 -0400
commit16bdf9225dd979feeea1580f78041016ce41643f (patch)
treef487cf458fcd1f4882e289404f2988847718c89c
parentd70e131247fcd5fb8ad2aad98a38e61e5f738cf2 (diff)
parent895946bb186a194d1545e4782715f074cc8f8f6c (diff)
downloadservo-16bdf9225dd979feeea1580f78041016ce41643f.tar.gz
servo-16bdf9225dd979feeea1580f78041016ce41643f.zip
Auto merge of #21088 - emilio:gecko-sync, r=emilio
style: Import changes from mozilla-central. See each individual commit for details.
-rw-r--r--components/layout/block.rs6
-rw-r--r--components/layout/construct.rs6
-rw-r--r--components/layout/display_list/builder.rs16
-rw-r--r--components/layout/flex.rs2
-rw-r--r--components/layout/fragment.rs14
-rw-r--r--components/layout/inline.rs4
-rw-r--r--components/layout/query.rs2
-rw-r--r--components/layout/table.rs16
-rw-r--r--components/layout/table_row.rs4
-rw-r--r--components/layout/table_rowgroup.rs2
-rw-r--r--components/layout/text.rs4
-rw-r--r--components/layout_thread/dom_wrapper.rs2
-rw-r--r--components/layout_thread/lib.rs6
-rw-r--r--components/script/dom/css.rs6
-rw-r--r--components/script/dom/cssmediarule.rs14
-rw-r--r--components/script/dom/cssstyledeclaration.rs17
-rw-r--r--components/script/dom/csssupportsrule.rs10
-rw-r--r--components/script/dom/document.rs7
-rw-r--r--components/script/dom/htmlimageelement.rs11
-rw-r--r--components/script/dom/htmllinkelement.rs7
-rw-r--r--components/script/dom/htmlstyleelement.rs33
-rw-r--r--components/script/dom/medialist.rs32
-rw-r--r--components/script/dom/window.rs18
-rw-r--r--components/style/counter_style/mod.rs16
-rw-r--r--components/style/encoding_support.rs17
-rw-r--r--components/style/error_reporting.rs18
-rw-r--r--components/style/font_face.rs14
-rw-r--r--components/style/gecko/data.rs13
-rw-r--r--components/style/gecko/media_queries.rs21
-rw-r--r--components/style/gecko/url.rs9
-rw-r--r--components/style/gecko_bindings/sugar/refptr.rs9
-rw-r--r--components/style/gecko_string_cache/mod.rs3
-rw-r--r--components/style/media_queries/media_list.rs19
-rw-r--r--components/style/parser.rs31
-rw-r--r--components/style/properties/build.py63
-rw-r--r--components/style/properties/data.py6
-rw-r--r--components/style/properties/declaration_block.rs145
-rw-r--r--components/style/properties/helpers/animated_properties.mako.rs4
-rw-r--r--components/style/properties/longhands/background.mako.rs (renamed from components/style/properties/longhand/background.mako.rs)0
-rw-r--r--components/style/properties/longhands/border.mako.rs (renamed from components/style/properties/longhand/border.mako.rs)0
-rw-r--r--components/style/properties/longhands/box.mako.rs (renamed from components/style/properties/longhand/box.mako.rs)5
-rw-r--r--components/style/properties/longhands/color.mako.rs (renamed from components/style/properties/longhand/color.mako.rs)0
-rw-r--r--components/style/properties/longhands/column.mako.rs (renamed from components/style/properties/longhand/column.mako.rs)0
-rw-r--r--components/style/properties/longhands/counters.mako.rs (renamed from components/style/properties/longhand/counters.mako.rs)0
-rw-r--r--components/style/properties/longhands/effects.mako.rs (renamed from components/style/properties/longhand/effects.mako.rs)0
-rw-r--r--components/style/properties/longhands/font.mako.rs (renamed from components/style/properties/longhand/font.mako.rs)0
-rw-r--r--components/style/properties/longhands/inherited_box.mako.rs (renamed from components/style/properties/longhand/inherited_box.mako.rs)0
-rw-r--r--components/style/properties/longhands/inherited_svg.mako.rs (renamed from components/style/properties/longhand/inherited_svg.mako.rs)0
-rw-r--r--components/style/properties/longhands/inherited_table.mako.rs (renamed from components/style/properties/longhand/inherited_table.mako.rs)0
-rw-r--r--components/style/properties/longhands/inherited_text.mako.rs (renamed from components/style/properties/longhand/inherited_text.mako.rs)0
-rw-r--r--components/style/properties/longhands/inherited_ui.mako.rs (renamed from components/style/properties/longhand/inherited_ui.mako.rs)0
-rw-r--r--components/style/properties/longhands/list.mako.rs (renamed from components/style/properties/longhand/list.mako.rs)0
-rw-r--r--components/style/properties/longhands/margin.mako.rs (renamed from components/style/properties/longhand/margin.mako.rs)0
-rw-r--r--components/style/properties/longhands/outline.mako.rs (renamed from components/style/properties/longhand/outline.mako.rs)0
-rw-r--r--components/style/properties/longhands/padding.mako.rs (renamed from components/style/properties/longhand/padding.mako.rs)0
-rw-r--r--components/style/properties/longhands/position.mako.rs (renamed from components/style/properties/longhand/position.mako.rs)0
-rw-r--r--components/style/properties/longhands/svg.mako.rs (renamed from components/style/properties/longhand/svg.mako.rs)0
-rw-r--r--components/style/properties/longhands/table.mako.rs (renamed from components/style/properties/longhand/table.mako.rs)0
-rw-r--r--components/style/properties/longhands/text.mako.rs (renamed from components/style/properties/longhand/text.mako.rs)0
-rw-r--r--components/style/properties/longhands/ui.mako.rs (renamed from components/style/properties/longhand/ui.mako.rs)0
-rw-r--r--components/style/properties/longhands/xul.mako.rs (renamed from components/style/properties/longhand/xul.mako.rs)0
-rw-r--r--components/style/properties/properties.mako.rs77
-rw-r--r--components/style/properties/shorthand/serialize.mako.rs27
-rw-r--r--components/style/properties/shorthands/background.mako.rs (renamed from components/style/properties/shorthand/background.mako.rs)0
-rw-r--r--components/style/properties/shorthands/border.mako.rs (renamed from components/style/properties/shorthand/border.mako.rs)0
-rw-r--r--components/style/properties/shorthands/box.mako.rs (renamed from components/style/properties/shorthand/box.mako.rs)0
-rw-r--r--components/style/properties/shorthands/column.mako.rs (renamed from components/style/properties/shorthand/column.mako.rs)0
-rw-r--r--components/style/properties/shorthands/font.mako.rs (renamed from components/style/properties/shorthand/font.mako.rs)0
-rw-r--r--components/style/properties/shorthands/inherited_svg.mako.rs (renamed from components/style/properties/shorthand/inherited_svg.mako.rs)0
-rw-r--r--components/style/properties/shorthands/inherited_text.mako.rs (renamed from components/style/properties/shorthand/inherited_text.mako.rs)0
-rw-r--r--components/style/properties/shorthands/list.mako.rs (renamed from components/style/properties/shorthand/list.mako.rs)0
-rw-r--r--components/style/properties/shorthands/margin.mako.rs (renamed from components/style/properties/shorthand/margin.mako.rs)0
-rw-r--r--components/style/properties/shorthands/outline.mako.rs (renamed from components/style/properties/shorthand/outline.mako.rs)0
-rw-r--r--components/style/properties/shorthands/padding.mako.rs (renamed from components/style/properties/shorthand/padding.mako.rs)0
-rw-r--r--components/style/properties/shorthands/position.mako.rs (renamed from components/style/properties/shorthand/position.mako.rs)0
-rw-r--r--components/style/properties/shorthands/svg.mako.rs (renamed from components/style/properties/shorthand/mask.mako.rs)0
-rw-r--r--components/style/properties/shorthands/text.mako.rs (renamed from components/style/properties/shorthand/text.mako.rs)0
-rw-r--r--components/style/servo/media_queries.rs2
-rw-r--r--components/style/sharing/mod.rs17
-rw-r--r--components/style/style_adjuster.rs26
-rw-r--r--components/style/stylesheets/font_feature_values_rule.rs30
-rw-r--r--components/style/stylesheets/keyframes_rule.rs31
-rw-r--r--components/style/stylesheets/mod.rs58
-rw-r--r--components/style/stylesheets/rule_parser.rs59
-rw-r--r--components/style/stylesheets/stylesheet.rs45
-rw-r--r--components/style/stylesheets/viewport_rule.rs18
-rw-r--r--components/style/stylist.rs33
-rw-r--r--components/style/values/computed/text.rs2
-rw-r--r--components/style/values/specified/text.rs6
-rw-r--r--components/style_derive/to_css.rs2
-rw-r--r--tests/unit/style/lib.rs2
-rw-r--r--tests/unit/style/media_queries.rs19
-rw-r--r--tests/unit/style/parsing/length.rs49
-rw-r--r--tests/unit/style/parsing/mod.rs4
-rw-r--r--tests/unit/style/parsing/value.rs25
-rw-r--r--tests/unit/style/properties/background.rs11
-rw-r--r--tests/unit/style/properties/mod.rs27
-rw-r--r--tests/unit/style/properties/serialization.rs38
-rw-r--r--tests/unit/style/rule_tree/bench.rs2
-rw-r--r--tests/unit/style/stylesheets.rs11
-rw-r--r--tests/unit/style/viewport.rs32
101 files changed, 645 insertions, 640 deletions
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<ComputedValues>) -> 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<Au>,
) {
- 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<CursorKind> {
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<N: LayoutNode>(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<UserAgentStylesheets, &'static str> {
MediaList::empty(),
shared_lock.clone(),
None,
- &NullReporter,
+ None,
QuirksMode::NoQuirks,
))))
}
@@ -1782,7 +1782,7 @@ fn get_ua_stylesheets() -> Result<UserAgentStylesheets, &'static str> {
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<Element>,
}
+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<u32>) -> Vec<Size
}
let mut input = ParserInput::new(&trimmed);
let url = ServoUrl::parse("about:blank").unwrap();
- let context = ParserContext::new_for_cssom(&url,
- None,
- ParsingMode::empty(),
- QuirksMode::NoQuirks);
+ let context = ParserContext::new_for_cssom(
+ &url,
+ None,
+ ParsingMode::empty(),
+ QuirksMode::NoQuirks,
+ None,
+ );
let mut parser = Parser::new(&mut input);
let length = parser.try(|i| Length::parse_non_negative(&context, i));
match length {
diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs
index ab84906d223..a86789dcd71 100644
--- a/components/script/dom/htmllinkelement.rs
+++ b/components/script/dom/htmllinkelement.rs
@@ -277,6 +277,7 @@ impl HTMLLinkElement {
let mut input = ParserInput::new(&mq_str);
let mut css_parser = CssParser::new(&mut input);
let doc_url = document.url();
+ let window = document.window();
// FIXME(emilio): This looks somewhat fishy, since we use the context
// only to parse the media query list, CssRuleType::Media doesn't make
// much sense.
@@ -285,13 +286,9 @@ impl HTMLLinkElement {
Some(CssRuleType::Media),
ParsingMode::DEFAULT,
document.quirks_mode(),
- );
- let window = document.window();
- let media = MediaList::parse(
- &context,
- &mut css_parser,
window.css_error_reporter(),
);
+ let media = MediaList::parse(&context, &mut css_parser);
let im_attribute = element.get_attribute(&ns!(), &local_name!("integrity"));
let integrity_val = im_attribute.r().map(|a| a.value());
diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs
index 6778af92218..82da9ba6180 100644
--- a/components/script/dom/htmlstyleelement.rs
+++ b/components/script/dom/htmlstyleelement.rs
@@ -84,25 +84,32 @@ impl HTMLStyleElement {
let data = node.GetTextContent().expect("Element.textContent must be a string");
let url = window.get_url();
- let context = CssParserContext::new_for_cssom(&url,
- Some(CssRuleType::Media),
- ParsingMode::DEFAULT,
- doc.quirks_mode());
+ let css_error_reporter = window.css_error_reporter();
+ let context = CssParserContext::new_for_cssom(
+ &url,
+ Some(CssRuleType::Media),
+ ParsingMode::DEFAULT,
+ doc.quirks_mode(),
+ css_error_reporter,
+ );
let shared_lock = node.owner_doc().style_shared_lock().clone();
let mut input = ParserInput::new(&mq_str);
- let css_error_reporter = window.css_error_reporter();
let mq = Arc::new(shared_lock.wrap(MediaList::parse(
&context,
&mut CssParser::new(&mut input),
- css_error_reporter),
- ));
+ )));
let loader = StylesheetLoader::for_element(self.upcast());
- let sheet = Stylesheet::from_str(&data, window.get_url(),
- Origin::Author, mq,
- shared_lock, Some(&loader),
- css_error_reporter,
- doc.quirks_mode(),
- self.line_number as u32);
+ let sheet = Stylesheet::from_str(
+ &data,
+ window.get_url(),
+ Origin::Author,
+ mq,
+ shared_lock,
+ Some(&loader),
+ css_error_reporter,
+ doc.quirks_mode(),
+ self.line_number as u32,
+ );
let sheet = Arc::new(sheet);
diff --git a/components/script/dom/medialist.rs b/components/script/dom/medialist.rs
index 2f5b33c1016..d43f6d3a710 100644
--- a/components/script/dom/medialist.rs
+++ b/components/script/dom/medialist.rs
@@ -77,14 +77,14 @@ impl MediaListMethods for MediaList {
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);
- *media_queries = StyleMediaList::parse(
- &context,
- &mut parser,
+ let context = ParserContext::new_for_cssom(
+ &url,
+ Some(CssRuleType::Media),
+ ParsingMode::DEFAULT,
+ quirks_mode,
window.css_error_reporter(),
);
+ *media_queries = StyleMediaList::parse(&context, &mut parser);
}
// https://drafts.csswg.org/cssom/#dom-medialist-length
@@ -117,9 +117,13 @@ impl MediaListMethods for MediaList {
let win = global.as_window();
let url = win.get_url();
let quirks_mode = win.Document().quirks_mode();
- let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media),
- ParsingMode::DEFAULT,
- quirks_mode);
+ let context = ParserContext::new_for_cssom(
+ &url,
+ Some(CssRuleType::Media),
+ ParsingMode::DEFAULT,
+ quirks_mode,
+ win.css_error_reporter(),
+ );
let m = MediaQuery::parse(&context, &mut parser);
// Step 2
if let Err(_) = m {
@@ -146,9 +150,13 @@ impl MediaListMethods for MediaList {
let win = global.as_window();
let url = win.get_url();
let quirks_mode = win.Document().quirks_mode();
- let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media),
- ParsingMode::DEFAULT,
- quirks_mode);
+ let context = ParserContext::new_for_cssom(
+ &url,
+ Some(CssRuleType::Media),
+ ParsingMode::DEFAULT,
+ quirks_mode,
+ win.css_error_reporter(),
+ );
let m = MediaQuery::parse(&context, &mut parser);
// Step 2
if let Err(_) = m {
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 0f259dd2ea7..b536f28345f 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -100,6 +100,7 @@ use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{Sender, channel};
use std::sync::mpsc::TryRecvError::{Disconnected, Empty};
+use style::error_reporting::ParseErrorReporter;
use style::media_queries;
use style::parser::ParserContext as CssParserContext;
use style::properties::{ComputedValues, PropertyId};
@@ -389,8 +390,8 @@ impl Window {
&self.bluetooth_extra_permission_data
}
- pub fn css_error_reporter(&self) -> &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);
diff --git a/components/style/counter_style/mod.rs b/components/style/counter_style/mod.rs
index 94b10aa0d33..2542dee3625 100644
--- a/components/style/counter_style/mod.rs
+++ b/components/style/counter_style/mod.rs
@@ -9,8 +9,8 @@
use Atom;
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser};
use cssparser::{CowRcStr, Parser, SourceLocation, Token};
-use error_reporting::{ContextualParseError, ParseErrorReporter};
-use parser::{Parse, ParserContext, ParserErrorContext};
+use error_reporting::ContextualParseError;
+use parser::{Parse, ParserContext};
use selectors::parser::SelectorParseErrorKind;
use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
use std::fmt::{self, Write};
@@ -73,16 +73,12 @@ pub fn parse_counter_style_name_definition<'i, 't>(
}
/// Parse the body (inside `{}`) of an @counter-style rule
-pub fn parse_counter_style_body<'i, 't, R>(
+pub fn parse_counter_style_body<'i, 't>(
name: CustomIdent,
context: &ParserContext,
- error_context: &ParserErrorContext<R>,
input: &mut Parser<'i, 't>,
location: SourceLocation,
-) -> Result<CounterStyleRuleData, ParseError<'i>>
-where
- R: ParseErrorReporter,
-{
+) -> Result<CounterStyleRuleData, ParseError<'i>> {
let start = input.current_source_location();
let mut rule = CounterStyleRuleData::empty(name, location);
{
@@ -98,7 +94,7 @@ where
slice,
error,
);
- context.log_css_error(error_context, location, error)
+ context.log_css_error(location, error)
}
}
}
@@ -134,7 +130,7 @@ where
_ => None,
};
if let Some(error) = error {
- context.log_css_error(error_context, start, error);
+ context.log_css_error(start, error);
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
} else {
Ok(rule)
diff --git a/components/style/encoding_support.rs b/components/style/encoding_support.rs
index eadcfa4c159..7aec18bee2c 100644
--- a/components/style/encoding_support.rs
+++ b/components/style/encoding_support.rs
@@ -55,7 +55,7 @@ impl Stylesheet {
///
/// Takes care of decoding the network bytes and forwards the resulting
/// string to `Stylesheet::from_str`.
- pub fn from_bytes<R>(
+ pub fn from_bytes(
bytes: &[u8],
url_data: UrlExtraData,
protocol_encoding_label: Option<&str>,
@@ -64,12 +64,9 @@ impl Stylesheet {
media: MediaList,
shared_lock: SharedRwLock,
stylesheet_loader: Option<&StylesheetLoader>,
- error_reporter: &R,
+ error_reporter: Option<&ParseErrorReporter>,
quirks_mode: QuirksMode,
- ) -> Stylesheet
- where
- R: ParseErrorReporter,
- {
+ ) -> Stylesheet {
let string = decode_stylesheet_bytes(bytes, protocol_encoding_label, environment_encoding);
Stylesheet::from_str(
&string,
@@ -86,17 +83,15 @@ impl Stylesheet {
/// Updates an empty stylesheet with a set of bytes that reached over the
/// network.
- pub fn update_from_bytes<R>(
+ pub fn update_from_bytes(
existing: &Stylesheet,
bytes: &[u8],
protocol_encoding_label: Option<&str>,
environment_encoding: Option<&'static encoding_rs::Encoding>,
url_data: UrlExtraData,
stylesheet_loader: Option<&StylesheetLoader>,
- error_reporter: &R,
- ) where
- R: ParseErrorReporter,
- {
+ error_reporter: Option<&ParseErrorReporter>,
+ ) {
let string = decode_stylesheet_bytes(bytes, protocol_encoding_label, environment_encoding);
Self::update_from_str(
existing,
diff --git a/components/style/error_reporting.rs b/components/style/error_reporting.rs
index 2af76be87b9..b5d5ba17ef8 100644
--- a/components/style/error_reporting.rs
+++ b/components/style/error_reporting.rs
@@ -7,7 +7,6 @@
#![deny(missing_docs)]
use cssparser::{BasicParseErrorKind, ParseErrorKind, SourceLocation, Token};
-use log;
use std::fmt;
use style_traits::ParseError;
use stylesheets::UrlExtraData;
@@ -229,8 +228,10 @@ pub trait ParseErrorReporter {
/// This logging is silent by default, and can be enabled with a `RUST_LOG=style=info`
/// environment variable.
/// (See [`env_logger`](https://rust-lang-nursery.github.io/log/env_logger/).)
+#[cfg(feature = "servo")]
pub struct RustLogReporter;
+#[cfg(feature = "servo")]
impl ParseErrorReporter for RustLogReporter {
fn report_error(
&self,
@@ -238,6 +239,7 @@ impl ParseErrorReporter for RustLogReporter {
location: SourceLocation,
error: ContextualParseError,
) {
+ use log;
if log_enabled!(log::Level::Info) {
info!(
"Url:\t{}\n{}:{} {}",
@@ -249,17 +251,3 @@ impl ParseErrorReporter for RustLogReporter {
}
}
}
-
-/// Error reporter which silently forgets errors
-pub struct NullReporter;
-
-impl ParseErrorReporter for NullReporter {
- fn report_error(
- &self,
- _url: &UrlExtraData,
- _location: SourceLocation,
- _error: ContextualParseError,
- ) {
- // do nothing
- }
-}
diff --git a/components/style/font_face.rs b/components/style/font_face.rs
index 57c0f3b0b77..d7501c1cca7 100644
--- a/components/style/font_face.rs
+++ b/components/style/font_face.rs
@@ -10,8 +10,8 @@ use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser};
use cssparser::{CowRcStr, SourceLocation};
#[cfg(feature = "gecko")]
use cssparser::UnicodeRange;
-use error_reporting::{ContextualParseError, ParseErrorReporter};
-use parser::{Parse, ParserContext, ParserErrorContext};
+use error_reporting::ContextualParseError;
+use parser::{Parse, ParserContext};
#[cfg(feature = "gecko")]
use properties::longhands::font_language_override;
use selectors::parser::SelectorParseErrorKind;
@@ -186,15 +186,11 @@ impl ToCss for FontStyle {
/// Parse the block inside a `@font-face` rule.
///
/// Note that the prelude parsing code lives in the `stylesheets` module.
-pub fn parse_font_face_block<R>(
+pub fn parse_font_face_block(
context: &ParserContext,
- error_context: &ParserErrorContext<R>,
input: &mut Parser,
location: SourceLocation,
-) -> FontFaceRuleData
-where
- R: ParseErrorReporter,
-{
+) -> FontFaceRuleData {
let mut rule = FontFaceRuleData::empty(location);
{
let parser = FontFaceRuleParser {
@@ -206,7 +202,7 @@ where
if let Err((error, slice)) = declaration {
let location = error.location;
let error = ContextualParseError::UnsupportedFontFaceDescriptor(slice, error);
- context.log_css_error(error_context, location, error)
+ context.log_css_error(location, error)
}
}
}
diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs
index a4ed8294ac2..6b9005c7560 100644
--- a/components/style/gecko/data.rs
+++ b/components/style/gecko/data.rs
@@ -18,13 +18,24 @@ use properties::ComputedValues;
use selector_parser::SnapshotMap;
use servo_arc::Arc;
use shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
+use std::fmt;
use stylesheets::{CssRule, Origin, StylesheetContents, StylesheetInDocument};
use stylist::Stylist;
/// Little wrapper to a Gecko style sheet.
-#[derive(Debug, Eq, PartialEq)]
+#[derive(Eq, PartialEq)]
pub struct GeckoStyleSheet(*const DomStyleSheet);
+impl fmt::Debug for GeckoStyleSheet {
+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ let contents = self.contents();
+ formatter.debug_struct("GeckoStyleSheet")
+ .field("origin", &contents.origin)
+ .field("url_data", &*contents.url_data.read())
+ .finish()
+ }
+}
+
impl ToMediaListKey for ::gecko::data::GeckoStyleSheet {
fn to_media_list_key(&self) -> MediaListKey {
use std::mem;
diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs
index 1c34762f286..771f4570b47 100644
--- a/components/style/gecko/media_queries.rs
+++ b/components/style/gecko/media_queries.rs
@@ -64,6 +64,27 @@ pub struct Device {
used_viewport_size: AtomicBool,
}
+impl fmt::Debug for Device {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ use nsstring::nsCString;
+
+ let mut doc_uri = nsCString::new();
+ unsafe {
+ let doc =
+ &*self.pres_context().mDocument.raw::<structs::nsIDocument>();
+
+ bindings::Gecko_nsIURI_Debug(
+ doc.mDocumentURI.raw::<structs::nsIURI>(),
+ &mut doc_uri,
+ )
+ };
+
+ f.debug_struct("Device")
+ .field("document_url", &doc_uri)
+ .finish()
+ }
+}
+
unsafe impl Sync for Device {}
unsafe impl Send for Device {}
diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs
index cb503f4720a..b94d2139764 100644
--- a/components/style/gecko/url.rs
+++ b/components/style/gecko/url.rs
@@ -6,7 +6,7 @@
use cssparser::Parser;
use gecko_bindings::bindings;
-use gecko_bindings::structs::{ServoBundledURI, URLExtraData};
+use gecko_bindings::structs::ServoBundledURI;
use gecko_bindings::structs::mozilla::css::URLValueData;
use gecko_bindings::structs::root::{RustString, nsStyleImageRequest};
use gecko_bindings::structs::root::mozilla::css::{ImageValue, URLValue};
@@ -18,6 +18,7 @@ use servo_arc::{Arc, RawOffsetArc};
use std::fmt::{self, Write};
use std::mem;
use style_traits::{CssWriter, ParseError, ToCss};
+use stylesheets::UrlExtraData;
use values::computed::{Context, ToComputedValue};
/// A CSS url() value for gecko.
@@ -32,7 +33,7 @@ pub struct CssUrl {
/// The URL extra data.
#[css(skip)]
- pub extra_data: RefPtr<URLExtraData>,
+ pub extra_data: UrlExtraData,
}
impl CssUrl {
@@ -58,7 +59,7 @@ impl CssUrl {
&url.mString as *const _ as *const RawOffsetArc<String>;
CssUrl {
serialization: Arc::from_raw_offset((*arc_type).clone()),
- extra_data: url.mExtraData.to_safe(),
+ extra_data: UrlExtraData(url.mExtraData.to_safe()),
}
}
@@ -88,7 +89,7 @@ impl CssUrl {
let arc_offset = Arc::into_raw_offset(self.serialization.clone());
ServoBundledURI {
mURLString: unsafe { mem::transmute::<_, RawOffsetArc<RustString>>(arc_offset) },
- mExtraData: self.extra_data.get(),
+ mExtraData: self.extra_data.0.get(),
}
}
}
diff --git a/components/style/gecko_bindings/sugar/refptr.rs b/components/style/gecko_bindings/sugar/refptr.rs
index 10c9e627699..6a32b81430e 100644
--- a/components/style/gecko_bindings/sugar/refptr.rs
+++ b/components/style/gecko_bindings/sugar/refptr.rs
@@ -78,15 +78,6 @@ impl<T: RefCounted> RefPtr<T> {
ret
}
- /// Create a reference to RefPtr from a reference to pointer.
- ///
- /// The pointer must be valid and non null.
- ///
- /// This method doesn't touch refcount.
- pub unsafe fn from_ptr_ref(ptr: &*mut T) -> &Self {
- mem::transmute(ptr)
- }
-
/// Produces an FFI-compatible RefPtr that can be stored in style structs.
///
/// structs::RefPtr does not have a destructor, so this may leak
diff --git a/components/style/gecko_string_cache/mod.rs b/components/style/gecko_string_cache/mod.rs
index 297599e2080..b0c8750265b 100644
--- a/components/style/gecko_string_cache/mod.rs
+++ b/components/style/gecko_string_cache/mod.rs
@@ -122,7 +122,8 @@ impl WeakAtom {
unsafe { u8_ptr.offset(string_offset) as *const u16 }
} else {
let atom_ptr = self.as_ptr() as *const nsDynamicAtom;
- unsafe { (*(atom_ptr)).mString }
+ // Dynamic atom chars are stored at the end of the object.
+ unsafe { atom_ptr.offset(1) as *const u16 }
};
unsafe { slice::from_raw_parts(string, self.len() as usize) }
}
diff --git a/components/style/media_queries/media_list.rs b/components/style/media_queries/media_list.rs
index 5243174e07f..a5604b6dc19 100644
--- a/components/style/media_queries/media_list.rs
+++ b/components/style/media_queries/media_list.rs
@@ -9,13 +9,13 @@
use context::QuirksMode;
use cssparser::{Delimiter, Parser};
use cssparser::{ParserInput, Token};
-use error_reporting::{ContextualParseError, ParseErrorReporter};
-use parser::{ParserContext, ParserErrorContext};
+use error_reporting::ContextualParseError;
+use parser::ParserContext;
use super::{Device, MediaQuery, Qualifier};
/// A type that encapsulates a media query list.
-#[css(comma)]
-#[derive(Clone, Debug, MallocSizeOf, ToCss)]
+#[css(comma, derive_debug)]
+#[derive(Clone, MallocSizeOf, ToCss)]
pub struct MediaList {
/// The list of media queries.
#[css(iterable)]
@@ -30,14 +30,10 @@ impl MediaList {
/// "not all", see:
///
/// <https://drafts.csswg.org/mediaqueries/#error-handling>
- pub fn parse<R>(
+ pub fn parse(
context: &ParserContext,
input: &mut Parser,
- error_reporter: &R,
- ) -> MediaList
- where
- R: ParseErrorReporter,
- {
+ ) -> Self {
if input.is_exhausted() {
return Self::empty();
}
@@ -54,8 +50,7 @@ impl MediaList {
let location = err.location;
let error =
ContextualParseError::InvalidMediaRule(input.slice_from(start_position), err);
- let error_context = ParserErrorContext { error_reporter };
- context.log_css_error(&error_context, location, error);
+ context.log_css_error(location, error);
},
}
diff --git a/components/style/parser.rs b/components/style/parser.rs
index 6dbfe1cfa01..a4b7d816203 100644
--- a/components/style/parser.rs
+++ b/components/style/parser.rs
@@ -36,12 +36,6 @@ pub fn assert_parsing_mode_match() {
}
}
-/// The context required to report a parse error.
-pub struct ParserErrorContext<'a, R: 'a> {
- /// An error reporter to report syntax errors.
- pub error_reporter: &'a R,
-}
-
/// The data that the parser needs from outside in order to parse a stylesheet.
pub struct ParserContext<'a> {
/// The `Origin` of the stylesheet, whether it's a user, author or
@@ -55,6 +49,8 @@ pub struct ParserContext<'a> {
pub parsing_mode: ParsingMode,
/// The quirks mode of this stylesheet.
pub quirks_mode: QuirksMode,
+ /// The active error reporter, or none if error reporting is disabled.
+ error_reporter: Option<&'a ParseErrorReporter>,
/// The currently active namespaces.
pub namespaces: Option<&'a Namespaces>,
}
@@ -68,6 +64,7 @@ impl<'a> ParserContext<'a> {
rule_type: Option<CssRuleType>,
parsing_mode: ParsingMode,
quirks_mode: QuirksMode,
+ error_reporter: Option<&'a ParseErrorReporter>,
) -> Self {
ParserContext {
stylesheet_origin,
@@ -75,6 +72,7 @@ impl<'a> ParserContext<'a> {
rule_type,
parsing_mode,
quirks_mode,
+ error_reporter,
namespaces: None,
}
}
@@ -86,6 +84,7 @@ impl<'a> ParserContext<'a> {
rule_type: Option<CssRuleType>,
parsing_mode: ParsingMode,
quirks_mode: QuirksMode,
+ error_reporter: Option<&'a ParseErrorReporter>,
) -> Self {
Self::new(
Origin::Author,
@@ -93,6 +92,7 @@ impl<'a> ParserContext<'a> {
rule_type,
parsing_mode,
quirks_mode,
+ error_reporter,
)
}
@@ -110,6 +110,7 @@ impl<'a> ParserContext<'a> {
parsing_mode: context.parsing_mode,
quirks_mode: context.quirks_mode,
namespaces: Some(namespaces),
+ error_reporter: context.error_reporter,
}
}
@@ -127,21 +128,17 @@ impl<'a> ParserContext<'a> {
}
/// Record a CSS parse error with this context’s error reporting.
- pub fn log_css_error<R>(
+ pub fn log_css_error(
&self,
- context: &ParserErrorContext<R>,
location: SourceLocation,
error: ContextualParseError,
- ) where
- R: ParseErrorReporter,
- {
- let location = SourceLocation {
- line: location.line,
- column: location.column,
+ ) {
+ let error_reporter = match self.error_reporter {
+ Some(r) => r,
+ None => return,
};
- context
- .error_reporter
- .report_error(self.url_data, location, error)
+
+ error_reporter.report_error(self.url_data, location, error)
}
/// Returns whether chrome-only rules should be parsed.
diff --git a/components/style/properties/build.py b/components/style/properties/build.py
index 04418723ee4..4f5da29246b 100644
--- a/components/style/properties/build.py
+++ b/components/style/properties/build.py
@@ -19,6 +19,34 @@ import data
RE_PYTHON_ADDR = re.compile(r'<.+? object at 0x[0-9a-fA-F]+>')
+OUT_DIR = os.environ.get("OUT_DIR", "")
+
+STYLE_STRUCT_LIST = [
+ "background",
+ "border",
+ "box",
+ "color",
+ "column",
+ "counters",
+ "effects",
+ "font",
+ "inherited_box",
+ "inherited_table",
+ "inherited_text",
+ "inherited_ui",
+ "inherited_svg",
+ "list",
+ "margin",
+ "outline",
+ "padding",
+ "position",
+ "table",
+ "text",
+ "ui",
+ "svg",
+ "xul",
+]
+
def main():
usage = "Usage: %s [ servo | gecko ] [ style-crate | geckolib <template> | html ]" % sys.argv[0]
@@ -31,14 +59,41 @@ def main():
abort(usage)
properties = data.PropertiesData(product=product)
- template = os.path.join(BASE, "properties.mako.rs")
- rust = render(template, product=product, data=properties, __file__=template)
+ files = {}
+ for kind in ["longhands", "shorthands"]:
+ files[kind] = {}
+ for struct in STYLE_STRUCT_LIST:
+ file_name = os.path.join(BASE, kind, "{}.mako.rs".format(struct))
+ if kind == "shorthands" and not os.path.exists(file_name):
+ files[kind][struct] = ""
+ continue
+ files[kind][struct] = render(
+ file_name,
+ product=product,
+ data=properties,
+ )
+ properties_template = os.path.join(BASE, "properties.mako.rs")
+ files["properties"] = render(
+ properties_template,
+ product=product,
+ data=properties,
+ __file__=properties_template,
+ OUT_DIR=OUT_DIR,
+ )
if output == "style-crate":
- write(os.environ["OUT_DIR"], "properties.rs", rust)
+ write(OUT_DIR, "properties.rs", files["properties"])
+ for kind in ["longhands", "shorthands"]:
+ for struct in files[kind]:
+ write(
+ os.path.join(OUT_DIR, kind),
+ "{}.rs".format(struct),
+ files[kind][struct],
+ )
+
if product == "gecko":
template = os.path.join(BASE, "gecko.mako.rs")
rust = render(template, data=properties)
- write(os.environ["OUT_DIR"], "gecko_properties.rs", rust)
+ write(OUT_DIR, "gecko_properties.rs", rust)
elif output == "geckolib":
if len(sys.argv) < 4:
abort(usage)
diff --git a/components/style/properties/data.py b/components/style/properties/data.py
index fca4b536e01..08001628e60 100644
--- a/components/style/properties/data.py
+++ b/components/style/properties/data.py
@@ -38,6 +38,10 @@ def to_rust_ident(name):
return name
+def to_snake_case(ident):
+ return re.sub("([A-Z]+)", lambda m: "_" + m.group(1).lower(), ident).strip("_")
+
+
def to_camel_case(ident):
return re.sub("(^|_|-)([a-z0-9])", lambda m: m.group(2).upper(), ident.strip("_").strip("-"))
@@ -451,7 +455,7 @@ class StyleStruct(object):
def __init__(self, name, inherited, gecko_name=None, additional_methods=None):
self.gecko_struct_name = "Gecko" + name
self.name = name
- self.name_lower = name.lower()
+ self.name_lower = to_snake_case(name)
self.ident = to_rust_ident(self.name_lower)
self.longhands = []
self.inherited = inherited
diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs
index 4e368c0c2b7..8727ba4cc41 100644
--- a/components/style/properties/declaration_block.rs
+++ b/components/style/properties/declaration_block.rs
@@ -11,8 +11,8 @@ use cssparser::{DeclarationListParser, parse_important, ParserInput, CowRcStr};
use cssparser::{Parser, AtRuleParser, DeclarationParser, Delimiter, ParseErrorKind};
use custom_properties::CustomPropertiesBuilder;
use error_reporting::{ParseErrorReporter, ContextualParseError};
-use parser::{ParserContext, ParserErrorContext};
-use properties::animated_properties::AnimationValue;
+use parser::ParserContext;
+use properties::animated_properties::{AnimationValue, AnimationValueMap};
use shared_lock::Locked;
use smallbitvec::{self, SmallBitVec};
use smallvec::SmallVec;
@@ -24,7 +24,6 @@ use style_traits::{CssWriter, ParseError, ParsingMode, StyleParseErrorKind, ToCs
use stylesheets::{CssRuleType, Origin, UrlExtraData};
use super::*;
use values::computed::Context;
-#[cfg(feature = "gecko")] use properties::animated_properties::AnimationValueMap;
/// The animation rules.
///
@@ -564,51 +563,71 @@ impl PropertyDeclarationBlock {
true
}
- /// <https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty>
- ///
- /// Returns whether any declaration was actually removed.
- pub fn remove_property<C>(
- &mut self,
+ /// Returns the first declaration that would be removed by removing
+ /// `property`.
+ #[inline]
+ pub fn first_declaration_to_remove(
+ &self,
property: &PropertyId,
- mut before_change_callback: C,
- ) -> bool
- where
- C: FnMut(&Self),
- {
- let longhand_id = property.longhand_id();
- if let Some(id) = longhand_id {
+ ) -> Option<usize> {
+ if let Some(id) = property.longhand_id() {
if !self.longhands.contains(id) {
- return false
+ return None;
}
}
- let mut removed_at_least_one = false;
- let mut i = 0;
- let mut len = self.len();
- while i < len {
- {
- let id = self.declarations[i].id();
- if !id.is_or_is_longhand_of(property) {
- i += 1;
- continue;
- }
- if !removed_at_least_one {
- before_change_callback(&*self);
- }
- removed_at_least_one = true;
- if let PropertyDeclarationId::Longhand(id) = id {
- self.longhands.remove(id);
- }
- self.declarations_importance.remove(i);
+ self.declarations.iter().position(|declaration| {
+ declaration.id().is_or_is_longhand_of(property)
+ })
+ }
+
+ /// Removes a given declaration at a given index.
+ #[inline]
+ fn remove_declaration_at(&mut self, i: usize) {
+ {
+ let id = self.declarations[i].id();
+ if let PropertyDeclarationId::Longhand(id) = id {
+ self.longhands.remove(id);
}
- self.declarations.remove(i);
- len -= 1;
+ self.declarations_importance.remove(i);
}
+ self.declarations.remove(i);
+ }
- if longhand_id.is_some() {
- debug_assert!(removed_at_least_one);
+ /// <https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty>
+ ///
+ /// `first_declaration` needs to be the result of
+ /// `first_declaration_to_remove`.
+ #[inline]
+ pub fn remove_property(
+ &mut self,
+ property: &PropertyId,
+ first_declaration: usize,
+ ) {
+ debug_assert_eq!(
+ Some(first_declaration),
+ self.first_declaration_to_remove(property)
+ );
+ debug_assert!(self.declarations[first_declaration].id().is_or_is_longhand_of(property));
+
+ self.remove_declaration_at(first_declaration);
+
+ let shorthand = match property.as_shorthand() {
+ Ok(s) => s,
+ Err(_longhand_or_custom) => return,
+ };
+
+ let mut i = first_declaration;
+ let mut len = self.len();
+ while i < len {
+ if !self.declarations[i].id().is_longhand_of(shorthand) {
+ i += 1;
+ continue;
+ }
+
+ self.remove_declaration_at(i);
+ len -= 1;
}
- removed_at_least_one
}
/// Take a declaration block known to contain a single property and serialize it.
@@ -667,7 +686,6 @@ impl PropertyDeclarationBlock {
}
/// Convert AnimationValueMap to PropertyDeclarationBlock.
- #[cfg(feature = "gecko")]
pub fn from_animation_value_map(animation_value_map: &AnimationValueMap) -> Self {
let len = animation_value_map.len();
let mut declarations = Vec::with_capacity(len);
@@ -687,7 +705,6 @@ impl PropertyDeclarationBlock {
/// Returns true if the declaration block has a CSSWideKeyword for the given
/// property.
- #[cfg(feature = "gecko")]
pub fn has_css_wide_keyword(&self, property: &PropertyId) -> bool {
if let Some(id) = property.longhand_id() {
if !self.longhands.contains(id) {
@@ -727,9 +744,7 @@ impl PropertyDeclarationBlock {
builder.build()
}
-}
-impl PropertyDeclarationBlock {
/// Like the method on ToCss, but without the type parameter to avoid
/// accidentally monomorphizing this large function multiple times for
/// different writers.
@@ -1061,50 +1076,49 @@ where
/// A helper to parse the style attribute of an element, in order for this to be
/// shared between Servo and Gecko.
-pub fn parse_style_attribute<R>(
+///
+/// Inline because we call this cross-crate.
+#[inline]
+pub fn parse_style_attribute(
input: &str,
url_data: &UrlExtraData,
- error_reporter: &R,
+ error_reporter: Option<&ParseErrorReporter>,
quirks_mode: QuirksMode,
-) -> PropertyDeclarationBlock
-where
- R: ParseErrorReporter
-{
+) -> PropertyDeclarationBlock {
let context = ParserContext::new(
Origin::Author,
url_data,
Some(CssRuleType::Style),
ParsingMode::DEFAULT,
quirks_mode,
+ error_reporter,
);
- let error_context = ParserErrorContext { error_reporter: error_reporter };
let mut input = ParserInput::new(input);
- parse_property_declaration_list(&context, &error_context, &mut Parser::new(&mut input))
+ parse_property_declaration_list(&context, &mut Parser::new(&mut input))
}
/// Parse a given property declaration. Can result in multiple
/// `PropertyDeclaration`s when expanding a shorthand, for example.
///
/// This does not attempt to parse !important at all.
-pub fn parse_one_declaration_into<R>(
+#[inline]
+pub fn parse_one_declaration_into(
declarations: &mut SourcePropertyDeclaration,
id: PropertyId,
input: &str,
url_data: &UrlExtraData,
- error_reporter: &R,
+ error_reporter: Option<&ParseErrorReporter>,
parsing_mode: ParsingMode,
quirks_mode: QuirksMode
-) -> Result<(), ()>
-where
- R: ParseErrorReporter
-{
+) -> Result<(), ()> {
let context = ParserContext::new(
Origin::Author,
url_data,
Some(CssRuleType::Style),
parsing_mode,
quirks_mode,
+ error_reporter,
);
let mut input = ParserInput::new(input);
@@ -1115,9 +1129,10 @@ where
}).map_err(|err| {
let location = err.location;
let error = ContextualParseError::UnsupportedPropertyDeclaration(
- parser.slice_from(start_position), err);
- let error_context = ParserErrorContext { error_reporter: error_reporter };
- context.log_css_error(&error_context, location, error);
+ parser.slice_from(start_position),
+ err,
+ );
+ context.log_css_error(location, error);
})
}
@@ -1177,14 +1192,10 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for PropertyDeclarationParser<'a, 'b> {
/// Parse a list of property declarations and return a property declaration
/// block.
-pub fn parse_property_declaration_list<R>(
+pub fn parse_property_declaration_list(
context: &ParserContext,
- error_context: &ParserErrorContext<R>,
input: &mut Parser,
-) -> PropertyDeclarationBlock
-where
- R: ParseErrorReporter
-{
+) -> PropertyDeclarationBlock {
let mut declarations = SourcePropertyDeclaration::new();
let mut block = PropertyDeclarationBlock::new();
let parser = PropertyDeclarationParser {
@@ -1212,7 +1223,7 @@ where
let location = error.location;
let error = ContextualParseError::UnsupportedPropertyDeclaration(slice, error);
- context.log_css_error(error_context, location, error);
+ context.log_css_error(location, error);
}
}
}
diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs
index de0e48c782d..7a34cc4ade4 100644
--- a/components/style/properties/helpers/animated_properties.mako.rs
+++ b/components/style/properties/helpers/animated_properties.mako.rs
@@ -25,7 +25,7 @@ use servo_arc::Arc;
use smallvec::SmallVec;
use std::{cmp, ptr};
use std::mem::{self, ManuallyDrop};
-#[cfg(feature = "gecko")] use hash::FnvHashMap;
+use hash::FnvHashMap;
use super::ComputedValues;
use values::CSSFloat;
use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
@@ -229,8 +229,8 @@ impl AnimatedProperty {
/// A collection of AnimationValue that were composed on an element.
/// This HashMap stores the values that are the last AnimationValue to be
/// composed for each TransitionProperty.
-#[cfg(feature = "gecko")]
pub type AnimationValueMap = FnvHashMap<LonghandId, AnimationValue>;
+
#[cfg(feature = "gecko")]
unsafe impl HasFFI for AnimationValueMap {
type FFIType = RawServoAnimationValueMap;
diff --git a/components/style/properties/longhand/background.mako.rs b/components/style/properties/longhands/background.mako.rs
index 9bb4e03e523..9bb4e03e523 100644
--- a/components/style/properties/longhand/background.mako.rs
+++ b/components/style/properties/longhands/background.mako.rs
diff --git a/components/style/properties/longhand/border.mako.rs b/components/style/properties/longhands/border.mako.rs
index 9bb3dbcec28..9bb3dbcec28 100644
--- a/components/style/properties/longhand/border.mako.rs
+++ b/components/style/properties/longhands/border.mako.rs
diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhands/box.mako.rs
index aea51fed766..ce04a0a66d2 100644
--- a/components/style/properties/longhand/box.mako.rs
+++ b/components/style/properties/longhands/box.mako.rs
@@ -606,8 +606,9 @@ ${helpers.single_keyword("-moz-appearance",
scalethumb-horizontal scalethumbstart scalethumbtick scalethumb-vertical scale-vertical
scrollbar scrollbar-horizontal scrollbar-small scrollbar-vertical scrollbarbutton-down
scrollbarbutton-left scrollbarbutton-right scrollbarbutton-up scrollbarthumb-horizontal
- scrollbarthumb-vertical scrollbartrack-horizontal scrollbartrack-vertical searchfield
- separator spinner spinner-downbutton spinner-textfield spinner-upbutton splitter statusbar
+ scrollbarthumb-vertical scrollbartrack-horizontal scrollbartrack-vertical scrollcorner
+ searchfield separator
+ spinner spinner-downbutton spinner-textfield spinner-upbutton splitter statusbar
statusbarpanel tab tabpanel tabpanels tab-scroll-arrow-back tab-scroll-arrow-forward
textfield textfield-multiline toolbar toolbarbutton toolbarbutton-dropdown toolbargripper
toolbox tooltip treeheader treeheadercell treeheadersortarrow treeitem treeline treetwisty
diff --git a/components/style/properties/longhand/color.mako.rs b/components/style/properties/longhands/color.mako.rs
index a4d1830190a..a4d1830190a 100644
--- a/components/style/properties/longhand/color.mako.rs
+++ b/components/style/properties/longhands/color.mako.rs
diff --git a/components/style/properties/longhand/column.mako.rs b/components/style/properties/longhands/column.mako.rs
index 7a97c3f41e3..7a97c3f41e3 100644
--- a/components/style/properties/longhand/column.mako.rs
+++ b/components/style/properties/longhands/column.mako.rs
diff --git a/components/style/properties/longhand/counters.mako.rs b/components/style/properties/longhands/counters.mako.rs
index ececf58310f..ececf58310f 100644
--- a/components/style/properties/longhand/counters.mako.rs
+++ b/components/style/properties/longhands/counters.mako.rs
diff --git a/components/style/properties/longhand/effects.mako.rs b/components/style/properties/longhands/effects.mako.rs
index 674340c391a..674340c391a 100644
--- a/components/style/properties/longhand/effects.mako.rs
+++ b/components/style/properties/longhands/effects.mako.rs
diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhands/font.mako.rs
index 69f95532c16..69f95532c16 100644
--- a/components/style/properties/longhand/font.mako.rs
+++ b/components/style/properties/longhands/font.mako.rs
diff --git a/components/style/properties/longhand/inherited_box.mako.rs b/components/style/properties/longhands/inherited_box.mako.rs
index 23dfe7fef5c..23dfe7fef5c 100644
--- a/components/style/properties/longhand/inherited_box.mako.rs
+++ b/components/style/properties/longhands/inherited_box.mako.rs
diff --git a/components/style/properties/longhand/inherited_svg.mako.rs b/components/style/properties/longhands/inherited_svg.mako.rs
index b3bc12b1367..b3bc12b1367 100644
--- a/components/style/properties/longhand/inherited_svg.mako.rs
+++ b/components/style/properties/longhands/inherited_svg.mako.rs
diff --git a/components/style/properties/longhand/inherited_table.mako.rs b/components/style/properties/longhands/inherited_table.mako.rs
index 4f55d9b1fa5..4f55d9b1fa5 100644
--- a/components/style/properties/longhand/inherited_table.mako.rs
+++ b/components/style/properties/longhands/inherited_table.mako.rs
diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhands/inherited_text.mako.rs
index 62819a78cbc..62819a78cbc 100644
--- a/components/style/properties/longhand/inherited_text.mako.rs
+++ b/components/style/properties/longhands/inherited_text.mako.rs
diff --git a/components/style/properties/longhand/inherited_ui.mako.rs b/components/style/properties/longhands/inherited_ui.mako.rs
index 9718e33a84d..9718e33a84d 100644
--- a/components/style/properties/longhand/inherited_ui.mako.rs
+++ b/components/style/properties/longhands/inherited_ui.mako.rs
diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhands/list.mako.rs
index 5ed1ea44831..5ed1ea44831 100644
--- a/components/style/properties/longhand/list.mako.rs
+++ b/components/style/properties/longhands/list.mako.rs
diff --git a/components/style/properties/longhand/margin.mako.rs b/components/style/properties/longhands/margin.mako.rs
index 1a964bcbb74..1a964bcbb74 100644
--- a/components/style/properties/longhand/margin.mako.rs
+++ b/components/style/properties/longhands/margin.mako.rs
diff --git a/components/style/properties/longhand/outline.mako.rs b/components/style/properties/longhands/outline.mako.rs
index 9446745ec3e..9446745ec3e 100644
--- a/components/style/properties/longhand/outline.mako.rs
+++ b/components/style/properties/longhands/outline.mako.rs
diff --git a/components/style/properties/longhand/padding.mako.rs b/components/style/properties/longhands/padding.mako.rs
index 3d2467c0ca0..3d2467c0ca0 100644
--- a/components/style/properties/longhand/padding.mako.rs
+++ b/components/style/properties/longhands/padding.mako.rs
diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhands/position.mako.rs
index a99cebfdba9..a99cebfdba9 100644
--- a/components/style/properties/longhand/position.mako.rs
+++ b/components/style/properties/longhands/position.mako.rs
diff --git a/components/style/properties/longhand/svg.mako.rs b/components/style/properties/longhands/svg.mako.rs
index 6d7bf803f1e..6d7bf803f1e 100644
--- a/components/style/properties/longhand/svg.mako.rs
+++ b/components/style/properties/longhands/svg.mako.rs
diff --git a/components/style/properties/longhand/table.mako.rs b/components/style/properties/longhands/table.mako.rs
index 2af39e1d6e3..2af39e1d6e3 100644
--- a/components/style/properties/longhand/table.mako.rs
+++ b/components/style/properties/longhands/table.mako.rs
diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhands/text.mako.rs
index 613ed6c5f67..613ed6c5f67 100644
--- a/components/style/properties/longhand/text.mako.rs
+++ b/components/style/properties/longhands/text.mako.rs
diff --git a/components/style/properties/longhand/ui.mako.rs b/components/style/properties/longhands/ui.mako.rs
index 13a940b2b96..13a940b2b96 100644
--- a/components/style/properties/longhand/ui.mako.rs
+++ b/components/style/properties/longhands/ui.mako.rs
diff --git a/components/style/properties/longhand/xul.mako.rs b/components/style/properties/longhands/xul.mako.rs
index 15b8a695411..15b8a695411 100644
--- a/components/style/properties/longhand/xul.mako.rs
+++ b/components/style/properties/longhands/xul.mako.rs
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index 4d18e0ca634..b6a8879e106 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -97,29 +97,9 @@ macro_rules! expanded {
/// A module with all the code for longhand properties.
#[allow(missing_docs)]
pub mod longhands {
- <%include file="/longhand/background.mako.rs" />
- <%include file="/longhand/border.mako.rs" />
- <%include file="/longhand/box.mako.rs" />
- <%include file="/longhand/color.mako.rs" />
- <%include file="/longhand/column.mako.rs" />
- <%include file="/longhand/counters.mako.rs" />
- <%include file="/longhand/effects.mako.rs" />
- <%include file="/longhand/font.mako.rs" />
- <%include file="/longhand/inherited_box.mako.rs" />
- <%include file="/longhand/inherited_table.mako.rs" />
- <%include file="/longhand/inherited_text.mako.rs" />
- <%include file="/longhand/inherited_ui.mako.rs" />
- <%include file="/longhand/list.mako.rs" />
- <%include file="/longhand/margin.mako.rs" />
- <%include file="/longhand/outline.mako.rs" />
- <%include file="/longhand/padding.mako.rs" />
- <%include file="/longhand/position.mako.rs" />
- <%include file="/longhand/table.mako.rs" />
- <%include file="/longhand/text.mako.rs" />
- <%include file="/longhand/ui.mako.rs" />
- <%include file="/longhand/inherited_svg.mako.rs" />
- <%include file="/longhand/svg.mako.rs" />
- <%include file="/longhand/xul.mako.rs" />
+ % for style_struct in data.style_structs:
+ include!("${repr(os.path.join(OUT_DIR, 'longhands/{}.rs'.format(style_struct.name_lower)))[1:-1]}");
+ % endfor
}
macro_rules! unwrap_or_initial {
@@ -137,23 +117,37 @@ pub mod shorthands {
use style_traits::{ParseError, StyleParseErrorKind};
use values::specified;
- <%include file="/shorthand/serialize.mako.rs" />
- <%include file="/shorthand/background.mako.rs" />
- <%include file="/shorthand/border.mako.rs" />
- <%include file="/shorthand/box.mako.rs" />
- <%include file="/shorthand/column.mako.rs" />
- <%include file="/shorthand/font.mako.rs" />
- <%include file="/shorthand/inherited_text.mako.rs" />
- <%include file="/shorthand/list.mako.rs" />
- <%include file="/shorthand/margin.mako.rs" />
- <%include file="/shorthand/mask.mako.rs" />
- <%include file="/shorthand/outline.mako.rs" />
- <%include file="/shorthand/padding.mako.rs" />
- <%include file="/shorthand/position.mako.rs" />
- <%include file="/shorthand/inherited_svg.mako.rs" />
- <%include file="/shorthand/text.mako.rs" />
-
- // We don't defined the 'all' shorthand using the regular helpers:shorthand
+ use style_traits::{CssWriter, ToCss};
+ use values::specified::{BorderStyle, Color};
+ use std::fmt::{self, Write};
+
+ fn serialize_directional_border<W, I,>(
+ dest: &mut CssWriter<W>,
+ width: &I,
+ style: &BorderStyle,
+ color: &Color,
+ ) -> fmt::Result
+ where
+ W: Write,
+ I: ToCss,
+ {
+ width.to_css(dest)?;
+ // FIXME(emilio): Should we really serialize the border style if it's
+ // `solid`?
+ dest.write_str(" ")?;
+ style.to_css(dest)?;
+ if *color != Color::CurrentColor {
+ dest.write_str(" ")?;
+ color.to_css(dest)?;
+ }
+ Ok(())
+ }
+
+ % for style_struct in data.style_structs:
+ include!("${repr(os.path.join(OUT_DIR, 'shorthands/{}.rs'.format(style_struct.name_lower)))[1:-1]}");
+ % endfor
+
+ // We didn't define the 'all' shorthand using the regular helpers:shorthand
// mechanism, since it causes some very large types to be generated.
//
// Also, make sure logical properties appear before its physical
@@ -1448,6 +1442,7 @@ impl UnparsedValue {
None,
ParsingMode::DEFAULT,
quirks_mode,
+ None,
);
let mut input = ParserInput::new(&css);
@@ -3852,7 +3847,7 @@ where
}
% if category_to_cascade_now == "early":
let writing_mode =
- WritingMode::new(context.builder.get_inheritedbox());
+ WritingMode::new(context.builder.get_inherited_box());
context.builder.writing_mode = writing_mode;
let mut _skip_font_family = false;
diff --git a/components/style/properties/shorthand/serialize.mako.rs b/components/style/properties/shorthand/serialize.mako.rs
deleted file mode 100644
index afcbe3c488b..00000000000
--- a/components/style/properties/shorthand/serialize.mako.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-/* 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 http://mozilla.org/MPL/2.0/. */
-
-use style_traits::{CssWriter, ToCss};
-use values::specified::{BorderStyle, Color};
-use std::fmt::{self, Write};
-
-fn serialize_directional_border<W, I,>(
- dest: &mut CssWriter<W>,
- width: &I,
- style: &BorderStyle,
- color: &Color,
-) -> fmt::Result
-where
- W: Write,
- I: ToCss,
-{
- width.to_css(dest)?;
- dest.write_str(" ")?;
- style.to_css(dest)?;
- if *color != Color::CurrentColor {
- dest.write_str(" ")?;
- color.to_css(dest)?;
- }
- Ok(())
-}
diff --git a/components/style/properties/shorthand/background.mako.rs b/components/style/properties/shorthands/background.mako.rs
index b16c9918a24..b16c9918a24 100644
--- a/components/style/properties/shorthand/background.mako.rs
+++ b/components/style/properties/shorthands/background.mako.rs
diff --git a/components/style/properties/shorthand/border.mako.rs b/components/style/properties/shorthands/border.mako.rs
index 056096353bc..056096353bc 100644
--- a/components/style/properties/shorthand/border.mako.rs
+++ b/components/style/properties/shorthands/border.mako.rs
diff --git a/components/style/properties/shorthand/box.mako.rs b/components/style/properties/shorthands/box.mako.rs
index 842dfbd7229..842dfbd7229 100644
--- a/components/style/properties/shorthand/box.mako.rs
+++ b/components/style/properties/shorthands/box.mako.rs
diff --git a/components/style/properties/shorthand/column.mako.rs b/components/style/properties/shorthands/column.mako.rs
index cdd05dc786b..cdd05dc786b 100644
--- a/components/style/properties/shorthand/column.mako.rs
+++ b/components/style/properties/shorthands/column.mako.rs
diff --git a/components/style/properties/shorthand/font.mako.rs b/components/style/properties/shorthands/font.mako.rs
index a53f899851c..a53f899851c 100644
--- a/components/style/properties/shorthand/font.mako.rs
+++ b/components/style/properties/shorthands/font.mako.rs
diff --git a/components/style/properties/shorthand/inherited_svg.mako.rs b/components/style/properties/shorthands/inherited_svg.mako.rs
index 09c533a708b..09c533a708b 100644
--- a/components/style/properties/shorthand/inherited_svg.mako.rs
+++ b/components/style/properties/shorthands/inherited_svg.mako.rs
diff --git a/components/style/properties/shorthand/inherited_text.mako.rs b/components/style/properties/shorthands/inherited_text.mako.rs
index 98ded998bb1..98ded998bb1 100644
--- a/components/style/properties/shorthand/inherited_text.mako.rs
+++ b/components/style/properties/shorthands/inherited_text.mako.rs
diff --git a/components/style/properties/shorthand/list.mako.rs b/components/style/properties/shorthands/list.mako.rs
index 67e141f5ac6..67e141f5ac6 100644
--- a/components/style/properties/shorthand/list.mako.rs
+++ b/components/style/properties/shorthands/list.mako.rs
diff --git a/components/style/properties/shorthand/margin.mako.rs b/components/style/properties/shorthands/margin.mako.rs
index 07b6ba6bbed..07b6ba6bbed 100644
--- a/components/style/properties/shorthand/margin.mako.rs
+++ b/components/style/properties/shorthands/margin.mako.rs
diff --git a/components/style/properties/shorthand/outline.mako.rs b/components/style/properties/shorthands/outline.mako.rs
index 14b935f3bfd..14b935f3bfd 100644
--- a/components/style/properties/shorthand/outline.mako.rs
+++ b/components/style/properties/shorthands/outline.mako.rs
diff --git a/components/style/properties/shorthand/padding.mako.rs b/components/style/properties/shorthands/padding.mako.rs
index 592048cf56f..592048cf56f 100644
--- a/components/style/properties/shorthand/padding.mako.rs
+++ b/components/style/properties/shorthands/padding.mako.rs
diff --git a/components/style/properties/shorthand/position.mako.rs b/components/style/properties/shorthands/position.mako.rs
index 19ca0cf1916..19ca0cf1916 100644
--- a/components/style/properties/shorthand/position.mako.rs
+++ b/components/style/properties/shorthands/position.mako.rs
diff --git a/components/style/properties/shorthand/mask.mako.rs b/components/style/properties/shorthands/svg.mako.rs
index aa73c77e46b..aa73c77e46b 100644
--- a/components/style/properties/shorthand/mask.mako.rs
+++ b/components/style/properties/shorthands/svg.mako.rs
diff --git a/components/style/properties/shorthand/text.mako.rs b/components/style/properties/shorthands/text.mako.rs
index 18a0786494d..18a0786494d 100644
--- a/components/style/properties/shorthand/text.mako.rs
+++ b/components/style/properties/shorthands/text.mako.rs
diff --git a/components/style/servo/media_queries.rs b/components/style/servo/media_queries.rs
index 2ab4edca611..336971f98df 100644
--- a/components/style/servo/media_queries.rs
+++ b/components/style/servo/media_queries.rs
@@ -24,7 +24,7 @@ use values::computed::font::FontSize;
/// is displayed in.
///
/// This is the struct against which media queries are evaluated.
-#[derive(MallocSizeOf)]
+#[derive(Debug, MallocSizeOf)]
pub struct Device {
/// The current media type used by de device.
media_type: MediaType,
diff --git a/components/style/sharing/mod.rs b/components/style/sharing/mod.rs
index 314e9877083..d6148d16b49 100644
--- a/components/style/sharing/mod.rs
+++ b/components/style/sharing/mod.rs
@@ -815,7 +815,11 @@ impl<E: TElement> StyleSharingCache<E> {
Some(candidate.element.borrow_data().unwrap().share_styles())
}
- /// Attempts to find an element in the cache with the given primary rule node and parent.
+ /// Attempts to find an element in the cache with the given primary rule
+ /// node and parent.
+ ///
+ /// FIXME(emilio): re-measure this optimization, and remove if it's not very
+ /// useful... It's probably not worth the complexity / obscure bugs.
pub fn lookup_by_rules(
&mut self,
shared_context: &SharedStyleContext,
@@ -841,7 +845,15 @@ impl<E: TElement> StyleSharingCache<E> {
if style.visited_rules() != visited_rules {
return None;
}
-
+ // NOTE(emilio): We only need to check name / namespace because we
+ // do name-dependent style adjustments, like the display: contents
+ // to display: none adjustment.
+ if target.namespace() != candidate.element.namespace() {
+ return None;
+ }
+ if target.local_name() != candidate.element.local_name() {
+ return None;
+ }
// Rule nodes and styles are computed independent of the element's
// actual visitedness, but at the end of the cascade (in
// `adjust_for_visited`) we do store the visitedness as a flag in
@@ -853,6 +865,7 @@ impl<E: TElement> StyleSharingCache<E> {
// FIXME(jryans): This seems like it breaks the constant time
// requirements of visited, assuming we get a cache hit on only one
// of unvisited vs. visited.
+ // TODO(emilio): We no longer have such a flag, remove this check.
if target.is_visited_link() != candidate.element.is_visited_link() {
return None;
}
diff --git a/components/style/style_adjuster.rs b/components/style/style_adjuster.rs
index 8bbc40ca8c6..754abab0993 100644
--- a/components/style/style_adjuster.rs
+++ b/components/style/style_adjuster.rs
@@ -19,6 +19,14 @@ use properties::longhands::position::computed_value::T as Position;
/// NOTE(emilio): If new adjustments are introduced that depend on reset
/// properties of the parent, you may need tweaking the
/// `ChildCascadeRequirement` code in `matching.rs`.
+///
+/// NOTE(emilio): Also, if new adjustments are introduced that break the
+/// following invariant:
+///
+/// Given same tag name, namespace, rules and parent style, two elements would
+/// end up with exactly the same style.
+///
+/// Then you need to adjust the lookup_by_rules conditions in the sharing cache.
pub struct StyleAdjuster<'a, 'b: 'a> {
style: &'a mut StyleBuilder<'b>,
}
@@ -248,8 +256,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
use computed_values::text_combine_upright::T as TextCombineUpright;
use computed_values::writing_mode::T as WritingMode;
- let writing_mode = self.style.get_inheritedbox().clone_writing_mode();
- let text_combine_upright = self.style.get_inheritedtext().clone_text_combine_upright();
+ let writing_mode = self.style.get_inherited_box().clone_writing_mode();
+ let text_combine_upright = self.style.get_inherited_text().clone_text_combine_upright();
if writing_mode != WritingMode::HorizontalTb &&
text_combine_upright == TextCombineUpright::All
@@ -258,7 +266,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
.flags
.insert(ComputedValueFlags::IS_TEXT_COMBINED);
self.style
- .mutate_inheritedbox()
+ .mutate_inherited_box()
.set_writing_mode(WritingMode::HorizontalTb);
}
}
@@ -297,8 +305,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// <https://lists.w3.org/Archives/Public/www-style/2017Mar/0045.html>
/// <https://github.com/servo/servo/issues/15754>
fn adjust_for_writing_mode(&mut self, layout_parent_style: &ComputedValues) {
- let our_writing_mode = self.style.get_inheritedbox().clone_writing_mode();
- let parent_writing_mode = layout_parent_style.get_inheritedbox().clone_writing_mode();
+ let our_writing_mode = self.style.get_inherited_box().clone_writing_mode();
+ let parent_writing_mode = layout_parent_style.get_inherited_box().clone_writing_mode();
if our_writing_mode != parent_writing_mode &&
self.style.get_box().clone_display() == Display::Inline
@@ -488,13 +496,13 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
return;
}
- match self.style.get_inheritedtext().clone_text_align() {
+ match self.style.get_inherited_text().clone_text_align() {
TextAlign::MozLeft | TextAlign::MozCenter | TextAlign::MozRight => {},
_ => return,
}
self.style
- .mutate_inheritedtext()
+ .mutate_inherited_text()
.set_text_align(TextAlign::Start)
}
@@ -508,8 +516,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
use values::computed::text::TextDecorationsInEffect;
let decorations_in_effect = TextDecorationsInEffect::from_style(&self.style);
- if self.style.get_inheritedtext().text_decorations_in_effect != decorations_in_effect {
- self.style.mutate_inheritedtext().text_decorations_in_effect = decorations_in_effect;
+ if self.style.get_inherited_text().text_decorations_in_effect != decorations_in_effect {
+ self.style.mutate_inherited_text().text_decorations_in_effect = decorations_in_effect;
}
}
diff --git a/components/style/stylesheets/font_feature_values_rule.rs b/components/style/stylesheets/font_feature_values_rule.rs
index 71fa8227928..8ce16e2ccf9 100644
--- a/components/style/stylesheets/font_feature_values_rule.rs
+++ b/components/style/stylesheets/font_feature_values_rule.rs
@@ -10,12 +10,12 @@ use Atom;
use cssparser::{AtRuleParser, AtRuleType, BasicParseErrorKind, CowRcStr};
use cssparser::{DeclarationListParser, DeclarationParser, Parser};
use cssparser::{QualifiedRuleParser, RuleListParser, SourceLocation, Token};
-use error_reporting::{ContextualParseError, ParseErrorReporter};
+use error_reporting::ContextualParseError;
#[cfg(feature = "gecko")]
use gecko_bindings::bindings::Gecko_AppendFeatureValueHashEntry;
#[cfg(feature = "gecko")]
use gecko_bindings::structs::{self, gfxFontFeatureValueSet, nsTArray};
-use parser::{Parse, ParserContext, ParserErrorContext};
+use parser::{Parse, ParserContext};
use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
use std::fmt::{self, Write};
use str::CssStringWriter;
@@ -267,27 +267,24 @@ macro_rules! font_feature_values_blocks {
}
/// Parses a `FontFeatureValuesRule`.
- pub fn parse<R>(context: &ParserContext,
- error_context: &ParserErrorContext<R>,
- input: &mut Parser,
- family_names: Vec<FamilyName>,
- location: SourceLocation)
- -> FontFeatureValuesRule
- where R: ParseErrorReporter
- {
+ pub fn parse(
+ context: &ParserContext,
+ input: &mut Parser,
+ family_names: Vec<FamilyName>,
+ location: SourceLocation,
+ ) -> Self {
let mut rule = FontFeatureValuesRule::new(family_names, location);
{
let mut iter = RuleListParser::new_for_nested_rule(input, FontFeatureValuesRuleParser {
context: context,
- error_context: error_context,
rule: &mut rule,
});
while let Some(result) = iter.next() {
if let Err((error, slice)) = result {
let location = error.location;
let error = ContextualParseError::UnsupportedRule(slice, error);
- context.log_css_error(error_context, location, error);
+ context.log_css_error(location, error);
}
}
}
@@ -398,20 +395,19 @@ macro_rules! font_feature_values_blocks {
/// }
/// <feature-type> = @stylistic | @historical-forms | @styleset |
/// @character-variant | @swash | @ornaments | @annotation
- struct FontFeatureValuesRuleParser<'a, R: 'a> {
+ struct FontFeatureValuesRuleParser<'a> {
context: &'a ParserContext<'a>,
- error_context: &'a ParserErrorContext<'a, R>,
rule: &'a mut FontFeatureValuesRule,
}
/// Default methods reject all qualified rules.
- impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for FontFeatureValuesRuleParser<'a, R> {
+ impl<'a, 'i> QualifiedRuleParser<'i> for FontFeatureValuesRuleParser<'a> {
type Prelude = ();
type QualifiedRule = ();
type Error = StyleParseErrorKind<'i>;
}
- impl<'a, 'i, R: ParseErrorReporter> AtRuleParser<'i> for FontFeatureValuesRuleParser<'a, R> {
+ impl<'a, 'i> AtRuleParser<'i> for FontFeatureValuesRuleParser<'a> {
type PreludeNoBlock = ();
type PreludeBlock = BlockType;
type AtRule = ();
@@ -450,7 +446,7 @@ macro_rules! font_feature_values_blocks {
let error = ContextualParseError::UnsupportedKeyframePropertyDeclaration(
slice, error
);
- self.context.log_css_error(self.error_context, location, error);
+ self.context.log_css_error(location, error);
}
}
},
diff --git a/components/style/stylesheets/keyframes_rule.rs b/components/style/stylesheets/keyframes_rule.rs
index 5f39267ac7b..a0cb5fa0b1d 100644
--- a/components/style/stylesheets/keyframes_rule.rs
+++ b/components/style/stylesheets/keyframes_rule.rs
@@ -6,8 +6,8 @@
use cssparser::{AtRuleParser, CowRcStr, Parser, ParserInput, QualifiedRuleParser, RuleListParser};
use cssparser::{parse_one_rule, DeclarationListParser, DeclarationParser, SourceLocation, Token};
-use error_reporting::{ContextualParseError, NullReporter, ParseErrorReporter};
-use parser::{ParserContext, ParserErrorContext};
+use error_reporting::ContextualParseError;
+use parser::ParserContext;
use properties::{DeclarationSource, Importance, PropertyDeclaration};
use properties::{LonghandId, PropertyDeclarationBlock, PropertyId};
use properties::{PropertyDeclarationId, SourcePropertyDeclaration};
@@ -211,7 +211,6 @@ impl Keyframe {
lock: &SharedRwLock,
) -> Result<Arc<Locked<Self>>, ParseError<'i>> {
let url_data = parent_stylesheet_contents.url_data.read();
- let error_reporter = NullReporter;
let namespaces = parent_stylesheet_contents.namespaces.read();
let mut context = ParserContext::new(
parent_stylesheet_contents.origin,
@@ -219,10 +218,8 @@ impl Keyframe {
Some(CssRuleType::Keyframe),
ParsingMode::DEFAULT,
parent_stylesheet_contents.quirks_mode,
+ None,
);
- let error_context = ParserErrorContext {
- error_reporter: &error_reporter,
- };
context.namespaces = Some(&*namespaces);
let mut input = ParserInput::new(css);
let mut input = Parser::new(&mut input);
@@ -230,7 +227,6 @@ impl Keyframe {
let mut declarations = SourcePropertyDeclaration::new();
let mut rule_parser = KeyframeListParser {
context: &context,
- error_context: &error_context,
shared_lock: &lock,
declarations: &mut declarations,
};
@@ -477,23 +473,18 @@ impl KeyframesAnimation {
/// 40%, 60%, 100% {
/// width: 100%;
/// }
-struct KeyframeListParser<'a, R: 'a> {
+struct KeyframeListParser<'a> {
context: &'a ParserContext<'a>,
- error_context: &'a ParserErrorContext<'a, R>,
shared_lock: &'a SharedRwLock,
declarations: &'a mut SourcePropertyDeclaration,
}
/// Parses a keyframe list from CSS input.
-pub fn parse_keyframe_list<R>(
+pub fn parse_keyframe_list(
context: &ParserContext,
- error_context: &ParserErrorContext<R>,
input: &mut Parser,
shared_lock: &SharedRwLock,
-) -> Vec<Arc<Locked<Keyframe>>>
-where
- R: ParseErrorReporter,
-{
+) -> Vec<Arc<Locked<Keyframe>>> {
debug_assert!(
context.namespaces.is_some(),
"Parsing a keyframe list from a context without namespaces?"
@@ -504,7 +495,6 @@ where
input,
KeyframeListParser {
context: context,
- error_context: error_context,
shared_lock: shared_lock,
declarations: &mut declarations,
},
@@ -512,7 +502,7 @@ where
.collect()
}
-impl<'a, 'i, R> AtRuleParser<'i> for KeyframeListParser<'a, R> {
+impl<'a, 'i> AtRuleParser<'i> for KeyframeListParser<'a> {
type PreludeNoBlock = ();
type PreludeBlock = ();
type AtRule = Arc<Locked<Keyframe>>;
@@ -525,7 +515,7 @@ struct KeyframeSelectorParserPrelude {
source_location: SourceLocation,
}
-impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for KeyframeListParser<'a, R> {
+impl<'a, 'i> QualifiedRuleParser<'i> for KeyframeListParser<'a> {
type Prelude = KeyframeSelectorParserPrelude;
type QualifiedRule = Arc<Locked<Keyframe>>;
type Error = StyleParseErrorKind<'i>;
@@ -547,8 +537,7 @@ impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for KeyframeListPars
input.slice_from(start_position),
e.clone(),
);
- self.context
- .log_css_error(self.error_context, location, error);
+ self.context.log_css_error(location, error);
Err(e)
},
}
@@ -585,7 +574,7 @@ impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for KeyframeListPars
let location = error.location;
let error =
ContextualParseError::UnsupportedKeyframePropertyDeclaration(slice, error);
- context.log_css_error(self.error_context, location, error);
+ context.log_css_error(location, error);
},
}
// `parse_important` is not called here, `!important` is not allowed in keyframe blocks.
diff --git a/components/style/stylesheets/mod.rs b/components/style/stylesheets/mod.rs
index 2d6539c08b4..e3641f3e515 100644
--- a/components/style/stylesheets/mod.rs
+++ b/components/style/stylesheets/mod.rs
@@ -24,10 +24,9 @@ pub mod supports_rule;
pub mod viewport_rule;
use cssparser::{parse_one_rule, Parser, ParserInput};
-use error_reporting::NullReporter;
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocSizeOfOps, MallocUnconditionalShallowSizeOf};
-use parser::{ParserContext, ParserErrorContext};
+use parser::ParserContext;
use servo_arc::Arc;
use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked};
use shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
@@ -62,22 +61,52 @@ pub type UrlExtraData = ::servo_url::ServoUrl;
/// Extra data that the backend may need to resolve url values.
#[cfg(feature = "gecko")]
-pub type UrlExtraData =
- ::gecko_bindings::sugar::refptr::RefPtr<::gecko_bindings::structs::URLExtraData>;
+#[derive(Clone, PartialEq)]
+pub struct UrlExtraData(
+ pub ::gecko_bindings::sugar::refptr::RefPtr<::gecko_bindings::structs::URLExtraData>
+);
#[cfg(feature = "gecko")]
impl UrlExtraData {
- /// Returns a string for the url.
+ /// True if this URL scheme is chrome.
+ #[inline]
+ pub fn is_chrome(&self) -> bool {
+ self.0.mIsChrome
+ }
+
+ /// Create a reference to this `UrlExtraData` from a reference to pointer.
///
- /// Unimplemented currently.
- pub fn as_str(&self) -> &str {
- // TODO
- "(stylo: not supported)"
+ /// The pointer must be valid and non null.
+ ///
+ /// This method doesn't touch refcount.
+ #[inline]
+ pub unsafe fn from_ptr_ref(ptr: &*mut ::gecko_bindings::structs::URLExtraData) -> &Self {
+ ::std::mem::transmute(ptr)
}
+}
- /// True if this URL scheme is chrome.
- pub fn is_chrome(&self) -> bool {
- self.mIsChrome
+#[cfg(feature = "gecko")]
+impl fmt::Debug for UrlExtraData {
+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ use gecko_bindings::{structs, bindings};
+
+ struct DebugURI(*mut structs::nsIURI);
+ impl fmt::Debug for DebugURI {
+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ use nsstring::nsCString;
+ let mut spec = nsCString::new();
+ unsafe {
+ bindings::Gecko_nsIURI_Debug(self.0, &mut spec);
+ }
+ spec.fmt(formatter)
+ }
+ }
+
+ formatter.debug_struct("URLExtraData")
+ .field("is_chrome", &self.is_chrome())
+ .field("base", &DebugURI(self.0.mBaseURI.raw::<structs::nsIURI>()))
+ .field("referrer", &DebugURI(self.0.mReferrer.raw::<structs::nsIURI>()))
+ .finish()
}
}
@@ -228,13 +257,13 @@ impl CssRule {
loader: Option<&StylesheetLoader>,
) -> Result<Self, RulesMutateError> {
let url_data = parent_stylesheet_contents.url_data.read();
- let error_reporter = NullReporter;
let context = ParserContext::new(
parent_stylesheet_contents.origin,
&url_data,
None,
ParsingMode::DEFAULT,
parent_stylesheet_contents.quirks_mode,
+ None,
);
let mut input = ParserInput::new(css);
@@ -246,9 +275,6 @@ impl CssRule {
let mut rule_parser = TopLevelRuleParser {
stylesheet_origin: parent_stylesheet_contents.origin,
context,
- error_context: ParserErrorContext {
- error_reporter: &error_reporter,
- },
shared_lock: &shared_lock,
loader,
state,
diff --git a/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs
index 259130dd89b..41d87aa07a4 100644
--- a/components/style/stylesheets/rule_parser.rs
+++ b/components/style/stylesheets/rule_parser.rs
@@ -8,10 +8,10 @@ use {Namespace, Prefix};
use counter_style::{parse_counter_style_body, parse_counter_style_name_definition};
use cssparser::{AtRuleParser, AtRuleType, Parser, QualifiedRuleParser, RuleListParser};
use cssparser::{BasicParseError, BasicParseErrorKind, CowRcStr, SourceLocation};
-use error_reporting::{ContextualParseError, ParseErrorReporter};
+use error_reporting::ContextualParseError;
use font_face::parse_font_face_block;
use media_queries::MediaList;
-use parser::{Parse, ParserContext, ParserErrorContext};
+use parser::{Parse, ParserContext};
use properties::parse_property_declaration_list;
use selector_parser::{SelectorImpl, SelectorParser};
use selectors::SelectorList;
@@ -40,7 +40,7 @@ pub struct InsertRuleContext<'a> {
}
/// The parser for the top-level rules in a stylesheet.
-pub struct TopLevelRuleParser<'a, R: 'a> {
+pub struct TopLevelRuleParser<'a> {
/// The origin of the stylesheet we're parsing.
pub stylesheet_origin: Origin,
/// A reference to the lock we need to use to create rules.
@@ -52,8 +52,6 @@ pub struct TopLevelRuleParser<'a, R: 'a> {
/// This won't contain any namespaces, and only nested parsers created with
/// `ParserContext::new_with_rule_type` will.
pub context: ParserContext<'a>,
- /// The context required for reporting parse errors.
- pub error_context: ParserErrorContext<'a, R>,
/// The current state of the parser.
pub state: State,
/// Whether we have tried to parse was invalid due to being in the wrong
@@ -68,13 +66,12 @@ pub struct TopLevelRuleParser<'a, R: 'a> {
pub insert_rule_context: Option<InsertRuleContext<'a>>,
}
-impl<'b, R> TopLevelRuleParser<'b, R> {
- fn nested<'a: 'b>(&'a self) -> NestedRuleParser<'a, 'b, R> {
+impl<'b> TopLevelRuleParser<'b> {
+ fn nested<'a: 'b>(&'a self) -> NestedRuleParser<'a, 'b> {
NestedRuleParser {
stylesheet_origin: self.stylesheet_origin,
shared_lock: self.shared_lock,
context: &self.context,
- error_context: &self.error_context,
namespaces: &self.namespaces,
}
}
@@ -176,7 +173,7 @@ pub enum AtRuleNonBlockPrelude {
Namespace(Option<Prefix>, Namespace, SourceLocation),
}
-impl<'a, 'i, R: ParseErrorReporter> AtRuleParser<'i> for TopLevelRuleParser<'a, R> {
+impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
type PreludeNoBlock = AtRuleNonBlockPrelude;
type PreludeBlock = AtRuleBlockPrelude;
type AtRule = CssRule;
@@ -197,11 +194,7 @@ impl<'a, 'i, R: ParseErrorReporter> AtRuleParser<'i> for TopLevelRuleParser<'a,
let url_string = input.expect_url_or_string()?.as_ref().to_owned();
let url = CssUrl::parse_from_string(url_string, &self.context);
- let media = MediaList::parse(
- &self.context,
- input,
- self.error_context.error_reporter,
- );
+ let media = MediaList::parse(&self.context, input);
let media = Arc::new(self.shared_lock.wrap(media));
let prelude = AtRuleNonBlockPrelude::Import(url, media, location);
@@ -296,7 +289,7 @@ pub struct QualifiedRuleParserPrelude {
source_location: SourceLocation,
}
-impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for TopLevelRuleParser<'a, R> {
+impl<'a, 'i> QualifiedRuleParser<'i> for TopLevelRuleParser<'a> {
type Prelude = QualifiedRuleParserPrelude;
type QualifiedRule = CssRule;
type Error = StyleParseErrorKind<'i>;
@@ -327,27 +320,29 @@ impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for TopLevelRulePars
}
#[derive(Clone)] // shallow, relatively cheap .clone
-struct NestedRuleParser<'a, 'b: 'a, R: 'b> {
+struct NestedRuleParser<'a, 'b: 'a> {
stylesheet_origin: Origin,
shared_lock: &'a SharedRwLock,
context: &'a ParserContext<'b>,
- error_context: &'a ParserErrorContext<'b, R>,
namespaces: &'a Namespaces,
}
-impl<'a, 'b, R: ParseErrorReporter> NestedRuleParser<'a, 'b, R> {
+impl<'a, 'b> NestedRuleParser<'a, 'b> {
fn parse_nested_rules(
&mut self,
input: &mut Parser,
rule_type: CssRuleType,
) -> Arc<Locked<CssRules>> {
- let context = ParserContext::new_with_rule_type(self.context, rule_type, self.namespaces);
+ let context = ParserContext::new_with_rule_type(
+ self.context,
+ rule_type,
+ self.namespaces,
+ );
let nested_parser = NestedRuleParser {
stylesheet_origin: self.stylesheet_origin,
shared_lock: self.shared_lock,
context: &context,
- error_context: &self.error_context,
namespaces: self.namespaces,
};
@@ -359,8 +354,7 @@ impl<'a, 'b, R: ParseErrorReporter> NestedRuleParser<'a, 'b, R> {
Err((error, slice)) => {
let location = error.location;
let error = ContextualParseError::InvalidRule(slice, error);
- self.context
- .log_css_error(self.error_context, location, error);
+ self.context.log_css_error(location, error);
},
}
}
@@ -368,7 +362,7 @@ impl<'a, 'b, R: ParseErrorReporter> NestedRuleParser<'a, 'b, R> {
}
}
-impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a, 'b, R> {
+impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
type PreludeNoBlock = AtRuleNonBlockPrelude;
type PreludeBlock = AtRuleBlockPrelude;
type AtRule = CssRule;
@@ -383,11 +377,7 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
match_ignore_ascii_case! { &*name,
"media" => {
- let media_queries = MediaList::parse(
- self.context,
- input,
- self.error_context.error_reporter,
- );
+ let media_queries = MediaList::parse(self.context, input);
let arc = Arc::new(self.shared_lock.wrap(media_queries));
Ok(AtRuleType::WithBlock(AtRuleBlockPrelude::Media(arc, location)))
},
@@ -473,7 +463,7 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
);
Ok(CssRule::FontFace(Arc::new(self.shared_lock.wrap(
- parse_font_face_block(&context, self.error_context, input, location).into(),
+ parse_font_face_block(&context, input, location).into(),
))))
},
AtRuleBlockPrelude::FontFeatureValues(family_names, location) => {
@@ -486,7 +476,6 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
Ok(CssRule::FontFeatureValues(Arc::new(self.shared_lock.wrap(
FontFeatureValuesRule::parse(
&context,
- self.error_context,
input,
family_names,
location,
@@ -505,7 +494,6 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
parse_counter_style_body(
name,
&context,
- self.error_context,
input,
location,
)?.into(),
@@ -544,7 +532,7 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
);
Ok(CssRule::Viewport(Arc::new(self.shared_lock.wrap(
- ViewportRule::parse(&context, self.error_context, input)?,
+ ViewportRule::parse(&context, input)?,
))))
},
AtRuleBlockPrelude::Keyframes(name, vendor_prefix, source_location) => {
@@ -559,7 +547,6 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
name,
keyframes: parse_keyframe_list(
&context,
- self.error_context,
input,
self.shared_lock,
),
@@ -576,7 +563,7 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
);
let declarations =
- parse_property_declaration_list(&context, self.error_context, input);
+ parse_property_declaration_list(&context, input);
Ok(CssRule::Page(Arc::new(self.shared_lock.wrap(PageRule {
block: Arc::new(self.shared_lock.wrap(declarations)),
source_location,
@@ -598,7 +585,7 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
}
}
-impl<'a, 'b, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for NestedRuleParser<'a, 'b, R> {
+impl<'a, 'b, 'i> QualifiedRuleParser<'i> for NestedRuleParser<'a, 'b> {
type Prelude = QualifiedRuleParserPrelude;
type QualifiedRule = CssRule;
type Error = StyleParseErrorKind<'i>;
@@ -627,7 +614,7 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for NestedRulePa
let context =
ParserContext::new_with_rule_type(self.context, CssRuleType::Style, self.namespaces);
- let declarations = parse_property_declaration_list(&context, self.error_context, input);
+ let declarations = parse_property_declaration_list(&context, input);
Ok(CssRule::Style(Arc::new(self.shared_lock.wrap(StyleRule {
selectors: prelude.selectors,
block: Arc::new(self.shared_lock.wrap(declarations)),
diff --git a/components/style/stylesheets/stylesheet.rs b/components/style/stylesheets/stylesheet.rs
index b33875a149c..ee24a918c73 100644
--- a/components/style/stylesheets/stylesheet.rs
+++ b/components/style/stylesheets/stylesheet.rs
@@ -13,7 +13,7 @@ use invalidation::media_queries::{MediaListKey, ToMediaListKey};
use malloc_size_of::{MallocSizeOfOps, MallocUnconditionalShallowSizeOf};
use media_queries::{Device, MediaList};
use parking_lot::RwLock;
-use parser::{ParserContext, ParserErrorContext};
+use parser::ParserContext;
use servo_arc::Arc;
use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard};
use std::mem;
@@ -69,13 +69,13 @@ pub struct StylesheetContents {
impl StylesheetContents {
/// Parse a given CSS string, with a given url-data, origin, and
/// quirks mode.
- pub fn from_str<R: ParseErrorReporter>(
+ pub fn from_str(
css: &str,
url_data: UrlExtraData,
origin: Origin,
shared_lock: &SharedRwLock,
stylesheet_loader: Option<&StylesheetLoader>,
- error_reporter: &R,
+ error_reporter: Option<&ParseErrorReporter>,
quirks_mode: QuirksMode,
line_number_offset: u32,
) -> Self {
@@ -137,7 +137,7 @@ impl DeepCloneWithLock for StylesheetContents {
url_data: RwLock::new((*self.url_data.read()).clone()),
namespaces: RwLock::new((*self.namespaces.read()).clone()),
source_map_url: RwLock::new((*self.source_map_url.read()).clone()),
- source_url: RwLock::new((*self.source_map_url.read()).clone()),
+ source_url: RwLock::new((*self.source_url.read()).clone()),
}
}
}
@@ -176,7 +176,7 @@ macro_rules! rule_filter {
}
/// A trait to represent a given stylesheet in a document.
-pub trait StylesheetInDocument {
+pub trait StylesheetInDocument : ::std::fmt::Debug {
/// Get the stylesheet origin.
fn origin(&self, guard: &SharedRwLockReadGuard) -> Origin;
@@ -263,7 +263,7 @@ impl StylesheetInDocument for Stylesheet {
/// A simple wrapper over an `Arc<Stylesheet>`, with pointer comparison, and
/// suitable for its use in a `StylesheetSet`.
-#[derive(Clone)]
+#[derive(Clone, Debug)]
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
pub struct DocumentStyleSheet(
#[cfg_attr(feature = "servo", ignore_malloc_size_of = "Arc")] pub Arc<Stylesheet>,
@@ -306,18 +306,16 @@ impl StylesheetInDocument for DocumentStyleSheet {
impl Stylesheet {
/// Updates an empty stylesheet from a given string of text.
- pub fn update_from_str<R>(
+ pub fn update_from_str(
existing: &Stylesheet,
css: &str,
url_data: UrlExtraData,
stylesheet_loader: Option<&StylesheetLoader>,
- error_reporter: &R,
+ error_reporter: Option<&ParseErrorReporter>,
line_number_offset: u32,
- ) where
- R: ParseErrorReporter,
- {
+ ) {
let namespaces = RwLock::new(Namespaces::default());
- let (rules, source_map_url, source_url) = Stylesheet::parse_rules(
+ let (rules, source_map_url, source_url) = Self::parse_rules(
css,
&url_data,
existing.contents.origin,
@@ -342,14 +340,14 @@ impl Stylesheet {
*existing.contents.source_url.write() = source_url;
}
- fn parse_rules<R: ParseErrorReporter>(
+ fn parse_rules(
css: &str,
url_data: &UrlExtraData,
origin: Origin,
namespaces: &mut Namespaces,
shared_lock: &SharedRwLock,
stylesheet_loader: Option<&StylesheetLoader>,
- error_reporter: &R,
+ error_reporter: Option<&ParseErrorReporter>,
quirks_mode: QuirksMode,
line_number_offset: u32,
) -> (Vec<CssRule>, Option<String>, Option<String>) {
@@ -357,16 +355,20 @@ impl Stylesheet {
let mut input = ParserInput::new_with_line_number_offset(css, line_number_offset);
let mut input = Parser::new(&mut input);
- let context = ParserContext::new(origin, url_data, None, ParsingMode::DEFAULT, quirks_mode);
-
- let error_context = ParserErrorContext { error_reporter };
+ let context = ParserContext::new(
+ origin,
+ url_data,
+ None,
+ ParsingMode::DEFAULT,
+ quirks_mode,
+ error_reporter,
+ );
let rule_parser = TopLevelRuleParser {
stylesheet_origin: origin,
shared_lock,
loader: stylesheet_loader,
context,
- error_context,
state: State::Start,
dom_error: None,
insert_rule_context: None,
@@ -390,7 +392,6 @@ impl Stylesheet {
let location = error.location;
let error = ContextualParseError::InvalidRule(slice, error);
iter.parser.context.log_css_error(
- &iter.parser.error_context,
location,
error,
);
@@ -409,17 +410,17 @@ impl Stylesheet {
///
/// Effectively creates a new stylesheet and forwards the hard work to
/// `Stylesheet::update_from_str`.
- pub fn from_str<R: ParseErrorReporter>(
+ pub fn from_str(
css: &str,
url_data: UrlExtraData,
origin: Origin,
media: Arc<Locked<MediaList>>,
shared_lock: SharedRwLock,
stylesheet_loader: Option<&StylesheetLoader>,
- error_reporter: &R,
+ error_reporter: Option<&ParseErrorReporter>,
quirks_mode: QuirksMode,
line_number_offset: u32,
- ) -> Stylesheet {
+ ) -> Self {
let contents = StylesheetContents::from_str(
css,
url_data,
diff --git a/components/style/stylesheets/viewport_rule.rs b/components/style/stylesheets/viewport_rule.rs
index b159b65d35b..1fc6a988c7c 100644
--- a/components/style/stylesheets/viewport_rule.rs
+++ b/components/style/stylesheets/viewport_rule.rs
@@ -11,11 +11,11 @@ use app_units::Au;
use context::QuirksMode;
use cssparser::{parse_important, AtRuleParser, DeclarationListParser, DeclarationParser, Parser};
use cssparser::CowRcStr;
-use error_reporting::{ContextualParseError, ParseErrorReporter};
+use error_reporting::ContextualParseError;
use euclid::TypedSize2D;
use font_metrics::get_metrics_provider_for_product;
use media_queries::Device;
-use parser::{ParserContext, ParserErrorContext};
+use parser::ParserContext;
use properties::StyleBuilder;
use rule_cache::RuleCacheConditions;
use selectors::parser::SelectorParseErrorKind;
@@ -355,15 +355,13 @@ fn is_whitespace_separator_or_equals(c: &char) -> bool {
impl ViewportRule {
/// Parse a single @viewport rule.
- pub fn parse<'i, 't, R>(
+ ///
+ /// TODO(emilio): This could use the `Parse` trait now.
+ pub fn parse<'i, 't>(
context: &ParserContext,
- error_context: &ParserErrorContext<R>,
input: &mut Parser<'i, 't>,
- ) -> Result<Self, ParseError<'i>>
- where
- R: ParseErrorReporter,
- {
- let parser = ViewportRuleParser { context: context };
+ ) -> Result<Self, ParseError<'i>> {
+ let parser = ViewportRuleParser { context };
let mut cascade = Cascade::new();
let mut parser = DeclarationListParser::new(input, parser);
@@ -380,7 +378,7 @@ impl ViewportRule {
slice,
error,
);
- context.log_css_error(error_context, location, error);
+ context.log_css_error(location, error);
},
}
}
diff --git a/components/style/stylist.rs b/components/style/stylist.rs
index e777921e668..aa5f77d0db4 100644
--- a/components/style/stylist.rs
+++ b/components/style/stylist.rs
@@ -75,6 +75,10 @@ impl UserAgentCascadeDataCache {
Self { entries: vec![] }
}
+ fn len(&self) -> usize {
+ self.entries.len()
+ }
+
// FIXME(emilio): This may need to be keyed on quirks-mode too, though there
// aren't class / id selectors on those sheets, usually, so it's probably
// ok...
@@ -90,6 +94,7 @@ impl UserAgentCascadeDataCache {
S: StylesheetInDocument + ToMediaListKey + PartialEq + 'static,
{
let mut key = EffectiveMediaQueryResults::new();
+ debug!("UserAgentCascadeDataCache::lookup({:?})", device);
for sheet in sheets.clone() {
CascadeData::collect_applicable_media_query_results_into(device, sheet, guard, &mut key)
}
@@ -105,6 +110,8 @@ impl UserAgentCascadeDataCache {
precomputed_pseudo_element_decls: PrecomputedPseudoElementDeclarations::default(),
};
+ debug!("> Picking the slow path");
+
for sheet in sheets {
new_data.cascade_data.add_stylesheet(
device,
@@ -117,7 +124,6 @@ impl UserAgentCascadeDataCache {
}
let new_data = Arc::new(new_data);
-
self.entries.push(new_data.clone());
Ok(new_data)
}
@@ -244,8 +250,8 @@ impl DocumentCascadeData {
let origin_sheets = flusher.origin_sheets(Origin::UserAgent);
let ua_cascade_data =
ua_cache.lookup(origin_sheets, device, quirks_mode, guards.ua_or_user)?;
-
ua_cache.expire_unused();
+ debug!("User agent data cache size {:?}", ua_cache.len());
self.user_agent = ua_cascade_data;
}
}
@@ -1085,7 +1091,7 @@ impl Stylist {
guards: &StylesheetGuards,
device: &Device,
) -> OriginSet {
- debug!("Stylist::media_features_change_changed_style");
+ debug!("Stylist::media_features_change_changed_style {:?}", device);
let mut origins = OriginSet::empty();
let stylesheets = self.stylesheets.iter();
@@ -2145,16 +2151,19 @@ impl CascadeData {
return;
}
+ debug!(" + {:?}", stylesheet);
results.saw_effective(stylesheet);
for rule in stylesheet.effective_rules(device, guard) {
match *rule {
CssRule::Import(ref lock) => {
let import_rule = lock.read_with(guard);
+ debug!(" + {:?}", import_rule.stylesheet.media(guard));
results.saw_effective(import_rule);
},
CssRule::Media(ref lock) => {
let media_rule = lock.read_with(guard);
+ debug!(" + {:?}", media_rule.media_queries.read_with(guard));
results.saw_effective(media_rule);
},
_ => {},
@@ -2346,8 +2355,10 @@ impl CascadeData {
if effective_now != effective_then {
debug!(
- " > Stylesheet changed -> {}, {}",
- effective_then, effective_now
+ " > Stylesheet {:?} changed -> {}, {}",
+ stylesheet.media(guard),
+ effective_then,
+ effective_now
);
return false;
}
@@ -2382,8 +2393,10 @@ impl CascadeData {
.was_effective(import_rule);
if effective_now != effective_then {
debug!(
- " > @import rule changed {} -> {}",
- effective_then, effective_now
+ " > @import rule {:?} changed {} -> {}",
+ import_rule.stylesheet.media(guard),
+ effective_then,
+ effective_now
);
return false;
}
@@ -2401,8 +2414,10 @@ impl CascadeData {
if effective_now != effective_then {
debug!(
- " > @media rule changed {} -> {}",
- effective_then, effective_now
+ " > @media rule {:?} changed {} -> {}",
+ mq,
+ effective_then,
+ effective_now
);
return false;
}
diff --git a/components/style/values/computed/text.rs b/components/style/values/computed/text.rs
index f2bcf11fe62..b41ecdb7e67 100644
--- a/components/style/values/computed/text.rs
+++ b/components/style/values/computed/text.rs
@@ -107,7 +107,7 @@ impl TextDecorationsInEffect {
let mut result = match style.get_box().clone_display() {
Display::InlineBlock | Display::InlineTable => Self::default(),
_ => style
- .get_parent_inheritedtext()
+ .get_parent_inherited_text()
.text_decorations_in_effect
.clone(),
};
diff --git a/components/style/values/specified/text.rs b/components/style/values/specified/text.rs
index 70947ac0826..ef0e66672d0 100644
--- a/components/style/values/specified/text.rs
+++ b/components/style/values/specified/text.rs
@@ -514,7 +514,7 @@ impl ToComputedValue for TextAlign {
}
let parent = _context
.builder
- .get_parent_inheritedtext()
+ .get_parent_inherited_text()
.clone_text_align();
let ltr = _context.builder.inherited_writing_mode().is_bidi_ltr();
match (parent, ltr) {
@@ -529,7 +529,7 @@ impl ToComputedValue for TextAlign {
TextAlign::MozCenterOrInherit => {
let parent = _context
.builder
- .get_parent_inheritedtext()
+ .get_parent_inherited_text()
.clone_text_align();
if parent == TextAlignKeyword::Start {
TextAlignKeyword::Center
@@ -653,7 +653,7 @@ impl ToComputedValue for TextEmphasisStyle {
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
match *self {
TextEmphasisStyle::Keyword(ref keyword) => {
- let default_shape = if context.style().get_inheritedbox().clone_writing_mode() ==
+ let default_shape = if context.style().get_inherited_box().clone_writing_mode() ==
SpecifiedWritingMode::HorizontalTb
{
TextEmphasisShapeKeyword::Circle
diff --git a/components/style_derive/to_css.rs b/components/style_derive/to_css.rs
index 471cf37b6de..83177f3c89f 100644
--- a/components/style_derive/to_css.rs
+++ b/components/style_derive/to_css.rs
@@ -231,6 +231,8 @@ pub struct CssInputAttrs {
#[derive(Default, FromVariant)]
pub struct CssVariantAttrs {
pub function: Option<Override<String>>,
+ // Here because structs variants are also their whole type definition.
+ pub derive_debug: bool,
pub comma: bool,
pub dimension: bool,
pub keyword: Option<String>,
diff --git a/tests/unit/style/lib.rs b/tests/unit/style/lib.rs
index d8e5464b75e..2c46bb65063 100644
--- a/tests/unit/style/lib.rs
+++ b/tests/unit/style/lib.rs
@@ -45,7 +45,7 @@ mod writing_modes {
#[test]
fn initial_writing_mode_is_empty() {
assert_eq!(
- WritingMode::new(INITIAL_SERVO_VALUES.get_inheritedbox()),
+ WritingMode::new(INITIAL_SERVO_VALUES.get_inherited_box()),
WritingMode::empty(),
)
}
diff --git a/tests/unit/style/media_queries.rs b/tests/unit/style/media_queries.rs
index 58b878bfb8d..044dee3db72 100644
--- a/tests/unit/style/media_queries.rs
+++ b/tests/unit/style/media_queries.rs
@@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use cssparser::SourceLocation;
use euclid::TypedScale;
use euclid::TypedSize2D;
use servo_arc::Arc;
@@ -10,7 +9,6 @@ use servo_url::ServoUrl;
use std::borrow::ToOwned;
use style::Atom;
use style::context::QuirksMode;
-use style::error_reporting::{ParseErrorReporter, ContextualParseError};
use style::media_queries::*;
use style::servo::media_queries::*;
use style::shared_lock::SharedRwLock;
@@ -18,18 +16,9 @@ use style::stylesheets::{AllRules, Stylesheet, StylesheetInDocument, Origin, Css
use style::values::{CustomIdent, specified};
use style_traits::ToCss;
-pub struct CSSErrorReporterTest;
-
-impl ParseErrorReporter for CSSErrorReporterTest {
- fn report_error(&self,
- _url: &ServoUrl,
- _location: SourceLocation,
- _error: ContextualParseError) {
- }
-}
-
fn test_media_rule<F>(css: &str, callback: F)
- where F: Fn(&MediaList, &str),
+where
+ F: Fn(&MediaList, &str),
{
let url = ServoUrl::parse("http://localhost").unwrap();
let css_str = css.to_owned();
@@ -37,7 +26,7 @@ fn test_media_rule<F>(css: &str, callback: F)
let media_list = Arc::new(lock.wrap(MediaList::empty()));
let stylesheet = Stylesheet::from_str(
css, url, Origin::Author, media_list, lock,
- None, &CSSErrorReporterTest, QuirksMode::NoQuirks, 0);
+ None, None, QuirksMode::NoQuirks, 0);
let dummy = Device::new(MediaType::screen(), TypedSize2D::new(200.0, 100.0), TypedScale::new(1.0));
let mut rule_count = 0;
let guard = stylesheet.shared_lock.read();
@@ -56,7 +45,7 @@ fn media_query_test(device: &Device, css: &str, expected_rule_count: usize) {
let media_list = Arc::new(lock.wrap(MediaList::empty()));
let ss = Stylesheet::from_str(
css, url, Origin::Author, media_list, lock,
- None, &CSSErrorReporterTest, QuirksMode::NoQuirks, 0);
+ None, None, QuirksMode::NoQuirks, 0);
let mut rule_count = 0;
ss.effective_style_rules(device, &ss.shared_lock.read(), |_| rule_count += 1);
assert!(rule_count == expected_rule_count, css.to_owned());
diff --git a/tests/unit/style/parsing/length.rs b/tests/unit/style/parsing/length.rs
deleted file mode 100644
index 0d506926ad8..00000000000
--- a/tests/unit/style/parsing/length.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-/* 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 http://mozilla.org/MPL/2.0/. */
-
-use cssparser::{Parser, ParserInput};
-use parsing::parse;
-use style::context::QuirksMode;
-use style::parser::{Parse, ParserContext};
-use style::stylesheets::{CssRuleType, Origin};
-use style::values::specified::length::{AbsoluteLength, Length, NoCalcLength};
-use style_traits::{ParsingMode, ToCss};
-
-#[test]
-fn test_calc() {
- assert!(parse(Length::parse, "calc(1px+ 2px)").is_err());
- assert!(parse(Length::parse, "calc(calc(1px) + calc(1px + 4px))").is_ok());
- assert!(parse(Length::parse, "calc( 1px + 2px )").is_ok());
- assert!(parse(Length::parse, "calc(1px + 2px )").is_ok());
- assert!(parse(Length::parse, "calc( 1px + 2px)").is_ok());
- assert!(parse(Length::parse, "calc( 1px + 2px / ( 1 + 2 - 1))").is_ok());
-}
-
-#[test]
-fn test_length_literals() {
- assert_roundtrip_with_context!(Length::parse, "0.33px", "0.33px");
- assert_roundtrip_with_context!(Length::parse, "0.33in", "0.33in");
- assert_roundtrip_with_context!(Length::parse, "0.33cm", "0.33cm");
- assert_roundtrip_with_context!(Length::parse, "0.33mm", "0.33mm");
- assert_roundtrip_with_context!(Length::parse, "0.33q", "0.33q");
- assert_roundtrip_with_context!(Length::parse, "0.33pt", "0.33pt");
- assert_roundtrip_with_context!(Length::parse, "0.33pc", "0.33pc");
-}
-
-#[test]
-fn test_parsing_modes() {
- // In default length mode, non-zero lengths must have a unit.
- assert!(parse(Length::parse, "1").is_err());
-
- // In SVG length mode, non-zero lengths are assumed to be px.
- let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
- let context = ParserContext::new(Origin::Author, &url,
- Some(CssRuleType::Style), ParsingMode::ALLOW_UNITLESS_LENGTH,
- QuirksMode::NoQuirks);
- let mut input = ParserInput::new("1");
- let mut parser = Parser::new(&mut input);
- let result = Length::parse(&context, &mut parser);
- assert!(result.is_ok());
- assert_eq!(result.unwrap(), Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(1.))));
-}
diff --git a/tests/unit/style/parsing/mod.rs b/tests/unit/style/parsing/mod.rs
index d89e76378f7..b75e3a7ce42 100644
--- a/tests/unit/style/parsing/mod.rs
+++ b/tests/unit/style/parsing/mod.rs
@@ -21,7 +21,7 @@ where F: Fn(&ParserContext, &mut Parser<'i, 't>) -> Result<T, ParseError<'i>> {
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Some(CssRuleType::Style),
ParsingMode::DEFAULT,
- QuirksMode::NoQuirks);
+ QuirksMode::NoQuirks, None);
let mut parser = Parser::new(input);
f(&context, &mut parser)
}
@@ -111,7 +111,6 @@ mod column;
mod effects;
mod image;
mod inherited_text;
-mod length;
mod outline;
mod position;
mod selectors;
@@ -119,4 +118,3 @@ mod supports;
mod text_overflow;
mod transition_duration;
mod transition_timing_function;
-mod value;
diff --git a/tests/unit/style/parsing/value.rs b/tests/unit/style/parsing/value.rs
deleted file mode 100644
index d464831f56b..00000000000
--- a/tests/unit/style/parsing/value.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-/* 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 http://mozilla.org/MPL/2.0/. */
-
-use cssparser::{Parser, ParserInput};
-use style::context::QuirksMode;
-use style::parser::ParserContext;
-use style::stylesheets::{CssRuleType, Origin};
-use style::values::specified::Number;
-use style_traits::ParsingMode;
-
-#[test]
-fn test_parsing_allo_all_numeric_values() {
- // In SVG length mode, non-zero lengths are assumed to be px.
- let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
- let context = ParserContext::new(Origin::Author, &url,
- Some(CssRuleType::Style), ParsingMode::ALLOW_ALL_NUMERIC_VALUES,
- QuirksMode::NoQuirks);
- let mut input = ParserInput::new("-1");
- let mut parser = Parser::new(&mut input);
- let result = Number::parse_non_negative(&context, &mut parser);
- assert!(result.is_ok());
- assert_eq!(result.unwrap(), Number::new(-1.));
-}
-
diff --git a/tests/unit/style/properties/background.rs b/tests/unit/style/properties/background.rs
deleted file mode 100644
index 6c0b27a49fe..00000000000
--- a/tests/unit/style/properties/background.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-/* 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 http://mozilla.org/MPL/2.0/. */
-
-use properties::parse;
-use style::properties::longhands::background_size;
-
-#[test]
-fn background_size_should_reject_negative_values() {
- assert!(parse(|c, _, i| background_size::parse(c, i), "-40% -40%").is_err());
-}
diff --git a/tests/unit/style/properties/mod.rs b/tests/unit/style/properties/mod.rs
index ccd4fdd7a0b..725aabc42a4 100644
--- a/tests/unit/style/properties/mod.rs
+++ b/tests/unit/style/properties/mod.rs
@@ -3,34 +3,32 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::{Parser, ParserInput};
-use media_queries::CSSErrorReporterTest;
use style::context::QuirksMode;
-use style::parser::{ParserContext, ParserErrorContext};
+use style::parser::ParserContext;
use style::stylesheets::{CssRuleType, Origin};
use style_traits::{ParsingMode, ParseError};
fn parse<T, F>(f: F, s: &'static str) -> Result<T, ParseError<'static>>
- where F: for<'t> Fn(&ParserContext,
- &ParserErrorContext<CSSErrorReporterTest>,
- &mut Parser<'static, 't>) -> Result<T, ParseError<'static>>
+where
+ F: for<'t> Fn(
+ &ParserContext,
+ &mut Parser<'static, 't>,
+ ) -> Result<T, ParseError<'static>>
{
let mut input = ParserInput::new(s);
parse_input(f, &mut input)
}
fn parse_input<'i: 't, 't, T, F>(f: F, input: &'t mut ParserInput<'i>) -> Result<T, ParseError<'i>>
- where F: Fn(&ParserContext,
- &ParserErrorContext<CSSErrorReporterTest>,
- &mut Parser<'i, 't>) -> Result<T, ParseError<'i>>
+where
+ F: Fn(&ParserContext, &mut Parser<'i, 't>) -> Result<T, ParseError<'i>>,
{
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Some(CssRuleType::Style),
ParsingMode::DEFAULT,
- QuirksMode::NoQuirks);
- let reporter = CSSErrorReporterTest;
- let error_context = ParserErrorContext { error_reporter: &reporter };
+ QuirksMode::NoQuirks, None);
let mut parser = Parser::new(input);
- f(&context, &error_context, &mut parser)
+ f(&context, &mut parser)
}
macro_rules! assert_roundtrip_with_context {
@@ -38,7 +36,7 @@ macro_rules! assert_roundtrip_with_context {
assert_roundtrip_with_context!($fun, $string, $string);
};
($fun:expr, $input:expr, $output:expr) => {{
- let serialized = parse(|context, _, i| {
+ let serialized = parse(|context, i| {
let parsed = $fun(context, i)
.expect(&format!("Failed to parse {}", $input));
let serialized = ToCss::to_css_string(&parsed);
@@ -47,7 +45,7 @@ macro_rules! assert_roundtrip_with_context {
}, $input).unwrap();
let mut input = ::cssparser::ParserInput::new(&serialized);
- let unwrapped = parse_input(|context, _, i| {
+ let unwrapped = parse_input(|context, i| {
let re_parsed = $fun(context, i)
.expect(&format!("Failed to parse serialization {}", $input));
let re_serialized = ToCss::to_css_string(&re_parsed);
@@ -58,6 +56,5 @@ macro_rules! assert_roundtrip_with_context {
}}
}
-mod background;
mod scaffolding;
mod serialization;
diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs
index e7b5689e05f..4ab79d25a2f 100644
--- a/tests/unit/style/properties/serialization.rs
+++ b/tests/unit/style/properties/serialization.rs
@@ -451,7 +451,7 @@ mod shorthand_serialization {
border-left: 4px solid; \
border-image: none;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -503,7 +503,7 @@ mod shorthand_serialization {
background-origin: border-box; \
background-clip: padding-box;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -527,7 +527,7 @@ mod shorthand_serialization {
background-origin: padding-box; \
background-clip: padding-box;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -551,7 +551,7 @@ mod shorthand_serialization {
background-origin: border-box, padding-box; \
background-clip: padding-box, padding-box;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -582,7 +582,7 @@ mod shorthand_serialization {
background-origin: border-box; \
background-clip: padding-box, padding-box;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -596,7 +596,7 @@ mod shorthand_serialization {
let block_text = "\
background-position-x: 30px;\
background-position-y: bottom 20px;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
assert_eq!(serialization, "background-position: left 30px bottom 20px;");
@@ -605,7 +605,7 @@ mod shorthand_serialization {
let block_text = "\
background-position-x: center;\
background-position-y: 20px;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
assert_eq!(serialization, "background-position: center 20px;");
}
@@ -691,7 +691,7 @@ mod shorthand_serialization {
animation-iteration-count: infinite;\
animation-play-state: paused;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -710,7 +710,7 @@ mod shorthand_serialization {
animation-iteration-count: infinite, 2;\
animation-play-state: paused, running;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -736,7 +736,7 @@ mod shorthand_serialization {
animation-iteration-count: infinite, 2; \
animation-play-state: paused, running;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -753,7 +753,7 @@ mod shorthand_serialization {
animation-iteration-count: infinite, 2; \
animation-play-state: paused, running;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -771,7 +771,7 @@ mod shorthand_serialization {
transition-delay: 4s; \
transition-timing-function: cubic-bezier(0.2, 5, 0.5, 2);";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -785,7 +785,7 @@ mod shorthand_serialization {
transition-delay: 4s, 5s; \
transition-timing-function: cubic-bezier(0.2, 5, 0.5, 2), ease;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -807,7 +807,7 @@ mod shorthand_serialization {
transition-delay: 4s, 5s; \
transition-timing-function: cubic-bezier(0.2, 5, 0.5, 2), ease;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -820,7 +820,7 @@ mod shorthand_serialization {
transition-duration: 3s; \
transition-delay: 4s; \
transition-timing-function: steps(2, start);";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -833,7 +833,7 @@ mod shorthand_serialization {
transition-duration: 3s; \
transition-delay: 4s; \
transition-timing-function: frames(2);";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
@@ -846,7 +846,7 @@ mod shorthand_serialization {
#[test]
fn css_wide_keywords_should_be_parsed() {
let block_text = "--a:inherit;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
assert_eq!(serialization, "--a: inherit;");
@@ -855,7 +855,7 @@ mod shorthand_serialization {
#[test]
fn non_keyword_custom_property_should_be_unparsed() {
let block_text = "--main-color: #06c;";
- let block = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), block_text).unwrap();
+ let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
assert_eq!(serialization, block_text);
@@ -885,7 +885,7 @@ mod shorthand_serialization {
let shadow_decl = BoxShadowList(vec![shadow_val]);
properties.push(PropertyDeclaration::BoxShadow(shadow_decl));
let shadow_css = "box-shadow: 1px 2px 3px 4px;";
- let shadow = parse(|c, e, i| Ok(parse_property_declaration_list(c, e, i)), shadow_css).unwrap();
+ let shadow = parse(|c, i| Ok(parse_property_declaration_list(c, i)), shadow_css).unwrap();
assert_eq!(shadow.to_css_string(), shadow_css);
}
diff --git a/tests/unit/style/rule_tree/bench.rs b/tests/unit/style/rule_tree/bench.rs
index 54af9d39532..c1ea58f5248 100644
--- a/tests/unit/style/rule_tree/bench.rs
+++ b/tests/unit/style/rule_tree/bench.rs
@@ -55,7 +55,7 @@ fn parse_rules(css: &str) -> Vec<(StyleSource, CascadeLevel)> {
media,
lock,
None,
- &ErrorringErrorReporter,
+ Some(&ErrorringErrorReporter),
QuirksMode::NoQuirks,
0);
let guard = s.shared_lock.read();
diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs
index be4e2d9cbc1..632d51074fe 100644
--- a/tests/unit/style/stylesheets.rs
+++ b/tests/unit/style/stylesheets.rs
@@ -4,7 +4,6 @@
use cssparser::{self, SourceLocation};
use html5ever::{Namespace as NsAtom};
-use media_queries::CSSErrorReporterTest;
use parking_lot::RwLock;
use selectors::attr::*;
use selectors::parser::*;
@@ -71,7 +70,7 @@ fn test_parse_stylesheet() {
let lock = SharedRwLock::new();
let media = Arc::new(lock.wrap(MediaList::empty()));
let stylesheet = Stylesheet::from_str(css, url.clone(), Origin::UserAgent, media, lock,
- None, &CSSErrorReporterTest, QuirksMode::NoQuirks, 0);
+ None, None, QuirksMode::NoQuirks, 0);
let mut namespaces = Namespaces::default();
namespaces.default = Some(ns!(html));
let expected = Stylesheet {
@@ -345,7 +344,7 @@ fn test_report_error_stylesheet() {
let lock = SharedRwLock::new();
let media = Arc::new(lock.wrap(MediaList::empty()));
Stylesheet::from_str(css, url.clone(), Origin::UserAgent, media, lock,
- None, &error_reporter, QuirksMode::NoQuirks, 5);
+ None, Some(&error_reporter), QuirksMode::NoQuirks, 5);
error_reporter.assert_messages_contain(&[
(8, 18, "Unsupported property declaration: 'display: invalid;'"),
@@ -387,7 +386,7 @@ fn test_no_report_unrecognized_vendor_properties() {
let lock = SharedRwLock::new();
let media = Arc::new(lock.wrap(MediaList::empty()));
Stylesheet::from_str(css, url, Origin::UserAgent, media, lock,
- None, &error_reporter, QuirksMode::NoQuirks, 0);
+ None, Some(&error_reporter), QuirksMode::NoQuirks, 0);
error_reporter.assert_messages_contain(&[
(4, 31, "Unsupported property declaration: '-moz-background-color: red;'"),
@@ -406,7 +405,7 @@ fn test_source_map_url() {
let lock = SharedRwLock::new();
let media = Arc::new(lock.wrap(MediaList::empty()));
let stylesheet = Stylesheet::from_str(test.0, url.clone(), Origin::UserAgent, media, lock,
- None, &CSSErrorReporterTest, QuirksMode::NoQuirks,
+ None, None, QuirksMode::NoQuirks,
0);
let url_opt = stylesheet.contents.source_map_url.read();
assert_eq!(*url_opt, test.1);
@@ -425,7 +424,7 @@ fn test_source_url() {
let lock = SharedRwLock::new();
let media = Arc::new(lock.wrap(MediaList::empty()));
let stylesheet = Stylesheet::from_str(test.0, url.clone(), Origin::UserAgent, media, lock,
- None, &CSSErrorReporterTest, QuirksMode::NoQuirks,
+ None, None, QuirksMode::NoQuirks,
0);
let url_opt = stylesheet.contents.source_url.read();
assert_eq!(*url_opt, test.1);
diff --git a/tests/unit/style/viewport.rs b/tests/unit/style/viewport.rs
index 44759bed701..9243dbcb403 100644
--- a/tests/unit/style/viewport.rs
+++ b/tests/unit/style/viewport.rs
@@ -5,13 +5,12 @@
use cssparser::{Parser, ParserInput};
use euclid::TypedScale;
use euclid::TypedSize2D;
-use media_queries::CSSErrorReporterTest;
use servo_arc::Arc;
use servo_config::prefs::{PREFS, PrefValue};
use servo_url::ServoUrl;
use style::context::QuirksMode;
use style::media_queries::{Device, MediaList, MediaType};
-use style::parser::{ParserContext, ParserErrorContext};
+use style::parser::ParserContext;
use style::shared_lock::{SharedRwLock, StylesheetGuards};
use style::stylesheets::{CssRuleType, Stylesheet, StylesheetInDocument, Origin};
use style::stylesheets::viewport_rule::*;
@@ -22,10 +21,10 @@ use style_traits::{ParsingMode, PinchZoomFactor};
use style_traits::viewport::*;
macro_rules! stylesheet {
- ($css:expr, $origin:ident, $error_reporter:expr) => {
- stylesheet!($css, $origin, $error_reporter, SharedRwLock::new())
+ ($css:expr, $origin:ident) => {
+ stylesheet!($css, $origin, SharedRwLock::new())
};
- ($css:expr, $origin:ident, $error_reporter:expr, $shared_lock:expr) => {
+ ($css:expr, $origin:ident, $shared_lock:expr) => {
Arc::new(Stylesheet::from_str(
$css,
ServoUrl::parse("http://localhost").unwrap(),
@@ -33,7 +32,7 @@ macro_rules! stylesheet {
Arc::new($shared_lock.wrap(MediaList::empty())),
$shared_lock,
None,
- &$error_reporter,
+ None,
QuirksMode::NoQuirks,
0
))
@@ -46,7 +45,7 @@ fn test_viewport_rule<F>(css: &str,
where F: Fn(&Vec<ViewportDescriptorDeclaration>, &str)
{
PREFS.set("layout.viewport.enabled", PrefValue::Boolean(true));
- let stylesheet = stylesheet!(css, Author, CSSErrorReporterTest);
+ let stylesheet = stylesheet!(css, Author);
let mut rule_count = 0;
stylesheet.effective_viewport_rules(&device, &stylesheet.shared_lock.read(), |rule| {
rule_count += 1;
@@ -259,15 +258,15 @@ fn cascading_within_viewport_rule() {
fn multiple_stylesheets_cascading() {
PREFS.set("layout.viewport.enabled", PrefValue::Boolean(true));
let device = Device::new(MediaType::screen(), TypedSize2D::new(800., 600.), TypedScale::new(1.0));
- let error_reporter = CSSErrorReporterTest;
let shared_lock = SharedRwLock::new();
let stylesheets = vec![
stylesheet!("@viewport { min-width: 100px; min-height: 100px; zoom: 1; }",
- UserAgent, error_reporter, shared_lock.clone()),
+ UserAgent,
+ shared_lock.clone()),
stylesheet!("@viewport { min-width: 200px; min-height: 200px; }",
- User, error_reporter, shared_lock.clone()),
+ User, shared_lock.clone()),
stylesheet!("@viewport { min-width: 300px; }",
- Author, error_reporter, shared_lock.clone())
+ Author, shared_lock.clone())
];
let declarations = Cascade::from_stylesheets(
@@ -282,11 +281,11 @@ fn multiple_stylesheets_cascading() {
let stylesheets = vec![
stylesheet!("@viewport { min-width: 100px !important; }",
- UserAgent, error_reporter, shared_lock.clone()),
+ UserAgent, shared_lock.clone()),
stylesheet!("@viewport { min-width: 200px !important; min-height: 200px !important; }",
- User, error_reporter, shared_lock.clone()),
+ User, shared_lock.clone()),
stylesheet!("@viewport { min-width: 300px !important; min-height: 300px !important; zoom: 3 !important; }",
- Author, error_reporter, shared_lock.clone())
+ Author, shared_lock.clone())
];
let declarations = Cascade::from_stylesheets(
stylesheets.iter().map(|s| (&**s, Origin::Author)),
@@ -304,12 +303,11 @@ fn constrain_viewport() {
let url = ServoUrl::parse("http://localhost").unwrap();
let context = ParserContext::new(Origin::Author, &url, Some(CssRuleType::Viewport),
ParsingMode::DEFAULT,
- QuirksMode::NoQuirks);
- let error_context = ParserErrorContext { error_reporter: &CSSErrorReporterTest };
+ QuirksMode::NoQuirks, None);
macro_rules! from_css {
($css:expr) => {
- &ViewportRule::parse(&context, &error_context, &mut Parser::new(&mut $css)).unwrap()
+ &ViewportRule::parse(&context, &mut Parser::new(&mut $css)).unwrap()
}
}