Further changes required by Servo

This commit is contained in:
Oriol Brufau 2023-08-15 02:53:35 +02:00 committed by Martin Robinson
parent b6e8088e8e
commit 274d273f50
11 changed files with 81 additions and 70 deletions

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);
let background_color = style.resolve_color(background.background_color.clone());
// XXXManishearth the below method should ideally use an iterator over
// backgrounds
self.build_display_list_for_background_if_applicable_with_background(
@ -1037,7 +1037,9 @@ 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).to_layout(),
color: style
.resolve_color(box_shadow.base.color.clone())
.to_layout(),
offset: LayoutVector2D::new(
box_shadow.base.horizontal.px(),
box_shadow.base.vertical.px(),
@ -1083,10 +1085,10 @@ impl Fragment {
let border_style_struct = style.get_border();
let mut colors = SideOffsets2D::new(
border_style_struct.border_top_color,
border_style_struct.border_right_color,
border_style_struct.border_bottom_color,
border_style_struct.border_left_color,
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(),
);
let mut border_style = SideOffsets2D::new(
border_style_struct.border_top_style,
@ -1316,7 +1318,7 @@ impl Fragment {
// Append the outline to the display list.
let color = style
.resolve_color(style.get_outline().outline_color)
.resolve_color(style.get_outline().outline_color.clone())
.to_layout();
let base = state.create_base_display_item(
clip,
@ -1451,7 +1453,8 @@ 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);
let background_color =
style.resolve_color(style.get_background().background_color.clone());
let base = state.create_base_display_item(
stacking_relative_border_box,
self.node,
@ -2055,7 +2058,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).to_layout(),
color: self.style.resolve_color(shadow.color.clone()).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).to_layout(),
color: style.resolve_color(stop.color.clone()).to_layout(),
})
}
stops

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);
.push_or_set(i, this_inline_border.clone());
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(table_border) => {
PreviousBlockCollapsedBorders::FromTable(ref 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);
let next_block = next_block.push_or_set(i, this_block_border.clone());
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);
let background_color = sty.resolve_color(background.background_color.clone());
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, Copy, Debug, Serialize)]
#[derive(Clone, 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,
self.inline_end_border.color,
self.block_end_border.color,
self.inline_start_border.color,
self.block_start_border.color.clone(),
self.inline_end_border.color.clone(),
self.block_end_border.color.clone(),
self.inline_start_border.color.clone(),
);
*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, Copy, Debug)]
#[derive(Clone, 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,
color: css_style.get_border().border_top_color.clone(),
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,
color: css_style.get_border().border_right_color.clone(),
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,
color: css_style.get_border().border_bottom_color.clone(),
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,
color: css_style.get_border().border_left_color.clone(),
provenance: provenance,
}
}
@ -883,18 +883,18 @@ impl CollapsedBorder {
match (self.style, other.style) {
// Step 1.
(BorderStyle::Hidden, _) => {},
(_, BorderStyle::Hidden) => *self = *other,
(_, BorderStyle::Hidden) => *self = other.clone(),
// Step 2.
(BorderStyle::None, _) => *self = *other,
(BorderStyle::None, _) => *self = other.clone(),
(_, BorderStyle::None) => {},
// Step 3.
_ if self.width > other.width => {},
_ if self.width < other.width => *self = *other,
_ if self.width < other.width => *self = other.clone(),
(this_style, other_style) if this_style > other_style => {},
(this_style, other_style) if this_style < other_style => *self = *other,
(this_style, other_style) if this_style < other_style => *self = other.clone(),
// Step 4.
_ if (self.provenance as i8) >= other.provenance as i8 => {},
_ => *self = *other,
_ => *self = other.clone(),
}
}
}
@ -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),
.map_or(CollapsedBorder::new(), |x| x.clone()),
inline_end_border: border_collapse_info
.collapsed_borders_for_row
.inline
.get(child_index + 1)
.map_or(CollapsedBorder::new(), |x| *x),
.map_or(CollapsedBorder::new(), |x| x.clone()),
block_start_border: border_collapse_info
.collapsed_borders_for_row
.block_start
.get(child_index)
.map_or(CollapsedBorder::new(), |x| *x),
.map_or(CollapsedBorder::new(), |x| x.clone()),
block_end_border: border_collapse_info
.collapsed_borders_for_row
.block_end
.get(child_index)
.map_or(CollapsedBorder::new(), |x| *x),
.map_or(CollapsedBorder::new(), |x| x.clone()),
inline_start_width: border_collapse_info
.collapsed_border_spacing_for_row
.inline

View file

