Commit 33e36790 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Fix block-level baseline for flipped-lines (vertical-lr)

Following CL:1074989 that fixed inline-level baseline for
flipped-lines (vertical-lr), this patch fixes block-level
baselines.

When NGBlockLayoutAlgorithm propagates baselines from its
child line boxes, line boxes and font metrics are in the
[line-relative] coordinates. This needs to be converted to
[flow-relative] coordinates when adding to box fragments.

[flow-relative]: https://drafts.csswg.org/css-writing-modes-3/#logical-directions
[line-relative]: https://drafts.csswg.org/css-writing-modes-3/#line-directions

Bug: 636993
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng;master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: If4ddc2374cc0351120ae672614a32f38bb1f3bc8
Reviewed-on: https://chromium-review.googlesource.com/1087192Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567092}
parent 46c552e5
......@@ -119,7 +119,6 @@ crbug.com/591099 css3/filters/composited-layer-child-bounds-after-composited-to-
crbug.com/591099 css3/filters/multiple-references-id-mutate-crash-2.html [ Crash ]
crbug.com/591099 css3/flexbox/bug646288.html [ Failure ]
crbug.com/591099 css3/flexbox/bug669714.html [ Failure ]
crbug.com/591099 css3/flexbox/flex-align-vertical-writing-mode.html [ Failure ]
crbug.com/591099 css3/flexbox/flex-flow-margins-auto-size.html [ Failure ]
crbug.com/591099 css3/flexbox/flex-item-contains-strict.html [ Failure ]
crbug.com/591099 css3/flexbox/intrinsic-width-orthogonal-writing-mode.html [ Failure ]
......@@ -159,10 +158,6 @@ crbug.com/591099 external/wpt/css/css-filter/filtered-inline-is-container.html [
crbug.com/714962 external/wpt/css/css-fonts/font-features-across-space-1.html [ Pass ]
crbug.com/714962 external/wpt/css/css-fonts/font-features-across-space-3.html [ Pass ]
crbug.com/591099 external/wpt/css/css-fonts/font-variant-ligatures-11.html [ Pass ]
crbug.com/591099 external/wpt/css/css-grid/alignment/grid-column-axis-self-baseline-synthesized-001.html [ Failure ]
crbug.com/591099 external/wpt/css/css-grid/alignment/grid-column-axis-self-baseline-synthesized-002.html [ Failure ]
crbug.com/591099 external/wpt/css/css-grid/alignment/grid-column-axis-self-baseline-synthesized-003.html [ Failure ]
crbug.com/591099 external/wpt/css/css-grid/alignment/grid-column-axis-self-baseline-synthesized-004.html [ Failure ]
crbug.com/591099 external/wpt/css/css-grid/alignment/grid-row-axis-self-baseline-synthesized-001.html [ Failure ]
crbug.com/591099 external/wpt/css/css-grid/alignment/grid-row-axis-self-baseline-synthesized-002.html [ Failure ]
crbug.com/591099 external/wpt/css/css-grid/alignment/grid-row-axis-self-baseline-synthesized-003.html [ Failure ]
......@@ -418,7 +413,6 @@ crbug.com/591099 fast/css-grid-layout/grid-align-baseline-vertical.html [ Failur
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-01.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-02-b.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-02.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-04.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-05.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-07.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-horiz-02.html [ Failure ]
......@@ -428,7 +422,6 @@ crbug.com/591099 fast/css-grid-layout/grid-self-baseline-horiz-05.html [ Failure
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-horiz-06.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-horiz-07.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-two-dimensional.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-vertical-lr-01.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-vertical-lr-02.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-vertical-lr-04.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/grid-self-baseline-vertical-lr-05.html [ Failure ]
......
......@@ -33,11 +33,12 @@ NGPhysicalLineBoxFragment::NGPhysicalLineBoxFragment(
base_direction_ = static_cast<unsigned>(base_direction);
}
LayoutUnit NGPhysicalLineBoxFragment::BaselinePosition(FontBaseline) const {
NGLineHeightMetrics NGPhysicalLineBoxFragment::BaselineMetrics(
FontBaseline) const {
// TODO(kojii): Computing other baseline types than the used one is not
// implemented yet.
// TODO(kojii): We might need locale/script to look up OpenType BASE table.
return metrics_.ascent;
return metrics_;
}
NGPhysicalOffsetRect NGPhysicalLineBoxFragment::InkOverflow() const {
......
......@@ -36,7 +36,7 @@ class CORE_EXPORT NGPhysicalLineBoxFragment final
}
// Compute baseline for the specified baseline type.
LayoutUnit BaselinePosition(FontBaseline) const;
NGLineHeightMetrics BaselineMetrics(FontBaseline) const;
// Ink overflow of itself including contents, in the local coordinate.
NGPhysicalOffsetRect InkOverflow() const;
......
......@@ -1814,6 +1814,31 @@ NGBlockLayoutAlgorithm::CreateConstraintSpaceForChild(
return space_builder.ToConstraintSpace(writing_mode);
}
LayoutUnit NGBlockLayoutAlgorithm::ComputeLineBoxBaselineOffset(
const NGBaselineRequest& request,
const NGPhysicalLineBoxFragment& line_box) const {
NGLineHeightMetrics metrics = line_box.BaselineMetrics(request.baseline_type);
// NGLineHeightMetrics is line-relative, which matches to the flow-relative
// unless this box is in flipped-lines writing-mode.
if (!Style().IsFlippedLinesWritingMode())
return metrics.ascent;
if (Node().IsInlineLevel()) {
// If this box is inline-level, since we're in NGBlockLayoutAlgorithm, this
// is an inline-block.
DCHECK(Node().IsAtomicInlineLevel());
// This box will be flipped when the containing line is flipped. Compute the
// baseline offset from the block-end (right in vertical-lr) content edge.
return metrics.ascent + border_scrollbar_padding_.block_end -
border_scrollbar_padding_.block_start;
}
// Otherwise, the baseline is offset by the descent from the block-start
// content edge.
return metrics.descent;
}
// Add a baseline from a child box fragment.
// @return false if the specified child is not a box or is OOF.
bool NGBlockLayoutAlgorithm::AddBaseline(const NGBaselineRequest& request,
......@@ -1828,7 +1853,7 @@ bool NGBlockLayoutAlgorithm::AddBaseline(const NGBaselineRequest& request,
if (line_box->Children().IsEmpty())
return false;
LayoutUnit offset = line_box->BaselinePosition(request.baseline_type);
LayoutUnit offset = ComputeLineBoxBaselineOffset(request, *line_box);
container_builder_.AddBaseline(request, offset + child_offset);
return true;
}
......
......@@ -18,6 +18,7 @@ namespace blink {
class NGConstraintSpace;
class NGFragment;
class NGLayoutResult;
class NGPhysicalLineBoxFragment;
// This struct is used for communicating to a child the position of the previous
// inflow child. This will be used to calculate the position of the next child.
......@@ -184,6 +185,13 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
const NGPhysicalFragment*,
LayoutUnit child_offset);
// Compute the baseline offset of a line box from the content box.
// Line boxes are in line-relative coordinates. This function returns the
// offset in flow-relative coordinates.
LayoutUnit ComputeLineBoxBaselineOffset(
const NGBaselineRequest&,
const NGPhysicalLineBoxFragment&) const;
// If still unresolved, resolve the fragment's BFC offset.
//
// This includes applying clearance, so the bfc_block_offset passed won't be
......
......@@ -568,6 +568,17 @@ void NGBlockNode::CopyChildFragmentPosition(
}
}
bool NGBlockNode::IsInlineLevel() const {
return GetLayoutObject()->IsInline();
}
bool NGBlockNode::IsAtomicInlineLevel() const {
// LayoutObject::IsAtomicInlineLevel() returns true for e.g., <img
// style="display: block">. Check IsInline() as well.
return GetLayoutObject()->IsAtomicInlineLevel() &&
GetLayoutObject()->IsInline();
}
scoped_refptr<NGLayoutResult> NGBlockNode::LayoutAtomicInline(
const NGConstraintSpace& parent_constraint_space,
FontBaseline baseline_type,
......
......@@ -57,6 +57,9 @@ class CORE_EXPORT NGBlockNode final : public NGLayoutInputNode {
NGLayoutInputNode FirstChild() const;
bool IsInlineLevel() const;
bool IsAtomicInlineLevel() const;
// Layout an atomic inline; e.g., inline block.
scoped_refptr<NGLayoutResult> LayoutAtomicInline(const NGConstraintSpace&,
FontBaseline,
......
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