mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
auto merge of #1407 : ibnc/servo/positioned_box_offsets, r=metajack
For #1406 Not really sure about some of my naming conventions, but offset was kinda taken in box.rs :/ Also this doesn't fully implement the offsets, but I'll do that alongside #782.
This commit is contained in:
commit
1593d2f695
2 changed files with 21 additions and 0 deletions
|
@ -85,6 +85,9 @@ pub struct Box {
|
||||||
|
|
||||||
/// Info specific to the kind of box. Keep this enum small.
|
/// Info specific to the kind of box. Keep this enum small.
|
||||||
specific: SpecificBoxInfo,
|
specific: SpecificBoxInfo,
|
||||||
|
|
||||||
|
/// positioned box offsets
|
||||||
|
position_offsets: Slot<SideOffsets2D<Au>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Info specific to the kind of box. Keep this enum small.
|
/// Info specific to the kind of box. Keep this enum small.
|
||||||
|
@ -254,6 +257,7 @@ impl Box {
|
||||||
padding: Slot::init(Zero::zero()),
|
padding: Slot::init(Zero::zero()),
|
||||||
margin: Slot::init(Zero::zero()),
|
margin: Slot::init(Zero::zero()),
|
||||||
specific: specific,
|
specific: specific,
|
||||||
|
position_offsets: Slot::init(Zero::zero()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,6 +280,7 @@ impl Box {
|
||||||
padding: Slot::init(self.padding.get()),
|
padding: Slot::init(self.padding.get()),
|
||||||
margin: Slot::init(self.margin.get()),
|
margin: Slot::init(self.margin.get()),
|
||||||
specific: specific,
|
specific: specific,
|
||||||
|
position_offsets: Slot::init(Zero::zero())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,6 +339,14 @@ impl Box {
|
||||||
style.Border.border_left_style)))
|
style.Border.border_left_style)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn compute_positioned_offset(&self, style: &ComputedValues) {
|
||||||
|
self.position_offsets.set(SideOffsets2D::new(
|
||||||
|
MaybeAuto::from_style(style.PositionOffsets.top, Au::new(0)).specified_or_zero(),
|
||||||
|
MaybeAuto::from_style(style.PositionOffsets.right, Au::new(0)).specified_or_zero(),
|
||||||
|
MaybeAuto::from_style(style.PositionOffsets.bottom, Au::new(0)).specified_or_zero(),
|
||||||
|
MaybeAuto::from_style(style.PositionOffsets.left, Au::new(0)).specified_or_zero()));
|
||||||
|
}
|
||||||
|
|
||||||
/// Populates the box model padding parameters from the given computed style.
|
/// Populates the box model padding parameters from the given computed style.
|
||||||
pub fn compute_padding(&self, style: &ComputedValues, containing_block_width: Au) {
|
pub fn compute_padding(&self, style: &ComputedValues, containing_block_width: Au) {
|
||||||
let padding = SideOffsets2D::new(self.compute_padding_length(style.Padding.padding_top,
|
let padding = SideOffsets2D::new(self.compute_padding_length(style.Padding.padding_top,
|
||||||
|
|
|
@ -223,6 +223,13 @@ pub mod longhands {
|
||||||
</%self:longhand>
|
</%self:longhand>
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
|
${new_style_struct("PositionOffsets")}
|
||||||
|
|
||||||
|
% for side in ["top", "right", "bottom", "left"]:
|
||||||
|
${predefined_type(side, "LengthOrPercentageOrAuto",
|
||||||
|
"computed::LPA_Auto")}
|
||||||
|
% endfor
|
||||||
|
|
||||||
// CSS 2.1, Section 9 - Visual formatting model
|
// CSS 2.1, Section 9 - Visual formatting model
|
||||||
|
|
||||||
${new_style_struct("Box")}
|
${new_style_struct("Box")}
|
||||||
|
@ -279,6 +286,7 @@ pub mod longhands {
|
||||||
"computed::LPN_None",
|
"computed::LPN_None",
|
||||||
"parse_non_negative")}
|
"parse_non_negative")}
|
||||||
|
|
||||||
|
|
||||||
<%self:single_component_value name="line-height">
|
<%self:single_component_value name="line-height">
|
||||||
#[deriving(Clone)]
|
#[deriving(Clone)]
|
||||||
pub enum SpecifiedValue {
|
pub enum SpecifiedValue {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue