diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-10-04 21:03:55 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-04 21:03:55 -0500 |
commit | 1c62520142a250da5dd6ac027ce531a255096acf (patch) | |
tree | 26be77f76af4f3c7b6586fe4d371816ccaeec0da /components/layout/fragment.rs | |
parent | eb3333eb2f6dbac75ecf23e84cbb12149b3dc969 (diff) | |
parent | 5232b0c85f0da367a9c381cb6d25eb7657e34e25 (diff) | |
download | servo-1c62520142a250da5dd6ac027ce531a255096acf.tar.gz servo-1c62520142a250da5dd6ac027ce531a255096acf.zip |
Auto merge of #13490 - pcwalton:inline-absolute-hypothetical-metrics, r=notriddle
layout: Place inline absolute hypothetical boxes properly during block fragment position assignment.
r? @notriddle
Closes #13471.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13490)
<!-- Reviewable:end -->
Diffstat (limited to 'components/layout/fragment.rs')
-rw-r--r-- | components/layout/fragment.rs | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 698ed517772..a6f3e92f1be 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -2044,7 +2044,7 @@ impl Fragment { /// Calculates block-size above baseline, depth below baseline, and ascent for this fragment /// when used in an inline formatting context. See CSS 2.1 § 10.8.1. pub fn inline_metrics(&self, layout_context: &LayoutContext) -> InlineMetrics { - match self.specific { + return match self.specific { SpecificFragmentInfo::Image(ref image_fragment_info) => { let computed_block_size = image_fragment_info.replaced_image_fragment_info .computed_block_size(); @@ -2082,30 +2082,13 @@ impl Fragment { } } SpecificFragmentInfo::InlineBlock(ref info) => { - // See CSS 2.1 § 10.8.1. - let flow = &info.flow_ref; - let block_flow = flow.as_block(); - let is_auto = self.style.get_position().height == LengthOrPercentageOrAuto::Auto; - let baseline_offset = match flow.baseline_offset_of_last_line_box_in_flow() { - Some(baseline_offset) if is_auto => baseline_offset, - _ => block_flow.fragment.border_box.size.block, - }; - let start_margin = block_flow.fragment.margin.block_start; - let end_margin = block_flow.fragment.margin.block_end; - let depth_below_baseline = flow::base(&**flow).position.size.block - - baseline_offset + end_margin; - InlineMetrics::new(baseline_offset + start_margin, - depth_below_baseline, - baseline_offset) + inline_metrics_of_block(&info.flow_ref, &*self.style) + } + SpecificFragmentInfo::InlineAbsoluteHypothetical(ref info) => { + inline_metrics_of_block(&info.flow_ref, &*self.style) } - SpecificFragmentInfo::InlineAbsoluteHypothetical(_) | SpecificFragmentInfo::InlineAbsolute(_) => { - // Hypothetical boxes take up no space. - InlineMetrics { - block_size_above_baseline: Au(0), - depth_below_baseline: Au(0), - ascent: Au(0), - } + InlineMetrics::new(Au(0), Au(0), Au(0)) } _ => { InlineMetrics { @@ -2114,6 +2097,23 @@ impl Fragment { ascent: self.border_box.size.block, } } + }; + + fn inline_metrics_of_block(flow: &FlowRef, style: &ServoComputedValues) -> InlineMetrics { + // See CSS 2.1 § 10.8.1. + let block_flow = flow.as_block(); + let is_auto = style.get_position().height == LengthOrPercentageOrAuto::Auto; + let baseline_offset = flow.baseline_offset_of_last_line_box_in_flow(); + let baseline_offset = match baseline_offset { + Some(baseline_offset) if is_auto => baseline_offset, + _ => block_flow.fragment.border_box.size.block, + }; + let start_margin = block_flow.fragment.margin.block_start; + let end_margin = block_flow.fragment.margin.block_end; + let block_size_above_baseline = baseline_offset + start_margin; + let depth_below_baseline = flow::base(&**flow).position.size.block - baseline_offset + + end_margin; + InlineMetrics::new(block_size_above_baseline, depth_below_baseline, baseline_offset) } } @@ -2932,3 +2932,4 @@ impl Encodable for DebugId { e.emit_u16(self.0) } } + |