Commit df72d27b authored by Rob Buis's avatar Rob Buis Committed by Commit Bot

[mathml] Make NGMathRowLayoutAlgorithm store margins

Make NGMathRowLayoutAlgorithm store margins. To help collect
the margins per child, add ChildWithOffsetAndMargins, based on
NGContainerFragmentBuilder::ChildWithOffset but with added
margin information.

Bug: 6606
Change-Id: Ib546caa720d982c37843717904f06c4c85bbe95c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2257894
Commit-Queue: Rob Buis <rbuis@igalia.com>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782588}
parent 49d22558
...@@ -38,7 +38,7 @@ NGMathRowLayoutAlgorithm::NGMathRowLayoutAlgorithm( ...@@ -38,7 +38,7 @@ NGMathRowLayoutAlgorithm::NGMathRowLayoutAlgorithm(
} }
void NGMathRowLayoutAlgorithm::LayoutRowItems( void NGMathRowLayoutAlgorithm::LayoutRowItems(
NGContainerFragmentBuilder::ChildrenVector* children, ChildrenVector* children,
LayoutUnit* max_row_block_baseline, LayoutUnit* max_row_block_baseline,
LogicalSize* row_total_size) { LogicalSize* row_total_size) {
LayoutUnit inline_offset, max_row_ascent, max_row_descent; LayoutUnit inline_offset, max_row_ascent, max_row_descent;
...@@ -74,8 +74,9 @@ void NGMathRowLayoutAlgorithm::LayoutRowItems( ...@@ -74,8 +74,9 @@ void NGMathRowLayoutAlgorithm::LayoutRowItems(
// TODO(rbuis): Operators can add lspace and rspace. // TODO(rbuis): Operators can add lspace and rspace.
children->emplace_back( children->emplace_back(
To<NGBlockNode>(child), margins,
LogicalOffset{inline_offset, margins.block_start - ascent}, LogicalOffset{inline_offset, margins.block_start - ascent},
&physical_fragment); std::move(&physical_fragment));
inline_offset += fragment.InlineSize() + margins.inline_end; inline_offset += fragment.InlineSize() + margins.inline_end;
...@@ -99,7 +100,7 @@ scoped_refptr<const NGLayoutResult> NGMathRowLayoutAlgorithm::Layout() { ...@@ -99,7 +100,7 @@ scoped_refptr<const NGLayoutResult> NGMathRowLayoutAlgorithm::Layout() {
const LogicalSize border_box_size = container_builder_.InitialBorderBoxSize(); const LogicalSize border_box_size = container_builder_.InitialBorderBoxSize();
NGContainerFragmentBuilder::ChildrenVector children; ChildrenVector children;
LayoutRowItems(&children, &max_row_block_baseline, &max_row_size); LayoutRowItems(&children, &max_row_block_baseline, &max_row_size);
// Add children taking into account centering, baseline and // Add children taking into account centering, baseline and
...@@ -110,10 +111,12 @@ scoped_refptr<const NGLayoutResult> NGMathRowLayoutAlgorithm::Layout() { ...@@ -110,10 +111,12 @@ scoped_refptr<const NGLayoutResult> NGMathRowLayoutAlgorithm::Layout() {
LogicalOffset adjust_offset = BorderScrollbarPadding().StartOffset(); LogicalOffset adjust_offset = BorderScrollbarPadding().StartOffset();
adjust_offset += LogicalOffset{center_offset, max_row_block_baseline}; adjust_offset += LogicalOffset{center_offset, max_row_block_baseline};
for (auto& child : children) { for (auto& child_data : children) {
child.offset += adjust_offset; child_data.offset += adjust_offset;
container_builder_.AddChild( container_builder_.AddChild(
To<NGPhysicalContainerFragment>(*child.fragment), child.offset); To<NGPhysicalContainerFragment>(*child_data.fragment),
child_data.offset);
child_data.child.StoreMargins(ConstraintSpace(), child_data.margins);
} }
container_builder_.SetBaseline(adjust_offset.block_offset); container_builder_.SetBaseline(adjust_offset.block_offset);
......
...@@ -19,17 +19,34 @@ class CORE_EXPORT NGMathRowLayoutAlgorithm ...@@ -19,17 +19,34 @@ class CORE_EXPORT NGMathRowLayoutAlgorithm
NGBoxFragmentBuilder, NGBoxFragmentBuilder,
NGBlockBreakToken> { NGBlockBreakToken> {
public: public:
NGMathRowLayoutAlgorithm(const NGLayoutAlgorithmParams& params); explicit NGMathRowLayoutAlgorithm(const NGLayoutAlgorithmParams& params);
protected: struct ChildWithOffsetAndMargins {
void LayoutRowItems(NGContainerFragmentBuilder::ChildrenVector*, DISALLOW_NEW();
LayoutUnit* max_row_block_baseline, ChildWithOffsetAndMargins(const NGBlockNode& child,
LogicalSize* row_total_size); const NGBoxStrut& margins,
LogicalOffset offset,
scoped_refptr<const NGPhysicalFragment> fragment)
: child(child),
margins(margins),
offset(offset),
fragment(std::move(fragment)) {}
NGBlockNode child;
NGBoxStrut margins;
LogicalOffset offset;
scoped_refptr<const NGPhysicalFragment> fragment;
};
typedef Vector<ChildWithOffsetAndMargins, 4> ChildrenVector;
private: private:
scoped_refptr<const NGLayoutResult> Layout() final; scoped_refptr<const NGLayoutResult> Layout() final;
MinMaxSizesResult ComputeMinMaxSizes(const MinMaxSizesInput&) const final; MinMaxSizesResult ComputeMinMaxSizes(const MinMaxSizesInput&) const final;
void LayoutRowItems(ChildrenVector*,
LayoutUnit* max_row_block_baseline,
LogicalSize* row_total_size);
}; };
} // namespace blink } // namespace blink
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment