Commit 4658c2a8 authored by Kurt Catti-Schmidt's avatar Kurt Catti-Schmidt Committed by Commit Bot

Initial plumbing for LayoutNG Grid

This change introduces two new classes that will be used for CSS Grid
in LayoutNG, as well as the runtime flag "LayoutNGGrid" that enables
CSS Grid support in LayoutNG.

This is not at all functional yet but will allow for the subsequent
changes to focus on the implementation instead of boilerplate.

Bug: 1045599
Change-Id: I04fb4455761b1f66cf567440fc5298a39230cbbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2042056Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Kurt Catti-Schmidt <kschmi@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#756274}
parent 923f750a
...@@ -396,6 +396,8 @@ blink_core_sources("layout") { ...@@ -396,6 +396,8 @@ blink_core_sources("layout") {
"ng/layout_ng_fieldset.h", "ng/layout_ng_fieldset.h",
"ng/layout_ng_flexible_box.cc", "ng/layout_ng_flexible_box.cc",
"ng/layout_ng_flexible_box.h", "ng/layout_ng_flexible_box.h",
"ng/layout_ng_grid.cc",
"ng/layout_ng_grid.h",
"ng/layout_ng_mixin.cc", "ng/layout_ng_mixin.cc",
"ng/layout_ng_mixin.h", "ng/layout_ng_mixin.h",
"ng/layout_ng_progress.cc", "ng/layout_ng_progress.cc",
...@@ -471,6 +473,8 @@ blink_core_sources("layout") { ...@@ -471,6 +473,8 @@ blink_core_sources("layout") {
"ng/ng_fragment_child_iterator.h", "ng/ng_fragment_child_iterator.h",
"ng/ng_fragmentation_utils.cc", "ng/ng_fragmentation_utils.cc",
"ng/ng_fragmentation_utils.h", "ng/ng_fragmentation_utils.h",
"ng/ng_grid_layout_algorithm.cc",
"ng/ng_grid_layout_algorithm.h",
"ng/ng_ink_overflow.cc", "ng/ng_ink_overflow.cc",
"ng/ng_ink_overflow.h", "ng/ng_ink_overflow.h",
"ng/ng_layout_algorithm.h", "ng/ng_layout_algorithm.h",
......
...@@ -278,7 +278,7 @@ LayoutObject* LayoutObject::CreateObject(Element* element, ...@@ -278,7 +278,7 @@ LayoutObject* LayoutObject::CreateObject(Element* element,
case EDisplay::kGrid: case EDisplay::kGrid:
case EDisplay::kInlineGrid: case EDisplay::kInlineGrid:
UseCounter::Count(element->GetDocument(), WebFeature::kCSSGridLayout); UseCounter::Count(element->GetDocument(), WebFeature::kCSSGridLayout);
return new LayoutGrid(element); return LayoutObjectFactory::CreateGrid(*element, style, legacy);
case EDisplay::kLayoutCustom: case EDisplay::kLayoutCustom:
case EDisplay::kInlineLayoutCustom: case EDisplay::kInlineLayoutCustom:
DCHECK(RuntimeEnabledFeatures::LayoutNGEnabled()); DCHECK(RuntimeEnabledFeatures::LayoutNGEnabled());
......
...@@ -2553,6 +2553,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, ...@@ -2553,6 +2553,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
kLayoutObjectNGBlockFlow, kLayoutObjectNGBlockFlow,
kLayoutObjectNGFieldset, kLayoutObjectNGFieldset,
kLayoutObjectNGFlexibleBox, kLayoutObjectNGFlexibleBox,
kLayoutObjectNGGrid,
kLayoutObjectNGMixin, kLayoutObjectNGMixin,
kLayoutObjectNGListItem, kLayoutObjectNGListItem,
kLayoutObjectNGInsideListMarker, kLayoutObjectNGInsideListMarker,
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "third_party/blink/renderer/core/layout/layout_fieldset.h" #include "third_party/blink/renderer/core/layout/layout_fieldset.h"
#include "third_party/blink/renderer/core/layout/layout_file_upload_control.h" #include "third_party/blink/renderer/core/layout/layout_file_upload_control.h"
#include "third_party/blink/renderer/core/layout/layout_flexible_box.h" #include "third_party/blink/renderer/core/layout/layout_flexible_box.h"
#include "third_party/blink/renderer/core/layout/layout_grid.h"
#include "third_party/blink/renderer/core/layout/layout_inside_list_marker.h" #include "third_party/blink/renderer/core/layout/layout_inside_list_marker.h"
#include "third_party/blink/renderer/core/layout/layout_list_item.h" #include "third_party/blink/renderer/core/layout/layout_list_item.h"
#include "third_party/blink/renderer/core/layout/layout_outside_list_marker.h" #include "third_party/blink/renderer/core/layout/layout_outside_list_marker.h"
...@@ -24,6 +25,7 @@ ...@@ -24,6 +25,7 @@
#include "third_party/blink/renderer/core/layout/ng/layout_ng_block_flow.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_block_flow.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_flexible_box.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_flexible_box.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_grid.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_progress.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_progress.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_table_caption.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_table_caption.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_table_cell.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_table_cell.h"
...@@ -107,6 +109,14 @@ LayoutBlock* LayoutObjectFactory::CreateFlexibleBox(Node& node, ...@@ -107,6 +109,14 @@ LayoutBlock* LayoutObjectFactory::CreateFlexibleBox(Node& node,
node, style, legacy, disable_ng_for_type); node, style, legacy, disable_ng_for_type);
} }
LayoutBlock* LayoutObjectFactory::CreateGrid(Node& node,
const ComputedStyle& style,
LegacyLayout legacy) {
bool disable_ng_for_type = !RuntimeEnabledFeatures::LayoutNGGridEnabled();
return CreateObject<LayoutBlock, LayoutNGGrid, LayoutGrid>(
node, style, legacy, disable_ng_for_type);
}
LayoutObject* LayoutObjectFactory::CreateListMarker(Node& node, LayoutObject* LayoutObjectFactory::CreateListMarker(Node& node,
const ComputedStyle& style, const ComputedStyle& style,
LegacyLayout legacy) { LegacyLayout legacy) {
......
...@@ -44,6 +44,7 @@ class LayoutObjectFactory { ...@@ -44,6 +44,7 @@ class LayoutObjectFactory {
static LayoutBlock* CreateFlexibleBox(Node&, static LayoutBlock* CreateFlexibleBox(Node&,
const ComputedStyle&, const ComputedStyle&,
LegacyLayout); LegacyLayout);
static LayoutBlock* CreateGrid(Node&, const ComputedStyle&, LegacyLayout);
static LayoutObject* CreateListMarker(Node&, static LayoutObject* CreateListMarker(Node&,
const ComputedStyle&, const ComputedStyle&,
LegacyLayout); LegacyLayout);
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/layout/ng/layout_ng_grid.h"
#include "third_party/blink/renderer/core/layout/ng/ng_layout_result.h"
namespace blink {
LayoutNGGrid::LayoutNGGrid(Element* element)
: LayoutNGMixin<LayoutBlock>(element) {}
void LayoutNGGrid::UpdateBlockLayout(bool relayout_children) {
if (IsOutOfFlowPositioned()) {
UpdateOutOfFlowBlockLayout();
return;
}
UpdateInFlowBlockLayout();
}
} // namespace blink
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_LAYOUT_NG_GRID_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_LAYOUT_NG_GRID_H_
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/layout_block.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_mixin.h"
namespace blink {
class CORE_EXPORT LayoutNGGrid : public LayoutNGMixin<LayoutBlock> {
public:
explicit LayoutNGGrid(Element*);
void UpdateBlockLayout(bool relayout_children) override;
const char* GetName() const override { return "LayoutNGGrid"; }
protected:
bool IsOfType(LayoutObjectType type) const override {
return type == kLayoutObjectNGGrid ||
LayoutNGMixin<LayoutBlock>::IsOfType(type);
}
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_LAYOUT_NG_GRID_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/layout/ng/ng_grid_layout_algorithm.h"
namespace blink {
NGGridLayoutAlgorithm::NGGridLayoutAlgorithm(
const NGLayoutAlgorithmParams& params)
: NGLayoutAlgorithm(params) {
DCHECK(params.space.IsNewFormattingContext());
DCHECK(!params.break_token);
container_builder_.SetIsNewFormattingContext(true);
container_builder_.SetInitialFragmentGeometry(params.fragment_geometry);
}
scoped_refptr<const NGLayoutResult> NGGridLayoutAlgorithm::Layout() {
return container_builder_.ToBoxFragment();
}
base::Optional<MinMaxSizes> NGGridLayoutAlgorithm::ComputeMinMaxSizes(
const MinMaxSizesInput& input) const {
base::Optional<MinMaxSizes> sizes;
return sizes;
}
} // namespace blink
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_NG_GRID_LAYOUT_ALGORITHM_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_NG_GRID_LAYOUT_ALGORITHM_H_
#include "third_party/blink/renderer/core/layout/ng/ng_block_break_token.h"
#include "third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.h"
#include "third_party/blink/renderer/core/layout/ng/ng_layout_algorithm.h"
namespace blink {
class CORE_EXPORT NGGridLayoutAlgorithm
: public NGLayoutAlgorithm<NGBlockNode,
NGBoxFragmentBuilder,
NGBlockBreakToken> {
public:
explicit NGGridLayoutAlgorithm(const NGLayoutAlgorithmParams& params);
scoped_refptr<const NGLayoutResult> Layout() override;
base::Optional<MinMaxSizes> ComputeMinMaxSizes(
const MinMaxSizesInput&) const override;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_NG_GRID_LAYOUT_ALGORITHM_H_
...@@ -917,7 +917,7 @@ ...@@ -917,7 +917,7 @@
// unit tests. // unit tests.
name: "LayoutNG", name: "LayoutNG",
// Keep this list in sync with the one in LayoutNGFlexBox below. // Keep this list in sync with the one in LayoutNGFlexBox below.
implied_by: ["LayoutNGBlockFragmentation", "LayoutNGFieldset", "LayoutNGFragmentItem", "LayoutNGLineCache", "EditingNG", "BidiCaretAffinity", "LayoutNGTable", "LayoutNGFragmentTraversal"], implied_by: ["LayoutNGBlockFragmentation", "LayoutNGFieldset", "LayoutNGFragmentItem", "LayoutNGGrid", "LayoutNGLineCache", "EditingNG", "BidiCaretAffinity", "LayoutNGTable", "LayoutNGFragmentTraversal"],
status: "stable", status: "stable",
}, },
{ {
...@@ -928,7 +928,7 @@ ...@@ -928,7 +928,7 @@
}, },
{ {
name: "LayoutNGFlexBox", name: "LayoutNGFlexBox",
implied_by: ["LayoutNGBlockFragmentation", "LayoutNGFieldset", "LayoutNGFragmentItem", "LayoutNGLineCache", "EditingNG", "BidiCaretAffinity", "LayoutNGTable", "LayoutNGFragmentTraversal"], implied_by: ["LayoutNGBlockFragmentation", "LayoutNGFieldset", "LayoutNGFragmentItem", "LayoutNGGrid", "LayoutNGLineCache", "EditingNG", "BidiCaretAffinity", "LayoutNGTable", "LayoutNGFragmentTraversal"],
status: "experimental", status: "experimental",
}, },
{ {
...@@ -945,6 +945,9 @@ ...@@ -945,6 +945,9 @@
// the layout object tree. // the layout object tree.
name: "LayoutNGFragmentTraversal", name: "LayoutNGFragmentTraversal",
}, },
{
name: "LayoutNGGrid",
},
{ {
name: "LayoutNGLineCache", name: "LayoutNGLineCache",
}, },
......
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