aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/main/layout/box_.rs24
-rw-r--r--src/components/main/layout/model.rs15
2 files changed, 22 insertions, 17 deletions
diff --git a/src/components/main/layout/box_.rs b/src/components/main/layout/box_.rs
index 19a9ed9adba..f5acd633944 100644
--- a/src/components/main/layout/box_.rs
+++ b/src/components/main/layout/box_.rs
@@ -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;
diff --git a/src/components/main/layout/model.rs b/src/components/main/layout/model.rs
index 8dacb8c6ea4..378c43d1bb6 100644
--- a/src/components/main/layout/model.rs
+++ b/src/components/main/layout/model.rs
@@ -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 doesn’t
+ /// 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)) |