Commit 5a6f4bdd authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

[LayoutNG] vertical-rl layout overflow should not include scrollbar

Legacy vertical-rl coordinates ignore scrollbars. This is wrong,
but we have to be Legacy compatible.

1 additional test passes, but it is a good one,
tests all writing modes.

css3/flexbox/scrollbars.html

Bug: 841587
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: Ie3093ceda3b6a1f1855f9e2353df69583e3c8f43
Reviewed-on: https://chromium-review.googlesource.com/1080233
Commit-Queue: Aleks Totic <atotic@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#563164}
parent 23311f5c
......@@ -162,7 +162,6 @@ crbug.com/591099 css3/flexbox/flexbox-with-multi-column-property.html [ Failure
crbug.com/591099 css3/flexbox/intrinsic-width-orthogonal-writing-mode.html [ Failure ]
crbug.com/591099 css3/flexbox/line-wrapping.html [ Failure ]
crbug.com/591099 css3/flexbox/scrollbars-auto.html [ Failure ]
crbug.com/591099 css3/flexbox/scrollbars.html [ Failure ]
crbug.com/714962 css3/masking/clip-path-reference-box-inline.html [ Failure ]
crbug.com/591099 css3/selectors3/html/css3-modsel-167.html [ Failure ]
crbug.com/591099 css3/selectors3/html/css3-modsel-167a.html [ Failure ]
......
......@@ -74,34 +74,7 @@ void LayoutNGMixin<Base>::AddOverflowFromChildren() {
// Add overflow from the last layout cycle.
if (Base::ChildrenInline()) {
if (const NGPhysicalBoxFragment* physical_fragment = CurrentFragment()) {
// LayoutOverflow is only computed if overflow is not hidden
if (physical_fragment->Style().OverflowX() != EOverflow::kHidden ||
physical_fragment->Style().OverflowY() != EOverflow::kHidden) {
// inline-end LayoutOverflow padding spec is still undecided:
// https://github.com/w3c/csswg-drafts/issues/129
// For backwards compatibility, if container clips overflow,
// padding is added to the inline-end for inline children.
base::Optional<NGPhysicalBoxStrut> padding_strut;
if (Base::HasOverflowClip()) {
padding_strut =
NGBoxStrut(LayoutUnit(), Base::PaddingEnd(), LayoutUnit(),
LayoutUnit())
.ConvertToPhysical(Base::StyleRef().GetWritingMode(),
Base::StyleRef().Direction());
}
NGPhysicalOffsetRect children_overflow;
for (const auto& child : physical_fragment->Children()) {
NGPhysicalOffsetRect child_scrollable_overflow =
child->ScrollableOverflow();
child_scrollable_overflow.offset += child->Offset();
if (child->IsLineBox() && padding_strut) {
child_scrollable_overflow.Expand(*padding_strut);
}
children_overflow.Unite(child_scrollable_overflow);
}
Base::AddLayoutOverflow(children_overflow.ToLayoutFlippedRect(
physical_fragment->Style(), physical_fragment->Size()));
}
AddScrollingOverflowFromChildren();
Base::AddSelfVisualOverflow(
physical_fragment->SelfVisualRect().ToLayoutFlippedRect(
physical_fragment->Style(), physical_fragment->Size()));
......@@ -119,6 +92,59 @@ void LayoutNGMixin<Base>::AddOverflowFromChildren() {
Base::AddOverflowFromChildren();
}
template <typename Base>
void LayoutNGMixin<Base>::AddScrollingOverflowFromChildren() {
const NGPhysicalBoxFragment* physical_fragment = CurrentFragment();
DCHECK(physical_fragment);
// LayoutOverflow is only computed if overflow is not hidden
if (physical_fragment->Style().OverflowX() == EOverflow::kHidden &&
physical_fragment->Style().OverflowY() == EOverflow::kHidden)
return;
// inline-end LayoutOverflow padding spec is still undecided:
// https://github.com/w3c/csswg-drafts/issues/129
// For backwards compatibility, if container clips overflow,
// padding is added to the inline-end for inline children.
base::Optional<NGPhysicalBoxStrut> padding_strut;
if (Base::HasOverflowClip()) {
padding_strut =
NGBoxStrut(LayoutUnit(), Base::PaddingEnd(), LayoutUnit(), LayoutUnit())
.ConvertToPhysical(Base::StyleRef().GetWritingMode(),
Base::StyleRef().Direction());
}
NGPhysicalOffsetRect children_overflow;
for (const auto& child : physical_fragment->Children()) {
NGPhysicalOffsetRect child_scrollable_overflow =
child->ScrollableOverflow();
child_scrollable_overflow.offset += child->Offset();
if (child->IsLineBox() && padding_strut) {
child_scrollable_overflow.Expand(*padding_strut);
}
children_overflow.Unite(child_scrollable_overflow);
}
// LayoutOverflow takes flipped blocks coordinates, adjust as needed.
LayoutRect children_flipped_overflow = children_overflow.ToLayoutFlippedRect(
physical_fragment->Style(), physical_fragment->Size());
if (physical_fragment->Style().IsFlippedBlocksWritingMode()) {
// Legacy overflow coordinate system for flipped blocks is broken.
// It coordinates are "flipped blocks pretending scrollbar does
// not exist. This is the scrollbar adjustment.
// For details, see comments in LayoutBox::NoOverflowRect
LayoutObject* layout_object = physical_fragment->GetLayoutObject();
if (layout_object && layout_object->IsBox()) {
const LayoutBox* box = ToLayoutBox(layout_object);
if (!box->ShouldPlaceBlockDirectionScrollbarOnLogicalLeft()) {
LayoutUnit right_scrollbar_width =
LayoutUnit(box->VerticalScrollbarWidth());
children_flipped_overflow.SetX(children_flipped_overflow.X() -
right_scrollbar_width);
}
}
}
Base::AddLayoutOverflow(children_flipped_overflow);
}
template <typename Base>
void LayoutNGMixin<Base>::AddOutlineRects(
Vector<LayoutRect>& rects,
......
......@@ -76,6 +76,10 @@ class CORE_TEMPLATE_CLASS_EXPORT LayoutNGMixin : public Base {
void AddOverflowFromChildren() override;
private:
void AddScrollingOverflowFromChildren();
protected:
void AddOutlineRects(
Vector<LayoutRect>&,
const LayoutPoint& additional_offset,
......
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