mirror of
https://github.com/servo/servo.git
synced 2025-07-24 07:40:27 +01:00
Auto merge of #17556 - jyc:inline-metrics-of-block, r=emilio
layout: Clean up inline_metrics_of_block a little. Previously the variable names were a little confusing (ascent was used for the space_above_baseline in one branch and the and ascent field in another branch, and was not really the ascent in one). Also add a small diagram. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because they just refactor existing code <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/17556) <!-- Reviewable:end -->
This commit is contained in:
commit
03450ee8e1
1 changed files with 29 additions and 11 deletions
|
@ -2158,17 +2158,35 @@ impl Fragment {
|
|||
let block_flow = flow.as_block();
|
||||
let start_margin = block_flow.fragment.margin.block_start;
|
||||
let end_margin = block_flow.fragment.margin.block_end;
|
||||
if style.get_box().overflow_y == overflow_x::T::visible {
|
||||
if let Some(baseline_offset) = flow.baseline_offset_of_last_line_box_in_flow() {
|
||||
let ascent = baseline_offset + start_margin;
|
||||
let space_below_baseline = block_flow.fragment.border_box.size.block -
|
||||
baseline_offset + end_margin;
|
||||
return InlineMetrics::new(ascent, space_below_baseline, baseline_offset)
|
||||
}
|
||||
}
|
||||
let ascent = block_flow.fragment.border_box.size.block + end_margin;
|
||||
let space_above_baseline = start_margin + ascent;
|
||||
InlineMetrics::new(space_above_baseline, Au(0), ascent)
|
||||
let border_box_block_size = block_flow.fragment.border_box.size.block;
|
||||
|
||||
// --------
|
||||
// margin
|
||||
// top -------- + +
|
||||
// | |
|
||||
// | |
|
||||
// A ..pogo.. | + baseline_offset_of_last_line_box_in_flow()
|
||||
// |
|
||||
// -------- + border_box_block_size
|
||||
// margin
|
||||
// B --------
|
||||
//
|
||||
// § 10.8.1 says that the baseline (and thus ascent, which is the
|
||||
// distance from the baseline to the top) should be A if it has an
|
||||
// in-flow line box and if overflow: visible, and B otherwise.
|
||||
let ascent =
|
||||
match (flow.baseline_offset_of_last_line_box_in_flow(),
|
||||
style.get_box().overflow_y) {
|
||||
// Case A
|
||||
(Some(baseline_offset), overflow_x::T::visible) => baseline_offset,
|
||||
// Case B
|
||||
_ => border_box_block_size + end_margin,
|
||||
};
|
||||
|
||||
let space_below_baseline = border_box_block_size + end_margin - ascent;
|
||||
let space_above_baseline = ascent + start_margin;
|
||||
|
||||
InlineMetrics::new(space_above_baseline, space_below_baseline, ascent)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue