mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
parent
3cdc412a4c
commit
94fa868d2b
4 changed files with 84 additions and 68 deletions
|
@ -4,6 +4,10 @@
|
|||
|
||||
// This file is a Mako template: http://www.makotemplates.org/
|
||||
|
||||
// XXXManishearth remove all unsafe blocks when
|
||||
// https://github.com/rust-lang/rust/issues/24880 is fixed
|
||||
// See #6376
|
||||
|
||||
use std::ascii::AsciiExt;
|
||||
use std::borrow::ToOwned;
|
||||
use std::default::Default;
|
||||
|
@ -5328,7 +5332,7 @@ impl ComputedValues {
|
|||
#[inline]
|
||||
pub fn mutate_${style_struct.name.lower()}
|
||||
<'a>(&'a mut self) -> &'a mut style_structs::${style_struct.name} {
|
||||
&mut *self.${style_struct.ident}.make_unique()
|
||||
unsafe{ &mut *self.${style_struct.ident}.make_unique() }
|
||||
}
|
||||
% endfor
|
||||
}
|
||||
|
@ -5439,8 +5443,8 @@ fn cascade_with_cached_declarations(
|
|||
.clone()
|
||||
}
|
||||
};
|
||||
style_${style_struct.ident}.make_unique()
|
||||
.${property.ident} = computed_value;
|
||||
unsafe { style_${style_struct.ident}.make_unique()
|
||||
.${property.ident} = computed_value; }
|
||||
% endif
|
||||
|
||||
% if property.name in DERIVED_LONGHANDS:
|
||||
|
@ -5450,13 +5454,13 @@ fn cascade_with_cached_declarations(
|
|||
.${property.ident}.clone();
|
||||
% endif
|
||||
% for derived in DERIVED_LONGHANDS[property.name]:
|
||||
style_${derived.style_struct.ident}
|
||||
unsafe { style_${derived.style_struct.ident}
|
||||
.make_unique()
|
||||
.${derived.ident} =
|
||||
longhands::${derived.ident}
|
||||
::derive_from_${property.ident}(
|
||||
computed_value,
|
||||
context);
|
||||
context); }
|
||||
% endfor
|
||||
% endif
|
||||
}
|
||||
|
@ -5473,7 +5477,7 @@ fn cascade_with_cached_declarations(
|
|||
|
||||
if seen.get_font_style() || seen.get_font_weight() || seen.get_font_stretch() ||
|
||||
seen.get_font_family() {
|
||||
compute_font_hash(&mut *style_font.make_unique())
|
||||
unsafe { compute_font_hash(&mut *style_font.make_unique()) }
|
||||
}
|
||||
|
||||
ComputedValues {
|
||||
|
@ -5685,18 +5689,18 @@ pub fn cascade(viewport_size: Size2D<Au>,
|
|||
.clone()
|
||||
}
|
||||
};
|
||||
style_${style_struct.ident}.make_unique()
|
||||
.${property.ident} = computed_value;
|
||||
unsafe { style_${style_struct.ident}.make_unique()
|
||||
.${property.ident} = computed_value; }
|
||||
|
||||
% if property.name in DERIVED_LONGHANDS:
|
||||
% for derived in DERIVED_LONGHANDS[property.name]:
|
||||
style_${derived.style_struct.ident}
|
||||
unsafe { style_${derived.style_struct.ident}
|
||||
.make_unique()
|
||||
.${derived.ident} =
|
||||
longhands::${derived.ident}
|
||||
::derive_from_${property.ident}(
|
||||
computed_value,
|
||||
&context);
|
||||
&context); }
|
||||
% endfor
|
||||
% endif
|
||||
}
|
||||
|
@ -5713,7 +5717,7 @@ pub fn cascade(viewport_size: Size2D<Au>,
|
|||
|
||||
// The initial value of border-*-width may be changed at computed value time.
|
||||
{
|
||||
let border = style_border.make_unique();
|
||||
let border = unsafe { style_border.make_unique() };
|
||||
% for side in ["top", "right", "bottom", "left"]:
|
||||
// Like calling to_computed_value, which wouldn't type check.
|
||||
if !context.border_${side}_present {
|
||||
|
@ -5724,7 +5728,7 @@ pub fn cascade(viewport_size: Size2D<Au>,
|
|||
|
||||
// The initial value of display may be changed at computed value time.
|
||||
if !seen.get_display() {
|
||||
let box_ = style_box_.make_unique();
|
||||
let box_ = unsafe { style_box_.make_unique() };
|
||||
box_.display = box_.display.to_computed_value(&context);
|
||||
}
|
||||
|
||||
|
@ -5734,7 +5738,7 @@ pub fn cascade(viewport_size: Size2D<Au>,
|
|||
|
||||
if seen.get_font_style() || seen.get_font_weight() || seen.get_font_stretch() ||
|
||||
seen.get_font_family() {
|
||||
compute_font_hash(&mut *style_font.make_unique())
|
||||
unsafe { compute_font_hash(&mut *style_font.make_unique()) }
|
||||
}
|
||||
|
||||
(ComputedValues {
|
||||
|
@ -5769,7 +5773,7 @@ pub fn cascade_anonymous(parent_style: &ComputedValues) -> ComputedValues {
|
|||
root_font_size: parent_style.root_font_size,
|
||||
};
|
||||
{
|
||||
let border = result.border.make_unique();
|
||||
let border = unsafe { result.border.make_unique() };
|
||||
% for side in ["top", "right", "bottom", "left"]:
|
||||
// Like calling to_computed_value, which wouldn't type check.
|
||||
border.border_${side}_width = Au(0);
|
||||
|
@ -5789,16 +5793,20 @@ pub fn cascade_anonymous(parent_style: &ComputedValues) -> ComputedValues {
|
|||
pub fn modify_style_for_replaced_content(style: &mut Arc<ComputedValues>) {
|
||||
// Reset `position` to handle cases like `<div style="position: absolute">foo bar baz</div>`.
|
||||
if style.box_.display != longhands::display::computed_value::T::inline {
|
||||
let mut style = style.make_unique();
|
||||
style.box_.make_unique().display = longhands::display::computed_value::T::inline;
|
||||
style.box_.make_unique().position = longhands::position::computed_value::T::static_;
|
||||
unsafe {
|
||||
let mut style = style.make_unique();
|
||||
style.box_.make_unique().display = longhands::display::computed_value::T::inline;
|
||||
style.box_.make_unique().position = longhands::position::computed_value::T::static_;
|
||||
}
|
||||
}
|
||||
|
||||
// Reset `vertical-align` to handle cases like `<sup>foo</sup>`.
|
||||
if style.box_.vertical_align != longhands::vertical_align::computed_value::T::baseline {
|
||||
let mut style = style.make_unique();
|
||||
style.box_.make_unique().vertical_align =
|
||||
longhands::vertical_align::computed_value::T::baseline
|
||||
unsafe {
|
||||
let mut style = style.make_unique();
|
||||
style.box_.make_unique().vertical_align =
|
||||
longhands::vertical_align::computed_value::T::baseline
|
||||
}
|
||||
}
|
||||
|
||||
// Reset margins.
|
||||
|
@ -5806,12 +5814,14 @@ pub fn modify_style_for_replaced_content(style: &mut Arc<ComputedValues>) {
|
|||
style.margin.margin_left != computed::LengthOrPercentageOrAuto::Length(Au(0)) ||
|
||||
style.margin.margin_bottom != computed::LengthOrPercentageOrAuto::Length(Au(0)) ||
|
||||
style.margin.margin_right != computed::LengthOrPercentageOrAuto::Length(Au(0)) {
|
||||
let mut style = style.make_unique();
|
||||
let margin = style.margin.make_unique();
|
||||
margin.margin_top = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||
margin.margin_left = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||
margin.margin_bottom = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||
margin.margin_right = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||
unsafe {
|
||||
let mut style = style.make_unique();
|
||||
let margin = style.margin.make_unique();
|
||||
margin.margin_top = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||
margin.margin_left = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||
margin.margin_bottom = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||
margin.margin_right = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5825,40 +5835,42 @@ pub fn modify_style_for_inline_sides(style: &mut Arc<ComputedValues>,
|
|||
is_first_fragment_of_element: bool,
|
||||
is_last_fragment_of_element: bool) {
|
||||
fn modify_side(style: &mut Arc<ComputedValues>, side: PhysicalSide) {
|
||||
let mut style = style.make_unique();
|
||||
let border = style.border.make_unique();
|
||||
match side {
|
||||
PhysicalSide::Left => {
|
||||
border.border_left_width = Au(0);
|
||||
border.border_left_style = BorderStyle::none;
|
||||
style.padding.make_unique().padding_left =
|
||||
computed::LengthOrPercentage::Length(Au(0));
|
||||
style.margin.make_unique().margin_left =
|
||||
computed::LengthOrPercentageOrAuto::Length(Au(0))
|
||||
}
|
||||
PhysicalSide::Right => {
|
||||
border.border_right_width = Au(0);
|
||||
border.border_right_style = BorderStyle::none;
|
||||
style.padding.make_unique().padding_right =
|
||||
computed::LengthOrPercentage::Length(Au(0));
|
||||
style.margin.make_unique().margin_right =
|
||||
computed::LengthOrPercentageOrAuto::Length(Au(0))
|
||||
}
|
||||
PhysicalSide::Bottom => {
|
||||
border.border_bottom_width = Au(0);
|
||||
border.border_bottom_style = BorderStyle::none;
|
||||
style.padding.make_unique().padding_bottom =
|
||||
computed::LengthOrPercentage::Length(Au(0));
|
||||
style.margin.make_unique().margin_bottom =
|
||||
computed::LengthOrPercentageOrAuto::Length(Au(0))
|
||||
}
|
||||
PhysicalSide::Top => {
|
||||
border.border_top_width = Au(0);
|
||||
border.border_top_style = BorderStyle::none;
|
||||
style.padding.make_unique().padding_top =
|
||||
computed::LengthOrPercentage::Length(Au(0));
|
||||
style.margin.make_unique().margin_top =
|
||||
computed::LengthOrPercentageOrAuto::Length(Au(0))
|
||||
unsafe {
|
||||
let mut style = style.make_unique();
|
||||
let border = style.border.make_unique();
|
||||
match side {
|
||||
PhysicalSide::Left => {
|
||||
border.border_left_width = Au(0);
|
||||
border.border_left_style = BorderStyle::none;
|
||||
style.padding.make_unique().padding_left =
|
||||
computed::LengthOrPercentage::Length(Au(0));
|
||||
style.margin.make_unique().margin_left =
|
||||
computed::LengthOrPercentageOrAuto::Length(Au(0))
|
||||
}
|
||||
PhysicalSide::Right => {
|
||||
border.border_right_width = Au(0);
|
||||
border.border_right_style = BorderStyle::none;
|
||||
style.padding.make_unique().padding_right =
|
||||
computed::LengthOrPercentage::Length(Au(0));
|
||||
style.margin.make_unique().margin_right =
|
||||
computed::LengthOrPercentageOrAuto::Length(Au(0))
|
||||
}
|
||||
PhysicalSide::Bottom => {
|
||||
border.border_bottom_width = Au(0);
|
||||
border.border_bottom_style = BorderStyle::none;
|
||||
style.padding.make_unique().padding_bottom =
|
||||
computed::LengthOrPercentage::Length(Au(0));
|
||||
style.margin.make_unique().margin_bottom =
|
||||
computed::LengthOrPercentageOrAuto::Length(Au(0))
|
||||
}
|
||||
PhysicalSide::Top => {
|
||||
border.border_top_width = Au(0);
|
||||
border.border_top_style = BorderStyle::none;
|
||||
style.padding.make_unique().padding_top =
|
||||
computed::LengthOrPercentage::Length(Au(0));
|
||||
style.margin.make_unique().margin_top =
|
||||
computed::LengthOrPercentageOrAuto::Length(Au(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue