[mathml] Use ComputeBlockSizeForFragment in NGMathPaddedLayoutAlgorithm
Current version of MathML Core says that CSS width/height properties are
treated as auto on MathML elements [1] (covered by existing tests) but
Chromium actually does take these properties into account [2]. One
exception is the `<mpadded>` element which currently ignores specified
CSS height. This CL changes that behavior by relying on
ComputeBlockSizeForFragment instead, so that the implementation does
not violate LayoutNG design. WPT tests will be added later when
consensus is reached in the Math WG and the spec updated accordingly.
[1] https://w3c.github.io/mathml-core/#css-styling
[2] https://github.com/w3c/mathml-core/issues/75#issuecomment-1354502109
Bug: 6606
Change-Id: I02226fb304400f24de834fa0c0254bfd0c09549b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4116578
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Frédéric Wang <fwang@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1085816}
diff --git a/third_party/blink/renderer/core/layout/ng/mathml/ng_math_padded_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/mathml/ng_math_padded_layout_algorithm.cc
index f815bc04..2a71873 100644
--- a/third_party/blink/renderer/core/layout/ng/mathml/ng_math_padded_layout_algorithm.cc
+++ b/third_party/blink/renderer/core/layout/ng/mathml/ng_math_padded_layout_algorithm.cc
@@ -91,8 +91,10 @@
// width/height/depth attributes can override width/ascent/descent.
LayoutUnit ascent = BorderScrollbarPadding().block_start +
RequestedAscent(content_ascent).value_or(content_ascent);
+ container_builder_.SetBaselines(ascent);
LayoutUnit descent =
- RequestedDescent(content_descent).value_or(content_descent);
+ RequestedDescent(content_descent).value_or(content_descent) +
+ BorderScrollbarPadding().block_end;
if (content_layout_result) {
// Need to take into account border/padding, lspace and voffset.
LogicalOffset content_offset = {
@@ -102,11 +104,13 @@
content.StoreMargins(ConstraintSpace(), content_margins);
}
- auto total_block_size = ascent + descent + BorderScrollbarPadding().block_end;
- container_builder_.SetIntrinsicBlockSize(total_block_size);
- container_builder_.SetFragmentsTotalBlockSize(total_block_size);
+ LayoutUnit intrinsic_block_size = ascent + descent;
+ LayoutUnit block_size = ComputeBlockSizeForFragment(
+ ConstraintSpace(), Style(), BorderPadding(), intrinsic_block_size,
+ container_builder_.InitialBorderBoxSize().inline_size);
- container_builder_.SetBaselines(ascent);
+ container_builder_.SetIntrinsicBlockSize(intrinsic_block_size);
+ container_builder_.SetFragmentsTotalBlockSize(block_size);
NGOutOfFlowLayoutPart(Node(), ConstraintSpace(), &container_builder_).Run();