servo: Merge #1872 - Add a trait for width calculation (from pradeep90:calculate-width-trait); r=pcwalton

+ Move out and separate the width calculation code for 6 cases like: block-replaced, block-non-replaced, float-replaced, etc.
  This implements #1683
+ Use the trait to have a common min-width and max-width calculation function (This completes #783 for blocks)
+ Add reftests for the above.

Source-Repo: https://github.com/servo/servo
Source-Revision: 9d5567b69f74a8be40c2e8ca0db5c0c40206cfc1
This commit is contained in:
S Pradeep Kumar 2014-03-11 19:22:55 -04:00
Родитель 61d9ab9d4c
Коммит 4c7b3dcb01
2 изменённых файлов: 712 добавлений и 519 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -584,6 +584,24 @@ impl Box {
.specified_or_zero()));
}
/// Compute and set margin-top and margin-bottom values.
///
/// If a value is specified or is a percentage, we calculate the right value here.
/// If it is auto, it is up to assign-height to ignore this value and
/// calculate the correct margin values.
pub fn compute_margin_top_bottom(&self, containing_block_width: Au) {
let style = self.style();
// Note: CSS 2.1 defines margin % values wrt CB *width* (not height).
let margin_top = MaybeAuto::from_style(style.Margin.get().margin_top,
containing_block_width).specified_or_zero();
let margin_bottom = MaybeAuto::from_style(style.Margin.get().margin_bottom,
containing_block_width).specified_or_zero();
let mut margin = self.margin.get();
margin.top = margin_top;
margin.bottom = margin_bottom;
self.margin.set(margin);
}
/// 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
@ -615,16 +633,6 @@ impl Box {
border_box_size.height - self.border.get().top - self.border.get().bottom)
}
pub fn border_and_padding_horiz(&self) -> Au {
self.border.get().left + self.border.get().right + self.padding.get().left
+ self.padding.get().right
}
pub fn border_and_padding_vert(&self) -> Au {
self.border.get().top + self.border.get().bottom + self.padding.get().top
+ self.padding.get().bottom
}
pub fn noncontent_width(&self) -> Au {
self.noncontent_left() + self.noncontent_right()
}