@ -275,11 +275,11 @@ fn fixup_stops(
for item in items {
match item {
GradientItem::SimpleColorStop(color) => stops.push(ColorStop {
color: super::rgba(style.resolve_color(*color)),
color: super::rgba(style.resolve_color(color.clone())),
position: None,
}),
GradientItem::ComplexColorStop { color, position } => stops.push(ColorStop {
color: super::rgba(style.resolve_color(*color)),
color: super::rgba(style.resolve_color(color.clone())),
position: Some(if gradient_line_length.px() == 0. {
0.
} else {

View file

@ -352,7 +352,7 @@ impl Fragment {
let text_decoration_color = fragment
.parent_style
.clone_text_decoration_color()
.to_rgba(color);
.into_rgba(color);
let text_decoration_style = fragment.parent_style.clone_text_decoration_style();
if text_decoration_style == ComputedTextDecorationStyle::MozNone {
return;
@ -535,7 +535,7 @@ impl<'a> BuilderForBoxFragment<'a> {
let source = background::Source::Fragment;
let style = &self.fragment.style;
let b = style.get_background();
let background_color = style.resolve_color(b.background_color);
let background_color = style.resolve_color(b.background_color.clone());
if background_color.alpha > 0 {
// https://drafts.csswg.org/css-backgrounds/#background-color
// “The background color is clipped according to the background-clip
@ -685,10 +685,15 @@ impl<'a> BuilderForBoxFragment<'a> {
}
let common = builder.common_properties(self.border_rect, &self.fragment.style);
let details = wr::BorderDetails::Normal(wr::NormalBorder {
top: self.build_border_side(border.border_top_style, border.border_top_color),
right: self.build_border_side(border.border_right_style, border.border_right_color),
bottom: self.build_border_side(border.border_bottom_style, border.border_bottom_color),
left: self.build_border_side(border.border_left_style, border.border_left_color),
top: self.build_border_side(border.border_top_style, border.border_top_color.clone()),
right: self
.build_border_side(border.border_right_style, border.border_right_color.clone()),
bottom: self.build_border_side(
border.border_bottom_style,
border.border_bottom_color.clone(),
),
left: self
.build_border_side(border.border_left_style, border.border_left_color.clone()),
radius: self.border_radius,
do_aa: true,
});
@ -718,7 +723,7 @@ impl<'a> BuilderForBoxFragment<'a> {
OutlineStyle::Auto => BorderStyle::Solid,
OutlineStyle::BorderStyle(s) => s,
};
let side = self.build_border_side(style, outline.outline_color);
let side = self.build_border_side(style, outline.outline_color.clone());
let details = wr::BorderDetails::Normal(wr::NormalBorder {
top: side,
right: side,

View file

@ -404,7 +404,7 @@ impl StackingContext {
.union(&fragment_tree.scrollable_overflow)
.to_webrender();
let background_color = style.resolve_color(style.get_background().background_color);
let background_color = style.resolve_color(style.get_background().background_color.clone());
if background_color.alpha > 0 {
let common = builder.common_properties(painting_area, &style);
let color = super::rgba(background_color);

View file

@ -465,7 +465,7 @@ impl ComputedValuesExt for ComputedValues {
/// Whether or not this style specifies a non-transparent background.
fn background_is_transparent(&self) -> bool {
let background = self.get_background();
let color = self.resolve_color(background.background_color);
let color = self.resolve_color(background.background_color.clone());
color.alpha == 0 &&
background
.background_image

View file

@ -1796,7 +1796,8 @@ fn get_root_flow_background_color(flow: &mut dyn Flow) -> ColorF {
.fragment
.style
.get_background()
.background_color,
.background_color
.clone(),
);
ColorF::new(
color.red_f32(),

View file

@ -1055,6 +1055,18 @@ impl<T: Copy> LogicalMargin<T> {
}
}
#[inline]
pub fn convert(&self, mode_from: WritingMode, mode_to: WritingMode) -> LogicalMargin<T> {
if mode_from == mode_to {
self.debug_writing_mode.check(mode_from);
*self
} else {
LogicalMargin::from_physical(mode_to, self.to_physical(mode_from))
}
}
}
impl<T: Clone> LogicalMargin<T> {
#[inline]
pub fn to_physical(&self, mode: WritingMode) -> SideOffsets2D<T> {
self.debug_writing_mode.check(mode);
@ -1064,42 +1076,32 @@ impl<T: Copy> LogicalMargin<T> {
let left;
if mode.is_vertical() {
if mode.is_vertical_lr() {
left = self.block_start;
right = self.block_end;
left = self.block_start.clone();
right = self.block_end.clone();
} else {
right = self.block_start;
left = self.block_end;
right = self.block_start.clone();
left = self.block_end.clone();
}
if mode.is_inline_tb() {
top = self.inline_start;
bottom = self.inline_end;
top = self.inline_start.clone();
bottom = self.inline_end.clone();
} else {
bottom = self.inline_start;
top = self.inline_end;
bottom = self.inline_start.clone();
top = self.inline_end.clone();
}
} else {
top = self.block_start;
bottom = self.block_end;
top = self.block_start.clone();
bottom = self.block_end.clone();
if mode.is_bidi_ltr() {
left = self.inline_start;
right = self.inline_end;
left = self.inline_start.clone();
right = self.inline_end.clone();
} else {
right = self.inline_start;
left = self.inline_end;
right = self.inline_start.clone();
left = self.inline_end.clone();
}
}
SideOffsets2D::new(top, right, bottom, left)
}
#[inline]
pub fn convert(&self, mode_from: WritingMode, mode_to: WritingMode) -> LogicalMargin<T> {
if mode_from == mode_to {
self.debug_writing_mode.check(mode_from);
*self
} else {
LogicalMargin::from_physical(mode_to, self.to_physical(mode_from))
}
}
}
impl<T: PartialEq + Zero> LogicalMargin<T> {