Commit bf1887d6 authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

[LayoutNG] Implement container overflow inline padding

Container adds inline_end padding to inline children

Bug: 728378
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: I43008ae9ec0b201eff0197fe457bc3a7483e4566
Reviewed-on: https://chromium-review.googlesource.com/1068139
Commit-Queue: Aleks Totic <atotic@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560810}
parent abd9f475
...@@ -1258,7 +1258,6 @@ crbug.com/591099 media/video-poster-scale.html [ Failure ] ...@@ -1258,7 +1258,6 @@ crbug.com/591099 media/video-poster-scale.html [ Failure ]
crbug.com/591099 media/video-replaces-poster.html [ Failure ] crbug.com/591099 media/video-replaces-poster.html [ Failure ]
crbug.com/591099 media/video-zoom.html [ Failure ] crbug.com/591099 media/video-zoom.html [ Failure ]
crbug.com/591099 netinfo/estimate-multiple-frames.html [ Failure Pass ] crbug.com/591099 netinfo/estimate-multiple-frames.html [ Failure Pass ]
crbug.com/728378 overflow/overflow-inline-001.html [ Failure ]
crbug.com/591099 paint/inline/focus-ring-under-absolute-with-relative-continuation.html [ Failure ] crbug.com/591099 paint/inline/focus-ring-under-absolute-with-relative-continuation.html [ Failure ]
crbug.com/591099 paint/invalidation/background/backgroundSizeRepaint.html [ Failure ] crbug.com/591099 paint/invalidation/background/backgroundSizeRepaint.html [ Failure ]
crbug.com/591099 paint/invalidation/block-layout-inline-children-replaced.html [ Failure ] crbug.com/591099 paint/invalidation/block-layout-inline-children-replaced.html [ Failure ]
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_physical_offset_rect.h" #include "third_party/blink/renderer/core/layout/ng/geometry/ng_physical_offset_rect.h"
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_box_strut.h"
#include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h"
#include "third_party/blink/renderer/platform/geometry/layout_rect.h" #include "third_party/blink/renderer/platform/geometry/layout_rect.h"
...@@ -36,6 +37,23 @@ void NGPhysicalOffsetRect::Unite(const NGPhysicalOffsetRect& other) { ...@@ -36,6 +37,23 @@ void NGPhysicalOffsetRect::Unite(const NGPhysicalOffsetRect& other) {
size = {right - left, bottom - top}; size = {right - left, bottom - top};
} }
void NGPhysicalOffsetRect::Expand(const NGPhysicalBoxStrut& strut) {
if (strut.top) {
offset.top -= strut.top;
size.height += strut.top;
}
if (strut.bottom) {
size.height += strut.bottom;
}
if (strut.left) {
offset.left -= strut.left;
size.width += strut.left;
}
if (strut.right) {
size.width += strut.right;
}
}
NGPhysicalOffsetRect::NGPhysicalOffsetRect(const LayoutRect& source) NGPhysicalOffsetRect::NGPhysicalOffsetRect(const LayoutRect& source)
: NGPhysicalOffsetRect({source.X(), source.Y()}, : NGPhysicalOffsetRect({source.X(), source.Y()},
{source.Width(), source.Height()}) {} {source.Width(), source.Height()}) {}
......
...@@ -15,6 +15,7 @@ namespace blink { ...@@ -15,6 +15,7 @@ namespace blink {
class ComputedStyle; class ComputedStyle;
class FloatRect; class FloatRect;
class LayoutRect; class LayoutRect;
struct NGPhysicalBoxStrut;
// NGPhysicalOffsetRect is the position and size of a rect (typically a // NGPhysicalOffsetRect is the position and size of a rect (typically a
// fragment) relative to its parent rect in the physical coordinate system. // fragment) relative to its parent rect in the physical coordinate system.
...@@ -37,6 +38,8 @@ struct CORE_EXPORT NGPhysicalOffsetRect { ...@@ -37,6 +38,8 @@ struct CORE_EXPORT NGPhysicalOffsetRect {
void Unite(const NGPhysicalOffsetRect&); void Unite(const NGPhysicalOffsetRect&);
void Expand(const NGPhysicalBoxStrut&);
// Conversions from/to existing code. New code prefers type safety for // Conversions from/to existing code. New code prefers type safety for
// logical/physical distinctions. // logical/physical distinctions.
explicit NGPhysicalOffsetRect(const LayoutRect&); explicit NGPhysicalOffsetRect(const LayoutRect&);
......
...@@ -62,22 +62,33 @@ void LayoutNGMixin<Base>::AddOverflowFromChildren() { ...@@ -62,22 +62,33 @@ void LayoutNGMixin<Base>::AddOverflowFromChildren() {
// Add overflow from the last layout cycle. // Add overflow from the last layout cycle.
if (Base::ChildrenInline()) { if (Base::ChildrenInline()) {
if (const NGPhysicalBoxFragment* physical_fragment = CurrentFragment()) { if (const NGPhysicalBoxFragment* physical_fragment = CurrentFragment()) {
bool has_width = // LayoutOverflow is only computed if overflow is not hidden
physical_fragment->Style().OverflowX() != EOverflow::kHidden; if (physical_fragment->Style().OverflowX() != EOverflow::kHidden ||
bool has_height = physical_fragment->Style().OverflowY() != EOverflow::kHidden) {
physical_fragment->Style().OverflowY() != EOverflow::kHidden; // inline-end LayoutOverflow padding spec is still undecided:
if (has_width || has_height) { // 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()) { for (const auto& child : physical_fragment->Children()) {
NGPhysicalOffsetRect child_overflow_rect = NGPhysicalOffsetRect child_scrollable_overflow =
child->ScrollableOverflow(); child->ScrollableOverflow();
child_overflow_rect.offset += child->Offset(); child_scrollable_overflow.offset += child->Offset();
if (!has_width) if (child->IsLineBox() && padding_strut) {
child_overflow_rect.size.width = LayoutUnit(); child_scrollable_overflow.Expand(*padding_strut);
if (!has_height) }
child_overflow_rect.size.height = LayoutUnit(); children_overflow.Unite(child_scrollable_overflow);
Base::AddLayoutOverflow(child_overflow_rect.ToLayoutFlippedRect(
physical_fragment->Style(), physical_fragment->Size()));
} }
Base::AddLayoutOverflow(children_overflow.ToLayoutFlippedRect(
physical_fragment->Style(), physical_fragment->Size()));
} }
Base::AddSelfVisualOverflow( Base::AddSelfVisualOverflow(
physical_fragment->SelfVisualRect().ToLayoutFlippedRect( physical_fragment->SelfVisualRect().ToLayoutFlippedRect(
......
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