Skip to content
Permalink
Browse files

Added recognition of positioned offsets

  top, bottom, right, and left
  • Loading branch information...
Isabelle Carter
Isabelle Carter committed Dec 13, 2013
1 parent 5302d87 commit 708bf471d0c0f460eb1850143f73e59acd3d4619
Showing with 21 additions and 0 deletions.
  1. +13 −0 src/components/main/layout/box.rs
  2. +8 −0 src/components/style/properties.rs.mako
@@ -85,6 +85,9 @@ pub struct Box {

/// Info specific to the kind of box. Keep this enum small.
specific: SpecificBoxInfo,

/// positioned box offsets
position_offsets: Slot<SideOffsets2D<Au>>,
}

/// Info specific to the kind of box. Keep this enum small.
@@ -254,6 +257,7 @@ impl Box {
padding: Slot::init(Zero::zero()),
margin: Slot::init(Zero::zero()),
specific: specific,
position_offsets: Slot::init(Zero::zero()),
}
}

@@ -276,6 +280,7 @@ impl Box {
padding: Slot::init(self.padding.get()),
margin: Slot::init(self.margin.get()),
specific: specific,
position_offsets: Slot::init(Zero::zero())
}
}

@@ -334,6 +339,14 @@ impl Box {
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.
pub fn compute_padding(&self, style: &ComputedValues, containing_block_width: Au) {
let padding = SideOffsets2D::new(self.compute_padding_length(style.Padding.padding_top,
@@ -223,6 +223,13 @@ pub mod longhands {
</%self:longhand>
% 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

${new_style_struct("Box")}
@@ -279,6 +286,7 @@ pub mod longhands {
"computed::LPN_None",
"parse_non_negative")}


<%self:single_component_value name="line-height">
#[deriving(Clone)]
pub enum SpecifiedValue {

5 comments on commit 708bf47

@bors-servo

This comment has been minimized.

Copy link
Contributor

replied Dec 16, 2013

saw approval from metajack
at ibnc@708bf47

@bors-servo

This comment has been minimized.

Copy link
Contributor

replied Dec 16, 2013

merging ibnc/servo/positioned_box_offsets = 708bf47 into auto

@bors-servo

This comment has been minimized.

Copy link
Contributor

replied Dec 16, 2013

ibnc/servo/positioned_box_offsets = 708bf47 merged ok, testing candidate = 1593d2f

@bors-servo

This comment has been minimized.

Copy link
Contributor

replied Dec 16, 2013

fast-forwarding master to auto = 1593d2f

Please sign in to comment.
You can’t perform that action at this time.