Commit d4992c6f authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[FlexNG] Fix auto scrollbars and scrollable overflow.

In order to get use the correct min/max sizes for flex-items we need
to perform a layout *before* calling ComputeMinMaxSize.

(This is yet another reason why we should merge the min/max sizes pass
 with regular layout).

Additionally this patch implements the:
LayoutBox::HasTopOverflow
LayoutBox::HasLeftOverflow
methods to correctly calculate the scrollable overflow.

Bug: 845235
Change-Id: I3059dfa72969c690abe3808629166194c84fcd75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1978103
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarDavid Grogan <dgrogan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728071}
parent 6da8104d
...@@ -17,6 +17,21 @@ namespace blink { ...@@ -17,6 +17,21 @@ namespace blink {
LayoutNGFlexibleBox::LayoutNGFlexibleBox(Element* element) LayoutNGFlexibleBox::LayoutNGFlexibleBox(Element* element)
: LayoutNGMixin<LayoutBlock>(element) {} : LayoutNGMixin<LayoutBlock>(element) {}
bool LayoutNGFlexibleBox::HasTopOverflow() const {
if (IsHorizontalWritingMode())
return StyleRef().ResolvedIsColumnReverseFlexDirection();
return StyleRef().IsLeftToRightDirection() ==
StyleRef().ResolvedIsRowReverseFlexDirection();
}
bool LayoutNGFlexibleBox::HasLeftOverflow() const {
if (IsHorizontalWritingMode()) {
return StyleRef().IsLeftToRightDirection() ==
StyleRef().ResolvedIsRowReverseFlexDirection();
}
return StyleRef().ResolvedIsColumnReverseFlexDirection();
}
void LayoutNGFlexibleBox::UpdateBlockLayout(bool relayout_children) { void LayoutNGFlexibleBox::UpdateBlockLayout(bool relayout_children) {
LayoutAnalyzer::BlockScope analyzer(*this); LayoutAnalyzer::BlockScope analyzer(*this);
......
...@@ -15,6 +15,9 @@ class CORE_EXPORT LayoutNGFlexibleBox : public LayoutNGMixin<LayoutBlock> { ...@@ -15,6 +15,9 @@ class CORE_EXPORT LayoutNGFlexibleBox : public LayoutNGMixin<LayoutBlock> {
public: public:
explicit LayoutNGFlexibleBox(Element*); explicit LayoutNGFlexibleBox(Element*);
bool HasTopOverflow() const override;
bool HasLeftOverflow() const override;
void UpdateBlockLayout(bool relayout_children) override; void UpdateBlockLayout(bool relayout_children) override;
bool IsFlexibleBoxIncludingDeprecatedAndNG() const final { return true; } bool IsFlexibleBoxIncludingDeprecatedAndNG() const final { return true; }
......
...@@ -345,18 +345,22 @@ void NGFlexLayoutAlgorithm::ConstructAndAppendFlexItems() { ...@@ -345,18 +345,22 @@ void NGFlexLayoutAlgorithm::ConstructAndAppendFlexItems() {
is_horizontal_flow_ ? physical_border_scrollbar_padding.HorizontalSum() is_horizontal_flow_ ? physical_border_scrollbar_padding.HorizontalSum()
: physical_border_scrollbar_padding.VerticalSum(); : physical_border_scrollbar_padding.VerticalSum();
// TODO(dgrogan): Don't layout every time, just when you need to.
// Use ChildHasIntrinsicMainAxisSize as a guide.
scoped_refptr<const NGLayoutResult> layout_result =
child.Layout(child_space, /* break_token */ nullptr);
NGFragment fragment_in_child_writing_mode(
child_style.GetWritingMode(), layout_result->PhysicalFragment());
// We want the child's min/max size in its writing mode, not ours. We'll // We want the child's min/max size in its writing mode, not ours. We'll
// only ever use it if the child's inline axis is our main axis. // only ever use it if the child's inline axis is our main axis.
//
// Always calculate the min/max sizes after a layout in order to corrrectly
// account for any scrollbars.
MinMaxSizeInput input( MinMaxSizeInput input(
/* percentage_resolution_block_size */ content_box_size_.block_size); /* percentage_resolution_block_size */ content_box_size_.block_size);
MinMaxSize intrinsic_sizes_border_box = child.ComputeMinMaxSize( MinMaxSize intrinsic_sizes_border_box = child.ComputeMinMaxSize(
child_style.GetWritingMode(), input, &child_space); child_style.GetWritingMode(), input, &child_space);
// TODO(dgrogan): Don't layout every time, just when you need to.
// Use ChildHasIntrinsicMainAxisSize as a guide.
scoped_refptr<const NGLayoutResult> layout_result =
child.Layout(child_space, nullptr /*break token*/);
NGFragment fragment_in_child_writing_mode(
child_style.GetWritingMode(), layout_result->PhysicalFragment());
LayoutUnit flex_base_border_box; LayoutUnit flex_base_border_box;
const Length& specified_length_in_main_axis = const Length& specified_length_in_main_axis =
......
...@@ -1308,7 +1308,6 @@ crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/flex-align-vertical-wri ...@@ -1308,7 +1308,6 @@ crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/flex-align-vertical-wri
crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/flex-align.html [ Failure ] crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/flex-align.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/flexbox-baseline-margins.html [ Failure ] crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/flexbox-baseline-margins.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/flexbox-baseline.html [ Failure ] crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/flexbox-baseline.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/flexbox-overflow-auto.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/minimum-size-image.html [ Failure ] crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/minimum-size-image.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/multiline-reverse-wrap-baseline.html [ Failure ] crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/multiline-reverse-wrap-baseline.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/negative-overflow.html [ Failure ] crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/negative-overflow.html [ Failure ]
...@@ -1340,8 +1339,6 @@ crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/overflo ...@@ -1340,8 +1339,6 @@ crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/overflo
crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/percentage-heights-007.html [ Failure ] crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/percentage-heights-007.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/percentage-heights-quirks-node.html [ Failure ] crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/percentage-heights-quirks-node.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/quirks-auto-block-size-with-percentage-item.html [ Pass Failure ] crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/quirks-auto-block-size-with-percentage-item.html [ Pass Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/scrollbars-auto.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/scrollbars.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/table-as-item-auto-min-width.html [ Failure ] crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/table-as-item-auto-min-width.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/ttwf-reftest-flex-inline.html [ Failure ] crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/ttwf-reftest-flex-inline.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/hittest-overlapping-margin.html [ Failure ] crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/hittest-overlapping-margin.html [ Failure ]
......
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