Adress more #1988 (Acid 2) review comments.

This commit is contained in:
Simon Sapin 2014-04-03 19:23:51 +01:00 committed by Patrick Walton
parent 9712e6d124
commit 8e14579797
2 changed files with 22 additions and 17 deletions

View file

@ -617,19 +617,19 @@ impl Box {
let style = self.style();
let width = MaybeAuto::from_style(style.Box.get().width, Au::new(0)).specified_or_zero();
let (mut margin_left, mut margin_right) = (Au(0), Au(0));
if use_margins {
margin_left = MaybeAuto::from_style(style.Margin.get().margin_left,
Au(0)).specified_or_zero();
margin_right = MaybeAuto::from_style(style.Margin.get().margin_right,
Au(0)).specified_or_zero();
}
let (margin_left, margin_right) = if use_margins {
(MaybeAuto::from_style(style.Margin.get().margin_left, Au(0)).specified_or_zero(),
MaybeAuto::from_style(style.Margin.get().margin_right, Au(0)).specified_or_zero())
} else {
(Au(0), Au(0))
};
let (mut padding_left, mut padding_right) = (Au(0), Au(0));
if use_padding {
padding_left = self.compute_padding_length(style.Padding.get().padding_left, Au(0));
padding_right = self.compute_padding_length(style.Padding.get().padding_right, Au(0));
}
let (padding_left, padding_right) = if use_padding {
(self.compute_padding_length(style.Padding.get().padding_left, Au(0)),
self.compute_padding_length(style.Padding.get().padding_right, Au(0)))
} else {
(Au(0), Au(0))
};
let surround_width = margin_left + margin_right + padding_left + padding_right +
self.border.get().left + self.border.get().right;

View file

@ -7,6 +7,7 @@
use layout::box_::Box;
use computed = style::computed_values;
use style::computed_values::{LPA_Auto, LPA_Length, LPA_Percentage};
use servo_util::geometry::Au;
use servo_util::geometry;
@ -61,7 +62,8 @@ pub enum CollapsibleMargins {
/// margins do not collapse through this flow.
MarginsCollapse(AdjoiningMargins, AdjoiningMargins),
/// Margins collapse *through* this flow. This means, essentially, that the flow is empty.
/// Margins collapse *through* this flow. This means, essentially, that the flow doesnt
/// have any border, padding, or out-of-flow (floating or positioned) content
MarginsCollapseThrough(AdjoiningMargins),
}
@ -108,9 +110,11 @@ impl MarginCollapseInfo {
-> (CollapsibleMargins, Au) {
let state = match self.state {
AccumulatingCollapsibleTopMargin => {
match MaybeAuto::from_style(fragment.style().Box.get().height, Au(0)) {
Auto | Specified(Au(0)) => MarginsCollapseThroughFinalMarginState,
Specified(_) => {
match fragment.style().Box.get().height {
LPA_Auto | LPA_Length(Au(0)) | LPA_Percentage(0.) => {
MarginsCollapseThroughFinalMarginState
},
_ => {
// If the box has an explicitly specified height, margins may not collapse
// through it.
BottomMarginCollapsesFinalMarginState
@ -205,7 +209,8 @@ impl MarginCollapseInfo {
Au(0)
}
(AccumulatingMarginIn, NoCollapsibleMargins(_, bottom)) => {
// Margin-in should have been set to zero above.
assert_eq!(self.margin_in.most_positive, Au(0));
assert_eq!(self.margin_in.most_negative, Au(0));
bottom
}
(AccumulatingMarginIn, MarginsCollapse(_, bottom)) |