mirror of
https://github.com/servo/servo.git
synced 2025-08-09 15:35:34 +01:00
Adress more #1988 (Acid 2) review comments.
This commit is contained in:
parent
9712e6d124
commit
8e14579797
2 changed files with 22 additions and 17 deletions
|
@ -617,19 +617,19 @@ impl Box {
|
||||||
let style = self.style();
|
let style = self.style();
|
||||||
let width = MaybeAuto::from_style(style.Box.get().width, Au::new(0)).specified_or_zero();
|
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));
|
let (margin_left, margin_right) = if use_margins {
|
||||||
if use_margins {
|
(MaybeAuto::from_style(style.Margin.get().margin_left, Au(0)).specified_or_zero(),
|
||||||
margin_left = MaybeAuto::from_style(style.Margin.get().margin_left,
|
MaybeAuto::from_style(style.Margin.get().margin_right, Au(0)).specified_or_zero())
|
||||||
Au(0)).specified_or_zero();
|
} else {
|
||||||
margin_right = MaybeAuto::from_style(style.Margin.get().margin_right,
|
(Au(0), Au(0))
|
||||||
Au(0)).specified_or_zero();
|
};
|
||||||
}
|
|
||||||
|
|
||||||
let (mut padding_left, mut padding_right) = (Au(0), Au(0));
|
let (padding_left, padding_right) = if use_padding {
|
||||||
if use_padding {
|
(self.compute_padding_length(style.Padding.get().padding_left, Au(0)),
|
||||||
padding_left = self.compute_padding_length(style.Padding.get().padding_left, Au(0));
|
self.compute_padding_length(style.Padding.get().padding_right, Au(0)))
|
||||||
padding_right = 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 +
|
let surround_width = margin_left + margin_right + padding_left + padding_right +
|
||||||
self.border.get().left + self.border.get().right;
|
self.border.get().left + self.border.get().right;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
use layout::box_::Box;
|
use layout::box_::Box;
|
||||||
|
|
||||||
use computed = style::computed_values;
|
use computed = style::computed_values;
|
||||||
|
use style::computed_values::{LPA_Auto, LPA_Length, LPA_Percentage};
|
||||||
use servo_util::geometry::Au;
|
use servo_util::geometry::Au;
|
||||||
use servo_util::geometry;
|
use servo_util::geometry;
|
||||||
|
|
||||||
|
@ -61,7 +62,8 @@ pub enum CollapsibleMargins {
|
||||||
/// margins do not collapse through this flow.
|
/// margins do not collapse through this flow.
|
||||||
MarginsCollapse(AdjoiningMargins, AdjoiningMargins),
|
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 doesn’t
|
||||||
|
/// have any border, padding, or out-of-flow (floating or positioned) content
|
||||||
MarginsCollapseThrough(AdjoiningMargins),
|
MarginsCollapseThrough(AdjoiningMargins),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,9 +110,11 @@ impl MarginCollapseInfo {
|
||||||
-> (CollapsibleMargins, Au) {
|
-> (CollapsibleMargins, Au) {
|
||||||
let state = match self.state {
|
let state = match self.state {
|
||||||
AccumulatingCollapsibleTopMargin => {
|
AccumulatingCollapsibleTopMargin => {
|
||||||
match MaybeAuto::from_style(fragment.style().Box.get().height, Au(0)) {
|
match fragment.style().Box.get().height {
|
||||||
Auto | Specified(Au(0)) => MarginsCollapseThroughFinalMarginState,
|
LPA_Auto | LPA_Length(Au(0)) | LPA_Percentage(0.) => {
|
||||||
Specified(_) => {
|
MarginsCollapseThroughFinalMarginState
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
// If the box has an explicitly specified height, margins may not collapse
|
// If the box has an explicitly specified height, margins may not collapse
|
||||||
// through it.
|
// through it.
|
||||||
BottomMarginCollapsesFinalMarginState
|
BottomMarginCollapsesFinalMarginState
|
||||||
|
@ -205,7 +209,8 @@ impl MarginCollapseInfo {
|
||||||
Au(0)
|
Au(0)
|
||||||
}
|
}
|
||||||
(AccumulatingMarginIn, NoCollapsibleMargins(_, bottom)) => {
|
(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
|
bottom
|
||||||
}
|
}
|
||||||
(AccumulatingMarginIn, MarginsCollapse(_, bottom)) |
|
(AccumulatingMarginIn, MarginsCollapse(_, bottom)) |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue