Revert "Backport several style changes from Gecko (5) (#30099)" (#30104)

This reverts commit 8e15389cae.
This commit is contained in:
Oriol Brufau 2023-08-16 08:24:42 +02:00 committed by GitHub
parent 8e15389cae
commit d6ae8dc112
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
152 changed files with 4622 additions and 5862 deletions

View file

@ -44,7 +44,6 @@ servo_atoms = { path = "../atoms" }
servo_config = { path = "../config" }
servo_geometry = { path = "../geometry" }
servo_url = { path = "../url" }
size_of_test = { path = "../size_of_test" }
smallvec = { workspace = true, features = ["union"] }
style = { path = "../style", features = ["servo"] }
style_traits = { path = "../style_traits" }
@ -53,3 +52,6 @@ unicode-script = { workspace = true }
webrender_api = { workspace = true }
xi-unicode = { workspace = true }
[dev-dependencies]
size_of_test = { path = "../size_of_test" }

View file

@ -653,7 +653,7 @@ impl Fragment {
absolute_bounds: Rect<Au>,
) {
let background = style.get_background();
let background_color = style.resolve_color(background.background_color.clone());
let background_color = style.resolve_color(background.background_color);
// XXXManishearth the below method should ideally use an iterator over
// backgrounds
self.build_display_list_for_background_if_applicable_with_background(
@ -1037,9 +1037,7 @@ impl Fragment {
webrender_api::BoxShadowDisplayItem {
common: items::empty_common_item_properties(),
box_bounds: absolute_bounds.to_layout(),
color: style
.resolve_color(box_shadow.base.color.clone())
.to_layout(),
color: style.resolve_color(box_shadow.base.color).to_layout(),
offset: LayoutVector2D::new(
box_shadow.base.horizontal.px(),
box_shadow.base.vertical.px(),
@ -1085,10 +1083,10 @@ impl Fragment {
let border_style_struct = style.get_border();
let mut colors = SideOffsets2D::new(
border_style_struct.border_top_color.clone(),
border_style_struct.border_right_color.clone(),
border_style_struct.border_bottom_color.clone(),
border_style_struct.border_left_color.clone(),
border_style_struct.border_top_color,
border_style_struct.border_right_color,
border_style_struct.border_bottom_color,
border_style_struct.border_left_color,
);
let mut border_style = SideOffsets2D::new(
border_style_struct.border_top_style,
@ -1318,7 +1316,7 @@ impl Fragment {
// Append the outline to the display list.
let color = style
.resolve_color(style.get_outline().outline_color.clone())
.resolve_color(style.get_outline().outline_color)
.to_layout();
let base = state.create_base_display_item(
clip,
@ -1453,8 +1451,7 @@ impl Fragment {
// TODO: Allow non-text fragments to be selected too.
if scanned_text_fragment_info.selected() {
let style = self.selected_style();
let background_color =
style.resolve_color(style.get_background().background_color.clone());
let background_color = style.resolve_color(style.get_background().background_color);
let base = state.create_base_display_item(
stacking_relative_border_box,
self.node,
@ -2058,7 +2055,7 @@ impl Fragment {
base: base.clone(),
shadow: webrender_api::Shadow {
offset: LayoutVector2D::new(shadow.horizontal.px(), shadow.vertical.px()),
color: self.style.resolve_color(shadow.color.clone()).to_layout(),
color: self.style.resolve_color(shadow.color).to_layout(),
blur_radius: shadow.blur.px(),
},
},

View file

@ -86,7 +86,7 @@ fn convert_gradient_stops(
// Only keep the color stops, discard the color interpolation hints.
let mut stop_items = gradient_items
.iter()
.filter_map(|item| match item {
.filter_map(|item| match *item {
GradientItem::SimpleColorStop(color) => Some(ColorStop {
color,
position: None,
@ -191,7 +191,7 @@ fn convert_gradient_stops(
assert!(offset.is_finite());
stops.push(GradientStop {
offset: offset,
color: style.resolve_color(stop.color.clone()).to_layout(),
color: style.resolve_color(stop.color).to_layout(),
})
}
stops

View file

@ -158,11 +158,6 @@ pub struct Fragment {
pub established_reference_frame: Option<ClipScrollNodeIndex>,
}
#[cfg(debug_assertions)]
size_of_test!(Fragment, 176);
#[cfg(not(debug_assertions))]
size_of_test!(Fragment, 152);
impl Serialize for Fragment {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut serializer = serializer.serialize_struct("fragment", 3)?;
@ -217,8 +212,6 @@ pub enum SpecificFragmentInfo {
TruncatedFragment(Box<TruncatedFragmentInfo>),
}
size_of_test!(SpecificFragmentInfo, 24);
impl SpecificFragmentInfo {
fn restyle_damage(&self) -> RestyleDamage {
let flow = match *self {

View file

@ -16,8 +16,6 @@ extern crate log;
extern crate range;
#[macro_use]
extern crate serde;
#[macro_use]
extern crate size_of_test;
#[macro_use]
pub mod layout_debug;

View file

@ -860,7 +860,7 @@ where
shared: &context.style_context,
thread_local: &mut tlc,
};
let styles = resolve_style(&mut context, element, RuleInclusion::All, None, None);
let styles = resolve_style(&mut context, element, RuleInclusion::All, None);
styles.primary().clone()
}
} else {
@ -916,13 +916,7 @@ pub fn process_resolved_style_request<'dom>(
thread_local: &mut tlc,
};
let styles = resolve_style(
&mut context,
element,
RuleInclusion::All,
pseudo.as_ref(),
None,
);
let styles = resolve_style(&mut context, element, RuleInclusion::All, pseudo.as_ref());
let style = styles.primary();
let longhand_id = match *property {
PropertyId::LonghandAlias(id, _) | PropertyId::Longhand(id) => id,

View file

@ -794,7 +794,7 @@ fn perform_border_collapse_for_row(
child_table_row
.final_collapsed_borders
.inline
.push_or_set(i, this_inline_border.clone());
.push_or_set(i, *this_inline_border);
if i == 0 {
child_table_row.final_collapsed_borders.inline[i].combine(&table_inline_borders.start);
} else if i + 1 == number_of_borders_inline_direction {
@ -821,7 +821,7 @@ fn perform_border_collapse_for_row(
this_border.combine(&previous_block_borders[i]);
}
},
PreviousBlockCollapsedBorders::FromTable(ref table_border) => {
PreviousBlockCollapsedBorders::FromTable(table_border) => {
this_border.combine(&table_border);
},
}
@ -837,7 +837,7 @@ fn perform_border_collapse_for_row(
.iter()
.enumerate()
{
let next_block = next_block.push_or_set(i, this_block_border.clone());
let next_block = next_block.push_or_set(i, *this_block_border);
match next_block_borders {
NextBlockCollapsedBorders::FromNextRow(next_block_borders) => {
if next_block_borders.len() > i {
@ -1358,7 +1358,7 @@ impl<'table> TableCellStyleInfo<'table> {
if background as *const Background == initial.get_background() as *const _ {
return;
}
let background_color = sty.resolve_color(background.background_color.clone());
let background_color = sty.resolve_color(background.background_color);
cell_flow.build_display_list_for_background_if_applicable_with_background(
state,
background,

View file

@ -375,7 +375,7 @@ impl fmt::Debug for TableCellFlow {
}
}
#[derive(Clone, Debug, Serialize)]
#[derive(Clone, Copy, Debug, Serialize)]
pub struct CollapsedBordersForCell {
pub inline_start_border: CollapsedBorder,
pub inline_end_border: CollapsedBorder,
@ -494,10 +494,10 @@ impl CollapsedBordersForCell {
) {
let logical_border_colors = LogicalMargin::new(
writing_mode,
self.block_start_border.color.clone(),
self.inline_end_border.color.clone(),
self.block_end_border.color.clone(),
self.inline_start_border.color.clone(),
self.block_start_border.color,
self.inline_end_border.color,
self.block_end_border.color,
self.inline_start_border.color,
);
*border_colors = logical_border_colors.to_physical(writing_mode);

View file

@ -718,7 +718,7 @@ impl CollapsedBorderSpacingForRow {
}
/// All aspects of a border that can collapse with adjacent borders. See CSS 2.1 § 17.6.2.1.
#[derive(Clone, Debug)]
#[derive(Clone, Copy, Debug)]
pub struct CollapsedBorder {
/// The style of the border.
pub style: BorderStyle,
@ -771,7 +771,7 @@ impl CollapsedBorder {
CollapsedBorder {
style: css_style.get_border().border_top_style,
width: Au::from(css_style.get_border().border_top_width),
color: css_style.get_border().border_top_color.clone(),
color: css_style.get_border().border_top_color,
provenance: provenance,
}
}
@ -782,7 +782,7 @@ impl CollapsedBorder {
CollapsedBorder {
style: css_style.get_border().border_right_style,
width: Au::from(css_style.get_border().border_right_width),
color: css_style.get_border().border_right_color.clone(),
color: css_style.get_border().border_right_color,
provenance: provenance,
}
}
@ -796,7 +796,7 @@ impl CollapsedBorder {
CollapsedBorder {
style: css_style.get_border().border_bottom_style,
width: Au::from(css_style.get_border().border_bottom_width),
color: css_style.get_border().border_bottom_color.clone(),
color: css_style.get_border().border_bottom_color,
provenance: provenance,
}
}
@ -807,7 +807,7 @@ impl CollapsedBorder {
CollapsedBorder {
style: css_style.get_border().border_left_style,
width: Au::from(css_style.get_border().border_left_width),
color: css_style.get_border().border_left_color.clone(),
color: css_style.get_border().border_left_color,
provenance: provenance,
}
}
@ -883,18 +883,18 @@ impl CollapsedBorder {
match (self.style, other.style) {
// Step 1.
(BorderStyle::Hidden, _) => {},
(_, BorderStyle::Hidden) => *self = other.clone(),
(_, BorderStyle::Hidden) => *self = *other,
// Step 2.
(BorderStyle::None, _) => *self = other.clone(),
(BorderStyle::None, _) => *self = *other,
(_, BorderStyle::None) => {},
// Step 3.
_ if self.width > other.width => {},
_ if self.width < other.width => *self = other.clone(),
_ if self.width < other.width => *self = *other,
(this_style, other_style) if this_style > other_style => {},
(this_style, other_style) if this_style < other_style => *self = other.clone(),
(this_style, other_style) if this_style < other_style => *self = *other,
// Step 4.
_ if (self.provenance as i8) >= other.provenance as i8 => {},
_ => *self = other.clone(),
_ => *self = *other,
}
}
}
@ -1013,22 +1013,22 @@ fn set_inline_position_of_child_flow(
.collapsed_borders_for_row
.inline
.get(child_index)
.map_or(CollapsedBorder::new(), |x| x.clone()),
.map_or(CollapsedBorder::new(), |x| *x),
inline_end_border: border_collapse_info
.collapsed_borders_for_row
.inline
.get(child_index + 1)
.map_or(CollapsedBorder::new(), |x| x.clone()),
.map_or(CollapsedBorder::new(), |x| *x),
block_start_border: border_collapse_info
.collapsed_borders_for_row
.block_start
.get(child_index)
.map_or(CollapsedBorder::new(), |x| x.clone()),
.map_or(CollapsedBorder::new(), |x| *x),
block_end_border: border_collapse_info
.collapsed_borders_for_row
.block_end
.get(child_index)
.map_or(CollapsedBorder::new(), |x| x.clone()),
.map_or(CollapsedBorder::new(), |x| *x),
inline_start_width: border_collapse_info
.collapsed_border_spacing_for_row
.inline

View file

@ -0,0 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#![cfg(target_pointer_width = "64")]
#[macro_use]
extern crate size_of_test;
use layout_2013::Fragment;
use layout_2013::SpecificFragmentInfo;
#[cfg(debug_assertions)]
size_of_test!(test_size_of_fragment, Fragment, 176);
#[cfg(not(debug_assertions))]
size_of_test!(test_size_of_fragment, Fragment, 152);
size_of_test!(
test_size_of_specific_fragment_info,
SpecificFragmentInfo,
24
);